summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api/qwebenginepage.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-01-15 19:10:22 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 08:45:25 +0100
commit1fcd7970e07a0ecab206224824d1c71488fc19e9 (patch)
tree7bc6ba73623a69aa303f1f4d5c075e8ef37ca45e /src/webenginewidgets/api/qwebenginepage.cpp
parent3fcd31f5bd86cb568b1ca4f4f5c7c12c6675dceb (diff)
Implement QWebEnginePage::toHtml and toPlainText
Those methods are now made asynchronous and need to be given a callback to handle the result. Update the code in the browser and fancybrowser examples using std::bind when using C++11 or tr1::bind with C++03 (which should be available with compilers on platforms that we support). Add a (currently failing) earlyToHtml test to make sure that an empty page doesn't crash because of a possibly incomplete attachment of the QtRenderViewObserver. Change-Id: I3ab7cb6f25b91b584dd80df5e4e9ad1e3214348e Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/webenginewidgets/api/qwebenginepage.cpp')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 8192f38ed..1a3cf5dde 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -151,6 +151,16 @@ void QWebEnginePagePrivate::didRunJavaScript(const QVariant& result, quint64 req
(*m_variantCallbacks.take(requestId))(result);
}
+void QWebEnginePagePrivate::didFetchDocumentMarkup(const QString& result, quint64 requestId)
+{
+ (*m_stringCallbacks.take(requestId))(result);
+}
+
+void QWebEnginePagePrivate::didFetchDocumentInnerText(const QString& result, quint64 requestId)
+{
+ (*m_stringCallbacks.take(requestId))(result);
+}
+
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
@@ -448,6 +458,20 @@ void QWebEnginePage::load(const QUrl& url)
d->adapter->load(url);
}
+void QWebEnginePage::toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
+{
+ Q_D(const QWebEnginePage);
+ quint64 requestId = d->adapter->fetchDocumentMarkup();
+ d->m_stringCallbacks.insert(requestId, resultCallback.d);
+}
+
+void QWebEnginePage::toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
+{
+ Q_D(const QWebEnginePage);
+ quint64 requestId = d->adapter->fetchDocumentInnerText();
+ d->m_stringCallbacks.insert(requestId, resultCallback.d);
+}
+
void QWebEnginePage::setHtml(const QString &html, const QUrl &baseUrl)
{
Q_D(QWebEnginePage);