Title: [110135] trunk/Source/WebCore
Revision
110135
Author
[email protected]
Date
2012-03-07 19:31:25 -0800 (Wed, 07 Mar 2012)

Log Message

Add RenderBoxModelObject::marginWidth() and marginHeight()
https://bugs.webkit.org/show_bug.cgi?id=80556

Reviewed by Kentaro Hara.

They make some code shorter.

No behavior change.

* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::marginHeight): Added.
(WebCore::RenderBoxModelObject::marginWidth): Added.
* inspector/DOMNodeHighlighter.cpp: Use marginHeight() and/or marginWidth().
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatWithRect::FloatWithRect): ditto.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::checkFloatsInCleanLine): ditto.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::repaintLayerRectsForImage): ditto.
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox): ditto.
(WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox): ditto.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::crossAxisMarginExtentForChild): ditto.
(WebCore::RenderFlexibleBox::computeNextFlexLine): ditto.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::culledInlineAbsoluteRects): ditto.
(WebCore::RenderInline::culledInlineAbsoluteQuads): ditto.
(WebCore::RenderInline::culledInlineBoundingBox): ditto.
* rendering/RenderScrollbar.cpp:
(WebCore::RenderScrollbar::trackPieceRectWithMargins): ditto.
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::computeLogicalHeight): ditto.
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::computeControlHeight): ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110134 => 110135)


--- trunk/Source/WebCore/ChangeLog	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/ChangeLog	2012-03-08 03:31:25 UTC (rev 110135)
@@ -1,3 +1,41 @@
+2012-03-07  Kent Tamura  <[email protected]>
+
+        Add RenderBoxModelObject::marginWidth() and marginHeight()
+        https://bugs.webkit.org/show_bug.cgi?id=80556
+
+        Reviewed by Kentaro Hara.
+
+        They make some code shorter.
+
+        No behavior change.
+
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::marginHeight): Added.
+        (WebCore::RenderBoxModelObject::marginWidth): Added.
+        * inspector/DOMNodeHighlighter.cpp: Use marginHeight() and/or marginWidth().
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::FloatWithRect::FloatWithRect): ditto.
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::checkFloatsInCleanLine): ditto.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::repaintLayerRectsForImage): ditto.
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox): ditto.
+        (WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox): ditto.
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::crossAxisMarginExtentForChild): ditto.
+        (WebCore::RenderFlexibleBox::computeNextFlexLine): ditto.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::culledInlineAbsoluteRects): ditto.
+        (WebCore::RenderInline::culledInlineAbsoluteQuads): ditto.
+        (WebCore::RenderInline::culledInlineBoundingBox): ditto.
+        * rendering/RenderScrollbar.cpp:
+        (WebCore::RenderScrollbar::trackPieceRectWithMargins): ditto.
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::computeLogicalHeight): ditto.
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::computeControlHeight): ditto.
+
 2012-03-07  Jessie Berlin  <[email protected]>
 
         Clean Windows build fails after r110033

Modified: trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp (110134 => 110135)


--- trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -414,7 +414,7 @@
             borderBox = LayoutRect(paddingBox.x() - renderBox->borderLeft(), paddingBox.y() - renderBox->borderTop(),
                     paddingBox.width() + renderBox->borderLeft() + renderBox->borderRight(), paddingBox.height() + renderBox->borderTop() + renderBox->borderBottom());
             marginBox = LayoutRect(borderBox.x() - renderBox->marginLeft(), borderBox.y() - renderBox->marginTop(),
-                    borderBox.width() + renderBox->marginLeft() + renderBox->marginRight(), borderBox.height() + renderBox->marginTop() + renderBox->marginBottom());
+                    borderBox.width() + renderBox->marginWidth(), borderBox.height() + renderBox->marginHeight());
         } else {
             RenderInline* renderInline = toRenderInline(renderer);
 
@@ -426,7 +426,7 @@
                     paddingBox.width() - renderInline->paddingLeft() - renderInline->paddingRight(), paddingBox.height() - renderInline->paddingTop() - renderInline->paddingBottom());
             // Ignore marginTop and marginBottom for inlines.
             marginBox = LayoutRect(borderBox.x() - renderInline->marginLeft(), borderBox.y(),
-                    borderBox.width() + renderInline->marginLeft() + renderInline->marginRight(), borderBox.height());
+                    borderBox.width() + renderInline->marginWidth(), borderBox.height());
         }
 
         FloatQuad absContentQuad = renderer->localToAbsoluteQuad(FloatRect(contentBox));

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2012-03-08 03:31:25 UTC (rev 110135)
@@ -532,7 +532,7 @@
     struct FloatWithRect {
         FloatWithRect(RenderBox* f)
             : object(f)
-            , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom()))
+            , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight()))
             , everHadLayout(f->everHadLayout())
         {
         }

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -1546,7 +1546,7 @@
     for (Vector<RenderBox*>::iterator it = cleanLineFloats->begin(); it != end; ++it) {
         RenderBox* floatingBox = *it;
         floatingBox->layoutIfNeeded();
-        LayoutSize newSize(floatingBox->width() + floatingBox->marginLeft() + floatingBox->marginRight(), floatingBox->height() + floatingBox->marginTop() + floatingBox->marginBottom());
+        LayoutSize newSize(floatingBox->width() + floatingBox->marginWidth(), floatingBox->height() + floatingBox->marginHeight());
         ASSERT(floatIndex < floats.size());
         if (floats[floatIndex].object != floatingBox) {
             encounteredNewFloat = true;

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -1188,8 +1188,8 @@
                     }
                     rendererRect = LayoutRect(-layerRenderer->marginLeft(),
                         -layerRenderer->marginTop(),
-                        max(layerRenderer->width() + layerRenderer->marginLeft() + layerRenderer->marginRight() + layerRenderer->borderLeft() + layerRenderer->borderRight(), rw),
-                        max(layerRenderer->height() + layerRenderer->marginTop() + layerRenderer->marginBottom() + layerRenderer->borderTop() + layerRenderer->borderBottom(), rh));
+                        max(layerRenderer->width() + layerRenderer->marginWidth() + layerRenderer->borderLeft() + layerRenderer->borderRight(), rw),
+                        max(layerRenderer->height() + layerRenderer->marginHeight() + layerRenderer->borderTop() + layerRenderer->borderBottom(), rh));
                 } else {
                     layerRenderer = this;
                     rendererRect = borderBoxRect();

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-03-08 03:31:25 UTC (rev 110135)
@@ -116,6 +116,8 @@
     virtual LayoutUnit marginAfter() const = 0;
     virtual LayoutUnit marginStart() const = 0;
     virtual LayoutUnit marginEnd() const = 0;
+    LayoutUnit marginHeight() const { return marginTop() + marginBottom(); }
+    LayoutUnit marginWidth() const { return marginLeft() + marginRight(); }
 
     bool hasInlineDirectionBordersPaddingOrMargin() const { return hasInlineDirectionBordersOrPadding() || marginStart()|| marginEnd(); }
     bool hasInlineDirectionBordersOrPadding() const { return borderStart() || borderEnd() || paddingStart()|| paddingEnd(); }

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -394,7 +394,7 @@
                 if (ascent == -1)
                     ascent = child->height() + child->marginBottom();
                 ascent += child->marginTop();
-                LayoutUnit descent = (child->marginTop() + child->height() + child->marginBottom()) - ascent;
+                LayoutUnit descent = (child->height() + child->marginHeight()) - ascent;
 
                 // Update our maximum ascent.
                 maxAscent = max(maxAscent, ascent);
@@ -406,7 +406,7 @@
                 setHeight(max(yPos + maxAscent + maxDescent, height()));
             }
             else
-                setHeight(max(height(), yPos + child->marginTop() + child->height() + child->marginBottom()));
+                setHeight(max(height(), yPos + child->height() + child->marginHeight()));
         }
 
         if (!iterator.first() && hasLineIfEmpty())
@@ -460,7 +460,7 @@
             LayoutUnit childY = yPos;
             switch (style()->boxAlign()) {
                 case BCENTER:
-                    childY += child->marginTop() + max<LayoutUnit>(0, (contentHeight() - (child->height() + child->marginTop() + child->marginBottom())) / 2);
+                    childY += child->marginTop() + max<LayoutUnit>(0, (contentHeight() - (child->height() + child->marginHeight())) / 2);
                     break;
                 case BBASELINE: {
                     LayoutUnit ascent = child->firstLineBoxBaseline();
@@ -699,7 +699,7 @@
             switch (style()->boxAlign()) {
                 case BCENTER:
                 case BBASELINE: // Baseline just maps to center for vertical boxes
-                    childX += child->marginLeft() + max<LayoutUnit>(0, (contentWidth() - (child->width() + child->marginLeft() + child->marginRight())) / 2);
+                    childX += child->marginLeft() + max<LayoutUnit>(0, (contentWidth() - (child->width() + child->marginWidth())) / 2);
                     break;
                 case BEND:
                     if (!style()->isLeftToRightDirection())

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -492,7 +492,7 @@
 
 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox* child) const
 {
-    return isHorizontalFlow() ? child->marginTop() + child->marginBottom() : child->marginLeft() + child->marginRight();
+    return isHorizontalFlow() ? child->marginHeight() : child->marginWidth();
 }
 
 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtent() const
@@ -632,9 +632,9 @@
 
         LayoutUnit childMainAxisExtent = mainAxisBorderAndPaddingExtentForChild(child) + preferredMainAxisContentExtentForChild(child);
         if (isHorizontalFlow())
-            childMainAxisExtent += child->marginLeft() + child->marginRight();
+            childMainAxisExtent += child->marginWidth();
         else
-            childMainAxisExtent += child->marginTop() + child->marginBottom();
+            childMainAxisExtent += child->marginHeight();
 
         if (isMultiline() && preferredMainAxisExtent + childMainAxisExtent > mainAxisContentExtent() && orderedChildren.size() > 0)
             break;

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -548,9 +548,9 @@
                 int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
                 FloatRect result;
                 if (isHorizontal)
-                    result = FloatRect(offset.width() + currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), offset.height() + logicalTop, currBox->width() + currBox->marginLeft() + currBox->marginRight(), logicalHeight);
+                    result = FloatRect(offset.width() + currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), offset.height() + logicalTop, currBox->width() + currBox->marginWidth(), logicalHeight);
                 else
-                    result = FloatRect(offset.width() + logicalTop, offset.height() + currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginTop() + currBox->marginBottom());
+                    result = FloatRect(offset.width() + logicalTop, offset.height() + currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginHeight());
                 rects.append(enclosingIntRect(result));
             }
         } else if (curr->isRenderInline()) {
@@ -632,9 +632,9 @@
                 int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
                 FloatRect result;
                 if (isHorizontal)
-                    result = FloatRect(currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), logicalTop, currBox->width() + currBox->marginLeft() + currBox->marginRight(), logicalHeight);
+                    result = FloatRect(currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), logicalTop, currBox->width() + currBox->marginWidth(), logicalHeight);
                 else
-                    result = FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginTop() + currBox->marginBottom());
+                    result = FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginHeight());
                 quads.append(localToAbsoluteQuad(result));
             }
         } else if (curr->isRenderInline()) {
@@ -838,9 +838,9 @@
                 int logicalTop = rootBox->logicalTop() + (rootBox->renderer()->style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent());
                 int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
                 if (isHorizontal)
-                    result.uniteIfNonZero(FloatRect(currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), logicalTop, currBox->width() + currBox->marginLeft() + currBox->marginRight(), logicalHeight));
+                    result.uniteIfNonZero(FloatRect(currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), logicalTop, currBox->width() + currBox->marginWidth(), logicalHeight));
                 else
-                    result.uniteIfNonZero(FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginTop() + currBox->marginBottom()));
+                    result.uniteIfNonZero(FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, currBox->height() + currBox->marginHeight()));
             }
         } else if (curr->isRenderInline()) {
             // If the child doesn't need line boxes either, then we can recur.

Modified: trunk/Source/WebCore/rendering/RenderScrollbar.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderScrollbar.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderScrollbar.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -355,10 +355,10 @@
     IntRect rect = oldRect;
     if (orientation() == HorizontalScrollbar) {
         rect.setX(rect.x() + partRenderer->marginLeft());
-        rect.setWidth(rect.width() - (partRenderer->marginLeft() + partRenderer->marginRight()));
+        rect.setWidth(rect.width() - partRenderer->marginWidth());
     } else {
         rect.setY(rect.y() + partRenderer->marginTop());
-        rect.setHeight(rect.height() - (partRenderer->marginTop() + partRenderer->marginBottom()));
+        rect.setHeight(rect.height() - partRenderer->marginHeight());
     }
     return rect;
 }

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -143,7 +143,7 @@
     HTMLElement* innerText = innerTextElement();
     ASSERT(innerText);
     RenderBox* innerTextBox = innerText->renderBox();
-    LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginTop() + innerTextBox->marginBottom();
+    LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
     setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight());
 
     // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (110134 => 110135)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2012-03-08 03:15:00 UTC (rev 110134)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2012-03-08 03:31:25 UTC (rev 110135)
@@ -430,13 +430,13 @@
     HTMLElement* resultsButton = resultsButtonElement();
     if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) {
         resultsRenderer->computeLogicalHeight();
-        nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingHeight() + resultsRenderer->marginTop() + resultsRenderer->marginBottom());
+        nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingHeight() + resultsRenderer->marginHeight());
         lineHeight = max(lineHeight, resultsRenderer->height());
     }
     HTMLElement* cancelButton = cancelButtonElement();
     if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0) {
         cancelRenderer->computeLogicalHeight();
-        nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingHeight() + cancelRenderer->marginTop() + cancelRenderer->marginBottom());
+        nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingHeight() + cancelRenderer->marginHeight());
         lineHeight = max(lineHeight, cancelRenderer->height());
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to