Title: [122639] trunk/Source/WebCore
Revision
122639
Author
[email protected]
Date
2012-07-13 15:57:16 -0700 (Fri, 13 Jul 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=91278
Improve block margin estimation function to account for not having a layout and for quirks mode
        
Reviewed by Simon Fraser.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::marginBeforeEstimateForChild):
Revise marginBeforeEstimateForChild so that it computes block margins for the grandchild before
recurring. This includes the quirks margin information as well. This ensures that the margins are
up-to-date when checked, even before the object has had its first layout.
        
* rendering/RenderBlock.h:
(WebCore::RenderBlock::setMarginStartForChild):
(WebCore::RenderBlock::setMarginEndForChild):
(WebCore::RenderBlock::setMarginBeforeForChild):
(WebCore::RenderBlock::setMarginAfterForChild):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeBlockDirectionMargins):
* rendering/RenderBox.h:
(RenderBox):
Add consts in order to compile.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122638 => 122639)


--- trunk/Source/WebCore/ChangeLog	2012-07-13 22:46:41 UTC (rev 122638)
+++ trunk/Source/WebCore/ChangeLog	2012-07-13 22:57:16 UTC (rev 122639)
@@ -1,3 +1,27 @@
+2012-07-13  David Hyatt  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=91278
+        Improve block margin estimation function to account for not having a layout and for quirks mode
+        
+        Reviewed by Simon Fraser.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::marginBeforeEstimateForChild):
+        Revise marginBeforeEstimateForChild so that it computes block margins for the grandchild before
+        recurring. This includes the quirks margin information as well. This ensures that the margins are
+        up-to-date when checked, even before the object has had its first layout.
+        
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::setMarginStartForChild):
+        (WebCore::RenderBlock::setMarginEndForChild):
+        (WebCore::RenderBlock::setMarginBeforeForChild):
+        (WebCore::RenderBlock::setMarginAfterForChild):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeBlockDirectionMargins):
+        * rendering/RenderBox.h:
+        (RenderBox):
+        Add consts in order to compile.
+
 2012-07-13  Ryosuke Niwa  <[email protected]>
 
         NodeLists should not invalidate on irreleavnt attribute changes

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (122638 => 122639)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-07-13 22:46:41 UTC (rev 122638)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-07-13 22:57:16 UTC (rev 122639)
@@ -2091,8 +2091,11 @@
 
 void RenderBlock::marginBeforeEstimateForChild(RenderBox* child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore) const
 {
-    // FIXME: We could get even more quirks mode cases right if we dealt with quirk containers.
     // FIXME: We should deal with the margin-collapse-* style extensions that prevent collapsing and that discard margins.
+    // Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky.
+    if (document()->inQuirksMode() && child->isMarginBeforeQuirk() && (isTableCell() || isBody()))
+        return;
+
     LayoutUnit beforeChildMargin = marginBeforeForChild(child);
     positiveMarginBefore = max(positiveMarginBefore, beforeChildMargin);
     negativeMarginBefore = max(negativeMarginBefore, -beforeChildMargin);
@@ -2118,6 +2121,13 @@
     if (!grandchildBox || grandchildBox->style()->clear() != CNONE)
         return;
 
+    // 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->setMarginBeforeQuirk(grandchildBox->style()->marginBefore().quirk());
+        grandchildBox->setMarginAfterQuirk(grandchildBox->style()->marginAfter().quirk());
+    }
+
     // Collapse the margin of the grandchild box with our own to produce an estimate.
     childBlock->marginBeforeEstimateForChild(grandchildBox, positiveMarginBefore, negativeMarginBefore);
 }

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (122638 => 122639)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2012-07-13 22:46:41 UTC (rev 122638)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2012-07-13 22:57:16 UTC (rev 122639)
@@ -295,10 +295,10 @@
     LayoutUnit marginAfterForChild(const RenderBoxModelObject* child) const { return child->marginAfter(style()); }
     LayoutUnit marginStartForChild(const RenderBoxModelObject* child) const { return child->marginStart(style()); }
     LayoutUnit marginEndForChild(const RenderBoxModelObject* child) const { return child->marginEnd(style()); }
-    void setMarginStartForChild(RenderBox* child, LayoutUnit value) { child->setMarginStart(value, style()); }
-    void setMarginEndForChild(RenderBox* child, LayoutUnit value) { child->setMarginEnd(value, style()); }
-    void setMarginBeforeForChild(RenderBox* child, LayoutUnit value) { child->setMarginBefore(value, style()); }
-    void setMarginAfterForChild(RenderBox* child, LayoutUnit value) { child->setMarginAfter(value, style()); }
+    void setMarginStartForChild(RenderBox* child, LayoutUnit value) const { child->setMarginStart(value, style()); }
+    void setMarginEndForChild(RenderBox* child, LayoutUnit value) const { child->setMarginEnd(value, style()); }
+    void setMarginBeforeForChild(RenderBox* child, LayoutUnit value) const { child->setMarginBefore(value, style()); }
+    void setMarginAfterForChild(RenderBox* child, LayoutUnit value) const { child->setMarginAfter(value, style()); }
     LayoutUnit collapsedMarginBeforeForChild(const RenderBox* child) const;
     LayoutUnit collapsedMarginAfterForChild(const RenderBox* child) const;
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (122638 => 122639)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-13 22:46:41 UTC (rev 122638)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-13 22:57:16 UTC (rev 122639)
@@ -2334,7 +2334,7 @@
     return containingBlock()->availableLogicalHeight();
 }
 
-void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)
+void RenderBox::computeBlockDirectionMargins(const RenderBlock* containingBlock)
 {
     if (isTableCell()) {
         // FIXME: Not right if we allow cells to have different directionality than the table.  If we do allow this, though,

Modified: trunk/Source/WebCore/rendering/RenderBox.h (122638 => 122639)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-07-13 22:46:41 UTC (rev 122638)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-07-13 22:57:16 UTC (rev 122639)
@@ -290,7 +290,7 @@
     void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth);
 
     // Used to resolve margins in the containing block's block-flow direction.
-    void computeBlockDirectionMargins(RenderBlock* containingBlock);
+    void computeBlockDirectionMargins(const RenderBlock* containingBlock);
 
     enum RenderBoxRegionInfoFlags { CacheRenderBoxRegionInfo, DoNotCacheRenderBoxRegionInfo };
     LayoutRect borderBoxRectInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage = 0, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to