Title: [144816] trunk/Source/WebCore
Revision
144816
Author
o...@chromium.org
Date
2013-03-05 14:04:52 -0800 (Tue, 05 Mar 2013)

Log Message

Inline min/maxInstrinsicLogicalWidth functions
https://bugs.webkit.org/show_bug.cgi?id=111399

Reviewed by Tony Chang.

Turns out these functions don't need to be public and only
have one caller. This patch is in preparation for supporting
intrinsic widths on tables, which will need to pass in the
border and padding width as an argument.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::fillAvailableMeasure):
(WebCore::RenderBox::computeIntrinsicLogicalWidthUsing):
(WebCore::RenderBox::computeLogicalWidthInRegionUsing):
* rendering/RenderBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (144815 => 144816)


--- trunk/Source/WebCore/ChangeLog	2013-03-05 22:04:23 UTC (rev 144815)
+++ trunk/Source/WebCore/ChangeLog	2013-03-05 22:04:52 UTC (rev 144816)
@@ -1,3 +1,21 @@
+2013-03-04  Ojan Vafai  <o...@chromium.org>
+
+        Inline min/maxInstrinsicLogicalWidth functions
+        https://bugs.webkit.org/show_bug.cgi?id=111399
+
+        Reviewed by Tony Chang.
+
+        Turns out these functions don't need to be public and only
+        have one caller. This patch is in preparation for supporting
+        intrinsic widths on tables, which will need to pass in the
+        border and padding width as an argument.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::fillAvailableMeasure):
+        (WebCore::RenderBox::computeIntrinsicLogicalWidthUsing):
+        (WebCore::RenderBox::computeLogicalWidthInRegionUsing):
+        * rendering/RenderBox.h:
+
 2013-03-05  Victor Carbune  <vcarb...@chromium.org>
 
         Cue line-height property shouldn't be inherited from the video element

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (144815 => 144816)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-03-05 22:04:23 UTC (rev 144815)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-03-05 22:04:52 UTC (rev 144816)
@@ -820,22 +820,6 @@
     paintRect = intersection(paintRect, clipRect);
 }
 
-LayoutUnit RenderBox::minIntrinsicLogicalWidth() const
-{
-    LayoutUnit minLogicalWidth = 0;
-    LayoutUnit maxLogicalWidth = 0;
-    computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
-    return minLogicalWidth + borderAndPaddingLogicalWidth();
-}
-
-LayoutUnit RenderBox::maxIntrinsicLogicalWidth() const
-{
-    LayoutUnit minLogicalWidth = 0;
-    LayoutUnit maxLogicalWidth = 0;
-    computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
-    return maxLogicalWidth + borderAndPaddingLogicalWidth();
-}
-
 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
 {
     minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth();
@@ -2064,28 +2048,44 @@
     }
 }
 
-LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const
+LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) const
 {
-    if (logicalWidthLength.type() == MinContent)
-        return minIntrinsicLogicalWidth();
-    if (logicalWidthLength.type() == MaxContent)
-        return maxIntrinsicLogicalWidth();
+    LayoutUnit marginStart = 0;
+    LayoutUnit marginEnd = 0;
+    return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd);
+}
 
+LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const
+{
     RenderView* renderView = view();
-    LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView);
-    LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView);
-    LayoutUnit fillAvailableMeasure = availableLogicalWidth - marginStart - marginEnd;
+    marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView);
+    marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView);
+    return availableLogicalWidth - marginStart - marginEnd;
+}
 
+LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const
+{
     if (logicalWidthLength.type() == FillAvailable)
-        return fillAvailableMeasure;
+        return fillAvailableMeasure(availableLogicalWidth);
+
+    LayoutUnit minLogicalWidth = 0;
+    LayoutUnit maxLogicalWidth = 0;
+    computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
+
+    LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
+
+    if (logicalWidthLength.type() == MinContent)
+        return minLogicalWidth + borderAndPadding;
+
+    if (logicalWidthLength.type() == MaxContent)
+        return maxLogicalWidth + borderAndPadding;
+
     if (logicalWidthLength.type() == FitContent) {
-        LayoutUnit minLogicalWidth = 0;
-        LayoutUnit maxLogicalWidth = 0;
-        computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
-        minLogicalWidth += borderAndPaddingLogicalWidth();
-        maxLogicalWidth += borderAndPaddingLogicalWidth();
-        return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure));
+        minLogicalWidth += borderAndPadding;
+        maxLogicalWidth += borderAndPadding;
+        return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure(availableLogicalWidth)));
     }
+
     ASSERT_NOT_REACHED();
     return 0;
 }
@@ -2115,13 +2115,12 @@
     if (logicalWidth.isIntrinsic())
         return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth);
 
-    RenderView* renderView = view();
-    LayoutUnit marginStart = minimumValueForLength(styleToUse->marginStart(), availableLogicalWidth, renderView);
-    LayoutUnit marginEnd = minimumValueForLength(styleToUse->marginEnd(), availableLogicalWidth, renderView);
-    LayoutUnit logicalWidthResult = availableLogicalWidth - marginStart - marginEnd;
+    LayoutUnit marginStart = 0;
+    LayoutUnit marginEnd = 0;
+    LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd);
 
     if (shrinkToAvoidFloats() && cb->containsFloats())
-        logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region, offsetFromLogicalTopOfFirstPage));
+        logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region, offsetFromLogicalTopOfFirstPage));        
 
     if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthType))
         return max(minPreferredLogicalWidth(), min(maxPreferredLogicalWidth(), logicalWidthResult));

Modified: trunk/Source/WebCore/rendering/RenderBox.h (144815 => 144816)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-03-05 22:04:23 UTC (rev 144815)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-03-05 22:04:52 UTC (rev 144816)
@@ -294,9 +294,6 @@
     virtual void paint(PaintInfo&, const LayoutPoint&);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
 
-    LayoutUnit minIntrinsicLogicalWidth() const;
-    LayoutUnit maxIntrinsicLogicalWidth() const;
-
     virtual LayoutUnit minPreferredLogicalWidth() const;
     virtual LayoutUnit maxPreferredLogicalWidth() const;
 
@@ -658,6 +655,9 @@
     void computePositionedLogicalHeightReplaced(LogicalExtentComputedValues&) const;
     void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) const;
 
+    LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth) const;
+    LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
+
     LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const;
 
     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to