[GTK][WK1] Add ProgressTrackerClient implementation
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 17:03:52 +0000 (17:03 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 17:03:52 +0000 (17:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127048

Reviewed by Anders Carlsson.

In r162034, the progress tracker client was separated from FrameLoaderClient into the
ProgressTrackerClient class. This patch adds the WebKit layer implementation of that
class for GTK-WK1 that's practically identical to the client implementation that was
in use under WebKit::FrameLoaderClient.

* GNUmakefile.am:
* WebCoreSupport/FrameLoaderClientGtk.cpp:
* WebCoreSupport/FrameLoaderClientGtk.h:
* WebCoreSupport/ProgressTrackerClientGtk.cpp: Added.
(WebKit::ProgressTrackerClient::ProgressTrackerClient):
(WebKit::ProgressTrackerClient::progressTrackerDestroyed):
(WebKit::ProgressTrackerClient::progressStarted):
(WebKit::ProgressTrackerClient::progressEstimateChanged):
(WebKit::ProgressTrackerClient::progressFinished):
* WebCoreSupport/ProgressTrackerClientGtk.h: Added.
* webkit/webkitwebview.cpp:
(webkit_web_view_init):

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

Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/GNUmakefile.am
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.cpp [new file with mode: 0644]
Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.h [new file with mode: 0644]
Source/WebKit/gtk/webkit/webkitwebview.cpp

index 21258db..4a33ef4 100644 (file)
@@ -1,3 +1,28 @@
+2014-01-15  Zan Dobersek  <zdobersek@igalia.com>
+
+        [GTK][WK1] Add ProgressTrackerClient implementation
+        https://bugs.webkit.org/show_bug.cgi?id=127048
+
+        Reviewed by Anders Carlsson.
+
+        In r162034, the progress tracker client was separated from FrameLoaderClient into the
+        ProgressTrackerClient class. This patch adds the WebKit layer implementation of that
+        class for GTK-WK1 that's practically identical to the client implementation that was
+        in use under WebKit::FrameLoaderClient.
+
+        * GNUmakefile.am:
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        * WebCoreSupport/FrameLoaderClientGtk.h:
+        * WebCoreSupport/ProgressTrackerClientGtk.cpp: Added.
+        (WebKit::ProgressTrackerClient::ProgressTrackerClient):
+        (WebKit::ProgressTrackerClient::progressTrackerDestroyed):
+        (WebKit::ProgressTrackerClient::progressStarted):
+        (WebKit::ProgressTrackerClient::progressEstimateChanged):
+        (WebKit::ProgressTrackerClient::progressFinished):
+        * WebCoreSupport/ProgressTrackerClientGtk.h: Added.
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_init):
+
 2014-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [SOUP] Add SoupNetworkSession class to wrap a SoupSession
index f94cf92..b6bc58c 100644 (file)
@@ -226,6 +226,8 @@ webkitgtk_sources += \
        Source/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h \
        Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.h \
        Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.cpp \
+       Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.cpp \
+       Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.h \
        Source/WebKit/gtk/WebCoreSupport/UserMediaClientGtk.cpp \
        Source/WebKit/gtk/WebCoreSupport/UserMediaClientGtk.h \
        Source/WebKit/gtk/WebCoreSupport/WebViewInputMethodFilter.cpp \
index 50af1bb..c6a49ea 100644 (file)
@@ -58,7 +58,6 @@
 #include "Page.h"
 #include "PluginDatabase.h"
 #include "PluginView.h"
-#include "ProgressTracker.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
 #include "ResourceHandle.h"
@@ -284,35 +283,6 @@ void FrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifie
     webkit_web_view_add_resource(getViewFromFrame(m_frame), identifierString.get(), webResource);
 }
 
