Title: [127346] trunk/Source/WebCore
Revision
127346
Author
[email protected]
Date
2012-08-31 18:00:10 -0700 (Fri, 31 Aug 2012)

Log Message

Make computeBlockDirectionMargins const
https://bugs.webkit.org/show_bug.cgi?id=95595

Reviewed by Ojan Vafai.

This is a step in making computeLogicalHeight const.
Refactor RenderBox::computeBlockDirectionMargins and make it const.
Add a helper method computeAndSetBlockDirectionMargins for the callers outside of
computeLogicalHeight that are calling this.

No new tests, this is already covered by tests in fast/writing-mode and fast/multicol.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::marginBeforeEstimateForChild): Switch to computeAndSetBlockDirectionMargins
(WebCore::RenderBlock::layoutBlockChild): Switch to computeAndSetBlockDirectionMargins
(WebCore::RenderBlock::insertFloatingObject): Switch to computeAndSetBlockDirectionMargins
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight): Use const version and fill in a MarginValues struct (to be merged in the next patch).
(WebCore::RenderBox::computeBlockDirectionMargins): Pass in out params.
(WebCore):
(WebCore::RenderBox::computeAndSetBlockDirectionMargins): Does the same as the old computeBlockDirectionMargins.
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox): Switch to computeAndSetBlockDirectionMargins
(WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox): Switch to computeAndSetBlockDirectionMargins
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::layout): Switch to computeAndSetBlockDirectionMargins

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127345 => 127346)


--- trunk/Source/WebCore/ChangeLog	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/ChangeLog	2012-09-01 01:00:10 UTC (rev 127346)
@@ -1,3 +1,34 @@
+2012-08-31  Tony Chang  <[email protected]>
+
+        Make computeBlockDirectionMargins const
+        https://bugs.webkit.org/show_bug.cgi?id=95595
+
+        Reviewed by Ojan Vafai.
+
+        This is a step in making computeLogicalHeight const.
+        Refactor RenderBox::computeBlockDirectionMargins and make it const.
+        Add a helper method computeAndSetBlockDirectionMargins for the callers outside of
+        computeLogicalHeight that are calling this.
+
+        No new tests, this is already covered by tests in fast/writing-mode and fast/multicol.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::marginBeforeEstimateForChild): Switch to computeAndSetBlockDirectionMargins
+        (WebCore::RenderBlock::layoutBlockChild): Switch to computeAndSetBlockDirectionMargins
+        (WebCore::RenderBlock::insertFloatingObject): Switch to computeAndSetBlockDirectionMargins
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeLogicalHeight): Use const version and fill in a MarginValues struct (to be merged in the next patch).
+        (WebCore::RenderBox::computeBlockDirectionMargins): Pass in out params.
+        (WebCore):
+        (WebCore::RenderBox::computeAndSetBlockDirectionMargins): Does the same as the old computeBlockDirectionMargins.
+        * rendering/RenderBox.h:
+        (RenderBox):
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox): Switch to computeAndSetBlockDirectionMargins
+        (WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox): Switch to computeAndSetBlockDirectionMargins
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::layout): Switch to computeAndSetBlockDirectionMargins
+
 2012-08-30  Dirk Schulze  <[email protected]>
 
         Introduce new CSS property for clip-path

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (127345 => 127346)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-09-01 01:00:10 UTC (rev 127346)
@@ -2164,7 +2164,7 @@
 
     // Make sure to update the block margins now for the grandchild box so that we're looking at current values.
     if (grandchildBox->needsLayout()) {
-        grandchildBox->computeBlockDirectionMargins(this); 
+        grandchildBox->computeAndSetBlockDirectionMargins(this);
         grandchildBox->setMarginBeforeQuirk(grandchildBox->style()->marginBefore().quirk());
         grandchildBox->setMarginAfterQuirk(grandchildBox->style()->marginAfter().quirk());
     }
@@ -2411,7 +2411,7 @@
     LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
 
     // The child is a normal flow object.  Compute the margins we will use for collapsing now.
-    child->computeBlockDirectionMargins(this);
+    child->computeAndSetBlockDirectionMargins(this);
 
     // Do not allow a collapse if the margin-before-collapse style is set to SEPARATE.
     RenderStyle* childStyle = child->style();
@@ -3761,7 +3761,7 @@
         o->layoutIfNeeded();
     else {
         o->computeLogicalWidth();
-        o->computeBlockDirectionMargins(this);
+        o->computeAndSetBlockDirectionMargins(this);
     }
     setLogicalWidthForFloat(newObj, logicalWidthForChild(o) + marginStartForChild(o) + marginEndForChild(o));
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (127345 => 127346)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-09-01 01:00:10 UTC (rev 127346)
@@ -1984,8 +1984,15 @@
         RenderBlock* cb = containingBlock();
         bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHorizontalWritingMode();
     
