Title: [119046] trunk/Source/WebKit
Revision
119046
Author
commit-qu...@webkit.org
Date
2012-05-30 20:59:39 -0700 (Wed, 30 May 2012)

Log Message

[BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.
https://bugs.webkit.org/show_bug.cgi?id=81001

Source/WebKit:

Patch by Konrad Piascik <kpias...@rim.com> on 2012-05-30
Reviewed by Antonio Gomes

Added new InspectorOverlay class

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

Patch by Konrad Piascik <kpias...@rim.com> on 2012-05-30
Reviewed by Antonio Gomes.

Implemented InspectorOverlay using WebOverlayAPI.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::renderContents):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
(BlackBerry::WebKit::WebPagePrivate::commitRootLayerIfNeeded):
(BlackBerry::WebKit::WebPagePrivate::setInspectorOverlayClient):
(WebKit):
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):
* WebCoreSupport/InspectorClientBlackBerry.cpp:
(WebCore::InspectorClientBlackBerry::highlight):
(WebCore::InspectorClientBlackBerry::hideHighlight):
(WebCore::InspectorClientBlackBerry::paintInspectorOverlay):
(WebCore):
* WebCoreSupport/InspectorClientBlackBerry.h:
(InspectorClientBlackBerry):
* WebCoreSupport/InspectorOverlay.cpp: Added.
(WebCore):
(WebCore::InspectorOverlay::create):
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::notifySyncRequired):
(WebCore::InspectorOverlay::paintContents):
(WebCore::InspectorOverlay::showDebugBorders):
(WebCore::InspectorOverlay::showRepaintCounter):
(WebCore::InspectorOverlay::contentsVisible):
(WebCore::InspectorOverlay::~InspectorOverlay):
(WebCore::InspectorOverlay::clear):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::paintWebFrame):
(WebCore::InspectorOverlay::invalidateWebFrame):
* WebCoreSupport/InspectorOverlay.h: Added.
(WebKit):
(WebCore):
(InspectorOverlay):
(InspectorOverlayClient):
(WebCore::InspectorOverlay::setClient):
(WebCore::InspectorOverlay::notifyAnimationStarted):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (119045 => 119046)


--- trunk/Source/WebKit/ChangeLog	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/ChangeLog	2012-05-31 03:59:39 UTC (rev 119046)
@@ -1,3 +1,14 @@
+2012-05-30  Konrad Piascik  <kpias...@rim.com>
+
+        [BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.
+        https://bugs.webkit.org/show_bug.cgi?id=81001
+
+        Reviewed by Antonio Gomes
+        
+        Added new InspectorOverlay class
+
+        * PlatformBlackBerry.cmake:
+
 2012-05-29  Arvid Nilsson  <anils...@rim.com>
 
         [BlackBerry] WebKit-side implementation of SelectionOverlay

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (119045 => 119046)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-31 03:59:39 UTC (rev 119046)
@@ -75,6 +75,7 @@
     blackberry/WebCoreSupport/GeolocationControllerClientBlackBerry.cpp
     blackberry/WebCoreSupport/IconDatabaseClientBlackBerry.cpp
     blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp
+    blackberry/WebCoreSupport/InspectorOverlay.cpp
     blackberry/WebCoreSupport/_javascript_DebuggerBlackBerry.cpp
     blackberry/WebCoreSupport/NotificationPresenterImpl.cpp
     blackberry/WebCoreSupport/VibrationClientBlackBerry.cpp

Modified: trunk/Source/WebKit/blackberry/Api/BackingStore.cpp (119045 => 119046)


--- trunk/Source/WebKit/blackberry/Api/BackingStore.cpp	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/Api/BackingStore.cpp	2012-05-31 03:59:39 UTC (rev 119046)
@@ -2443,7 +2443,8 @@
         if (m_webPage->d->m_page->inspectorController()->enabled()) {
             WebCore::IntPoint scrollPosition = m_client->frame()->view()->scrollPosition();
             graphicsContext.translate(scrollPosition.x(), scrollPosition.y());
-            m_webPage->d->m_page->inspectorController()->drawHighlight(graphicsContext);
+            if (m_webPage->d->m_inspectorOverlay)
+                m_webPage->d->m_inspectorOverlay->paintWebFrame(graphicsContext);
         }
 #endif
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (119045 => 119046)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-31 03:59:39 UTC (rev 119046)
@@ -75,6 +75,7 @@
 #include "InspectorBackendDispatcher.h"
 #include "InspectorClientBlackBerry.h"
 #include "InspectorController.h"
+#include "InspectorOverlay.h"
 #include "_javascript_DebuggerBlackBerry.h"
 #include "LayerWebKitThread.h"
 #include "NetworkManager.h"
@@ -3217,6 +3218,8 @@
         // Must be called on the WebKit thread.
         if (m_selectionHandler->isSelectionActive())
             m_selectionHandler->selectionPositionChanged(true /* visualChangeOnly */);
+        if (m_inspectorOverlay)
+            m_inspectorOverlay->update();
 
     } else if (m_selectionHandler->isSelectionActive()) {
         // Don't bother dispatching to webkit thread if selection and tap highlight are not active.
@@ -5759,6 +5762,7 @@
     double scale = currentScale();
     if (m_frameLayers && m_frameLayers->hasLayer())
         m_frameLayers->commitOnWebKitThread(scale);
+
     updateDelegatedOverlays();
     if (m_overlayLayer)
         m_overlayLayer->platformLayer()->commitOnWebKitThread(scale);
@@ -6284,5 +6288,23 @@
     m_parentPopup = webPopup;
 }
 
