Changeset 129174 in webkit


Ignore:
Timestamp:
Sep 20, 2012 4:11:16 PM (12 years ago)
Author:
tony@chromium.org
Message:

Replace RenderListBox::updateLogicalHeight with RenderListBox::computeLogicalHeight
https://bugs.webkit.org/show_bug.cgi?id=97263

Reviewed by Ojan Vafai.

This is part of making computeLogicalHeight virtual so with any RenderBox pointer, one
can compute the logical height without mutating the RenderBox.

No new tests, this is a refactor and existing list box tests should pass.

  • rendering/RenderBox.h:

(RenderBox):

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::layout): Move layout related logic here.
(WebCore::RenderListBox::computeLogicalHeight): Use const version and remove layout related code.

  • rendering/RenderListBox.h:

(RenderListBox): Override computeLogicalHeight.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r129168 r129174  
     12012-09-20  Tony Chang  <tony@chromium.org>
     2
     3        Replace RenderListBox::updateLogicalHeight with RenderListBox::computeLogicalHeight
     4        https://bugs.webkit.org/show_bug.cgi?id=97263
     5
     6        Reviewed by Ojan Vafai.
     7
     8        This is part of making computeLogicalHeight virtual so with any RenderBox pointer, one
     9        can compute the logical height without mutating the RenderBox.
     10
     11        No new tests, this is a refactor and existing list box tests should pass.
     12
     13        * rendering/RenderBox.h:
     14        (RenderBox):
     15        * rendering/RenderListBox.cpp:
     16        (WebCore::RenderListBox::layout): Move layout related logic here.
     17        (WebCore::RenderListBox::computeLogicalHeight): Use const version and remove layout related code.
     18        * rendering/RenderListBox.h:
     19        (RenderListBox): Override computeLogicalHeight.
     20
    1212012-09-20  Mike West  <mkwst@chromium.org>
    222
  • trunk/Source/WebCore/rendering/RenderBox.h

    r129078 r129174  
    367367    virtual void updateLogicalWidth();
    368368    virtual void updateLogicalHeight();
    369     void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
     369    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
    370370
    371371    RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r128201 r129174  
    174174{
    175175    RenderBlock::layout();
     176
     177    if (m_vBar) {
     178        bool enabled = numVisibleItems() < numItems();
     179        m_vBar->setEnabled(enabled);
     180        m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight());
     181        m_vBar->setProportion(numVisibleItems(), numItems());
     182        if (!enabled) {
     183            scrollToOffsetWithoutAnimation(VerticalScrollbar, 0);
     184            m_indexOffset = 0;
     185        }
     186    }
     187
    176188    if (m_scrollToRevealSelectionAfterLayout) {
    177189        LayoutStateDisabler layoutStateDisabler(view());
     
    251263}
    252264
    253 void RenderListBox::updateLogicalHeight()
    254 {
    255     int toAdd = borderAndPaddingHeight();
    256  
    257     int itemHeight = RenderListBox::itemHeight();
    258     setHeight(itemHeight * size() - rowSpacing + toAdd);
    259    
    260     RenderBlock::updateLogicalHeight();
    261    
    262     if (m_vBar) {
    263         bool enabled = numVisibleItems() < numItems();
    264         m_vBar->setEnabled(enabled);
    265         m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight);
    266         m_vBar->setProportion(numVisibleItems(), numItems());
    267         if (!enabled) {
    268             scrollToOffsetWithoutAnimation(VerticalScrollbar, 0);
    269             m_indexOffset = 0;
    270         }
    271     }
     265void RenderListBox::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
     266{
     267    LayoutUnit height = itemHeight() * size() - rowSpacing + borderAndPaddingHeight();
     268    RenderBox::computeLogicalHeight(height, logicalTop, computedValues);
    272269}
    273270
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r128201 r129174  
    7878    virtual void computePreferredLogicalWidths();
    7979    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    80     virtual void updateLogicalHeight() OVERRIDE;
     80    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE;
    8181
    8282    virtual void layout();
Note: See TracChangeset for help on using the changeset viewer.