Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1402)

Unified Diff: Source/core/paint/DeprecatedPaintLayerStackingNode.cpp

Issue 1199413006: Switch DPLStackingNode to use LayoutBoxModelObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
diff --git a/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp b/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
index 83f947c472a1c49fb2c74f4950aa5bf393ba1a70..7be96acae49c3aea6cab14a56455721de5afcd13 100644
--- a/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
+++ b/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
@@ -44,6 +44,7 @@
#include "config.h"
#include "core/paint/DeprecatedPaintLayerStackingNode.h"
+#include "core/dom/Node.h"
#include "core/layout/LayoutView.h"
#include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
#include "core/paint/DeprecatedPaintLayer.h"
@@ -54,8 +55,8 @@ namespace blink {
// FIXME: This should not require DeprecatedPaintLayer. There is currently a cycle where
// in order to determine if we shoulBeTreatedAsStackingContextForPainting() we have to ask the paint
// layer about some of its state.
-DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPaintLayer* layer)
- : m_layer(layer)
+DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(LayoutBoxModelObject& layoutObject)
+ : m_layoutObject(layoutObject)
, m_normalFlowListDirty(true)
#if ENABLE(ASSERT)
, m_layerListMutationAllowed(true)
@@ -72,7 +73,7 @@ DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPai
DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode()
{
#if ENABLE(ASSERT)
- if (!layoutObject()->documentBeingDestroyed()) {
+ if (!layoutObject().documentBeingDestroyed()) {
ASSERT(!isInStackingParentZOrderLists());
ASSERT(!isInStackingParentNormalFlowList());
@@ -90,8 +91,8 @@ static inline bool compareZIndex(DeprecatedPaintLayerStackingNode* first, Deprec
DeprecatedPaintLayerCompositor* DeprecatedPaintLayerStackingNode::compositor() const
{
- ASSERT(layoutObject()->view());
- return layoutObject()->view()->compositor();
+ ASSERT(layoutObject().view());
+ return layoutObject().view()->compositor();
}
void DeprecatedPaintLayerStackingNode::dirtyZOrderLists()
@@ -109,7 +110,7 @@ void DeprecatedPaintLayerStackingNode::dirtyZOrderLists()
m_negZOrderList->clear();
m_zOrderListsDirty = true;
- if (!layoutObject()->documentBeingDestroyed())
+ if (!layoutObject().documentBeingDestroyed())
compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
}
@@ -131,18 +132,45 @@ void DeprecatedPaintLayerStackingNode::dirtyNormalFlowList()
m_normalFlowList->clear();
m_normalFlowListDirty = true;
- if (!layoutObject()->documentBeingDestroyed())
+ if (!layoutObject().documentBeingDestroyed())
compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
}
+static bool isInTopLayer(const LayoutObject& layoutObject)
+{
+ const Node* node = layoutObject.node();
+ return node && node->isElementNode() && toElement(node)->isInTopLayer();
+}
+
void DeprecatedPaintLayerStackingNode::rebuildZOrderLists()
{
ASSERT(m_layerListMutationAllowed);
ASSERT(isDirtyStackingContext());
- for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = child->nextSibling()) {
- if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child)
- child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderList);
+ for (LayoutObject* descendant = layoutObject().slowFirstChild(); descendant;) {
+ if (isInTopLayer(*descendant)) {
+ // Top layer objects are handled below.
+ descendant = descendant->nextInPreOrderAfterChildren(&layoutObject());
+ continue;
+ }
+
+ // FIXME: Some non-LayoutBoxModeObject can have position != static and thus would be treated like
+ // stacking context. However we can't make store them in the lists unless they have a DeprecatedPaintLayer.
dsinclair 2015/06/24 19:40:50 I think you have an extra make in that sentence.
Julien - ping for review 2015/06/24 21:40:00 Removed.
+ if (descendant->styleRef().isTreatedAsStackingContextForPainting() && descendant->hasLayer()) {
+ OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (descendant->style()->zIndex() >= 0) ? m_posZOrderList : m_negZOrderList;
+ if (!buffer)
+ buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>);
+ buffer->append(toLayoutBoxModelObject(descendant)->layer()->stackingNode());
+ }
+
+ if (descendant->styleRef().isStackingContext()) {
+ // We found a stacking context, just continue walking the other subtrees.
+ // They will collect their own descendant stacking contexts.
+ descendant = descendant->nextInPreOrderAfterChildren(&layoutObject());
+ } else {
+ // Not stacking context, continue deeper.
+ descendant = descendant->nextInPreOrder(&layoutObject());
+ }
}
// Sort the two lists.
@@ -152,19 +180,19 @@ void DeprecatedPaintLayerStackingNode::rebuildZOrderLists()
if (m_negZOrderList)
std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compareZIndex);
- // Append layers for top layer elements after normal layer collection, to ensure they are on top regardless of z-indexes.
+ // Append stacking contexts for top layer elements after normal layer collection, to ensure they are on top regardless of z-indexes.
// The layoutObjects of top layer elements are children of the view, sorted in top layer stacking order.
- if (layer()->isRootLayer()) {
- LayoutView* view = layoutObject()->view();
- for (LayoutObject* child = view->firstChild(); child; child = child->nextSibling()) {
- Element* childElement = (child->node() && child->node()->isElementNode()) ? toElement(child->node()) : 0;
- if (childElement && childElement->isInTopLayer()) {
- DeprecatedPaintLayer* layer = toLayoutBoxModelObject(child)->layer();
- // Create the buffer if it doesn't exist yet.
- if (!m_posZOrderList)
- m_posZOrderList = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>);
- m_posZOrderList->append(layer->stackingNode());
- }
+ if (layoutObject().isLayoutView()) {
+ LayoutView& view = toLayoutView(layoutObject());
+ for (LayoutObject* child = view.firstChild(); child; child = child->nextSibling()) {
+ if (!isInTopLayer(*child))
+ continue;
+
+ // Create the buffer if it doesn't exist yet.
+ if (!m_posZOrderList)
+ m_posZOrderList = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>);
+ ASSERT(child->style()->isStackingContext());
+ m_posZOrderList->append(toLayoutBoxModelObject(child)->layer()->stackingNode());
}
}
@@ -197,26 +225,6 @@ void DeprecatedPaintLayerStackingNode::updateNormalFlowList()
m_normalFlowListDirty = false;
}
-void DeprecatedPaintLayerStackingNode::collectLayers(OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& posBuffer, OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& negBuffer)
-{
- if (layer()->isInTopLayer())
- return;
-
- if (isTreatedAsStackingContextForPainting()) {
- OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (zIndex() >= 0) ? posBuffer : negBuffer;
- if (!buffer)
- buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>);
- buffer->append(this);
- }
-
- if (!isStackingContext()) {
- for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = child->nextSibling()) {
- if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child)
- child->stackingNode()->collectLayers(posBuffer, negBuffer);
- }
- }
-}
-
#if ENABLE(ASSERT)
bool DeprecatedPaintLayerStackingNode::isInStackingParentZOrderLists() const
{
@@ -314,9 +322,9 @@ DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac
return 0;
}
-LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const
+DeprecatedPaintLayer* DeprecatedPaintLayerStackingNode::layer() const
{
- return m_layer->layoutObject();
+ return layoutObject().layer();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698