OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
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. | |
17 * | |
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. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "core/rendering/RenderLayerStackingNodeIterator.h" | |
33 | |
34 #include "core/rendering/RenderLayer.h" | |
35 #include "core/rendering/RenderLayerStackingNode.h" | |
36 | |
37 namespace blink { | |
38 | |
39 RenderLayerStackingNode* RenderLayerStackingNodeIterator::next() | |
40 { | |
41 if (m_remainingChildren & NegativeZOrderChildren) { | |
42 Vector<RenderLayerStackingNode*>* negZOrderList = m_root.negZOrderList()
; | |
43 if (negZOrderList && m_index < negZOrderList->size()) | |
44 return negZOrderList->at(m_index++); | |
45 | |
46 m_index = 0; | |
47 m_remainingChildren &= ~NegativeZOrderChildren; | |
48 } | |
49 | |
50 if (m_remainingChildren & NormalFlowChildren) { | |
51 Vector<RenderLayerStackingNode*>* normalFlowList = m_root.normalFlowList
(); | |
52 if (normalFlowList && m_index < normalFlowList->size()) | |
53 return normalFlowList->at(m_index++); | |
54 | |
55 m_index = 0; | |
56 m_remainingChildren &= ~NormalFlowChildren; | |
57 } | |
58 | |
59 if (m_remainingChildren & PositiveZOrderChildren) { | |
60 Vector<RenderLayerStackingNode*>* posZOrderList = m_root.posZOrderList()
; | |
61 if (posZOrderList && m_index < posZOrderList->size()) | |
62 return posZOrderList->at(m_index++); | |
63 | |
64 m_index = 0; | |
65 m_remainingChildren &= ~PositiveZOrderChildren; | |
66 } | |
67 | |
68 return 0; | |
69 } | |
70 | |
71 RenderLayerStackingNode* RenderLayerStackingNodeReverseIterator::next() | |
72 { | |
73 if (m_remainingChildren & NegativeZOrderChildren) { | |
74 Vector<RenderLayerStackingNode*>* negZOrderList = m_root.negZOrderList()
; | |
75 if (negZOrderList && m_index >= 0) | |
76 return negZOrderList->at(m_index--); | |
77 | |
78 m_remainingChildren &= ~NegativeZOrderChildren; | |
79 setIndexToLastItem(); | |
80 } | |
81 | |
82 if (m_remainingChildren & NormalFlowChildren) { | |
83 Vector<RenderLayerStackingNode*>* normalFlowList = m_root.normalFlowList
(); | |
84 if (normalFlowList && m_index >= 0) | |
85 return normalFlowList->at(m_index--); | |
86 | |
87 m_remainingChildren &= ~NormalFlowChildren; | |
88 setIndexToLastItem(); | |
89 } | |
90 | |
91 if (m_remainingChildren & PositiveZOrderChildren) { | |
92 Vector<RenderLayerStackingNode*>* posZOrderList = m_root.posZOrderList()
; | |
93 if (posZOrderList && m_index >= 0) | |
94 return posZOrderList->at(m_index--); | |
95 | |
96 m_remainingChildren &= ~PositiveZOrderChildren; | |
97 setIndexToLastItem(); | |
98 } | |
99 | |
100 return 0; | |
101 } | |
102 | |
103 void RenderLayerStackingNodeReverseIterator::setIndexToLastItem() | |
104 { | |
105 if (m_remainingChildren & NegativeZOrderChildren) { | |
106 Vector<RenderLayerStackingNode*>* negZOrderList = m_root.negZOrderList()
; | |
107 if (negZOrderList) { | |
108 m_index = negZOrderList->size() - 1; | |
109 return; | |
110 } | |
111 | |
112 m_remainingChildren &= ~NegativeZOrderChildren; | |
113 } | |
114 | |
115 if (m_remainingChildren & NormalFlowChildren) { | |
116 Vector<RenderLayerStackingNode*>* normalFlowList = m_root.normalFlowList
(); | |
117 if (normalFlowList) { | |
118 m_index = normalFlowList->size() - 1; | |
119 return; | |
120 } | |
121 | |
122 m_remainingChildren &= ~NormalFlowChildren; | |
123 } | |
124 | |
125 if (m_remainingChildren & PositiveZOrderChildren) { | |
126 Vector<RenderLayerStackingNode*>* posZOrderList = m_root.posZOrderList()
; | |
127 if (posZOrderList) { | |
128 m_index = posZOrderList->size() - 1; | |
129 return; | |
130 } | |
131 | |
132 m_remainingChildren &= ~PositiveZOrderChildren; | |
133 } | |
134 | |
135 // No more list to visit. | |
136 ASSERT(!m_remainingChildren); | |
137 m_index = -1; | |
138 } | |
139 | |
140 } // namespace blink | |
OLD | NEW |