Index: Source/core/paint/DeprecatedPaintLayerStackingNodeIterator.cpp |
diff --git a/Source/core/paint/DeprecatedPaintLayerStackingNodeIterator.cpp b/Source/core/paint/DeprecatedPaintLayerStackingNodeIterator.cpp |
index c767e84978dea41a9c1e5ad0d880cd5785b196e4..3c2a988b566944fdc830a4ba8061c0bc8b0e888d 100644 |
--- a/Source/core/paint/DeprecatedPaintLayerStackingNodeIterator.cpp |
+++ b/Source/core/paint/DeprecatedPaintLayerStackingNodeIterator.cpp |
@@ -31,10 +31,21 @@ |
#include "config.h" |
#include "core/paint/DeprecatedPaintLayerStackingNodeIterator.h" |
+// FIXME: We should build our primitive on top of |
+// DeprecatedLayerStackingNode and remove this include. |
+#include "core/paint/DeprecatedPaintLayer.h" |
#include "core/paint/DeprecatedPaintLayerStackingNode.h" |
namespace blink { |
+DeprecatedPaintLayerStackingNodeIterator::DeprecatedPaintLayerStackingNodeIterator(const DeprecatedPaintLayerStackingNode& root, unsigned whichChildren) |
+ : m_root(root) |
+ , m_remainingChildren(whichChildren) |
+ , m_index(0) |
+{ |
+ m_normalFlowCurrent = root.layer()->firstChild(); |
+} |
+ |
DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNodeIterator::next() |
{ |
if (m_remainingChildren & NegativeZOrderChildren) { |
@@ -47,11 +58,16 @@ DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNodeIterator::next |
} |
if (m_remainingChildren & NormalFlowChildren) { |
- Vector<DeprecatedPaintLayerStackingNode*>* normalFlowList = m_root.normalFlowList(); |
- if (normalFlowList && m_index < normalFlowList->size()) |
- return normalFlowList->at(m_index++); |
+ for (; m_normalFlowCurrent; m_normalFlowCurrent = m_normalFlowCurrent->nextSibling()) { |
+ if (!m_normalFlowCurrent->stackingNode()->isTreatedAsStackingContextForPainting() && (!m_root.layer()->reflectionInfo() || m_root.layer()->reflectionInfo()->reflectionLayer() != m_normalFlowCurrent)) { |
dsinclair
2015/06/24 15:22:42
Can this condition be pulled out into a local isNo
Julien - ping for review
2015/06/24 16:51:57
I did something even better:
(!m_root.layer()->re
|
+ DeprecatedPaintLayer* normalFlowChild = m_normalFlowCurrent; |
+ m_normalFlowCurrent = m_normalFlowCurrent->nextSibling(); |
+ return normalFlowChild->stackingNode(); |
+ } |
+ } |
- m_index = 0; |
+ // We reset the iterator in case we reuse it. |
+ m_normalFlowCurrent = m_root.layer()->firstChild(); |
m_remainingChildren &= ~NormalFlowChildren; |
} |
@@ -79,9 +95,13 @@ DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNodeReverseIterato |
} |
if (m_remainingChildren & NormalFlowChildren) { |
- Vector<DeprecatedPaintLayerStackingNode*>* normalFlowList = m_root.normalFlowList(); |
- if (normalFlowList && m_index >= 0) |
- return normalFlowList->at(m_index--); |
+ for (; m_normalFlowCurrent; m_normalFlowCurrent = m_normalFlowCurrent->previousSibling()) { |
+ if (!m_normalFlowCurrent->stackingNode()->isTreatedAsStackingContextForPainting() && (!m_root.layer()->reflectionInfo() || m_root.layer()->reflectionInfo()->reflectionLayer() != m_normalFlowCurrent)) { |
+ DeprecatedPaintLayer* normalFlowChild = m_normalFlowCurrent; |
+ m_normalFlowCurrent = m_normalFlowCurrent->previousSibling(); |
+ return normalFlowChild->stackingNode(); |
+ } |
+ } |
m_remainingChildren &= ~NormalFlowChildren; |
setIndexToLastItem(); |
@@ -112,13 +132,8 @@ void DeprecatedPaintLayerStackingNodeReverseIterator::setIndexToLastItem() |
} |
if (m_remainingChildren & NormalFlowChildren) { |
- Vector<DeprecatedPaintLayerStackingNode*>* normalFlowList = m_root.normalFlowList(); |
- if (normalFlowList) { |
- m_index = normalFlowList->size() - 1; |
- return; |
- } |
- |
- m_remainingChildren &= ~NormalFlowChildren; |
+ m_normalFlowCurrent = m_root.layer()->lastChild(); |
+ return; |
} |
if (m_remainingChildren & PositiveZOrderChildren) { |