Changeset 147163 in webkit


Ignore:
Timestamp:
Mar 28, 2013 2:50:39 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Support bottom-right anchored fixed-position elements during a pinch gesture
https://bugs.webkit.org/show_bug.cgi?id=111670

Patch by Tien-Ren Chen <trchen@chromium.org> on 2013-03-28
Reviewed by James Robinson.

Source/Platform:

Added WebLayerPositionConstraint for layers that need position
adjustment during threaded scrolling.
Currently it is only used for fixed-position layers.

  • Platform.gypi:
  • chromium/public/WebLayer.h:

(WebKit):
(WebLayer):
(WebKit::WebLayer::setPositionConstraint):
(WebKit::WebLayer::positionConstraint):
(WebKit::WebLayer::setFixedToContainerLayer):
(WebKit::WebLayer::fixedToContainerLayer):

  • chromium/public/WebLayerPositionConstraint.h: Added.

(WebKit):
(WebLayerPositionConstraint):
(WebKit::WebLayerPositionConstraint::WebLayerPositionConstraint):
(WebKit::WebLayerPositionConstraint::fixedPosition):

Source/WebCore:

This patch adds support to bottom-right fixed-position elements by
introducing WebLayerPositionConstraint to WebLayer.

No new tests. Can't test until chromium patch landed.

  • page/scrolling/ScrollingCoordinator.h:

(WebCore::ScrollingCoordinator::updateLayerPositionConstraint):

  • page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:

(WebCore::clearPositionConstraintExceptForLayer):
(WebCore):
(WebCore::computePositionConstraint):
(WebCore::ScrollingCoordinatorChromium::updateLayerPositionConstraint):

  • page/scrolling/chromium/ScrollingCoordinatorChromium.h:

(ScrollingCoordinatorChromium):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::registerScrollingLayers):

  • rendering/RenderLayerBacking.h:

(WebCore::RenderLayerBacking::contentsContainmentLayer):
(RenderLayerBacking):

  • rendering/RenderLayerCompositor.cpp:
  • rendering/RenderLayerCompositor.h:
