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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 friend class OrderIteratorPopulator; | 44 friend class OrderIteratorPopulator; |
45 | 45 |
46 OrderIterator(const RenderBox*); | 46 OrderIterator(const RenderBox*); |
47 | 47 |
48 RenderBox* currentChild() const { return m_currentChild; } | 48 RenderBox* currentChild() const { return m_currentChild; } |
49 RenderBox* first(); | 49 RenderBox* first(); |
50 RenderBox* next(); | 50 RenderBox* next(); |
51 void reset(); | 51 void reset(); |
52 | 52 |
53 private: | 53 private: |
| 54 RenderBox* firstChildBox(); |
| 55 RenderBox* nextSiblingBox(); |
| 56 |
| 57 // If |m_children| is not empty, we will use it to iterate over this fixed s
ubset. |
54 const RenderBox* m_containerBox; | 58 const RenderBox* m_containerBox; |
| 59 Vector<RenderBox*> m_children; |
| 60 |
55 RenderBox* m_currentChild; | 61 RenderBox* m_currentChild; |
| 62 size_t m_childIndex; |
| 63 |
56 // The inline capacity for a single item is used to cover the most | 64 // The inline capacity for a single item is used to cover the most |
57 // common case by far: if we only have the default 'order' value 0. | 65 // common case by far: if we only have the default 'order' value 0. |
58 typedef Vector<int, 1> OrderValues; | 66 typedef Vector<int, 1> OrderValues; |
59 OrderValues m_orderValues; | 67 OrderValues m_orderValues; |
60 Vector<int>::const_iterator m_orderValuesIterator; | 68 Vector<int>::const_iterator m_orderValuesIterator; |
61 }; | 69 }; |
62 | 70 |
63 class OrderIteratorPopulator { | 71 class OrderIteratorPopulator { |
64 public: | 72 public: |
65 OrderIteratorPopulator(OrderIterator& iterator) | 73 OrderIteratorPopulator(OrderIterator& iterator) |
66 : m_iterator(iterator) | 74 : m_iterator(iterator) |
67 , m_anyChildHasDefaultOrderValue(false) | 75 , m_anyChildHasDefaultOrderValue(false) |
68 { | 76 { |
69 // Note that we don't release the memory here, we only invalidate the si
ze. | 77 // Note that we don't release the memory here, we only invalidate the si
ze. |
70 // This avoids unneeded reallocation if the size ends up not changing. | 78 // This avoids unneeded reallocation if the size ends up not changing. |
71 m_iterator.m_orderValues.shrink(0); | 79 m_iterator.m_orderValues.shrink(0); |
72 } | 80 } |
73 | 81 |
74 ~OrderIteratorPopulator(); | 82 ~OrderIteratorPopulator(); |
75 | 83 |
| 84 void storeChild(RenderBox*); |
76 void collectChild(const RenderBox*); | 85 void collectChild(const RenderBox*); |
77 | 86 |
78 private: | 87 private: |
79 void removeDuplicatedOrderValues(); | 88 void removeDuplicatedOrderValues(); |
80 | 89 |
81 OrderIterator& m_iterator; | 90 OrderIterator& m_iterator; |
82 bool m_anyChildHasDefaultOrderValue; | 91 bool m_anyChildHasDefaultOrderValue; |
83 }; | 92 }; |
84 | 93 |
85 } // namespace WebCore | 94 } // namespace WebCore |
86 | 95 |
87 #endif // OrderIterator_h | 96 #endif // OrderIterator_h |
OLD | NEW |