Introduce the "stacking container" concept.
authorvollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 01:42:08 +0000 (01:42 +0000)
committervollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 01:42:08 +0000 (01:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107734

Reviewed by Simon Fraser.

A stacking container is treated just like a stacking context. That
is, it has z-order lists, it and its descendants are stacked as a
unit, and when the RenderLayerCompositor does its overlap testing,
the composited regions for all layer lists take effect only once the
stacking container is done being processed.

This patch also adds the function RenderLayer::isStackingContainer().
Currently, this is equivalent to RenderLayer::isStackingContext(),
but in future, the definition of stacking container will be broadened
to encompass more than just stacking contexts.

Other than the addition of this extra function, the patch is mostly
comprised of name changes. Any code that used to refer to the
stacking context concept, but didn't necessarily require a stacking
context in the strict, CSS-sense, was switched to refer to stacking
container. No functionality was changed.

No new tests, no change in functionality.

Source/WebCore:

* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::buildObjectForLayer):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
(WebCore):
(WebCore::RenderLayer::updatePagination):
(WebCore::RenderLayer::canBeStackingContainer):
(WebCore::RenderLayer::setHasVisibleContent):
(WebCore::RenderLayer::dirty3DTransformedDescendantStatus):
(WebCore::RenderLayer::stackingContainer):
(WebCore::compositingContainer):
(WebCore::expandClipRectForDescendantsAndReflection):
(WebCore::RenderLayer::addChild):
(WebCore::RenderLayer::removeChild):
(WebCore::RenderLayer::updateNeedsCompositedScrolling):
(WebCore::RenderLayer::updateCompositingLayersAfterScroll):
(WebCore::RenderLayer::paintPaginatedChildLayer):
(WebCore::RenderLayer::hitTestPaginatedChildLayer):
(WebCore::RenderLayer::calculateLayerBounds):
(WebCore::RenderLayer::dirtyZOrderLists):
(WebCore::RenderLayer::dirtyStackingContainerZOrderLists):
(WebCore::RenderLayer::collectLayers):
(WebCore::RenderLayer::updateCompositingAndLayerListsIfNeeded):
(WebCore::RenderLayer::updateStackingContextsAfterStyleChange):
(WebCore::RenderLayer::styleChanged):
* rendering/RenderLayer.h:
(RenderLayer):
(WebCore::RenderLayer::isStackingContainer):
(WebCore::RenderLayer::posZOrderList):
(WebCore::RenderLayer::negZOrderList):
(WebCore::RenderLayer::isDirtyStackingContainer):
(WebCore::RenderLayer::clearZOrderLists):
(WebCore::RenderLayer::updateZOrderLists):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::compositingOpacity):
(WebCore::RenderLayerBacking::hasVisibleNonCompositingDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::enclosingNonStackingClippingLayer):
(WebCore::RenderLayerCompositor::addToOverlapMapRecursive):
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
(WebCore::RenderLayerCompositor::updateLayerTreeGeometry):
(WebCore::RenderLayerCompositor::updateCompositingDescendantGeometry):
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):
(WebCore::RenderLayerCompositor::layerHas3DContent):
(WebCore::isRootmostFixedOrStickyLayer):

Source/WebKit2:

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::updateOffsetFromViewportForSelf):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140620 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorLayerTreeAgent.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

