Title: [141669] trunk/Source/WebCore
Revision
141669
Author
e...@chromium.org
Date
2013-02-01 17:10:04 -0800 (Fri, 01 Feb 2013)

Log Message

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

Reviewed by Levi Weintraub.

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 (141668 => 141669)


--- trunk/Source/WebCore/ChangeLog	2013-02-02 01:05:04 UTC (rev 141668)
+++ trunk/Source/WebCore/ChangeLog	2013-02-02 01:10:04 UTC (rev 141669)
@@ -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 Levi Weintraub.
+        
+        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-01  Mark Lam  <mark....@apple.com>
 
         Replace ExceptionCode with DatabaseError in the openDatabase() code path.

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (141668 => 141669)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-02-02 01:05:04 UTC (rev 141668)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-02-02 01:10:04 UTC (rev 141669)
@@ -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 (141668 => 141669)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-02-02 01:05:04 UTC (rev 141668)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-02-02 01:10:04 UTC (rev 141669)
@@ -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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to