+void WebPagePrivate::setInspectorOverlayClient(WebCore::InspectorOverlay::InspectorOverlayClient* inspectorOverlayClient)
+{
+    if (inspectorOverlayClient) {
+        if (!m_inspectorOverlay)
+            m_inspectorOverlay = WebCore::InspectorOverlay::create(this, inspectorOverlayClient);
+        else
+            m_inspectorOverlay->setClient(inspectorOverlayClient);
+        m_inspectorOverlay->update();
+        scheduleRootLayerCommit();
+    } else {
+        if (m_inspectorOverlay) {
+            m_inspectorOverlay->clear();
+            m_inspectorOverlay = nullptr;
+            scheduleRootLayerCommit();
+        }
+    }
 }
+
 }
+}

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (119045 => 119046)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-31 03:59:39 UTC (rev 119046)
@@ -20,6 +20,7 @@
 #define WebPage_p_h
 
 #include "ChromeClient.h"
+#include "InspectorOverlay.h"
 #if USE(ACCELERATED_COMPOSITING)
 #include "GLES2Context.h"
 #include "LayerRenderer.h"
@@ -42,6 +43,7 @@
 class Document;
 class Frame;
 class GeolocationControllerClientBlackBerry;
+class GraphicsLayerBlackBerry;
 class _javascript_DebuggerBlackBerry;
 class LayerWebKitThread;
 class Node;
@@ -425,6 +427,8 @@
 
     void deferredTasksTimerFired(WebCore::Timer<WebPagePrivate>*);
 
+    void setInspectorOverlayClient(WebCore::InspectorOverlay::InspectorOverlayClient*);
+
     WebPage* m_webPage;
     WebPageClient* m_client;
     WebCore::Page* m_page;
@@ -548,6 +552,7 @@
     RefPtr<WebCore::DOMWrapperWorld> m_isolatedWorld;
     bool m_hasInRegionScrollableAreas;
     bool m_updateDelegatedOverlaysDispatched;
+    OwnPtr<WebCore::InspectorOverlay> m_inspectorOverlay;
 
     // There is no need to initialize the following members in WebPagePrivate's constructor,
     // because they are only used by WebPageTasks and the tasks will initialize them when