Location:
trunk/Source
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r147137 r147163  
     12013-03-28  Tien-Ren Chen  <trchen@chromium.org>
     2
     3        Support bottom-right anchored fixed-position elements during a pinch gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=111670
     5
     6        Reviewed by James Robinson.
     7
     8        Added WebLayerPositionConstraint for layers that need position
     9        adjustment during threaded scrolling.
     10        Currently it is only used for fixed-position layers.
     11
     12        * Platform.gypi:
     13        * chromium/public/WebLayer.h:
     14        (WebKit):
     15        (WebLayer):
     16        (WebKit::WebLayer::setPositionConstraint):
     17        (WebKit::WebLayer::positionConstraint):
     18        (WebKit::WebLayer::setFixedToContainerLayer):
     19        (WebKit::WebLayer::fixedToContainerLayer):
     20        * chromium/public/WebLayerPositionConstraint.h: Added.
     21        (WebKit):
     22        (WebLayerPositionConstraint):
     23        (WebKit::WebLayerPositionConstraint::WebLayerPositionConstraint):
     24        (WebKit::WebLayerPositionConstraint::fixedPosition):
     25
    1262013-03-28  Zan Dobersek  <zdobersek@igalia.com>
    227
  • trunk/Source/Platform/Platform.gypi

    r146957 r147163  
    8484            'chromium/public/WebImageLayer.h',
    8585            'chromium/public/WebLayer.h',
     86            'chromium/public/WebLayerPositionConstraint.h',
    8687            'chromium/public/WebLayerScrollClient.h',
    8788            'chromium/public/WebLayerTreeView.h',
  • trunk/Source/Platform/chromium/public/WebLayer.h

    r146487 r147163  
    3030#include "WebColor.h"
    3131#include "WebCommon.h"
     32
     33// Remove after making setPositionConstraint() pure virtual.
     34#include "WebLayerPositionConstraint.h"
     35
    3236#include "WebPoint.h"
    3337#include "WebPrivatePtr.h"
     
    4549struct WebFloatPoint;
    4650struct WebFloatRect;
     51struct WebLayerPositionConstraint;
    4752struct WebSize;
    4853
     
    190195    virtual bool isContainerForFixedPositionLayers() const = 0;
    191196
    192     virtual void setFixedToContainerLayer(bool) = 0;
    193     virtual bool fixedToContainerLayer() const = 0;
     197    // This function sets layer position constraint. The constraint will be used
     198    // to adjust layer position during threaded scrolling.
     199    // FIXME: Make pure virtual after implementation lands.
     200    virtual void setPositionConstraint(const WebLayerPositionConstraint& constraint) { setFixedToContainerLayer(constraint.isFixedPosition); }
     201    virtual WebLayerPositionConstraint positionConstraint() const { return WebLayerPositionConstraint(); }
    194202
    195203    // The scroll client is notified when the scroll position of the WebLayer
     
    206214    // True if the layer is not part of a tree attached to a WebLayerTreeView.
    207215    virtual bool isOrphan() const = 0;
     216
     217    // DEPRECATED
     218    virtual void setFixedToContainerLayer(bool) { }
     219    virtual bool fixedToContainerLayer() const { return positionConstraint().isFixedPosition; }
    208220};
    209221
  • trunk/Source/WebCore/ChangeLog

    r147157 r147163  
     12013-03-28  Tien-Ren Chen  <trchen@chromium.org>
     2
     3        Support bottom-right anchored fixed-position elements during a pinch gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=111670
     5
     6        Reviewed by James Robinson.
     7
     8        This patch adds support to bottom-right fixed-position elements by
     9        introducing WebLayerPositionConstraint to WebLayer.
     10
     11        No new tests. Can't test until chromium patch landed.
     12
     13        * page/scrolling/ScrollingCoordinator.h:
     14        (WebCore::ScrollingCoordinator::updateLayerPositionConstraint):
     15        * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
     16        (WebCore::clearPositionConstraintExceptForLayer):
     17        (WebCore):
     18        (WebCore::computePositionConstraint):
     19        (WebCore::ScrollingCoordinatorChromium::updateLayerPositionConstraint):
     20        * page/scrolling/chromium/ScrollingCoordinatorChromium.h:
     21        (ScrollingCoordinatorChromium):
     22        * rendering/RenderLayerBacking.cpp:
     23        (WebCore::RenderLayerBacking::registerScrollingLayers):
     24        * rendering/RenderLayerBacking.h:
     25        (WebCore::RenderLayerBacking::contentsContainmentLayer):
     26        (RenderLayerBacking):
     27        * rendering/RenderLayerCompositor.cpp:
     28        * rendering/RenderLayerCompositor.h:
     29
    1302013-03-28  James Robinson  <jamesr@chromium.org>
    231
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r144823 r147163  
    154154    virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea*, ScrollbarOrientation) { }
    155155    virtual void setLayerIsContainerForFixedPositionLayers(GraphicsLayer*, bool) { }
    156     virtual void setLayerIsFixedToContainerLayer(GraphicsLayer*, bool) { }
     156    virtual void updateLayerPositionConstraint(RenderLayer*) { }
    157157    virtual void touchEventTargetRectsDidChange(const Document*) { }
    158158
  • trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp

    r146399 r147163  
    3333#include "Page.h"
    3434#include "Region.h"
     35#include "RenderLayerBacking.h"
    3536#include "RenderLayerCompositor.h"
    3637#include "RenderView.h"
     
    4041#include <public/Platform.h>
    4142#include <public/WebCompositorSupport.h>
     43#include <public/WebLayerPositionConstraint.h>
    4244#include <public/WebScrollbar.h>
    4345#include <public/WebScrollbarLayer.h>
     
    4648
    4749using WebKit::WebLayer;
     50using WebKit::WebLayerPositionConstraint;
    4851using WebKit::WebRect;
    4952using WebKit::WebScrollbarLayer;
     
    234237}
    235238
    236 void ScrollingCoordinatorChromium::setLayerIsFixedToContainerLayer(GraphicsLayer* layer, bool enable)
    237 {
    238     if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer))
    239         scrollableLayer->setFixedToContainerLayer(enable);
     239static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, GraphicsLayer* except)
     240{
     241    if (layer && layer != except && scrollingWebLayerForGraphicsLayer(layer))
     242        scrollingWebLayerForGraphicsLayer(layer)->setPositionConstraint(WebLayerPositionConstraint());
     243}
     244
     245static WebLayerPositionConstraint computePositionConstraint(const RenderLayer* layer)
     246{
     247    ASSERT(layer->isComposited());
     248    do {
     249        if (layer->renderer()->style()->position() == FixedPosition) {
     250            const RenderObject* fixedPositionObject = layer->renderer();
     251            bool fixedToRight = !fixedPositionObject->style()->right().isAuto();
     252            bool fixedToBottom = !fixedPositionObject->style()->bottom().isAuto();
     253            return WebLayerPositionConstraint::fixedPosition(fixedToRight, fixedToBottom);
     254        }
     255
     256        layer = layer->parent();
     257    } while (layer && !layer->isComposited());
     258    return WebLayerPositionConstraint();
     259}
     260
     261void ScrollingCoordinatorChromium::updateLayerPositionConstraint(RenderLayer* layer)
     262{
     263    ASSERT(layer->backing());
     264    RenderLayerBacking* backing = layer->backing();
     265    GraphicsLayer* mainLayer = backing->childForSuperlayers();
     266
     267    // Avoid unnecessary commits
     268    clearPositionConstraintExceptForLayer(backing->ancestorClippingLayer(), mainLayer);
     269    clearPositionConstraintExceptForLayer(backing->contentsContainmentLayer(), mainLayer);
     270    clearPositionConstraintExceptForLayer(backing->graphicsLayer(), mainLayer);
     271
     272    if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(mainLayer))
     273        scrollableLayer->setPositionConstraint(computePositionConstraint(layer));
    240274}
    241275
  • trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.h

    r144024 r147163  
    5454
    5555    // Attach/detach layer position to ancestor fixed position container.
    56     virtual void setLayerIsFixedToContainerLayer(GraphicsLayer*, bool);
     56    virtual void updateLayerPositionConstraint(RenderLayer*);
    5757
    5858    // Should be called when a ScrollableArea is getting destroyed.
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r146531 r147163  
    861861    compositor()->updateViewportConstraintStatus(m_owningLayer);
    862862
    863     // FIXME: it would be nice to avoid all this work if the platform doesn't implement setLayerIsFixedToContainerLayer().
    864     if (renderer()->style()->position() == FixedPosition || compositor()->fixedPositionedByAncestor(m_owningLayer))
    865         scrollingCoordinator->setLayerIsFixedToContainerLayer(childForSuperlayers(), true);
    866     else {
    867         if (m_ancestorClippingLayer)
    868             scrollingCoordinator->setLayerIsFixedToContainerLayer(m_ancestorClippingLayer.get(), false);
    869         scrollingCoordinator->setLayerIsFixedToContainerLayer(m_graphicsLayer.get(), false);
    870     }
     863    if (!scrollingCoordinator->supportsFixedPositionLayers())
     864        return;
     865
     866    scrollingCoordinator->updateLayerPositionConstraint(m_owningLayer);
     867
    871868    // Page scale is applied as a transform on the root render view layer. Because the scroll
    872869    // layer is further up in the hierarchy, we need to avoid marking the root render view
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r145563 r147163  
    8888    GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLayer.get(); }
    8989
     90    GraphicsLayer* contentsContainmentLayer() const { return m_contentsContainmentLayer.get(); }
     91
    9092    bool hasContentsLayer() const { return m_foregroundLayer != 0; }
    9193    GraphicsLayer* foregroundLayer() const { return m_foregroundLayer.get(); }
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r147120 r147163  
    19381938}
    19391939
    1940 // Return true if there is an ancestor layer that is fixed positioned to the view.
    1941 // Note that if the ancestor has a stacking context and is fixed position then this method
    1942 // will return false.
    1943 bool RenderLayerCompositor::fixedPositionedByAncestor(const RenderLayer* layer) const
    1944 {
    1945     if (!layer->isComposited() || !layer->parent())
    1946         return false;
    1947 
    1948     const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
    1949     if (!compositingAncestor)
    1950         return false;
    1951 
    1952     const RenderLayer* curr = layer;
    1953     while (curr) {
    1954         const RenderLayer* next = curr->parent();
    1955         if (next == compositingAncestor)
    1956             return false;
    1957 
    1958         if (next && next->renderer()->style()->position() == FixedPosition)
    1959             return true;
    1960         curr = next;
    1961     }
    1962     return false;
    1963 }
    1964 
    19651940bool RenderLayerCompositor::requiresCompositingForScrollableFrame() const
    19661941{
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r147039 r147163  
    155155    bool clipsCompositingDescendants(const RenderLayer*) const;
    156156
    157     // Whether the layer is fixed positioned to the view by an ancestor layer.
    158     bool fixedPositionedByAncestor(const RenderLayer*) const;
    159 
    160157    // Whether the given layer needs an extra 'contents' layer.
    161158    bool needsContentsCompositingLayer(const RenderLayer*) const;
Note: See TracChangeset for help on using the changeset viewer.