index 608c3d2..2751e16 100644 (file)
@@ -1,3 +1,77 @@
+2013-01-23  Ian Vollick  <vollick@chromium.org>
+
+        Introduce the "stacking container" concept.
+        https://bugs.webkit.org/show_bug.cgi?id=107734
+
+        Reviewed by Simon Fraser.
+
+        A stacking container is treated just like a stacking context. That
+        is, it has z-order lists, it and its descendants are stacked as a
+        unit, and when the RenderLayerCompositor does its overlap testing,
+        the composited regions for all layer lists take effect only once the
+        stacking container is done being processed.
+
+        This patch also adds the function RenderLayer::isStackingContainer().
+        Currently, this is equivalent to RenderLayer::isStackingContext(),
+        but in future, the definition of stacking container will be broadened
+        to encompass more than just stacking contexts.
+
+        Other than the addition of this extra function, the patch is mostly
+        comprised of name changes. Any code that used to refer to the
+        stacking context concept, but didn't necessarily require a stacking
+        context in the strict, CSS-sense, was switched to refer to stacking
+        container. No functionality was changed.
+
+        No new tests, no change in functionality.
+
+        * inspector/InspectorLayerTreeAgent.cpp:
+        (WebCore::InspectorLayerTreeAgent::buildObjectForLayer):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::RenderLayer):
+        (WebCore):
+        (WebCore::RenderLayer::updatePagination):
+        (WebCore::RenderLayer::canBeStackingContainer):
+        (WebCore::RenderLayer::setHasVisibleContent):
+        (WebCore::RenderLayer::dirty3DTransformedDescendantStatus):
+        (WebCore::RenderLayer::stackingContainer):
+        (WebCore::compositingContainer):
+        (WebCore::expandClipRectForDescendantsAndReflection):
+        (WebCore::RenderLayer::addChild):
+        (WebCore::RenderLayer::removeChild):
+        (WebCore::RenderLayer::updateNeedsCompositedScrolling):
+        (WebCore::RenderLayer::updateCompositingLayersAfterScroll):
+        (WebCore::RenderLayer::paintPaginatedChildLayer):
+        (WebCore::RenderLayer::hitTestPaginatedChildLayer):
+        (WebCore::RenderLayer::calculateLayerBounds):
+        (WebCore::RenderLayer::dirtyZOrderLists):
+        (WebCore::RenderLayer::dirtyStackingContainerZOrderLists):
+        (WebCore::RenderLayer::collectLayers):
+        (WebCore::RenderLayer::updateCompositingAndLayerListsIfNeeded):
+        (WebCore::RenderLayer::updateStackingContextsAfterStyleChange):
+        (WebCore::RenderLayer::styleChanged):
+        * rendering/RenderLayer.h:
+        (RenderLayer):
+        (WebCore::RenderLayer::isStackingContainer):
+        (WebCore::RenderLayer::posZOrderList):
+        (WebCore::RenderLayer::negZOrderList):
+        (WebCore::RenderLayer::isDirtyStackingContainer):
+        (WebCore::RenderLayer::clearZOrderLists):
+        (WebCore::RenderLayer::updateZOrderLists):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
+        (WebCore::RenderLayerBacking::compositingOpacity):
+        (WebCore::RenderLayerBacking::hasVisibleNonCompositingDescendantLayers):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::enclosingNonStackingClippingLayer):
+        (WebCore::RenderLayerCompositor::addToOverlapMapRecursive):
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        (WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
+        (WebCore::RenderLayerCompositor::updateLayerTreeGeometry):
+        (WebCore::RenderLayerCompositor::updateCompositingDescendantGeometry):
+        (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
+        (WebCore::RenderLayerCompositor::layerHas3DContent):
+        (WebCore::isRootmostFixedOrStickyLayer):
+
 2013-01-23  Simon Fraser  <simon.fraser@apple.com>
 
         Have scrollperf logging log information about wheel event handlers
index f5583c8..c77d118 100644 (file)
@@ -149,7 +149,7 @@ PassRefPtr<TypeBuilder::LayerTree::Layer> InspectorLayerTreeAgent::buildObjectFo
     if (renderLayer->reflectionLayer())
         childrenArray->addItem(buildObjectForLayer(renderLayer->reflectionLayer()));
 
-    if (renderLayer->isStackingContext()) {
+    if (renderLayer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = renderLayer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
@@ -163,7 +163,7 @@ PassRefPtr<TypeBuilder::LayerTree::Layer> InspectorLayerTreeAgent::buildObjectFo
             childrenArray->addItem(buildObjectForLayer(normalFlowList->at(i)));
     }
     
-    if (renderLayer->isStackingContext()) {
+    if (renderLayer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = renderLayer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
index b89ccd3..894ac3d 100644 (file)
@@ -196,9 +196,9 @@ RenderLayer::RenderLayer(RenderLayerModelObject* renderer)
     m_isNormalFlowOnly = shouldBeNormalFlowOnly();
     m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
 
-    // Non-stacking contexts should have empty z-order lists. As this is already the case,
+    // Non-stacking containers should have empty z-order lists. As this is already the case,
     // there is no need to dirty / recompute these lists.
-    m_zOrderListsDirty = isStackingContext();
+    m_zOrderListsDirty = isStackingContainer();
 
     ScrollableArea::setConstrainsScrollingToContentEdge(false);
 
@@ -522,10 +522,10 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
         && renderer()->frame()->page()->settings()->acceleratedCompositingForOverflowScrollEnabled();
 }
 
-// If we are a stacking context, then this function will determine if our
+// If we are a stacking container, then this function will determine if our
 // descendants for a contiguous block in stacking order. This is required in
-// order for an element to be safely promoted to a stacking context. It is safe
-// to become a stacking context if this change would not alter the stacking
+// order for an element to be safely promoted to a stacking container. It is safe
+// to become a stacking container if this change would not alter the stacking
 // order of layers on the page. That can only happen if a non-descendant appear
 // between us and our descendants in stacking order. Here's an example:
 //
@@ -538,8 +538,8 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
 //                                   5
 //
 // I've labeled our normal flow descendants A, B, C, and D, our stacking
-// context descendants with their z indices, and us with 'this' (we're a
-// stacking context and our zIndex doesn't matter here). These nodes appear in
+// container descendants with their z indices, and us with 'this' (we're a
+// stacking container and our zIndex doesn't matter here). These nodes appear in
 // three lists: posZOrder, negZOrder, and normal flow (keep in mind that normal
 // flow layers don't overlap). So if we arrange these lists in order we get our
 // stacking order:
@@ -555,10 +555,10 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
 //
 // Note that the normal flow descendants can share an index because they don't
 // stack/overlap. Now our problem becomes very simple: a layer can safely become
-// a stacking context if the stacking-order indices of it and its descendants
+// a stacking container if the stacking-order indices of it and its descendants
 // appear in a contiguous block in the list of stacking indices. This problem
 // can be solved very efficiently by calculating the min/max stacking indices in
-// the subtree, and the number stacking context descendants. Once we have this
+// the subtree, and the number stacking container descendants. Once we have this
 // information, we know that the subtree's indices form a contiguous block if:
 //
 //           maxStackIndex - minStackIndex == numSCDescendants
@@ -573,7 +573,7 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
 //  ===>                      1 - (-1) == 2
 //  ===>                             2 == 2
 //
-//  Since this is true, A can safely become a stacking context.
+//  Since this is true, A can safely become a stacking container.
 //  Now, for node C we have:
 //
 //   maxStackIndex = 4
@@ -585,7 +585,7 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
 //  ===>                         4 - 0 == 2
 //  ===>                             4 == 2
 //
-// Since this is false, C cannot be safely promoted to a stacking context. This
+// Since this is false, C cannot be safely promoted to a stacking container. This
 // happened because of the elements with z-index 5 and 0. Now if 5 had been a
 // child of C rather than D, and A had no child with Z index 0, we would have had:
 //
@@ -915,21 +915,21 @@ void RenderLayer::updatePagination()
         return;
     }
 
-    // If we're not normal flow, then we need to look for a multi-column object between us and our stacking context.
-    RenderLayer* ancestorStackingContext = stackingContext();
+    // If we're not normal flow, then we need to look for a multi-column object between us and our stacking container.
+    RenderLayer* ancestorStackingContainer = stackingContainer();
     for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
         if (curr->renderer()->hasColumns()) {
             m_isPaginated = checkContainingBlockChainForPagination(renderer(), curr->renderBox());
             return;
         }
-        if (curr == ancestorStackingContext)
+        if (curr == ancestorStackingContainer)
             return;
     }
 }
 
-bool RenderLayer::canSafelyEstablishAStackingContext() const
+bool RenderLayer::canBeStackingContainer() const
 {
-    if (isStackingContext() || !stackingContext())
+    if (isStackingContext() || !stackingContainer())
         return true;
 
     return m_descendantsAreContiguousInStackingOrder;
@@ -947,9 +947,9 @@ void RenderLayer::setHasVisibleContent()
     computeRepaintRects(renderer()->containerForRepaint());
     if (!isNormalFlowOnly()) {
         // We don't collect invisible layers in z-order lists if we are not in compositing mode.
-        // As we became visible, we need to dirty our stacking contexts ancestors to be properly
+        // As we became visible, we need to dirty our stacking containers ancestors to be properly
         // collected. FIXME: When compositing, we could skip this dirtying phase.
-        for (RenderLayer* sc = stackingContext(); sc; sc = sc->stackingContext()) {
+        for (RenderLayer* sc = stackingContainer(); sc; sc = sc->stackingContainer()) {
             sc->dirtyZOrderLists();
             if (sc->hasVisibleContent())
                 break;
@@ -1068,15 +1068,15 @@ void RenderLayer::updateDescendantDependentFlags(HashSet<const RenderObject*>* o
 
 void RenderLayer::dirty3DTransformedDescendantStatus()
 {
-    RenderLayer* curr = stackingContext();
+    RenderLayer* curr = stackingContainer();
     if (curr)
         curr->m_3DTransformedDescendantStatusDirty = true;
         
     // This propagates up through preserve-3d hierarchies to the enclosing flattening layer.
-    // Note that preserves3D() creates stacking context, so we can just run up the stacking contexts.
+    // Note that preserves3D() creates stacking context, so we can just run up the stacking containers.
     while (curr && curr->preserves3D()) {
         curr->m_3DTransformedDescendantStatusDirty = true;
-        curr = curr->stackingContext();
+        curr = curr->stackingContainer();
     }
 }
 
@@ -1239,13 +1239,13 @@ FloatPoint RenderLayer::perspectiveOrigin() const
                       floatValueForLength(style->perspectiveOriginY(), borderBox.height()));
 }
 
-RenderLayer* RenderLayer::stackingContext() const
+RenderLayer* RenderLayer::stackingContainer() const
 {
     RenderLayer* layer = parent();
-    while (layer && !layer->isStackingContext())
+    while (layer && !layer->isStackingContainer())
         layer = layer->parent();
 
-    ASSERT(!layer || layer->isStackingContext());
+    ASSERT(!layer || layer->isStackingContainer());
     return layer;
 }
 
@@ -1295,7 +1295,7 @@ RenderLayer* RenderLayer::enclosingTransformedAncestor() const
 
 static inline const RenderLayer* compositingContainer(const RenderLayer* layer)
 {
-    return layer->isNormalFlowOnly() ? layer->parent() : layer->stackingContext();
+    return layer->isNormalFlowOnly() ? layer->parent() : layer->stackingContainer();
 }
 
 inline bool RenderLayer::shouldRepaintAfterLayout() const
@@ -1509,7 +1509,7 @@ static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons
     // no need to examine child layers).
     if (!layer->renderer()->hasMask()) {
         // Note: we don't have to walk z-order lists since transparent elements always establish
-        // a stacking context.  This means we can just walk the layer tree directly.
+        // a stacking container. This means we can just walk the layer tree directly.
         for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling()) {
             if (!layer->reflection() || layer->reflectionLayer() != curr)
                 clipRect.unite(transparencyClipBox(curr, rootLayer, paintBehavior));
@@ -1624,10 +1624,10 @@ void RenderLayer::addChild(RenderLayer* child, RenderLayer* beforeChild)
         dirtyNormalFlowList();
 
     if (!child->isNormalFlowOnly() || child->firstChild()) {
-        // Dirty the z-order list in which we are contained.  The stackingContext() can be null in the
-        // case where we're building up generated content layers.  This is ok, since the lists will start
+        // Dirty the z-order list in which we are contained. The stackingContainer() can be null in the
+        // case where we're building up generated content layers. This is ok, since the lists will start
         // off dirty in that case anyway.
-        child->dirtyStackingContextZOrderLists();
+        child->dirtyStackingContainerZOrderLists();
     }
 
     child->updateDescendantDependentFlags();
@@ -1668,8 +1668,8 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild)
     if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) { 
         // Dirty the z-order list in which we are contained.  When called via the
         // reattachment process in removeOnlyThisLayer, the layer may already be disconnected
-        // from the main layer tree, so we need to null-check the |stackingContext| value.
-        oldChild->dirtyStackingContextZOrderLists();
+        // from the main layer tree, so we need to null-check the |stackingContainer| value.
+        oldChild->dirtyStackingContainerZOrderLists();
     }
 
     if ((oldChild->renderer() && oldChild->renderer()->isOutOfFlowPositioned()) || oldChild->hasOutOfFlowPositionedDescendant())
@@ -1904,7 +1904,7 @@ void RenderLayer::updateNeedsCompositedScrolling()
         m_needsCompositedScrolling = false;
     else {
         bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScrollEnabled()
-            && canSafelyEstablishAStackingContext()
+            && canBeStackingContainer()
             && !hasOutOfFlowPositionedDescendant();
 
 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
@@ -2217,9 +2217,9 @@ void RenderLayer::updateCompositingLayersAfterScroll()
 {
 #if USE(ACCELERATED_COMPOSITING)
     if (compositor()->inCompositingMode()) {
-        // Our stacking context is guaranteed to contain all of our descendants that may need
+        // Our stacking container is guaranteed to contain all of our descendants that may need
         // repositioning, so update compositing layers from there.
-        if (RenderLayer* compositingAncestor = stackingContext()->enclosingCompositingLayer()) {
+        if (RenderLayer* compositingAncestor = stackingContainer()->enclosingCompositingLayer()) {
             if (compositor()->compositingConsultsOverlap())
                 compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor);
             else
@@ -3842,7 +3842,7 @@ void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsCont
 {
     // We need to do multiple passes, breaking up our child layer into strips.
     Vector<RenderLayer*> columnLayers;
-    RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContext();
+    RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContainer();
     for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) {
         if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagination(childLayer->renderer(), curr->renderBox()))
             columnLayers.append(curr);
@@ -4356,7 +4356,7 @@ RenderLayer* RenderLayer::hitTestPaginatedChildLayer(RenderLayer* childLayer, Re
                                                      const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset)
 {
     Vector<RenderLayer*> columnLayers;
-    RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContext();
+    RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContainer();
     for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) {
         if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagination(childLayer->renderer(), curr->renderBox()))
             columnLayers.append(curr);
@@ -4918,7 +4918,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons
         }
     }
     
-    ASSERT(isStackingContext() || (!posZOrderList() || !posZOrderList()->size()));
+    ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size()));
 
 #if !ASSERT_DISABLED
     LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this));
@@ -5099,7 +5099,7 @@ static inline bool compareZIndex(RenderLayer* first, RenderLayer* second)
 void RenderLayer::dirtyZOrderLists()
 {
     ASSERT(m_layerListMutationAllowed);
-    ASSERT(isStackingContext());
+    ASSERT(isStackingContainer());
 
     if (m_posZOrderList)
         m_posZOrderList->clear();
@@ -5116,9 +5116,9 @@ void RenderLayer::dirtyZOrderLists()
 #endif
 }
 
-void RenderLayer::dirtyStackingContextZOrderLists()
+void RenderLayer::dirtyStackingContainerZOrderLists()
 {
-    RenderLayer* sc = stackingContext();
+    RenderLayer* sc = stackingContainer();
     if (sc)
         sc->dirtyZOrderLists();
 }
@@ -5207,8 +5207,9 @@ void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa
 
     updateDescendantDependentFlags();
 
+    bool isStacking = isStackingContainer();
     // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists.
-    bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_hasVisibleDescendant && isStackingContext()));
+    bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_hasVisibleDescendant && isStacking));
     if (includeHiddenLayer && !isNormalFlowOnly() && !renderer()->isRenderFlowThread()) {
         // Determine which buffer the child should be in.
         OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : negBuffer;
@@ -5222,8 +5223,8 @@ void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa
     }
 
     // Recur into our children to collect more layers, but only if we don't establish