Modified: trunk/Source/WebKit/blackberry/ChangeLog (119045 => 119046)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-31 03:59:39 UTC (rev 119046)
@@ -1,3 +1,51 @@
+2012-05-30  Konrad Piascik  <kpias...@rim.com>
+
+        [BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.
+        https://bugs.webkit.org/show_bug.cgi?id=81001
+
+        Reviewed by Antonio Gomes.
+        
+        Implemented InspectorOverlay using WebOverlayAPI.
+
+        * Api/BackingStore.cpp:
+        (BlackBerry::WebKit::BackingStorePrivate::renderContents):
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
+        (BlackBerry::WebKit::WebPagePrivate::commitRootLayerIfNeeded):
+        (BlackBerry::WebKit::WebPagePrivate::setInspectorOverlayClient):
+        (WebKit):
+        * Api/WebPage_p.h:
+        (WebCore):
+        (WebPagePrivate):
+        * WebCoreSupport/InspectorClientBlackBerry.cpp:
+        (WebCore::InspectorClientBlackBerry::highlight):
+        (WebCore::InspectorClientBlackBerry::hideHighlight):
+        (WebCore::InspectorClientBlackBerry::paintInspectorOverlay):
+        (WebCore):
+        * WebCoreSupport/InspectorClientBlackBerry.h:
+        (InspectorClientBlackBerry):
+        * WebCoreSupport/InspectorOverlay.cpp: Added.
+        (WebCore):
+        (WebCore::InspectorOverlay::create):
+        (WebCore::InspectorOverlay::InspectorOverlay):
+        (WebCore::InspectorOverlay::notifySyncRequired):
+        (WebCore::InspectorOverlay::paintContents):
+        (WebCore::InspectorOverlay::showDebugBorders):
+        (WebCore::InspectorOverlay::showRepaintCounter):
+        (WebCore::InspectorOverlay::contentsVisible):
+        (WebCore::InspectorOverlay::~InspectorOverlay):
+        (WebCore::InspectorOverlay::clear):
+        (WebCore::InspectorOverlay::update):
+        (WebCore::InspectorOverlay::paintWebFrame):
+        (WebCore::InspectorOverlay::invalidateWebFrame):
+        * WebCoreSupport/InspectorOverlay.h: Added.
+        (WebKit):
+        (WebCore):
+        (InspectorOverlay):
+        (InspectorOverlayClient):
+        (WebCore::InspectorOverlay::setClient):
+        (WebCore::InspectorOverlay::notifyAnimationStarted):
+
 2012-05-30  Sean Wang  <xuewen.w...@torchmobile.com.cn>
 
         [BlackBerry] Browser crashed when selecting in textarea

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp (119045 => 119046)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp	2012-05-31 03:59:39 UTC (rev 119046)
@@ -22,7 +22,10 @@
 
 #include "BackingStore.h"
 #include "Frame.h"
+#include "GraphicsContext.h"
+#include "InspectorController.h"
 #include "NotImplemented.h"
+#include "Page.h"
 #include "RenderObject.h"
 #include "WebPageClient.h"
 #include "WebPage_p.h"
@@ -42,17 +45,16 @@
 
 void InspectorClientBlackBerry::highlight()
 {
-    hideHighlight();
+    m_webPagePrivate->setInspectorOverlayClient(this);
+    if (!m_webPagePrivate->isAcceleratedCompositingActive())
+        m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
 }
 
 void InspectorClientBlackBerry::hideHighlight()
 {
-    if (!m_webPagePrivate->mainFrame() || !m_webPagePrivate->mainFrame()->document() || !m_webPagePrivate->mainFrame()->document()->documentElement()
-        || !m_webPagePrivate->mainFrame()->document()->documentElement()->renderer())
-        return;
-
-    // FIXME: Potentially slow hack, but invalidating everything should work since the actual highlight is drawn by BackingStorePrivate::renderContents().
-    m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
+    m_webPagePrivate->setInspectorOverlayClient(0);
+    if (!m_webPagePrivate->isAcceleratedCompositingActive())
+        m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
 }
 
 void InspectorClientBlackBerry::openInspectorFrontend(InspectorController*)
@@ -92,4 +94,11 @@
     notImplemented();
 };
 
