summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Chaffraix <jchaffraix@chromium.org>2015-10-05 16:15:20 -0700
committerJulien Chaffraix <jchaffraix@chromium.org>2015-10-05 23:16:23 +0000
commitcb99be31329580644510a3c67b68de521645f69c (patch)
treea0a04b9154232b047e7014e9e858d4fe6bc85839
parenta1e4dac6815ea66b0fe31cb6a0b28eb2bc66a13a (diff)
downloadchromium_src-cb99be31329580644510a3c67b68de521645f69c.zip
chromium_src-cb99be31329580644510a3c67b68de521645f69c.tar.gz
chromium_src-cb99be31329580644510a3c67b68de521645f69c.tar.bz2
Revert "Switch DPLStackingNode to use LayoutBoxModelObject"
This reverts commit 3c21051c2de67b51e59ca99c99a4f3ed7d66a3d2. This is also a cleaner merge of trunk's revert: https://codereview.chromium.org/1346103003. BUG=527927 Review URL: https://codereview.chromium.org/1385743004 . Cr-Commit-Position: refs/branch-heads/2490@{#494} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925}
-rw-r--r--third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.cpp8
-rw-r--r--third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.h2
-rw-r--r--third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp96
-rw-r--r--third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.h17
4 files changed, 61 insertions, 62 deletions
diff --git a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.cpp b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.cpp
index a767aca..7504710 100644
--- a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.cpp
@@ -1350,7 +1350,7 @@ void DeprecatedPaintLayer::updateStackingNode()
{
ASSERT(!m_stackingNode);
if (requiresStackingNode())
- m_stackingNode = adoptPtr(new DeprecatedPaintLayerStackingNode(*layoutObject()));
+ m_stackingNode = adoptPtr(new DeprecatedPaintLayerStackingNode(this));
}
void DeprecatedPaintLayer::updateScrollableArea()
@@ -1524,6 +1524,12 @@ Node* DeprecatedPaintLayer::enclosingElement() const
return 0;
}
+bool DeprecatedPaintLayer::isInTopLayer() const
+{
+ Node* node = layoutObject()->node();
+ return node && node->isElementNode() && toElement(node)->isInTopLayer();
+}
+
// Compute the z-offset of the point in the transformState.
// This is effectively projecting a ray normal to the plane of ancestor, finding where that
// ray intersects target, and computing the z delta between those two points.
diff --git a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.h b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.h
index b474e98..8fe5ea5 100644
--- a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.h
+++ b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayer.h
@@ -375,6 +375,8 @@ public:
Node* enclosingElement() const;
+ bool isInTopLayer() const;
+
bool scrollsWithViewport() const;
bool scrollsWithRespectTo(const DeprecatedPaintLayer*) const;
diff --git a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
index d20cea4..b1fb9c5 100644
--- a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
+++ b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.cpp
@@ -44,7 +44,6 @@
#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"
@@ -55,8 +54,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(LayoutBoxModelObject& layoutObject)
- : m_layoutObject(layoutObject)
+DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPaintLayer* layer)
+ : m_layer(layer)
#if ENABLE(ASSERT)
, m_layerListMutationAllowed(true)
, m_stackingParent(0)
@@ -72,7 +71,7 @@ DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(LayoutBoxMode
DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode()
{
#if ENABLE(ASSERT)
- if (!layoutObject().documentBeingDestroyed()) {
+ if (!layoutObject()->documentBeingDestroyed()) {
ASSERT(!isInStackingParentZOrderLists());
updateStackingParentForZOrderLists(0);
@@ -88,8 +87,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()
@@ -107,7 +106,7 @@ void DeprecatedPaintLayerStackingNode::dirtyZOrderLists()
m_negZOrderList->clear();
m_zOrderListsDirty = true;
- if (!layoutObject().documentBeingDestroyed())
+ if (!layoutObject()->documentBeingDestroyed())
compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
}
@@ -117,41 +116,14 @@ void DeprecatedPaintLayerStackingNode::dirtyStackingContextZOrderLists()
stackingNode->dirtyZOrderLists();
}
-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 (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 store them in the lists unless they have a DeprecatedPaintLayer.
- 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());
- }
+ for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = child->nextSibling()) {
+ if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child)
+ child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderList);
}
// Sort the two lists.
@@ -161,19 +133,19 @@ void DeprecatedPaintLayerStackingNode::rebuildZOrderLists()
if (m_negZOrderList)
std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compareZIndex);
- // Append stacking contexts for top layer elements after normal layer collection, to ensure they are on top regardless of z-indexes.
+ // Append layers 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 (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());
+ 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());
+ }
}
}
@@ -184,6 +156,26 @@ void DeprecatedPaintLayerStackingNode::rebuildZOrderLists()
m_zOrderListsDirty = 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
{
@@ -249,7 +241,7 @@ void DeprecatedPaintLayerStackingNode::updateIsTreatedAsStackingContextForPainti
return;
m_isTreatedAsStackingContextForPainting = isTreatedAsStackingContextForPainting;
- if (!layoutObject().documentBeingDestroyed() && !layer()->isRootLayer())
+ if (!layoutObject()->documentBeingDestroyed() && !layer()->isRootLayer())
compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
dirtyStackingContextZOrderLists();
}
@@ -264,9 +256,9 @@ DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac
return 0;
}
-DeprecatedPaintLayer* DeprecatedPaintLayerStackingNode::layer() const
+LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const
{
- return layoutObject().layer();
+ return m_layer->layoutObject();
}
} // namespace blink
diff --git a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.h b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.h
index c54e26e..022d989 100644
--- a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.h
+++ b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerStackingNode.h
@@ -61,12 +61,12 @@ class LayoutBoxModelObject;
class CORE_EXPORT DeprecatedPaintLayerStackingNode {
WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerStackingNode);
public:
- explicit DeprecatedPaintLayerStackingNode(LayoutBoxModelObject&);
+ explicit DeprecatedPaintLayerStackingNode(DeprecatedPaintLayer*);
~DeprecatedPaintLayerStackingNode();
- int zIndex() const { return layoutObject().style()->zIndex(); }
+ int zIndex() const { return layoutObject()->style()->zIndex(); }
- bool isStackingContext() const { return layoutObject().style()->isStackingContext(); }
+ bool isStackingContext() const { return layoutObject()->style()->isStackingContext(); }
// Update our normal and z-index lists.
void updateLayerListsIfNeeded();
@@ -87,9 +87,7 @@ public:
DeprecatedPaintLayerStackingNode* ancestorStackingContextNode() const;
- // FIXME: A lot of code depends on this function but shouldn't. We should
- // build our code on top of LayoutBoxModelObject, not DeprecatedPaintLayer.
- DeprecatedPaintLayer* layer() const;
+ DeprecatedPaintLayer* layer() const { return m_layer; }
#if ENABLE(ASSERT)
bool layerListMutationAllowed() const { return m_layerListMutationAllowed; }
@@ -116,6 +114,7 @@ private:
}
void rebuildZOrderLists();
+ void collectLayers(OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& posZOrderList, OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& negZOrderList);
#if ENABLE(ASSERT)
bool isInStackingParentZOrderLists() const;
@@ -123,15 +122,15 @@ private:
void setStackingParent(DeprecatedPaintLayerStackingNode* stackingParent) { m_stackingParent = stackingParent; }
#endif
- bool shouldBeTreatedAsStackingContextForPainting() const { return layoutObject().style()->isTreatedAsStackingContextForPainting(); }
+ bool shouldBeTreatedAsStackingContextForPainting() const { return layoutObject()->style()->isTreatedAsStackingContextForPainting(); }
bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackingContext(); }
DeprecatedPaintLayerCompositor* compositor() const;
// We can't return a LayoutBox as LayoutInline can be a stacking context.
- LayoutBoxModelObject& layoutObject() const { return m_layoutObject; }
+ LayoutBoxModelObject* layoutObject() const;
- LayoutBoxModelObject& m_layoutObject;
+ DeprecatedPaintLayer* m_layer;
// m_posZOrderList holds a sorted list of all the descendant nodes within
// that have z-indices of 0 or greater (auto will count as 0).