-    // a stacking context.
-    if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStackingContext()) {
+    // a stacking context/container.
+    if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) {
         for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) {
             // Ignore reflections.
             if (!m_reflection || reflectionLayer() != child)
@@ -5252,7 +5253,7 @@ void RenderLayer::updateCompositingAndLayerListsIfNeeded()
 {
 #if USE(ACCELERATED_COMPOSITING)
     if (compositor()->inCompositingMode()) {
-        if (isDirtyStackingContext() || m_normalFlowListDirty)
+        if (isDirtyStackingContainer() || m_normalFlowListDirty)
             compositor()->updateCompositingLayers(CompositingUpdateOnHitTest, this);
         return;
     }
@@ -5373,7 +5374,7 @@ void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS
     bool wasStackingContext = isStackingContext(oldStyle);
     bool isStackingContext = this->isStackingContext();
     if (isStackingContext != wasStackingContext) {
-        dirtyStackingContextZOrderLists();
+        dirtyStackingContainerZOrderLists();
         if (isStackingContext)
             dirtyZOrderLists();
         else
@@ -5384,7 +5385,7 @@ void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS
     // FIXME: RenderLayer already handles visibility changes through our visiblity dirty bits. This logic could
     // likely be folded along with the rest.
     if (oldStyle->zIndex() != renderer()->style()->zIndex() || oldStyle->visibility() != renderer()->style()->visibility()) {
-        dirtyStackingContextZOrderLists();
+        dirtyStackingContainerZOrderLists();
         if (isStackingContext)
             dirtyZOrderLists();
     }
@@ -5480,7 +5481,7 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
         RenderLayer* p = parent();
         if (p)
             p->dirtyNormalFlowList();
-        dirtyStackingContextZOrderLists();
+        dirtyStackingContainerZOrderLists();
     }
 
     if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->marqueeBehavior() != MNONE && renderer()->isBox()) {
@@ -5534,7 +5535,7 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
     else if (m_backing)
         m_backing->updateGraphicsLayerGeometry();
     else if (oldStyle && oldStyle->overflowX() != renderer()->style()->overflowX()) {
-        if (stackingContext()->hasCompositingDescendant())
+        if (stackingContainer()->hasCompositingDescendant())
             compositor()->setCompositingLayersNeedRebuild();
     }
 #endif
index 86e7421..3d6eaa1 100644 (file)
@@ -427,18 +427,23 @@ public:
     void clearBlockSelectionGapsBounds();
     void repaintBlockSelectionGaps();
 
-    // Get the enclosing stacking context for this layer.  A stacking context is a layer
-    // that has a non-auto z-index.
-    RenderLayer* stackingContext() const;
+    // A stacking context is a layer that has a non-auto z-index.
     bool isStackingContext() const { return isStackingContext(renderer()->style()); }
 
+    // A stacking container can have z-order lists. All stacking contexts are
+    // stacking containers, but the converse is not true.
+    bool isStackingContainer() const { return isStackingContext(); }
+
+    // Gets the enclosing stacking container for this layer.
+    RenderLayer* stackingContainer() const;
+
     void dirtyZOrderLists();
-    void dirtyStackingContextZOrderLists();
+    void dirtyStackingContainerZOrderLists();
 
     Vector<RenderLayer*>* posZOrderList() const
     {
         ASSERT(!m_zOrderListsDirty);
-        ASSERT(isStackingContext() || !m_posZOrderList);
+        ASSERT(isStackingContainer() || !m_posZOrderList);
         return m_posZOrderList.get();
     }
 
@@ -447,7 +452,7 @@ public:
     Vector<RenderLayer*>* negZOrderList() const
     {
         ASSERT(!m_zOrderListsDirty);
-        ASSERT(isStackingContext() || !m_negZOrderList);
+        ASSERT(isStackingContainer() || !m_negZOrderList);
         return m_negZOrderList.get();
     }
 
@@ -760,7 +765,8 @@ private:
     void updateNormalFlowList();
 
     bool isStackingContext(const RenderStyle* style) const { return !style->hasAutoZIndex() || isRootLayer(); }
-    bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackingContext(); }
+
+    bool isDirtyStackingContainer() const { return m_zOrderListsDirty && isStackingContainer(); }
 
     void setAncestorChainHasSelfPaintingLayerDescendant();
     void dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
@@ -985,8 +991,8 @@ private:
     bool mustCompositeForIndirectReasons() const { return m_indirectCompositingReason; }
 #endif
 
-    // Returns true if z ordering would not change if this layer were to establish a stacking context.
-    bool canSafelyEstablishAStackingContext() const;
+    // Returns true if z ordering would not change if this layer were a stacking container.
+    bool canBeStackingContainer() const;
 
     friend class RenderLayerBacking;
     friend class RenderLayerCompositor;
@@ -1153,7 +1159,7 @@ private:
 
 inline void RenderLayer::clearZOrderLists()
 {
-    ASSERT(!isStackingContext());
+    ASSERT(!isStackingContainer());
 
     m_posZOrderList.clear();
     m_negZOrderList.clear();
@@ -1164,7 +1170,7 @@ inline void RenderLayer::updateZOrderLists()
     if (!m_zOrderListsDirty)
         return;
 
-    if (!isStackingContext()) {
+    if (!isStackingContainer()) {
         clearZOrderLists();
         m_zOrderListsDirty = false;
         return;
index 6e5de42..576f843 100644 (file)
@@ -565,7 +565,7 @@ static IntRect clipBox(RenderBox* renderer)
 void RenderLayerBacking::updateGraphicsLayerGeometry()
 {
     // If we haven't built z-order lists yet, wait until later.
-    if (m_owningLayer->isStackingContext() && m_owningLayer->m_zOrderListsDirty)
+    if (m_owningLayer->isStackingContainer() && m_owningLayer->m_zOrderListsDirty)
         return;
 
     // Set transform property, if it is not animating. We have to do this here because the transform
@@ -1265,7 +1265,7 @@ float RenderLayerBacking::compositingOpacity(float rendererOpacity) const
     for (RenderLayer* curr = m_owningLayer->parent(); curr; curr = curr->parent()) {
         // We only care about parents that are stacking contexts.
         // Recall that opacity creates stacking context.
-        if (!curr->isStackingContext())
+        if (!curr->isStackingContainer())
             continue;
         
         // If we found a compositing layer, we want to compute opacity
@@ -1475,7 +1475,7 @@ bool RenderLayerBacking::hasVisibleNonCompositingDescendantLayers() const
         }
     }
 
-    if (m_owningLayer->isStackingContext()) {
+    if (m_owningLayer->isStackingContainer()) {
         if (!m_owningLayer->hasVisibleDescendant())
             return false;
 
index 667c46a..24441fb 100644 (file)
@@ -733,7 +733,7 @@ void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer*
 RenderLayer* RenderLayerCompositor::enclosingNonStackingClippingLayer(const RenderLayer* layer) const
 {
     for (RenderLayer* curr = layer->parent(); curr != 0; curr = curr->parent()) {
-        if (curr->isStackingContext())
+        if (curr->isStackingContainer())
             return 0;
 
         if (curr->renderer()->hasClipOrOverflowClip())
@@ -780,7 +780,7 @@ void RenderLayerCompositor::addToOverlapMapRecursive(OverlapMap& overlapMap, Ren
     LayerListMutationDetector mutationChecker(layer);
 #endif
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -798,7 +798,7 @@ void RenderLayerCompositor::addToOverlapMapRecursive(OverlapMap& overlapMap, Ren
         }
     }
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -883,7 +883,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
 
     bool anyDescendantHas3DTransform = false;
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -915,7 +915,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
         }
     }
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -1096,7 +1096,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
     LayerListMutationDetector mutationChecker(layer);
 #endif
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -1118,7 +1118,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
         }
     }
     
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -1334,7 +1334,7 @@ void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer, int dept
     LayerListMutationDetector mutationChecker(layer);
 #endif
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
@@ -1348,7 +1348,7 @@ void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer, int dept
             updateLayerTreeGeometry(normalFlowList->at(i), depth + 1);
     }
     
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
@@ -1385,7 +1385,7 @@ void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayer* com
     LayerListMutationDetector mutationChecker(layer);
 #endif
     
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
@@ -1399,7 +1399,7 @@ void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayer* com
             updateCompositingDescendantGeometry(compositingAncestor, normalFlowList->at(i), compositedChildrenOnly);
     }
     
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i)
@@ -2033,7 +2033,7 @@ bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
     
     EPosition position = renderer->style()->position();
     bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPosition;
-    if (isFixed && !layer->isStackingContext())
+    if (isFixed && !layer->isStackingContainer())
         return false;
     
     bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition;
@@ -2644,7 +2644,7 @@ bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
     LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(layer));
 #endif
 
