Title: [129174] trunk/Source/WebCore
Revision
129174
Author
[email protected]
Date
2012-09-20 16:11:16 -0700 (Thu, 20 Sep 2012)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129173 => 129174)


--- trunk/Source/WebCore/ChangeLog	2012-09-20 22:30:04 UTC (rev 129173)
+++ trunk/Source/WebCore/ChangeLog	2012-09-20 23:11:16 UTC (rev 129174)
@@ -1,3 +1,23 @@
+2012-09-20  Tony Chang  <[email protected]>
+
+        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.
+
 2012-09-20  Mike West  <[email protected]>
 
         CSP reports should send an empty "blocked-uri" rather than nothing.

Modified: trunk/Source/WebCore/rendering/RenderBox.h (129173 => 129174)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-09-20 22:30:04 UTC (rev 129173)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-09-20 23:11:16 UTC (rev 129174)
@@ -366,7 +366,7 @@
 
     virtual void updateLogicalWidth();
     virtual void updateLogicalHeight();
-    void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
+    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
 
     RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
     void computeLogicalWidthInRegion(LogicalExtentComputedValues&, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT) const;

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (129173 => 129174)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-09-20 22:30:04 UTC (rev 129173)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-09-20 23:11:16 UTC (rev 129174)
@@ -173,6 +173,18 @@
 void RenderListBox::layout()
 {
     RenderBlock::layout();
+
+    if (m_vBar) {
+        bool enabled = numVisibleItems() < numItems();
+        m_vBar->setEnabled(enabled);
+        m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight());
+        m_vBar->setProportion(numVisibleItems(), numItems());
+        if (!enabled) {
+            scrollToOffsetWithoutAnimation(VerticalScrollbar, 0);
+            m_indexOffset = 0;
+        }
+    }
+
     if (m_scrollToRevealSelectionAfterLayout) {
         LayoutStateDisabler layoutStateDisabler(view());
         scrollToRevealSelection();
@@ -250,25 +262,10 @@
     return itemHeight() * numItems() - rowSpacing;
 }
 
-void RenderListBox::updateLogicalHeight()
+void RenderListBox::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
 {
-    int toAdd = borderAndPaddingHeight();
- 
-    int itemHeight = RenderListBox::itemHeight();
-    setHeight(itemHeight * size() - rowSpacing + toAdd);
-    
-    RenderBlock::updateLogicalHeight();
-    
-    if (m_vBar) {
-        bool enabled = numVisibleItems() < numItems();
-        m_vBar->setEnabled(enabled);
-        m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight);
-        m_vBar->setProportion(numVisibleItems(), numItems());
-        if (!enabled) {
-            scrollToOffsetWithoutAnimation(VerticalScrollbar, 0);
-            m_indexOffset = 0;
-        }
-    }
+    LayoutUnit height = itemHeight() * size() - rowSpacing + borderAndPaddingHeight();
+    RenderBox::computeLogicalHeight(height, logicalTop, computedValues);
 }
 
 LayoutUnit RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (129173 => 129174)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2012-09-20 22:30:04 UTC (rev 129173)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2012-09-20 23:11:16 UTC (rev 129174)
@@ -77,7 +77,7 @@
 
     virtual void computePreferredLogicalWidths();
     virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
-    virtual void updateLogicalHeight() OVERRIDE;
+    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE;
 
     virtual void layout();
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to