summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-05-12 15:10:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-12 19:11:32 +0200
commit55f1130be067fbf32f4be6953d3cea6cb72705b9 (patch)
tree17d7df256cab232a2efc8f61f398df4e2cde7363
parent6f5e9d0355872be7ab944f08ca1362c6f5bc7879 (diff)
Remove the xPath argument from runJavaScript
This value is only used internally by Chromium and risks being removed at anytime, for which we would then have to maintain a downstream implementation. Chromium also only supports frame values, while a complete support of the interface would require also supporting this xPath to point to individual document element by affecting the value of "this", the same way that QWebElement::evaluateJavaScript allowed in QtWebKit. Change-Id: Id0cb1b8e3bdf9a6db0ca786fb5eb46ffd726d165 Reviewed-by: Michael Bruning <michael.bruning@digia.com>
-rw-r--r--src/core/web_contents_adapter.cpp10
-rw-r--r--src/core/web_contents_adapter.h4
-rw-r--r--src/webengine/api/qquickwebengineview.cpp4
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp8
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h4
5 files changed, 16 insertions, 14 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 3ea5e416..ffb31ce8 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -610,21 +610,23 @@ void WebContentsAdapter::enableInspector(bool enable)
ContentBrowserClientQt::Get()->enableInspector(enable);
}
-void WebContentsAdapter::runJavaScript(const QString &javaScript, const QString &xPath)
+void WebContentsAdapter::runJavaScript(const QString &javaScript)
{
Q_D(WebContentsAdapter);
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
Q_ASSERT(rvh);
- rvh->ExecuteJavascriptInWebFrame(toString16(xPath), toString16(javaScript));
+ base::string16 mainFrameXPath;
+ rvh->ExecuteJavascriptInWebFrame(mainFrameXPath, toString16(javaScript));
}
-quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript, const QString &xPath)
+quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript)
{
Q_D(WebContentsAdapter);
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
Q_ASSERT(rvh);
content::RenderViewHost::JavascriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, ++d->lastRequestId);
- rvh->ExecuteJavascriptInWebFrameCallbackResult(toString16(xPath), toString16(javaScript), callback);
+ base::string16 mainFrameXPath;
+ rvh->ExecuteJavascriptInWebFrameCallbackResult(mainFrameXPath, toString16(javaScript), callback);
return d->lastRequestId;
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 371be5d9..d327de04 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -97,8 +97,8 @@ public:
qreal currentZoomFactor() const;
void enableInspector(bool);
void filesSelectedInChooser(const QStringList &fileList, WebContentsAdapterClient::FileChooserMode);
- void runJavaScript(const QString &javaScript, const QString &xPath);
- quint64 runJavaScriptCallbackResult(const QString &javaScript, const QString &xPath);
+ void runJavaScript(const QString &javaScript);
+ quint64 runJavaScriptCallbackResult(const QString &javaScript);
quint64 fetchDocumentMarkup();
quint64 fetchDocumentInnerText();
quint64 findText(const QString &subString, bool caseSensitively, bool findBackward);
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 0a5150c3..a11a57cd 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -550,10 +550,10 @@ QQmlComponent *QQuickWebEngineViewExperimental::extraContextMenuEntriesComponent
void QQuickWebEngineViewExperimental::runJavaScript(const QString &script, const QJSValue &callback)
{
if (!callback.isUndefined()) {
- quint64 requestId = d_ptr->adapter->runJavaScriptCallbackResult(script, /*xPath=*/QString());
+ quint64 requestId = d_ptr->adapter->runJavaScriptCallbackResult(script);
d_ptr->m_callbacks.insert(requestId, callback);
} else
- d_ptr->adapter->runJavaScript(script, /*xPath=*/QString());
+ d_ptr->adapter->runJavaScript(script);
}
QQuickWebEngineHistory *QQuickWebEngineViewExperimental::navigationHistory() const
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 2abfa4de..4bd97c07 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -803,16 +803,16 @@ void QWebEnginePage::setZoomFactor(qreal factor)
d->adapter->setZoomFactor(factor);
}
-void QWebEnginePage::runJavaScript(const QString &scriptSource, const QString &xPath)
+void QWebEnginePage::runJavaScript(const QString &scriptSource)
{
Q_D(QWebEnginePage);
- d->adapter->runJavaScript(scriptSource, xPath);
+ d->adapter->runJavaScript(scriptSource);
}
-void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback, const QString &xPath)
+void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
{
Q_D(QWebEnginePage);
- quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource, xPath);
+ quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource);
d->m_callbacks.registerCallback(requestId, resultCallback.d);
}
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 4c24db61..be5e4c52 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -175,8 +175,8 @@ public:
qreal zoomFactor() const;
void setZoomFactor(qreal factor);
- void runJavaScript(const QString& scriptSource, const QString &xPath = QString());
- void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback, const QString &xPath = QString());
+ void runJavaScript(const QString& scriptSource);
+ void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback);
Q_SIGNALS:
void loadStarted();