-    if (layer->isStackingContext()) {
+    if (layer->isStackingContainer()) {
         if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
@@ -2694,8 +2694,8 @@ static bool isRootmostFixedOrStickyLayer(RenderLayer* layer)
     if (layer->renderer()->style()->position() != FixedPosition)
         return false;
 
-    for (RenderLayer* stackingContext = layer->stackingContext(); stackingContext; stackingContext = stackingContext->stackingContext()) {
-        if (stackingContext->isComposited() && stackingContext->renderer()->style()->position() == FixedPosition)
+    for (RenderLayer* stackingContainer = layer->stackingContainer(); stackingContainer; stackingContainer = stackingContainer->stackingContainer()) {
+        if (stackingContainer->isComposited() && stackingContainer->renderer()->style()->position() == FixedPosition)
             return false;
     }
 
index 63ce850..d4ff0a7 100644 (file)
@@ -1,3 +1,32 @@
+2013-01-23  Ian Vollick  <vollick@chromium.org>
+
+        Introduce the "stacking container" concept.
+        https://bugs.webkit.org/show_bug.cgi?id=107734
+
+        Reviewed by Simon Fraser.
+
+        A stacking container is treated just like a stacking context. That
+        is, it has z-order lists, it and its descendants are stacked as a
+        unit, and when the RenderLayerCompositor does its overlap testing,
+        the composited regions for all layer lists take effect only once the
+        stacking container is done being processed.
+
+        This patch also adds the function RenderLayer::isStackingContainer().
+        Currently, this is equivalent to RenderLayer::isStackingContext(),
+        but in future, the definition of stacking container will be broadened
+        to encompass more than just stacking contexts.
+
+        Other than the addition of this extra function, the patch is mostly
+        comprised of name changes. Any code that used to refer to the
+        stacking context concept, but didn't necessarily require a stacking
+        context in the strict, CSS-sense, was switched to refer to stacking
+        container. No functionality was changed.
+
+        No new tests, no change in functionality.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::updateOffsetFromViewportForSelf):
+
 2013-01-23  Anders Carlsson  <andersca@apple.com>
 
         Move Move WebKeyValueStorageManager to WebProcess/Storage.
index 797aee3..1765442 100644 (file)
@@ -480,7 +480,7 @@ static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer)
     if (!renderLayer->renderer()->container()->isRenderView())
         return;
 
-    if (!renderLayer->isStackingContext())
+    if (!renderLayer->isStackingContainer())
         return;
 
     CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer());