Title: [141775] trunk/Source/WebCore
Revision
141775
Author
e...@chromium.org
Date
2013-02-04 09:45:19 -0800 (Mon, 04 Feb 2013)

Log Message

Remove duplicate code in RenderBoxModelObject::computedCSSPadding*
https://bugs.webkit.org/show_bug.cgi?id=108707

Reviewed by Eric Seidel.
        
The computedCSSPaddingTop/Bottom/... methods in
RenderBoxModelObject all do pretty much exactly the same thing
yet share no code.
        
Break out shared code into computedCSSPadding method and have
the top/bottom/left/right/... ones call it with the appropriate
length value.

No new tests, no change in functionality.

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::computedCSSPadding):
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::computedCSSPaddingTop):
(WebCore::RenderBoxModelObject::computedCSSPaddingBottom):
(WebCore::RenderBoxModelObject::computedCSSPaddingLeft):
(WebCore::RenderBoxModelObject::computedCSSPaddingRight):
(WebCore::RenderBoxModelObject::computedCSSPaddingBefore):
(WebCore::RenderBoxModelObject::computedCSSPaddingAfter):
(WebCore::RenderBoxModelObject::computedCSSPaddingStart):
(WebCore::RenderBoxModelObject::computedCSSPaddingEnd):
(RenderBoxModelObject):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141774 => 141775)


--- trunk/Source/WebCore/ChangeLog	2013-02-04 17:42:19 UTC (rev 141774)
+++ trunk/Source/WebCore/ChangeLog	2013-02-04 17:45:19 UTC (rev 141775)
@@ -1,3 +1,33 @@
+2013-02-01  Emil A Eklund  <e...@chromium.org>
+
+        Remove duplicate code in RenderBoxModelObject::computedCSSPadding*
+        https://bugs.webkit.org/show_bug.cgi?id=108707
+
+        Reviewed by Eric Seidel.
+        
+        The computedCSSPaddingTop/Bottom/... methods in
+        RenderBoxModelObject all do pretty much exactly the same thing
+        yet share no code.
+        
+        Break out shared code into computedCSSPadding method and have
+        the top/bottom/left/right/... ones call it with the appropriate
+        length value.
+
+        No new tests, no change in functionality.
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::computedCSSPadding):
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::computedCSSPaddingTop):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingBottom):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingLeft):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingRight):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingBefore):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingAfter):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingStart):
+        (WebCore::RenderBoxModelObject::computedCSSPaddingEnd):
+        (RenderBoxModelObject):
+
 2013-02-04  Andrey Lushnikov  <lushni...@chromium.org>
 
         Web Inspector: add round braces to _javascript_ tokenizer

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (141774 => 141775)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-02-04 17:42:19 UTC (rev 141774)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-02-04 17:45:19 UTC (rev 141775)
@@ -558,11 +558,10 @@
     return snapSizeToPixel(offsetHeight(), offsetTop());
 }
 
-LayoutUnit RenderBoxModelObject::computedCSSPaddingTop() const
+LayoutUnit RenderBoxModelObject::computedCSSPadding(Length padding) const
 {
     LayoutUnit w = 0;
     RenderView* renderView = 0;
-    Length padding = style()->paddingTop();
     if (padding.isPercent())
         w = containingBlockLogicalWidthForContent();
     else if (padding.isViewportPercentage())
@@ -570,90 +569,6 @@
     return minimumValueForLength(padding, w, renderView);
 }
 
-LayoutUnit RenderBoxModelObject::computedCSSPaddingBottom() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingBottom();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingLeft() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingLeft();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingRight() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingRight();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingBefore() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingBefore();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingAfter() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingAfter();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingStart() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingStart();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
-LayoutUnit RenderBoxModelObject::computedCSSPaddingEnd() const
-{
-    LayoutUnit w = 0;
-    RenderView* renderView = 0;
-    Length padding = style()->paddingEnd();
-    if (padding.isPercent())
-        w = containingBlockLogicalWidthForContent();
-    else if (padding.isViewportPercentage())
-        renderView = view();
-    return minimumValueForLength(padding, w, renderView);
-}
-
 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
     bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (141774 => 141775)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-02-04 17:42:19 UTC (rev 141774)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-02-04 17:45:19 UTC (rev 141775)
@@ -91,14 +91,14 @@
     virtual IntRect borderBoundingBox() const = 0;
 
     // These return the CSS computed padding values.
-    LayoutUnit computedCSSPaddingTop() const;
-    LayoutUnit computedCSSPaddingBottom() const;
-    LayoutUnit computedCSSPaddingLeft() const;
-    LayoutUnit computedCSSPaddingRight() const;
-    LayoutUnit computedCSSPaddingBefore() const;
-    LayoutUnit computedCSSPaddingAfter() const;
-    LayoutUnit computedCSSPaddingStart() const;
-    LayoutUnit computedCSSPaddingEnd() const;
+    LayoutUnit computedCSSPaddingTop() const { return computedCSSPadding(style()->paddingTop()); }
+    LayoutUnit computedCSSPaddingBottom() const { return computedCSSPadding(style()->paddingBottom()); }
+    LayoutUnit computedCSSPaddingLeft() const { return computedCSSPadding(style()->paddingLeft()); }
+    LayoutUnit computedCSSPaddingRight() const { return computedCSSPadding(style()->paddingRight()); }
+    LayoutUnit computedCSSPaddingBefore() const { return computedCSSPadding(style()->paddingBefore()); }
+    LayoutUnit computedCSSPaddingAfter() const { return computedCSSPadding(style()->paddingAfter()); }
+    LayoutUnit computedCSSPaddingStart() const { return computedCSSPadding(style()->paddingStart()); }
+    LayoutUnit computedCSSPaddingEnd() const { return computedCSSPadding(style()->paddingEnd()); }
 
     // These functions are used during layout. Table cells and the MathML
     // code override them to include some extra intrinsic padding.
@@ -278,6 +278,7 @@
     void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRemoveInsert = false);
 
 private:
+    LayoutUnit computedCSSPadding(Length) const;
     virtual bool isBoxModelObject() const { return true; }
     
     virtual LayoutRect frameRectForStickyPositioning() const = 0;

Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (141774 => 141775)


--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp	2013-02-04 17:42:19 UTC (rev 141774)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp	2013-02-04 17:45:19 UTC (rev 141775)
@@ -122,3 +122,4 @@
 #include "RootInlineBox.cpp"
 #include "ScrollBehavior.cpp"
 #include "break_lines.cpp"
+

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp (141774 => 141775)


--- trunk/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp	2013-02-04 17:42:19 UTC (rev 141774)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp	2013-02-04 17:45:19 UTC (rev 141775)
@@ -77,3 +77,4 @@
 #include "SVGTextMetrics.cpp"
 #include "SVGTextMetricsBuilder.cpp"
 #include "SVGTextQuery.cpp"
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to