Title: [126474] trunk/Source/WebKit/blackberry
Revision
126474
Author
[email protected]
Date
2012-08-23 13:39:11 -0700 (Thu, 23 Aug 2012)

Log Message

[BlackBerry] Unify slow and fast in-region scrolling code paths
https://bugs.webkit.org/show_bug.cgi?id=94834
PR #197662

Reviewed by Rob Buis.
Patch by Antonio Gomes <[email protected]>
Internally reviewed by Arvid Nilsson.

In order to be able to remove a bunch of obsolete code from
InRegionScroller.cpp, we need to unify the codepaths for slow
and fast in-region scrolling.

This patch caches the root scrollable node of each scrollable block
in InRegionScrollableArea also for the non-composited-scrolling case now too
(analogly to the way we cache LayerWebKitThread for the composited scrolling case).

Now the client (libwebview) can dispatch an in-region scrolling with one single code path,
making use of a boolean (argh!) to inform if the scroll of the given
layer supports compositing or not. Later on, this boolean is used to casting the proper element.

* Api/InRegionScroller.cpp:
(BlackBerry::WebKit::InRegionScroller::setScrollPositionWebKitThread):
(BlackBerry::WebKit::InRegionScrollerPrivate::setScrollPositionWebKitThread):
* Api/InRegionScroller.h:
* Api/InRegionScroller_p.h:
(InRegionScrollerPrivate):
* WebKitSupport/InRegionScrollableArea.cpp:
(WebKit):
(BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea):
(BlackBerry::WebKit::enclosingLayerNode):
* WebKitSupport/InRegionScrollableArea.h:
(WebCore):
(InRegionScrollableArea):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp (126473 => 126474)


--- trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp	2012-08-23 20:39:11 UTC (rev 126474)
@@ -65,12 +65,12 @@
     return d->setScrollPositionCompositingThread(camouflagedLayer, d->m_webPage->mapFromTransformed(scrollPosition));
 }
 
-bool InRegionScroller::setScrollPositionWebKitThread(unsigned camouflagedLayer, const Platform::IntPoint& scrollPosition)
+bool InRegionScroller::setScrollPositionWebKitThread(unsigned camouflagedLayer, const Platform::IntPoint& scrollPosition, bool supportsAcceleratedScrolling)
 {
     ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
 
     // FIXME: Negative values won't work with map{To,From}Transform methods.
-    return d->setScrollPositionWebKitThread(camouflagedLayer, d->m_webPage->mapFromTransformed(scrollPosition));
+    return d->setScrollPositionWebKitThread(camouflagedLayer, d->m_webPage->mapFromTransformed(scrollPosition), supportsAcceleratedScrolling);
 }
 
 InRegionScrollerPrivate::InRegionScrollerPrivate(WebPagePrivate* webPagePrivate)
@@ -118,16 +118,25 @@
     return true;
 }
 
