| 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 23 matching lines...) Expand all Loading... |
| 34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class RenderBox; | 39 class RenderBox; |
| 40 | 40 |
| 41 class OrderIterator { | 41 class OrderIterator { |
| 42 WTF_MAKE_NONCOPYABLE(OrderIterator); | 42 WTF_MAKE_NONCOPYABLE(OrderIterator); |
| 43 public: | 43 public: |
| 44 friend class OrderIteratorPopulator; |
| 45 |
| 44 OrderIterator(const RenderBox*); | 46 OrderIterator(const RenderBox*); |
| 45 | 47 |
| 46 void setOrderValues(Vector<int>&); | |
| 47 RenderBox* currentChild() const { return m_currentChild; } | 48 RenderBox* currentChild() const { return m_currentChild; } |
| 48 RenderBox* first(); | 49 RenderBox* first(); |
| 49 RenderBox* next(); | 50 RenderBox* next(); |
| 50 void reset(); | 51 void reset(); |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 const RenderBox* m_containerBox; | 54 const RenderBox* m_containerBox; |
| 54 RenderBox* m_currentChild; | 55 RenderBox* m_currentChild; |
| 55 Vector<int> m_orderValues; | 56 // 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. |
| 58 typedef Vector<int, 1> OrderValues; |
| 59 OrderValues m_orderValues; |
| 56 Vector<int>::const_iterator m_orderValuesIterator; | 60 Vector<int>::const_iterator m_orderValuesIterator; |
| 57 }; | 61 }; |
| 58 | 62 |
| 63 class OrderIteratorPopulator { |
| 64 public: |
| 65 OrderIteratorPopulator(OrderIterator& iterator) |
| 66 : m_iterator(iterator) |
| 67 , m_anyChildHasDefaultOrderValue(false) |
| 68 { |
| 69 // 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. |
| 71 m_iterator.m_orderValues.shrink(0); |
| 72 } |
| 73 |
| 74 ~OrderIteratorPopulator(); |
| 75 |
| 76 void collectChild(const RenderBox*); |
| 77 |
| 78 private: |
| 79 void removeDuplicatedOrderValues(); |
| 80 |
| 81 OrderIterator& m_iterator; |
| 82 bool m_anyChildHasDefaultOrderValue; |
| 83 }; |
| 84 |
| 59 } // namespace WebCore | 85 } // namespace WebCore |
| 60 | 86 |
| 61 #endif // OrderIterator_h | 87 #endif // OrderIterator_h |
| OLD | NEW |