Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / paint / DeprecatedPaintLayerStackingNodeIterator.cpp
blob10c8c51a322a46dac52b0c293a1db48dfa3086df
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "config.h"
32 #include "core/paint/DeprecatedPaintLayerStackingNodeIterator.h"
34 // FIXME: We should build our primitive on top of
35 // DeprecatedLayerStackingNode and remove this include.
36 #include "core/paint/DeprecatedPaintLayer.h"
37 #include "core/paint/DeprecatedPaintLayerStackingNode.h"
39 namespace blink {
41 DeprecatedPaintLayerStackingNodeIterator::DeprecatedPaintLayerStackingNodeIterator(const DeprecatedPaintLayerStackingNode& root, unsigned whichChildren)
42 : m_root(root)
43 , m_remainingChildren(whichChildren)
44 , m_index(0)
46 m_currentNormalFlowChild = root.layer()->firstChild();
49 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNodeIterator::next()
51 if (m_remainingChildren & NegativeZOrderChildren) {
52 Vector<DeprecatedPaintLayerStackingNode*>* negZOrderList = m_root.negZOrderList();
53 if (negZOrderList && m_index < negZOrderList->size())
54 return negZOrderList->at(m_index++);
56 m_index = 0;
57 m_remainingChildren &= ~NegativeZOrderChildren;
60 if (m_remainingChildren & NormalFlowChildren) {
61 for (; m_currentNormalFlowChild; m_currentNormalFlowChild = m_currentNormalFlowChild->nextSibling()) {
62 if (!m_currentNormalFlowChild->stackingNode()->isTreatedAsOrStackingContext() && !m_currentNormalFlowChild->isReflection()) {
63 DeprecatedPaintLayer* normalFlowChild = m_currentNormalFlowChild;
64 m_currentNormalFlowChild = m_currentNormalFlowChild->nextSibling();
65 return normalFlowChild->stackingNode();
69 // We reset the iterator in case we reuse it.
70 m_currentNormalFlowChild = m_root.layer()->firstChild();
71 m_remainingChildren &= ~NormalFlowChildren;
74 if (m_remainingChildren & PositiveZOrderChildren) {
75 Vector<DeprecatedPaintLayerStackingNode*>* posZOrderList = m_root.posZOrderList();
76 if (posZOrderList && m_index < posZOrderList->size())
77 return posZOrderList->at(m_index++);
79 m_index = 0;
80 m_remainingChildren &= ~PositiveZOrderChildren;
83 return 0;
86 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNodeReverseIterator::next()
88 if (m_remainingChildren & NegativeZOrderChildren) {
89 Vector<DeprecatedPaintLayerStackingNode*>* negZOrderList = m_root.negZOrderList();
90 if (negZOrderList && m_index >= 0)
91 return negZOrderList->at(m_index--);
93 m_remainingChildren &= ~NegativeZOrderChildren;
94 setIndexToLastItem();
97 if (m_remainingChildren & NormalFlowChildren) {
98 for (; m_currentNormalFlowChild; m_currentNormalFlowChild = m_currentNormalFlowChild->previousSibling()) {
99 if (!m_currentNormalFlowChild->stackingNode()->isTreatedAsOrStackingContext() && !m_currentNormalFlowChild->isReflection()) {
100 DeprecatedPaintLayer* normalFlowChild = m_currentNormalFlowChild;
101 m_currentNormalFlowChild = m_currentNormalFlowChild->previousSibling();
102 return normalFlowChild->stackingNode();
106 m_remainingChildren &= ~NormalFlowChildren;
107 setIndexToLastItem();
110 if (m_remainingChildren & PositiveZOrderChildren) {
111 Vector<DeprecatedPaintLayerStackingNode*>* posZOrderList = m_root.posZOrderList();
112 if (posZOrderList && m_index >= 0)
113 return posZOrderList->at(m_index--);
115 m_remainingChildren &= ~PositiveZOrderChildren;
116 setIndexToLastItem();
119 return 0;
122 void DeprecatedPaintLayerStackingNodeReverseIterator::setIndexToLastItem()
124 if (m_remainingChildren & NegativeZOrderChildren) {
125 Vector<DeprecatedPaintLayerStackingNode*>* negZOrderList = m_root.negZOrderList();
126 if (negZOrderList) {
127 m_index = negZOrderList->size() - 1;
128 return;
131 m_remainingChildren &= ~NegativeZOrderChildren;
134 if (m_remainingChildren & NormalFlowChildren) {
135 m_currentNormalFlowChild = m_root.layer()->lastChild();
136 return;
139 if (m_remainingChildren & PositiveZOrderChildren) {
140 Vector<DeprecatedPaintLayerStackingNode*>* posZOrderList = m_root.posZOrderList();
141 if (posZOrderList) {
142 m_index = posZOrderList->size() - 1;
143 return;
146 m_remainingChildren &= ~PositiveZOrderChildren;
149 // No more list to visit.
150 ASSERT(!m_remainingChildren);
151 m_index = -1;
154 } // namespace blink