-        if (!hasPerpendicularContainingBlock)
-            computeBlockDirectionMargins(cb);
+        if (!hasPerpendicularContainingBlock) {
+            ComputedMarginValues marginValues;
+            bool shouldFlipBeforeAfter = cb->style()->writingMode() != style()->writingMode();
+            computeBlockDirectionMargins(cb,
+                shouldFlipBeforeAfter ? marginValues.m_after : marginValues.m_before,
+                shouldFlipBeforeAfter ? marginValues.m_before : marginValues.m_after);
+            setMarginBefore(marginValues.m_before);
+            setMarginAfter(marginValues.m_after);
+        }
 
         // For tables, calculate margins only.
         if (isTable()) {
@@ -2361,13 +2368,13 @@
     return containingBlock()->availableLogicalHeight();
 }
 
-void RenderBox::computeBlockDirectionMargins(const RenderBlock* containingBlock)
+void RenderBox::computeBlockDirectionMargins(const RenderBlock* containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const
 {
     if (isTableCell()) {
         // FIXME: Not right if we allow cells to have different directionality than the table.  If we do allow this, though,
         // we may just do it with an extra anonymous block inside the cell.
-        setMarginBefore(0);
-        setMarginAfter(0);
+        marginBefore = 0;
+        marginAfter = 0;
         return;
     }
 
@@ -2376,10 +2383,19 @@
     LayoutUnit cw = containingBlockLogicalWidthForContent();
     RenderView* renderView = view();
     RenderStyle* containingBlockStyle = containingBlock->style();
-    containingBlock->setMarginBeforeForChild(this, minimumValueForLength(style()->marginBeforeUsing(containingBlockStyle), cw, renderView));
-    containingBlock->setMarginAfterForChild(this, minimumValueForLength(style()->marginAfterUsing(containingBlockStyle), cw, renderView));
+    marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBlockStyle), cw, renderView);
+    marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBlockStyle), cw, renderView);
 }
 
+void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containingBlock)
+{
+    LayoutUnit marginBefore;
+    LayoutUnit marginAfter;
+    computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter);
+    containingBlock->setMarginBeforeForChild(this, marginBefore);
+    containingBlock->setMarginAfterForChild(this, marginAfter);
+}
+
 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,
     LayoutUnit offsetFromLogicalTopOfFirstPage, bool checkForPerpendicularWritingMode) const
 {

Modified: trunk/Source/WebCore/rendering/RenderBox.h (127345 => 127346)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-09-01 01:00:10 UTC (rev 127346)
@@ -335,7 +335,8 @@
     void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
 
     // Used to resolve margins in the containing block's block-flow direction.
-    void computeBlockDirectionMargins(const RenderBlock* containingBlock);
+    void computeBlockDirectionMargins(const RenderBlock* containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const;
+    void computeAndSetBlockDirectionMargins(const RenderBlock* containingBlock);
 
     enum RenderBoxRegionInfoFlags { CacheRenderBoxRegionInfo, DoNotCacheRenderBoxRegionInfo };
     LayoutRect borderBoxRectInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage = 0, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (127345 => 127346)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-09-01 01:00:10 UTC (rev 127346)
@@ -379,7 +379,7 @@
                 continue;
 
             // Compute the child's vertical margins.
-            child->computeBlockDirectionMargins(this);
+            child->computeAndSetBlockDirectionMargins(this);
 
             if (!child->needsLayout())
                 child->markForPaginationRelayoutIfNeeded();
@@ -684,7 +684,7 @@
             }
 
             // Compute the child's vertical margins.
-            child->computeBlockDirectionMargins(this);
+            child->computeAndSetBlockDirectionMargins(this);
 
             // Add in the child's marginTop to our height.
             setHeight(height() + child->marginTop());

Modified: trunk/Source/WebCore/rendering/RenderTableRow.cpp (127345 => 127346)


--- trunk/Source/WebCore/rendering/RenderTableRow.cpp	2012-09-01 00:46:58 UTC (rev 127345)
+++ trunk/Source/WebCore/rendering/RenderTableRow.cpp	2012-09-01 01:00:10 UTC (rev 127346)
@@ -151,7 +151,7 @@
                 cell->setChildNeedsLayout(true, MarkOnlyThis);
 
             if (child->needsLayout()) {
-                cell->computeBlockDirectionMargins(table());
+                cell->computeAndSetBlockDirectionMargins(table());
                 cell->layout();
             }
         }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to