Title: [114079] trunk/Source/WebCore
Revision
114079
Author
[email protected]
Date
2012-04-12 21:19:42 -0700 (Thu, 12 Apr 2012)

Log Message

Prepare functions in LengthFunctions.h for LayoutUnits
https://bugs.webkit.org/show_bug.cgi?id=83726

Reviewed by Eric Seidel.

Preparing the functions that live in LengthFunctions for sub-pixel layout, which entails
using and returning LayoutUnits instead of integers. There are a number of rendering
classes that are laid out using integers -- see https://trac.webkit.org/wiki/LayoutUnit
for details -- so this also adds integer-specific versions of the length functions for
explicit use in those classes.

No new tests. No change in behavior.

* css/LengthFunctions.h:
(WebCore): Using LayoutUnits for sub-pixel precision and adding integer-specific versions
of minimumValueForLength and valueForLength that truncate.
* css/LengthFunctions.cpp:
(WebCore):
* dom/Document.cpp:
(WebCore::Document::pageSizeAndMarginsInPixels): Document sizes are integral.
* rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::layOutAxis): The frame tree continues to be integral.
* rendering/RenderMarquee.cpp:
(WebCore::RenderMarquee::timerFired): RenderMarquee scrolling uses integral values.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowLogicalHeight): Table layout is integral.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114078 => 114079)


--- trunk/Source/WebCore/ChangeLog	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/ChangeLog	2012-04-13 04:19:42 UTC (rev 114079)
@@ -1,3 +1,32 @@
+2012-04-12  Levi Weintraub  <[email protected]>
+
+        Prepare functions in LengthFunctions.h for LayoutUnits
+        https://bugs.webkit.org/show_bug.cgi?id=83726
+
+        Reviewed by Eric Seidel.
+
+        Preparing the functions that live in LengthFunctions for sub-pixel layout, which entails
+        using and returning LayoutUnits instead of integers. There are a number of rendering
+        classes that are laid out using integers -- see https://trac.webkit.org/wiki/LayoutUnit
+        for details -- so this also adds integer-specific versions of the length functions for
+        explicit use in those classes.
+
+        No new tests. No change in behavior.
+
+        * css/LengthFunctions.h:
+        (WebCore): Using LayoutUnits for sub-pixel precision and adding integer-specific versions
+        of minimumValueForLength and valueForLength that truncate.
+        * css/LengthFunctions.cpp:
+        (WebCore):
+        * dom/Document.cpp:
+        (WebCore::Document::pageSizeAndMarginsInPixels): Document sizes are integral.
+        * rendering/RenderFrameSet.cpp:
+        (WebCore::RenderFrameSet::layOutAxis): The frame tree continues to be integral.
+        * rendering/RenderMarquee.cpp:
+        (WebCore::RenderMarquee::timerFired): RenderMarquee scrolling uses integral values.
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::calcRowLogicalHeight): Table layout is integral.
+
 2012-04-12  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r114075.

Modified: trunk/Source/WebCore/css/LengthFunctions.cpp (114078 => 114079)


--- trunk/Source/WebCore/css/LengthFunctions.cpp	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/css/LengthFunctions.cpp	2012-04-13 04:19:42 UTC (rev 114079)
@@ -29,46 +29,56 @@
 
 namespace WebCore {
 
-int minimumValueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages)
+int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
 {
+    return static_cast<int>(minimumValueForLength(length, maximumValue, renderView, roundPercentages));
+}
+
+int intValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
+{
+    return static_cast<int>(valueForLength(length, maximumValue, renderView, roundPercentages));
+}
+
+LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
+{
     switch (length.type()) {
     case Fixed:
         return length.value();
     case Percent:
         if (roundPercentages)
-            return static_cast<int>(round(maximumValue * length.percent() / 100.0f));
+            return static_cast<LayoutUnit>(round(maximumValue * length.percent() / 100.0f));
         // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
-        return static_cast<int>(static_cast<float>(maximumValue * length.percent() / 100.0f));
+        return static_cast<LayoutUnit>(static_cast<float>(maximumValue * length.percent() / 100.0f));
     case Calculated:
         return length.nonNanCalculatedValue(maximumValue);
     case ViewportPercentageWidth:
         if (renderView)
-            return static_cast<int>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f);
-        return 0;
+            return static_cast<LayoutUnit>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f);
+        return ZERO_LAYOUT_UNIT;
     case ViewportPercentageHeight:
         if (renderView)
-            return static_cast<int>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f);
-        return 0;
+            return static_cast<LayoutUnit>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f);
+        return ZERO_LAYOUT_UNIT;
     case ViewportPercentageMin:
         if (renderView) {
             IntSize viewportSize = renderView->viewportSize();
-            return static_cast<int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f);
+            return static_cast<LayoutUnit>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f);
         }
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     case Auto:
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     case Relative:
     case Intrinsic:
     case MinIntrinsic:
     case Undefined:
         ASSERT_NOT_REACHED();
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     }
     ASSERT_NOT_REACHED();
-    return 0;
+    return ZERO_LAYOUT_UNIT;
 }
 
-int valueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages)
+LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
 {
     switch (length.type()) {
     case Fixed:
@@ -83,23 +93,23 @@
     // multiple assertions are used below to provide more useful debug output.
     case Relative:
         ASSERT_NOT_REACHED();
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     case Intrinsic:
         ASSERT_NOT_REACHED();
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     case MinIntrinsic:
         ASSERT_NOT_REACHED();
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     case Undefined:
         ASSERT_NOT_REACHED();
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     }
     ASSERT_NOT_REACHED();
-    return 0;
+    return ZERO_LAYOUT_UNIT;
 }
 
 // FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143.
