diff options
Diffstat (limited to 'src/webenginewidgets/api/qwebenginepage.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 760a8eff7..ca1c203dd 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -57,6 +57,9 @@ CallbackDirectory::~CallbackDirectory() case CallbackSharedDataPointer::String: (*sharedPtr.stringCallback)(QString()); break; + case CallbackSharedDataPointer::Bool: + (*sharedPtr.boolCallback)(false); + break; default: Q_UNREACHABLE(); } @@ -73,6 +76,11 @@ void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySha m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data())); } +void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<BoolCallback> &callback) +{ + m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data())); +} + void CallbackDirectory::invoke(quint64 requestId, const QVariant &result) { CallbackSharedDataPointer sharedPtr = m_callbackMap.take(requestId); @@ -91,6 +99,15 @@ void CallbackDirectory::invoke(quint64 requestId, const QString &result) } } +void CallbackDirectory::invoke(quint64 requestId, bool result) +{ + CallbackSharedDataPointer sharedPtr = m_callbackMap.take(requestId); + if (sharedPtr) { + Q_ASSERT(sharedPtr.type == CallbackSharedDataPointer::Bool); + (*sharedPtr.boolCallback)(result); + } +} + void CallbackDirectory::CallbackSharedDataPointer::doRef() { switch (type) { @@ -102,6 +119,9 @@ void CallbackDirectory::CallbackSharedDataPointer::doRef() case String: stringCallback->ref.ref(); break; + case Bool: + boolCallback->ref.ref(); + break; } } @@ -118,6 +138,10 @@ void CallbackDirectory::CallbackSharedDataPointer::doDeref() if (!stringCallback->ref.deref()) delete stringCallback; break; + case Bool: + if (!boolCallback->ref.deref()) + delete boolCallback; + break; } } @@ -251,6 +275,11 @@ void QWebEnginePagePrivate::didFetchDocumentInnerText(quint64 requestId, const Q m_callbacks.invoke(requestId, result); } +void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount) +{ + m_callbacks.invoke(requestId, matchCount > 0); +} + void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const { #ifdef QT_NO_ACTION @@ -414,6 +443,20 @@ void QWebEnginePage::triggerAction(WebAction action, bool) } } +void QWebEnginePage::findText(const QString &subString, FindFlags options, const QWebEngineCallback<bool> &resultCallback) +{ + Q_D(QWebEnginePage); + if (subString.isEmpty()) { + d->adapter->stopFinding(); + if (resultCallback.d) + (*resultCallback.d)(false); + } else { + quint64 requestId = d->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward); + if (resultCallback.d) + d->m_callbacks.registerCallback(requestId, resultCallback.d); + } +} + void QWebEnginePage::setViewportSize(const QSize &size) const { Q_UNUSED(size) |