[Qt] Use WebPageGroup to create user scripts instead of Qt-specific function in WebPage
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jan 2013 17:10:24 +0000 (17:10 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jan 2013 17:10:24 +0000 (17:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105921

Reviewed by Simon Hausmann.

After r131281 the WebPageGroup.h (in UIProcess) exposes a way to add user scripts, so we can
use this directly to implement the user script functionality in Qt. The previous solution was
a Qt-port specific function in WebPage that can be removed now.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::updateUserScripts): Use WebPageGroup functions to manipulate user scripts directly.
* UIProcess/WebPageProxy.h:
(WebPageProxy): Remove now unused function.
* UIProcess/qt/WebPageProxyQt.cpp: Ditto.
* WebProcess/WebPage/WebPage.messages.in: Ditto.
* WebProcess/WebPage/qt/WebPageQt.cpp: Remove now unused function and headers.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138621 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp

index 6bf142c..b4e9133 100644 (file)
@@ -1,3 +1,22 @@
+2013-01-02  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        [Qt] Use WebPageGroup to create user scripts instead of Qt-specific function in WebPage
+        https://bugs.webkit.org/show_bug.cgi?id=105921
+
+        Reviewed by Simon Hausmann.
+
+        After r131281 the WebPageGroup.h (in UIProcess) exposes a way to add user scripts, so we can
+        use this directly to implement the user script functionality in Qt. The previous solution was
+        a Qt-port specific function in WebPage that can be removed now.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::updateUserScripts): Use WebPageGroup functions to manipulate user scripts directly.
+        * UIProcess/WebPageProxy.h:
+        (WebPageProxy): Remove now unused function.
+        * UIProcess/qt/WebPageProxyQt.cpp: Ditto.
+        * WebProcess/WebPage/WebPage.messages.in: Ditto.
+        * WebProcess/WebPage/qt/WebPageQt.cpp: Remove now unused function and headers.
+
 2013-01-02  Heikki Paajanen  <heikki.paajanen@palm.com>
 
         [Qt][WK2] Add experimental API to find text from page
index 555780e..2502a81 100644 (file)
@@ -757,8 +757,10 @@ static QString readUserScript(const QUrl& url)
 
 void QQuickWebViewPrivate::updateUserScripts()
 {
-    Vector<String> scripts;
-    scripts.reserveCapacity(userScripts.size());
+    // This feature works per-WebView because we keep an unique page group for
+    // each Page/WebView pair we create.
+    WebPageGroup* pageGroup = webPageProxy->pageGroup();
+    pageGroup->removeAllUserScripts();
 
     for (unsigned i = 0; i < userScripts.size(); ++i) {
         const QUrl& url = userScripts.at(i);
@@ -770,10 +772,8 @@ void QQuickWebViewPrivate::updateUserScripts()
         QString contents = readUserScript(url);
         if (contents.isEmpty())
             continue;
-        scripts.append(String(contents));
+        pageGroup->addUserScript(String(contents), emptyString(), 0, 0, InjectInTopFrameOnly, InjectAtDocumentEnd);
     }
-
-    webPageProxy->setUserScripts(scripts);
 }
 
 QPointF QQuickWebViewPrivate::contentPos() const
index b8a0b67..4f8c37b 100644 (file)
@@ -373,7 +373,6 @@ public:
     void authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password);
     void certificateVerificationRequest(const String& hostname, bool& ignoreErrors);
     void proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password);
-    void setUserScripts(const Vector<String>&);
 #endif // PLATFORM(QT).
 #if PLATFORM(EFL)
     void setThemePath(const String&);
index 6d1b7fd..e6d9b90 100644 (file)
@@ -86,11 +86,6 @@ void WebPageProxy::sendApplicationSchemeReply(const QQuickNetworkReply* reply)
 #endif
 }
 
-void WebPageProxy::setUserScripts(const Vector<String>& scripts)
-{
-    process()->send(Messages::WebPage::SetUserScripts(scripts), m_pageID);
-}
-
 void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
 {
     m_pageClient->didFindZoomableArea(target, area);
index 5a3fa90..490e495 100644 (file)
@@ -74,7 +74,6 @@ messages -> WebPage {
 #if PLATFORM(QT)
     ApplicationSchemeReply(WebKit::QtNetworkReplyData reply)
     RegisterApplicationScheme(WTF::String scheme)
-    SetUserScripts(WTF::Vector<WTF::String> script)
 #endif
 
     StopLoadingFrame(uint64_t frameID)
index 94ac02b..48a8010 100644 (file)
 #include "PopupMenuClient.h"
 #include "WebEditorClient.h"
 #include "WebEvent.h"
-#include "WebPageGroupProxy.h"
 #include "WebPageProxyMessages.h"
 #include "WebPopupMenu.h"
 #include "WebProcess.h"
 #include <QClipboard>
 #include <QGuiApplication>
-#include <WebCore/DOMWrapperWorld.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
 #include <WebCore/KeyboardEvent.h>
 #include <WebCore/Page.h>
-#include <WebCore/PageGroup.h>
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/Range.h>
 #include <WebCore/Settings.h>
@@ -334,15 +331,6 @@ void WebPage::applicationSchemeReply(const QtNetworkReplyData& replyData)
     networkReply->finalize();
 }
 
-void WebPage::setUserScripts(const Vector<String>& scripts)
-{
-    // This works because we keep an unique page group for each Page.
-    PageGroup* pageGroup = PageGroup::pageGroup(this->pageGroup()->identifier());
-    pageGroup->removeUserScriptsFromWorld(mainThreadNormalWorld());
-    for (unsigned i = 0; i < scripts.size(); ++i)
-        pageGroup->addUserScriptToWorld(mainThreadNormalWorld(), scripts.at(i), KURL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInTopFrameOnly);
-}
-
 void WebPage::selectedIndex(int32_t newIndex)
 {
     changeSelectedIndex(newIndex);