OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (m_orderValuesIterator == m_orderValues.end()) | 55 if (m_orderValuesIterator == m_orderValues.end()) |
56 return 0; | 56 return 0; |
57 if (m_orderValuesIterator) { | 57 if (m_orderValuesIterator) { |
58 ++m_orderValuesIterator; | 58 ++m_orderValuesIterator; |
59 if (m_orderValuesIterator == m_orderValues.end()) | 59 if (m_orderValuesIterator == m_orderValues.end()) |
60 return 0; | 60 return 0; |
61 } else { | 61 } else { |
62 m_orderValuesIterator = m_orderValues.begin(); | 62 m_orderValuesIterator = m_orderValues.begin(); |
63 } | 63 } |
64 | 64 |
65 m_currentChild = m_containerBox->firstChildBox(); | 65 m_currentChild = firstChildBox(); |
66 } else { | 66 } else { |
67 m_currentChild = m_currentChild->nextSiblingBox(); | 67 m_currentChild = nextSiblingBox(); |
68 } | 68 } |
69 } while (!m_currentChild || m_currentChild->style()->order() != *m_orderValu
esIterator); | 69 } while (!m_currentChild || m_currentChild->style()->order() != *m_orderValu
esIterator); |
70 | 70 |
71 return m_currentChild; | 71 return m_currentChild; |
72 } | 72 } |
73 | 73 |
74 void OrderIterator::reset() | 74 void OrderIterator::reset() |
75 { | 75 { |
76 m_currentChild = 0; | 76 m_currentChild = 0; |
77 m_orderValuesIterator = 0; | 77 m_orderValuesIterator = 0; |
78 } | 78 } |
79 | 79 |
| 80 RenderBox* OrderIterator::firstChildBox() |
| 81 { |
| 82 if (m_children.isEmpty()) |
| 83 return m_containerBox->firstChildBox(); |
| 84 |
| 85 m_childIndex = 0; |
| 86 return m_children[0]; |
| 87 } |
| 88 |
| 89 RenderBox* OrderIterator::nextSiblingBox() |
| 90 { |
| 91 if (m_children.isEmpty()) |
| 92 return m_currentChild->nextSiblingBox(); |
| 93 |
| 94 if (m_childIndex >= m_children.size() - 1) |
| 95 return 0; |
| 96 |
| 97 return m_children[++m_childIndex]; |
| 98 } |
| 99 |
80 OrderIteratorPopulator::~OrderIteratorPopulator() | 100 OrderIteratorPopulator::~OrderIteratorPopulator() |
81 { | 101 { |
82 m_iterator.reset(); | 102 m_iterator.reset(); |
83 | 103 |
84 if (m_anyChildHasDefaultOrderValue) | 104 if (m_anyChildHasDefaultOrderValue) |
85 m_iterator.m_orderValues.append(0); | 105 m_iterator.m_orderValues.append(0); |
86 | 106 |
87 if (m_iterator.m_orderValues.size() > 1) | 107 if (m_iterator.m_orderValues.size() > 1) |
88 removeDuplicatedOrderValues(); | 108 removeDuplicatedOrderValues(); |
89 | 109 |
(...skipping 13 matching lines...) Expand all Loading... |
103 int current = orderValues[i]; | 123 int current = orderValues[i]; |
104 if (current == previous) | 124 if (current == previous) |
105 continue; | 125 continue; |
106 ++uniqueItemIndex; | 126 ++uniqueItemIndex; |
107 std::swap(orderValues[i], orderValues[uniqueItemIndex]); | 127 std::swap(orderValues[i], orderValues[uniqueItemIndex]); |
108 previous = current; | 128 previous = current; |
109 } | 129 } |
110 orderValues.shrink(uniqueItemIndex + 1); | 130 orderValues.shrink(uniqueItemIndex + 1); |
111 } | 131 } |
112 | 132 |
| 133 void OrderIteratorPopulator::storeChild(RenderBox* child) |
| 134 { |
| 135 m_iterator.m_children.append(child); |
| 136 |
| 137 collectChild(child); |
| 138 } |
| 139 |
113 void OrderIteratorPopulator::collectChild(const RenderBox* child) | 140 void OrderIteratorPopulator::collectChild(const RenderBox* child) |
114 { | 141 { |
115 // Avoid growing the vector for the common-case default value of 0. | 142 // Avoid growing the vector for the common-case default value of 0. |
116 if (int order = child->style()->order()) | 143 if (int order = child->style()->order()) |
117 m_iterator.m_orderValues.append(order); | 144 m_iterator.m_orderValues.append(order); |
118 else | 145 else |
119 m_anyChildHasDefaultOrderValue = true; | 146 m_anyChildHasDefaultOrderValue = true; |
120 } | 147 } |
121 | 148 |
122 } // namespace WebCore | 149 } // namespace WebCore |
OLD | NEW |