Changeset 107317 in webkit


Ignore:
Timestamp:
Feb 9, 2012 5:15:16 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Remove TreeOrderIterator and iterate over the child boxes directly.
https://bugs.webkit.org/show_bug.cgi?id=78294

Reviewed by Tony Chang.

No new tests. This is purely a refactor. No change in behavior.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutFlexItems):
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):

  • rendering/RenderFlexibleBox.h:

(RenderFlexibleBox):
(FlexOrderHashTraits):
(WebCore::RenderFlexibleBox::FlexOrderHashTraits::emptyValue):
(WebCore::RenderFlexibleBox::FlexOrderHashTraits::constructDeletedValue):
(WebCore::RenderFlexibleBox::FlexOrderHashTraits::isDeletedValue):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107314 r107317  
     12012-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
    1202012-02-09  Kentaro Hara  <haraken@chromium.org>
    221
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r107310 r107317  
    4141// we make the two smallest int values invalid flex-order values (in the css parser code we clamp them to
    4242// int min + 2).
    43 struct FlexOrderHashTraits : WTF::GenericHashTraits<int> {
     43struct RenderFlexibleBox::FlexOrderHashTraits : WTF::GenericHashTraits<int> {
    4444    static const bool emptyValueIsZero = false;
    4545    static int emptyValue() { return std::numeric_limits<int>::min(); }
    4646    static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; }
    4747    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;
    9048};
    9149
     
    466424void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren)
    467425{
    468     TreeOrderIterator treeIterator(this);
    469     computeMainAxisPreferredSizes(relayoutChildren, treeIterator);
     426    FlexOrderHashSet flexOrderValues;
     427    computeMainAxisPreferredSizes(relayoutChildren, flexOrderValues);
    470428
    471429    OrderedFlexItemList orderedChildren;
     
    473431    float totalPositiveFlexibility;
    474432    float totalNegativeFlexibility;
    475     FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues());
     433    FlexOrderIterator flexIterator(this, flexOrderValues);
    476434    computeFlexOrder(flexIterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility);
    477435
     
    512470}
    513471
    514 void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator& iterator)
     472void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet& flexOrderValues)
    515473{
    516474    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
    518478        if (child->isPositioned())
    519479            continue;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r107310 r107317  
    5050
    5151private:
    52     class TreeOrderIterator;
     52    struct FlexOrderHashTraits;
     53    typedef HashSet<int, DefaultHash<int>::Hash, FlexOrderHashTraits> FlexOrderHashSet;
     54
    5355    class FlexOrderIterator;
    5456    typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
     
    9799    LayoutUnit marginBoxAscent(RenderBox*);
    98100
    99     void computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator&);
     101    void computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet&);
    100102    void computeFlexOrder(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
    101103    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.