-void FrameLoaderClient::progressStarted(WebCore::Frame&)
-{
-    WebKitWebView* webView = getViewFromFrame(m_frame);
-    g_signal_emit_by_name(webView, "load-started", m_frame);
-
-    g_object_notify(G_OBJECT(webView), "progress");
-}
-
-void FrameLoaderClient::progressEstimateChanged(WebCore::Frame&)
-{
-    WebKitWebView* webView = getViewFromFrame(m_frame);
-    Page* corePage = core(webView);
-
-    g_signal_emit_by_name(webView, "load-progress-changed", lround(corePage->progress().estimatedProgress()*100));
-
-    g_object_notify(G_OBJECT(webView), "progress");
-}
-
-void FrameLoaderClient::progressFinished(WebCore::Frame&)
-{
-    WebKitWebView* webView = getViewFromFrame(m_frame);
-    WebKitWebViewPrivate* privateData = webView->priv;
-
-    // We can get a stopLoad() from dispose when the object is being
-    // destroyed, don't emit the signal in that case.
-    if (!privateData->disposing)
-        g_signal_emit_by_name(webView, "load-finished", m_frame);
-}
-
 void FrameLoaderClient::frameLoaderDestroyed()
 {
     webkit_web_frame_core_frame_gone(m_frame);
index a8ff46a..84ea636 100644 (file)
@@ -31,7 +31,6 @@
 #define FrameLoaderClientGtk_h
 
 #include "FrameLoaderClient.h"
-#include "ProgressTrackerClient.h"
 #include "ResourceResponse.h"
 #include "webkitwebpolicydecision.h"
 
@@ -43,7 +42,7 @@ class PluginView;
 
 namespace WebKit {
 
-    class FrameLoaderClient : public WebCore::FrameLoaderClient, public WebCore::ProgressTrackerClient {
+    class FrameLoaderClient : public WebCore::FrameLoaderClient {
     public:
         FrameLoaderClient(WebKitWebFrame* = 0);
         virtual ~FrameLoaderClient();
@@ -112,10 +111,6 @@ namespace WebKit {
         virtual void revertToProvisionalState(WebCore::DocumentLoader*) { }
         virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&);
 
-        virtual void progressStarted(WebCore::Frame&);
-        virtual void progressEstimateChanged(WebCore::Frame&);
-        virtual void progressFinished(WebCore::Frame&);
-
         virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::URL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
                                    const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
         virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::URL&, const WTF::Vector<WTF::String>&, const WTF::Vector<WTF::String>&, const WTF::String&, bool);
diff --git a/Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.cpp
new file mode 100644 (file)
index 0000000..629d3be
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "ProgressTrackerClientGtk.h"
+
+#include "Page.h"
+#include "ProgressTracker.h"
+#include "webkitwebframeprivate.h"
+#include "webkitwebviewprivate.h"
+
+namespace WebKit {
+
+ProgressTrackerClient::ProgressTrackerClient(WebKitWebView* webView)
+    : m_webView(webView)
+{
+    ASSERT(m_webView);
+}
+
+void ProgressTrackerClient::progressTrackerDestroyed()
+{
+    delete this;
+}
+
+void ProgressTrackerClient::progressStarted(WebCore::Frame& originatingProgressFrame)
+{
+    WebKitWebFrame* frame = kit(&originatingProgressFrame);
+    ASSERT(m_webView == getViewFromFrame(frame));
+
+    g_signal_emit_by_name(m_webView, "load-started", frame);
+
+    g_object_notify(G_OBJECT(m_webView), "progress");
+}
+
+void ProgressTrackerClient::progressEstimateChanged(WebCore::Frame& originatingProgressFrame)
+{
+    ASSERT(m_webView == getViewFromFrame(kit(&originatingProgressFrame)));
+
+    WebCore::Page* corePage = core(m_webView);
+    g_signal_emit_by_name(m_webView, "load-progress-changed", lround(corePage->progress().estimatedProgress()*100));
+
+    g_object_notify(G_OBJECT(m_webView), "progress");
+}
+
+void ProgressTrackerClient::progressFinished(WebCore::Frame& originatingProgressFrame)
+{
+    WebKitWebFrame* frame = kit(&originatingProgressFrame);
+    ASSERT(m_webView == getViewFromFrame(frame));
+
+    // We can get a stopLoad() from dispose when the object is being
+    // destroyed, don't emit the signal in that case.
+    if (!m_webView->priv->disposing)
+        g_signal_emit_by_name(m_webView, "load-finished", frame);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/ProgressTrackerClientGtk.h
new file mode 100644 (file)
index 0000000..ada3dd0
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef ProgressTrackerClientGtk_h
+#define ProgressTrackerClientGtk_h
+
+#include "ProgressTrackerClient.h"
+
+typedef struct _WebKitWebView WebKitWebView;
+
+namespace WebKit {
+
+class ProgressTrackerClient FINAL : public WebCore::ProgressTrackerClient {
+public:
+    explicit ProgressTrackerClient(WebKitWebView*);
+
+private:
+    virtual void progressTrackerDestroyed() OVERRIDE;
+
+    virtual void progressStarted(WebCore::Frame&) OVERRIDE;
+    virtual void progressEstimateChanged(WebCore::Frame&) OVERRIDE;
+    virtual void progressFinished(WebCore::Frame&) OVERRIDE;
+
+    WebKitWebView* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // ProgressTrackerClientGtk_h
index 45c531c..b4f9a9c 100644 (file)
@@ -82,6 +82,7 @@
 #include "PlatformKeyboardEvent.h"
 #include "PlatformWheelEvent.h"
 #include "ProgressTracker.h"
+#include "ProgressTrackerClientGtk.h"
 #include "RenderView.h"
 #include "ResourceHandle.h"
 #include "RuntimeEnabledFeatures.h"
@@ -3810,7 +3811,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
 #endif
     pageClients.inspectorClient = new WebKit::InspectorClient(webView);
     pageClients.loaderClientForMainFrame = new WebKit::FrameLoaderClient;
-    pageClients.progressTrackerClient = static_cast<WebKit::FrameLoaderClient*>(pageClients.loaderClientForMainFrame);
+    pageClients.progressTrackerClient = new WebKit::ProgressTrackerClient(webView);
 
     priv->corePage = new Page(pageClients);