Changeset 149137 in webkit


Ignore:
Timestamp:
Apr 25, 2013 1:02:55 PM (11 years ago)
Author:
commit-queue@webkit.org
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 <shuwu@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.

  1. 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):

Location:
trunk/Source/WebKit/blackberry
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r149135 r149137  
    52395239}
    52405240
     5241Platform::IntSize WebPage::fixedElementSizeDelta()
     5242{
     5243    ASSERT(userInterfaceThreadMessageClient()->isCurrentThread());
     5244
     5245    // Traverse the layer tree and find the fixed element rect if there is one.
     5246    IntRect fixedElementRect;
     5247    if (d->compositor() && d->compositor()->rootLayer())
     5248        d->compositor()->findFixedElementRect(d->compositor()->rootLayer(), fixedElementRect);
     5249
     5250    // Ignore the fixed element if it is not at the top of page.
     5251    if (!fixedElementRect.isEmpty() && !fixedElementRect.y())
     5252        return Platform::IntSize(0, fixedElementRect.height());
     5253    return Platform::IntSize();
     5254}
     5255
    52415256bool WebPagePrivate::compositorDrawsRootLayer() const
    52425257{
  • trunk/Source/WebKit/blackberry/Api/WebPage.h

    r148543 r149137  
    333333
    334334    Platform::IntPoint adjustDocumentScrollPosition(const Platform::IntPoint& documentScrollPosition, const Platform::IntRect& documentPaddingRect);
     335    Platform::IntSize fixedElementSizeDelta();
    335336
    336337    // FIXME: Needs API review on this header. See PR #120402.
  • trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp

    r148676 r149137  
    281281}
    282282
     283void WebPageCompositorPrivate::findFixedElementRect(LayerCompositingThread* layer, WebCore::IntRect& fixedElementRect)
     284{
     285    if ((layer->hasFixedContainer() || layer->isFixedPosition() || layer->hasFixedAncestorInDOMTree()) && layer->layerRenderer()) {
     286        IntRect fixedRect = layer->layerRenderer()->toPixelViewportCoordinates(layer->getDrawRect());
     287        // FIXME: It's possible that the rects don't intersect now, but will be connected by a fixed rect found later.
     288        // We need to handle it as well.
     289        if (fixedElementRect.isEmpty() || fixedElementRect.intersects(fixedRect)) // Unite rects if they intersect each other.
     290            fixedElementRect.unite(fixedRect);
     291        else if (fixedRect.y() < fixedElementRect.y()) // Replace the fixedElementRect with fixedRect if fixedRect is above it (closer to top).
     292            fixedElementRect = fixedRect;
     293    }
     294
     295    const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->getSublayers();
     296    for (size_t i = 0; i < sublayers.size(); i++)
     297        findFixedElementRect(sublayers[i].get(), fixedElementRect);
     298}
     299
    283300WebPageCompositor::WebPageCompositor(WebPage* page, WebPageCompositorClient* client)
    284301{
  • trunk/Source/WebKit/blackberry/Api/WebPageCompositor_p.h

    r147136 r149137  
    105105    void removeOverlay(WebCore::LayerCompositingThread*);
    106106
     107    void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
     108
    107109protected:
    108110    WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
  • trunk/Source/WebKit/blackberry/ChangeLog

    r149135 r149137  
     12013-04-25  Iris Wu  <shuwu@blackberry.com>
     2
     3        [BlackBerry] Make scroll position adjustment work with pages with fixed position elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=115178
     5
     6        Reviewed by Rob Buis.
     7
     8        PR 308796
     9
     10        Currently the position WebPage::adjustDocumentScrollPosition adjusts is the top
     11        left point of the viewport.
     12        On the page with fixed position elements, we want it to adjust the position beneath
     13        the fixed elements so it can be always visible.
     14
     15        The basic idea is:
     16        1.  Detect if there are fixed position elements before going through ProximityDetector.
     17        2.  If the fixed element exists, calculate its the size and the actual visible position
     18            beneath it.
     19        3.  Pass the position to ProximityDetector. Then according to the new position we get,
     20            calculate the top left position of the viewport (final scroll position).
     21
     22        * Api/WebPage.cpp:
     23        (BlackBerry::WebKit::WebPage::fixedElementSizeDelta):
     24        (WebKit):
     25        * Api/WebPage.h:
     26        * Api/WebPageCompositor.cpp:
     27        (BlackBerry::WebKit::WebPageCompositorPrivate::findFixedElementRect):
     28        (WebKit):
     29        * Api/WebPageCompositor_p.h:
     30        (WebPageCompositorPrivate):
     31
    1322013-04-25  Mike Lattanzio  <mlattanzio@blackberry.com>
    233
Note: See TracChangeset for help on using the changeset viewer.