-bool InRegionScrollerPrivate::setScrollPositionWebKitThread(unsigned camouflagedLayer, const WebCore::IntPoint& scrollPosition)
+bool InRegionScrollerPrivate::setScrollPositionWebKitThread(unsigned camouflagedLayer, const WebCore::IntPoint& scrollPosition, bool supportsAcceleratedScrolling)
 {
     RenderLayer* layer = 0;
 
-    LayerWebKitThread* layerWebKitThread = reinterpret_cast<LayerWebKitThread*>(camouflagedLayer);
-    ASSERT(layerWebKitThread);
-    if (layerWebKitThread->owner()) {
-        GraphicsLayer* graphicsLayer = layerWebKitThread->owner();
-        RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(graphicsLayer->client());
-        layer = backing->owningLayer();
+    if (supportsAcceleratedScrolling) {
+        LayerWebKitThread* layerWebKitThread = reinterpret_cast<LayerWebKitThread*>(camouflagedLayer);
+        ASSERT(layerWebKitThread);
+        if (layerWebKitThread->owner()) {
+            GraphicsLayer* graphicsLayer = layerWebKitThread->owner();
+            RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(graphicsLayer->client());
+            layer = backing->owningLayer();
+        }
+    } else {
+        Node* node = reinterpret_cast<Node*>(camouflagedLayer);
+        ASSERT(node);
+        if (!node->renderer())
+            return false;
+
+        layer = node->renderer()->enclosingLayer();
     }
 
     if (!layer)

Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller.h (126473 => 126474)


--- trunk/Source/WebKit/blackberry/Api/InRegionScroller.h	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller.h	2012-08-23 20:39:11 UTC (rev 126474)
@@ -36,7 +36,7 @@
     ~InRegionScroller();
 
     bool setScrollPositionCompositingThread(unsigned camouflagedLayer, const Platform::IntPoint& /*scrollPosition*/);
-    bool setScrollPositionWebKitThread(unsigned camouflagedLayer, const Platform::IntPoint& /*scrollPosition*/);
+    bool setScrollPositionWebKitThread(unsigned camouflagedLayer, const Platform::IntPoint& /*scrollPosition*/, bool acceleratedScrolling);
 
 private:
     friend class WebPagePrivate;

Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h (126473 => 126474)


--- trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h	2012-08-23 20:39:11 UTC (rev 126474)
@@ -52,7 +52,7 @@
     bool scrollBy(const Platform::IntSize& delta);
 
     bool setScrollPositionCompositingThread(unsigned camouflagedLayer, const WebCore::IntPoint& scrollPosition);
-    bool setScrollPositionWebKitThread(unsigned camouflagedLayer, const WebCore::IntPoint& scrollPosition);
+    bool setScrollPositionWebKitThread(unsigned camouflagedLayer, const WebCore::IntPoint& scrollPosition, bool supportsAcceleratedScrolling);
 
     void calculateInRegionScrollableAreasForPoint(const WebCore::IntPoint&);
     const std::vector<Platform::ScrollViewBase*>& activeInRegionScrollableAreas() const;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (126473 => 126474)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-08-23 20:39:11 UTC (rev 126474)
@@ -1,3 +1,39 @@
+2012-08-23  Antonio Gomes  <[email protected]>
+
+        [BlackBerry] Unify slow and fast in-region scrolling code paths
+        https://bugs.webkit.org/show_bug.cgi?id=94834
+        PR #197662
+
+        Reviewed by Rob Buis.
+
+        Internally reviewed by Arvid Nilsson.
+
+        In order to be able to remove a bunch of obsolete code from
+        InRegionScroller.cpp, we need to unify the codepaths for slow
+        and fast in-region scrolling.
+
+        This patch caches the root scrollable node of each scrollable block
+        in InRegionScrollableArea also for the non-composited-scrolling case now too
+        (analogly to the way we cache LayerWebKitThread for the composited scrolling case).
+
+        Now the client (libwebview) can dispatch an in-region scrolling with one single code path,
+        making use of a boolean (argh!) to inform if the scroll of the given
+        layer supports compositing or not. Later on, this boolean is used to casting the proper element.
+
+        * Api/InRegionScroller.cpp:
+        (BlackBerry::WebKit::InRegionScroller::setScrollPositionWebKitThread):
+        (BlackBerry::WebKit::InRegionScrollerPrivate::setScrollPositionWebKitThread):
+        * Api/InRegionScroller.h:
+        * Api/InRegionScroller_p.h:
+        (InRegionScrollerPrivate):
+        * WebKitSupport/InRegionScrollableArea.cpp:
+        (WebKit):
+        (BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea):
+        (BlackBerry::WebKit::enclosingLayerNode):
+        * WebKitSupport/InRegionScrollableArea.h:
+        (WebCore):
+        (InRegionScrollableArea):
+
 2012-08-23  Jacky Jiang  <[email protected]>
 
         [BlackBerry] Web pages are zoomed out to much on initial load

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp (126473 => 126474)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp	2012-08-23 20:39:11 UTC (rev 126474)
@@ -46,6 +46,17 @@
         m_cachedCompositedScrollableLayer->clearOverride();
 }
 
+// FIXME: Make RenderLayer::enclosingElement public so this one can be removed.
+static Node* enclosingLayerNode(RenderLayer* layer)
+{
+    for (RenderObject* r = layer->renderer(); r; r = r->parent()) {
+        if (Node* e = r->node())
+            return e;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
 InRegionScrollableArea::InRegionScrollableArea(WebPagePrivate* webPage, RenderLayer* layer)
     : m_webPage(webPage)
     , m_layer(layer)
@@ -92,11 +103,17 @@
         m_scrollsHorizontally = box->scrollWidth() != box->clientWidth() && box->scrollsOverflowX();
         m_scrollsVertically = box->scrollHeight() != box->clientHeight() && box->scrollsOverflowY();
 
+        // Both caches below are self-exclusive.
         if (m_layer->usesCompositedScrolling()) {
             m_supportsCompositedScrolling = true;
             ASSERT(m_layer->backing()->hasScrollingLayer());
             m_camouflagedCompositedScrollableLayer = reinterpret_cast<unsigned>(m_layer->backing()->scrollingLayer()->platformLayer());
             m_cachedCompositedScrollableLayer = m_layer->backing()->scrollingLayer()->platformLayer();
+            ASSERT(!m_cachedNonCompositedScrollableNode);
+        } else {
+            m_camouflagedCompositedScrollableLayer = reinterpret_cast<unsigned>(enclosingLayerNode(m_layer));
+            m_cachedNonCompositedScrollableNode = enclosingLayerNode(m_layer);
+            ASSERT(!m_cachedCompositedScrollableLayer);
         }
 
         m_overscrollLimitFactor = 0.0;

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h (126473 => 126474)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h	2012-08-23 20:31:46 UTC (rev 126473)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h	2012-08-23 20:39:11 UTC (rev 126474)
@@ -25,6 +25,7 @@
 
 namespace WebCore {
 class LayerWebKitThread;
+class Node;
 class RenderLayer;
 }
 
@@ -49,7 +50,10 @@
     WebPagePrivate* m_webPage;
     WebCore::RenderLayer* m_layer;
 
+    // We either cache one here: in case of a composited scrollable layer
+    // cache the LayerWebKitThread. Otherwise, the Node.
     RefPtr<WebCore::LayerWebKitThread> m_cachedCompositedScrollableLayer;
+    RefPtr<WebCore::Node> m_cachedNonCompositedScrollableNode;
 
     bool m_hasWindowVisibleRectCalculated;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to