Changeset 107317 in webkit
- Timestamp:
- Feb 9, 2012 5:15:16 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107314 r107317 1 2012-02-09 Ojan Vafai <ojan@chromium.org> 2 3 Remove TreeOrderIterator and iterate over the child boxes directly. 4 https://bugs.webkit.org/show_bug.cgi?id=78294 5 6 Reviewed by Tony Chang. 7 8 No new tests. This is purely a refactor. No change in behavior. 9 10 * rendering/RenderFlexibleBox.cpp: 11 (WebCore::RenderFlexibleBox::layoutFlexItems): 12 (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): 13 * rendering/RenderFlexibleBox.h: 14 (RenderFlexibleBox): 15 (FlexOrderHashTraits): 16 (WebCore::RenderFlexibleBox::FlexOrderHashTraits::emptyValue): 17 (WebCore::RenderFlexibleBox::FlexOrderHashTraits::constructDeletedValue): 18 (WebCore::RenderFlexibleBox::FlexOrderHashTraits::isDeletedValue): 19 1 20 2012-02-09 Kentaro Hara <haraken@chromium.org> 2 21 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r107310 r107317 41 41 // we make the two smallest int values invalid flex-order values (in the css parser code we clamp them to 42 42 // int min + 2). 43 struct FlexOrderHashTraits : WTF::GenericHashTraits<int> {43 struct RenderFlexibleBox::FlexOrderHashTraits : WTF::GenericHashTraits<int> { 44 44 static const bool emptyValueIsZero = false; 45 45 static int emptyValue() { return std::numeric_limits<int>::min(); } 46 46 static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; } 47 47 static bool isDeletedValue(int value) { return value == std::numeric_limits<int>::min() + 1; } 48 };49 50 typedef HashSet<int, DefaultHash<int>::Hash, FlexOrderHashTraits> FlexOrderHashSet;51 52 class RenderFlexibleBox::TreeOrderIterator {53 public:54 explicit TreeOrderIterator(RenderFlexibleBox* flexibleBox)55 : m_flexibleBox(flexibleBox)56 , m_currentChild(0)57 {58 }59 60 RenderBox* first()61 {62 reset();63 return next();64 }65 66 RenderBox* next()67 {68 m_currentChild = m_currentChild ? m_currentChild->nextSiblingBox() : m_flexibleBox->firstChildBox();69 70 if (m_currentChild)71 m_flexOrderValues.add(m_currentChild->style()->flexOrder());72 73 return m_currentChild;74 }75 76 void reset()77 {78 m_currentChild = 0;79 }80 81 const FlexOrderHashSet& flexOrderValues()82 {83 return m_flexOrderValues;84 }85 86 private:87 RenderFlexibleBox* m_flexibleBox;88 RenderBox* m_currentChild;89 FlexOrderHashSet m_flexOrderValues;90 48 }; 91 49 … … 466 424 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) 467 425 { 468 TreeOrderIterator treeIterator(this);469 computeMainAxisPreferredSizes(relayoutChildren, treeIterator);426 FlexOrderHashSet flexOrderValues; 427 computeMainAxisPreferredSizes(relayoutChildren, flexOrderValues); 470 428 471 429 OrderedFlexItemList orderedChildren; … … 473 431 float totalPositiveFlexibility; 474 432 float totalNegativeFlexibility; 475 FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues());433 FlexOrderIterator flexIterator(this, flexOrderValues); 476 434 computeFlexOrder(flexIterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility); 477 435 … … 512 470 } 513 471 514 void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator& iterator)472 void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet& flexOrderValues) 515 473 { 516 474 LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent(); 517 for (RenderBox* child = iterator.first(); child; child = iterator.next()) { 475 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { 476 flexOrderValues.add(child->style()->flexOrder()); 477 518 478 if (child->isPositioned()) 519 479 continue; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r107310 r107317 50 50 51 51 private: 52 class TreeOrderIterator; 52 struct FlexOrderHashTraits; 53 typedef HashSet<int, DefaultHash<int>::Hash, FlexOrderHashTraits> FlexOrderHashSet; 54 53 55 class FlexOrderIterator; 54 56 typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize; … … 97 99 LayoutUnit marginBoxAscent(RenderBox*); 98 100 99 void computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator&);101 void computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet&); 100 102 void computeFlexOrder(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility); 101 103 bool runFreeSpaceAllocationAlgorithm(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
Note: See TracChangeset
for help on using the changeset viewer.