+void InspectorClientBlackBerry::paintInspectorOverlay(GraphicsContext& gc)
+{
+    InspectorController* inspectorController = m_webPagePrivate->m_page->inspectorController();
+    if (inspectorController)
+        inspectorController->drawHighlight(gc);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.h (119045 => 119046)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.h	2012-05-31 03:56:21 UTC (rev 119045)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorClientBlackBerry.h	2012-05-31 03:59:39 UTC (rev 119046)
@@ -21,6 +21,7 @@
 #define InspectorClientBlackBerry_h
 
 #include "InspectorClient.h"
+#include "InspectorOverlay.h"
 #include "PlatformString.h"
 #include <wtf/HashMap.h>
 
@@ -32,7 +33,7 @@
 
 namespace WebCore {
 
-class InspectorClientBlackBerry : public InspectorClient {
+class InspectorClientBlackBerry : public InspectorClient, public InspectorOverlay::InspectorOverlayClient {
 public:
     InspectorClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
     virtual void inspectorDestroyed();
@@ -50,6 +51,7 @@
     virtual bool canClearBrowserCache() { return true; }
     virtual void clearBrowserCookies();
     virtual bool canClearBrowserCookies() { return true; }
+    virtual void paintInspectorOverlay(WebCore::GraphicsContext&);
 
     virtual void updateInspectorStateCookie(const String&);
 

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp (0 => 119046)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp	2012-05-31 03:59:39 UTC (rev 119046)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * 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 "InspectorOverlay.h"
+
+#include "Frame.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "GraphicsLayer.h"
+#include "Page.h"
+#include "Settings.h"
+#include "WebPage_p.h"
+
+
+namespace WebCore {
+
+PassOwnPtr<InspectorOverlay> InspectorOverlay::create(BlackBerry::WebKit::WebPagePrivate* page, InspectorOverlayClient* client)
+{
+    return adoptPtr(new InspectorOverlay(page, client));
+}
+
+InspectorOverlay::InspectorOverlay(BlackBerry::WebKit::WebPagePrivate* page, InspectorOverlayClient* client)
+    : m_webPage(page)
+    , m_client(client)
+{
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void InspectorOverlay::notifySyncRequired(const GraphicsLayer*)
+{
+    m_webPage->scheduleRootLayerCommit();
+}
+
+void InspectorOverlay::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& inClip)
+{
+    context.save();
+    IntPoint scrollPosition = m_webPage->focusedOrMainFrame()->view()->scrollPosition();
+    context.translate(scrollPosition.x(), scrollPosition.y());
+    m_client->paintInspectorOverlay(context);
+    context.restore();
+}
+
+bool InspectorOverlay::showDebugBorders(const GraphicsLayer*) const
+{
+    return m_webPage->m_page->settings()->showDebugBorders();
+}
+
+bool InspectorOverlay::showRepaintCounter(const GraphicsLayer*) const
+{
+    return m_webPage->m_page->settings()->showRepaintCounter();
+}
+
+bool InspectorOverlay::contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const
+{
+    return true;
+}
+#endif
+
+InspectorOverlay::~InspectorOverlay() { }
+
+void InspectorOverlay::clear()
+{
+    invalidateWebFrame();
+
+#if USE(ACCELERATED_COMPOSITING)
+    if (m_overlay) {
+        m_overlay->removeFromParent();
+        m_overlay = nullptr;
+    }
+#endif
+}
+
+void InspectorOverlay::update()
+{
+    invalidateWebFrame();
+
+#if USE(ACCELERATED_COMPOSITING)
+    if (!m_overlay) {
+        m_overlay = adoptPtr(new BlackBerry::WebKit::WebOverlay(this));
+        const IntSize size = m_webPage->viewportSize();
+        m_overlay->setSize(FloatSize(size.width(), size.height()));
+        m_webPage->m_webPage->addOverlay(m_overlay.get());
+    }
+
+    m_overlay->setDrawsContent(true);
+    m_overlay->setOpacity(1.0);
+    m_overlay->invalidate();
+#endif
+}
+
+void InspectorOverlay::paintWebFrame(GraphicsContext& gc)
+{
+    if (!m_webPage->isAcceleratedCompositingActive())
+        m_client->paintInspectorOverlay(gc);
+}
+
+void InspectorOverlay::invalidateWebFrame()
+{
+    // InspectorOverlayClient does the actual painting of the overlay.
+    // Here we just make sure to invalidate.
+    if (!m_webPage->isAcceleratedCompositingActive()) {
+        // FIXME: able to invalidate a smaller rect.
+        // FIXME: Is it important to just invalidate a smaller rect given that
+        // this is not on a critical codepath? In order to do so, we'd
+        // have to take scrolling into account.
+        const IntSize size = m_webPage->viewportSize();
+        IntRect damagedRect(0, 0, size.width(), size.height());
+    }
+}
+
+}

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h (0 => 119046)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h	2012-05-31 03:59:39 UTC (rev 119046)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * 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 InspectorOverlay_h
+#define InspectorOverlay_h
+
+#include "WebOverlay.h"
+#include <GraphicsLayerClient.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace WebCore {
+class GraphicsContext;
+class GraphicsLayer;
+
+
+class InspectorOverlay : public WebCore::GraphicsLayerClient {
+public:
+    class InspectorOverlayClient {
+    public:
+        virtual void paintInspectorOverlay(GraphicsContext&) = 0;
+    };
+
+    static PassOwnPtr<InspectorOverlay> create(BlackBerry::WebKit::WebPagePrivate*, InspectorOverlayClient*);
+
+    ~InspectorOverlay();
+
+    void setClient(InspectorOverlayClient* client) { m_client = client; }
+
+    void clear();
+    void update();
+    void paintWebFrame(GraphicsContext&);
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
+    virtual void notifySyncRequired(const GraphicsLayer*);
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
+    virtual bool showDebugBorders(const GraphicsLayer*) const;
+    virtual bool showRepaintCounter(const GraphicsLayer*) const;
+
+    virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const;
+#endif
+
+private:
+    InspectorOverlay(BlackBerry::WebKit::WebPagePrivate*, InspectorOverlayClient*);
+    void invalidateWebFrame();
+
+    BlackBerry::WebKit::WebPagePrivate* m_webPage;
+    InspectorOverlayClient* m_client;
+    OwnPtr<BlackBerry::WebKit::WebOverlay> m_overlay;
+};
+
+} // namespace WebCore
+
+
+#endif /* InspectorOverlay_h */
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to