Title: [149137] trunk/Source/WebKit/blackberry
Revision
149137
Author
commit-qu...@webkit.org
Date
2013-04-25 13:02:55 -0700 (Thu, 25 Apr 2013)

Log Message

[BlackBerry] Make scroll position adjustment work with pages with fixed position elements.
https://bugs.webkit.org/show_bug.cgi?id=115178

Patch by Iris Wu <sh...@blackberry.com> on 2013-04-25
Reviewed by Rob Buis.

PR 308796

Currently the position WebPage::adjustDocumentScrollPosition adjusts is the top
left point of the viewport.
On the page with fixed position elements, we want it to adjust the position beneath
the fixed elements so it can be always visible.

The basic idea is:
1.  Detect if there are fixed position elements before going through ProximityDetector.
2.  If the fixed element exists, calculate its the size and the actual visible position
    beneath it.
3.  Pass the position to ProximityDetector. Then according to the new position we get,
    calculate the top left position of the viewport (final scroll position).

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::fixedElementSizeDelta):
(WebKit):
* Api/WebPage.h:
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::findFixedElementRect):
(WebKit):
* Api/WebPageCompositor_p.h:
(WebPageCompositorPrivate):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (149136 => 149137)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-04-25 20:00:36 UTC (rev 149136)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-04-25 20:02:55 UTC (rev 149137)
@@ -5238,6 +5238,21 @@
     return d->m_proximityDetector->findBestPoint(documentScrollPosition, documentPaddingRect);
 }
 
+Platform::IntSize WebPage::fixedElementSizeDelta()
+{
+    ASSERT(userInterfaceThreadMessageClient()->isCurrentThread());
+
+    // Traverse the layer tree and find the fixed element rect if there is one.
+    IntRect fixedElementRect;
+    if (d->compositor() && d->compositor()->rootLayer())
+        d->compositor()->findFixedElementRect(d->compositor()->rootLayer(), fixedElementRect);
+
+    // Ignore the fixed element if it is not at the top of page.
+    if (!fixedElementRect.isEmpty() && !fixedElementRect.y())
+        return Platform::IntSize(0, fixedElementRect.height());
+    return Platform::IntSize();
+}
+
 bool WebPagePrivate::compositorDrawsRootLayer() const
 {
     if (!m_mainFrame)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (149136 => 149137)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2013-04-25 20:00:36 UTC (rev 149136)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2013-04-25 20:02:55 UTC (rev 149137)
@@ -332,6 +332,7 @@
     void inspectCurrentContextElement();
 
     Platform::IntPoint adjustDocumentScrollPosition(const Platform::IntPoint& documentScrollPosition, const Platform::IntRect& documentPaddingRect);
+    Platform::IntSize fixedElementSizeDelta();
 
     // FIXME: Needs API review on this header. See PR #120402.
     void notifyPagePause();

Modified: trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp (149136 => 149137)


--- trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp	2013-04-25 20:00:36 UTC (rev 149136)
+++ trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp	2013-04-25 20:02:55 UTC (rev 149137)
@@ -280,6 +280,23 @@
         m_compositingThreadOverlayLayer.clear();
 }
 
+void WebPageCompositorPrivate::findFixedElementRect(LayerCompositingThread* layer, WebCore::IntRect& fixedElementRect)
+{
+    if ((layer->hasFixedContainer() || layer->isFixedPosition() || layer->hasFixedAncestorInDOMTree()) && layer->layerRenderer()) {
+        IntRect fixedRect = layer->layerRenderer()->toPixelViewportCoordinates(layer->getDrawRect());
+        // FIXME: It's possible that the rects don't intersect now, but will be connected by a fixed rect found later.
+        // We need to handle it as well.
+        if (fixedElementRect.isEmpty() || fixedElementRect.intersects(fixedRect)) // Unite rects if they intersect each other.
+            fixedElementRect.unite(fixedRect);
+        else if (fixedRect.y() < fixedElementRect.y()) // Replace the fixedElementRect with fixedRect if fixedRect is above it (closer to top).
+            fixedElementRect = fixedRect;
+    }
+
+    const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->getSublayers();
+    for (size_t i = 0; i < sublayers.size(); i++)
+        findFixedElementRect(sublayers[i].get(), fixedElementRect);
+}
+
 WebPageCompositor::WebPageCompositor(WebPage* page, WebPageCompositorClient* client)
 {
     using namespace BlackBerry::Platform;

Modified: trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h (149136 => 149137)


--- trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h	2013-04-25 20:00:36 UTC (rev 149136)
+++ trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h	2013-04-25 20:02:55 UTC (rev 149137)
@@ -104,6 +104,8 @@
     void addOverlay(WebCore::LayerCompositingThread*);
     void removeOverlay(WebCore::LayerCompositingThread*);
 
+    void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
+
 protected:
     WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (149136 => 149137)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-04-25 20:00:36 UTC (rev 149136)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-04-25 20:02:55 UTC (rev 149137)
@@ -1,3 +1,34 @@
+2013-04-25  Iris Wu  <sh...@blackberry.com>
+
+        [BlackBerry] Make scroll position adjustment work with pages with fixed position elements.
+        https://bugs.webkit.org/show_bug.cgi?id=115178
+
+        Reviewed by Rob Buis.
+
+        PR 308796
+
+        Currently the position WebPage::adjustDocumentScrollPosition adjusts is the top
+        left point of the viewport.
+        On the page with fixed position elements, we want it to adjust the position beneath
+        the fixed elements so it can be always visible.
+
+        The basic idea is:
+        1.  Detect if there are fixed position elements before going through ProximityDetector.
+        2.  If the fixed element exists, calculate its the size and the actual visible position
+            beneath it.
+        3.  Pass the position to ProximityDetector. Then according to the new position we get,
+            calculate the top left position of the viewport (final scroll position).
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPage::fixedElementSizeDelta):
+        (WebKit):
+        * Api/WebPage.h:
+        * Api/WebPageCompositor.cpp:
+        (BlackBerry::WebKit::WebPageCompositorPrivate::findFixedElementRect):
+        (WebKit):
+        * Api/WebPageCompositor_p.h:
+        (WebPageCompositorPrivate):
+
 2013-04-25  Mike Lattanzio  <mlattan...@blackberry.com>
 
         [BlackBerry] Enable balanced page group load deferrer behaviour.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to