-float floatValueForLength(const Length& length, int maximumValue, RenderView* renderView)
+float floatValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView)
 {
     switch (length.type()) {
     case Fixed:

Modified: trunk/Source/WebCore/css/LengthFunctions.h (114078 => 114079)


--- trunk/Source/WebCore/css/LengthFunctions.h	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/css/LengthFunctions.h	2012-04-13 04:19:42 UTC (rev 114079)
@@ -24,14 +24,18 @@
 #ifndef LengthFunctions_h
 #define LengthFunctions_h
 
+#include "LayoutTypes.h"
+
 namespace WebCore {
 
 class RenderView;
 struct Length;
 
-int minimumValueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false);
-int valueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false);
-float floatValueForLength(const Length&, int maximumValue, RenderView* = 0);
+int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
+int intValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
+LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
+LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
+float floatValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0);
 float floatValueForLength(const Length&, float maximumValue, RenderView* = 0);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Document.cpp (114078 => 114079)


--- trunk/Source/WebCore/dom/Document.cpp	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-04-13 04:19:42 UTC (rev 114079)
@@ -1850,10 +1850,10 @@
 
     // The percentage is calculated with respect to the width even for margin top and bottom.
     // http://www.w3.org/TR/CSS2/box.html#margin-properties
-    marginTop = style->marginTop().isAuto() ? marginTop : valueForLength(style->marginTop(), width, view);
-    marginRight = style->marginRight().isAuto() ? marginRight : valueForLength(style->marginRight(), width, view);
-    marginBottom = style->marginBottom().isAuto() ? marginBottom : valueForLength(style->marginBottom(), width, view);
-    marginLeft = style->marginLeft().isAuto() ? marginLeft : valueForLength(style->marginLeft(), width, view);
+    marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(style->marginTop(), width, view);
+    marginRight = style->marginRight().isAuto() ? marginRight : intValueForLength(style->marginRight(), width, view);
+    marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLength(style->marginBottom(), width, view);
+    marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(style->marginLeft(), width, view);
 }
 
 void Document::setIsViewSource(bool isViewSource)

Modified: trunk/Source/WebCore/rendering/RenderFrameSet.cpp (114078 => 114079)


--- trunk/Source/WebCore/rendering/RenderFrameSet.cpp	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/rendering/RenderFrameSet.cpp	2012-04-13 04:19:42 UTC (rev 114079)
@@ -215,7 +215,7 @@
         // Count the total length of all of the fixed columns/rows -> totalFixed
         // Count the number of columns/rows which are fixed -> countFixed
         if (grid[i].isFixed()) {
-            gridLayout[i] = max(grid[i].value(), 0);
+            gridLayout[i] = max(grid[i].intValue(), 0);
             totalFixed += gridLayout[i];
             countFixed++;
         }
@@ -223,7 +223,7 @@
         // Count the total percentage of all of the percentage columns/rows -> totalPercent
         // Count the number of columns/rows which are percentages -> countPercent
         if (grid[i].isPercent()) {
-            gridLayout[i] = max(valueForLength(grid[i], availableLen), 0);
+            gridLayout[i] = max(intValueForLength(grid[i], availableLen), 0);
             totalPercent += gridLayout[i];
             countPercent++;
         }
@@ -231,7 +231,7 @@
         // Count the total relative of all the relative columns/rows -> totalRelative
         // Count the number of columns/rows which are relative -> countRelative
         if (grid[i].isRelative()) {
-            totalRelative += max(grid[i].value(), 1);
+            totalRelative += max(grid[i].intValue(), 1);
             countRelative++;
         }            
     }
@@ -276,7 +276,7 @@
 
         for (int i = 0; i < gridLen; ++i) {
             if (grid[i].isRelative()) {
-                gridLayout[i] = (max(grid[i].value(), 1) * remainingRelative) / totalRelative;
+                gridLayout[i] = (max(grid[i].intValue(), 1) * remainingRelative) / totalRelative;
                 remainingLen -= gridLayout[i];
                 lastRelative = i;
             }

Modified: trunk/Source/WebCore/rendering/RenderMarquee.cpp (114078 => 114079)


--- trunk/Source/WebCore/rendering/RenderMarquee.cpp	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/rendering/RenderMarquee.cpp	2012-04-13 04:19:42 UTC (rev 114079)
@@ -289,7 +289,7 @@
         }
         bool positive = range > 0;
         int clientSize = (isHorizontal() ? m_layer->renderBox()->clientWidth() : m_layer->renderBox()->clientHeight());
-        int increment = abs(valueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize));
+        int increment = abs(intValueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize));
         int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->scrollYOffset());
         newPos =  currentPos + (addIncrement ? increment : -increment);
         if (positive)

Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (114078 => 114079)


--- trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-04-13 03:51:43 UTC (rev 114078)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-04-13 04:19:42 UTC (rev 114079)
@@ -334,7 +334,7 @@
         LayoutUnit baselineDescent = 0;
 
         // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
-        m_rowPos[r + 1] = max(m_rowPos[r] + minimumValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
+        m_rowPos[r + 1] = max(m_rowPos[r] + minimumIntValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
 
         Row& row = m_grid[r].row;
         unsigned totalCols = row.size();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to