[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 13:49:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5fe64f055cb6eea545eb8bda070453eee00f33cf
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 21:56:19 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=46649, fix failing layout tests.
    
    Reviewed by Sam Weinig.
    
    The implementation of setting the before/after margins was wrong and poking the wrong margin values.
    
    Once I made them set the correct values, it revealed that one of the new block flow tests wasn't
    actually working.  In order to fix it, I had to make the block direction margin computation actually
    use the containing block's block-flow in order to return the right answer.  This involved cleaning
    up computeBlockDirectionMargins to be more like computeInlineDirectionMargins.
    
    fast/css/logical-property-resolution.html also caught the bug.  Its results are now correct.
    
    WebCore:
    
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::adjustPositionedBlock):
    (WebCore::RenderBlock::determineHorizontalPosition):
    (WebCore::RenderBlock::layoutBlockChild):
    (WebCore::RenderBlock::insertFloatingObject):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::setMarginBeforeUsing):
    (WebCore::RenderBox::setMarginAfterUsing):
    (WebCore::RenderBox::computeLogicalWidth):
    (WebCore::RenderBox::computeInlineDirectionMargins):
    (WebCore::RenderBox::computeLogicalHeight):
    (WebCore::RenderBox::computeBlockDirectionMargins):
    * rendering/RenderBox.h:
    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::layoutHorizontalBox):
    (WebCore::RenderFlexibleBox::layoutVerticalBox):
    * rendering/RenderObject.h:
    * rendering/RenderTable.cpp:
    (WebCore::RenderTable::computeLogicalWidth):
    * rendering/RenderTableRow.cpp:
    (WebCore::RenderTableRow::layout):
    * rendering/style/RenderStyle.cpp:
    (WebCore::RenderStyle::marginBeforeUsing):
    (WebCore::RenderStyle::marginAfterUsing):
    * rendering/style/RenderStyle.h:
    
    LayoutTests:
    
    * fast/css/logical-property-resolution-expected.txt:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 696505f..2aee27f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-27  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46649, fix failing layout tests.
+
+        The implementation of setting the before/after margins was wrong and poking the wrong margin values.
+        
+        Once I made them set the correct values, it revealed that one of the new block flow tests wasn't
+        actually working.  In order to fix it, I had to make the block direction margin computation actually
+        use the containing block's block-flow in order to return the right answer.  This involved cleaning
+        up computeBlockDirectionMargins to be more like computeInlineDirectionMargins.
+        
+        fast/css/logical-property-resolution.html also caught the bug.  Its results are now correct.
+
+        * fast/css/logical-property-resolution-expected.txt:
+
 2010-09-14  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/LayoutTests/fast/css/logical-property-resolution-expected.txt b/LayoutTests/fast/css/logical-property-resolution-expected.txt
index f4b2bb0..01f4038 100644
--- a/LayoutTests/fast/css/logical-property-resolution-expected.txt
+++ b/LayoutTests/fast/css/logical-property-resolution-expected.txt
@@ -6,7 +6,7 @@ Borders: 1px solid rgb(0, 0, 0), 2px dotted rgb(0, 128, 0), 3px dashed rgb(255,
 Width: 100px
 Height: 50px
 Block #2:
-Margins: 1px 2px 3px 4px
+Margins: 3px 2px 1px 4px
 Padding: 2px 3px 4px 1px
 Borders: 3px dashed rgb(255, 255, 0), 2px dotted rgb(0, 128, 0), 1px solid rgb(0, 0, 0), 4px double rgb(128, 0, 128)
 Width: 100px
@@ -24,7 +24,7 @@ Borders: 4px double rgb(128, 0, 128), 1px solid rgb(0, 0, 0), 2px dotted rgb(0,
 Width: 50px
 Height: 100px
 Block #5:
-Margins: 3px 4px 1px 2px
+Margins: 1px 4px 3px 2px
 Padding: 4px 1px 2px 3px
 Borders: 1px solid rgb(0, 0, 0), 4px double rgb(128, 0, 128), 3px dashed rgb(255, 255, 0), 2px dotted rgb(0, 128, 0)
 Width: 100px
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2aca7f8..555750a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,44 @@
+2010-09-27  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46649, fix failing layout tests.
+
+        The implementation of setting the before/after margins was wrong and poking the wrong margin values.
+        
+        Once I made them set the correct values, it revealed that one of the new block flow tests wasn't
+        actually working.  In order to fix it, I had to make the block direction margin computation actually
+        use the containing block's block-flow in order to return the right answer.  This involved cleaning
+        up computeBlockDirectionMargins to be more like computeInlineDirectionMargins.
+        
+        fast/css/logical-property-resolution.html also caught the bug.  Its results are now correct.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::adjustPositionedBlock):
+        (WebCore::RenderBlock::determineHorizontalPosition):
+        (WebCore::RenderBlock::layoutBlockChild):
+        (WebCore::RenderBlock::insertFloatingObject):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::setMarginBeforeUsing):
+        (WebCore::RenderBox::setMarginAfterUsing):
+        (WebCore::RenderBox::computeLogicalWidth):
+        (WebCore::RenderBox::computeInlineDirectionMargins):
+        (WebCore::RenderBox::computeLogicalHeight):
+        (WebCore::RenderBox::computeBlockDirectionMargins):
+        * rendering/RenderBox.h:
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutHorizontalBox):
+        (WebCore::RenderFlexibleBox::layoutVerticalBox):
+        * rendering/RenderObject.h:
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::computeLogicalWidth):
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::layout):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::marginBeforeUsing):
+        (WebCore::RenderStyle::marginAfterUsing):
+        * rendering/style/RenderStyle.h:
+
 2010-09-14  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index bc20b47..299ab2d 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -1332,7 +1332,7 @@ void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marg
     if (child->style()->hasStaticY()) {
         int y = height();
         if (!marginInfo.canCollapseWithTop()) {
-            child->computeBlockDirectionMargins();
+            child->computeBlockDirectionMargins(this);
             int marginTop = child->marginTop();
             int collapsedTopPos = marginInfo.posMargin();
             int collapsedTopNeg = marginInfo.negMargin();
@@ -1663,7 +1663,7 @@ void RenderBlock::determineHorizontalPosition(RenderBox* child)
                 // width computation will take into account the delta between |leftOff| and |xPos|
                 // so that we can just pass the content width in directly to the |computeMarginsInContainingBlockInlineDirection|
                 // function.
-                child->computeMarginsInContainingBlockInlineDirection(this, availableLogicalWidthForLine(child->y(), false), child->width());
+                child->computeInlineDirectionMargins(this, availableLogicalWidthForLine(child->y(), false), child->width());
                 chPos = leftOff + child->marginLeft();
             }
         }
@@ -1684,7 +1684,7 @@ void RenderBlock::determineHorizontalPosition(RenderBox* child)
                 // width computation will take into account the delta between |rightOff| and |xPos|
                 // so that we can just pass the content width in directly to the |computeInlineDirectionMargins|
                 // function.
-                child->computeMarginsInContainingBlockInlineDirection(this, availableLogicalWidthForLine(child->y(), false), child->width());
+                child->computeInlineDirectionMargins(this, availableLogicalWidthForLine(child->y(), false), child->width());
                 chPos = rightOff - child->marginRight() - child->width();
             }
         }
@@ -1805,7 +1805,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
     int oldTopNegMargin = maxTopNegMargin();
 
     // The child is a normal flow object.  Compute its vertical margins now.
-    child->computeBlockDirectionMargins();
+    child->computeBlockDirectionMargins(this);
 
     // Do not allow a collapse if the margin top collapse style is set to SEPARATE.
     if (child->style()->marginTopCollapse() == MSEPARATE) {
@@ -2927,7 +2927,7 @@ RenderBlock::FloatingObject* RenderBlock::insertFloatingObject(RenderBox* o)
         o->layoutIfNeeded();
     else {
         o->computeLogicalWidth();
-        o->computeBlockDirectionMargins();
+        o->computeBlockDirectionMargins(this);
     }
     newObj->m_width = o->width() + o->marginLeft() + o->marginRight();
 
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index fc8b305..b7d0856 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -201,31 +201,37 @@ void RenderBox::setMarginAfter(int margin)
 
 void RenderBox::setMarginBeforeUsing(const RenderStyle* s, int margin)
 {
-    if (s->isVerticalBlockFlow()) {
-        if (s->direction() == LTR)
-            m_marginTop = margin;
-        else
-            m_marginBottom = margin;
-    } else {
-        if (s->direction() == LTR)
-            m_marginBottom = margin;
-        else
-            m_marginTop = margin;
+    switch (s->blockFlow()) {
+    case TopToBottomBlockFlow:
+        m_marginTop = margin;
+        break;
+    case BottomToTopBlockFlow:
+        m_marginBottom = margin;
+        break;
+    case LeftToRightBlockFlow:
+        m_marginLeft = margin;
+        break;
+    case RightToLeftBlockFlow:
+        m_marginRight = margin;
+        break;
     }
 }
 
 void RenderBox::setMarginAfterUsing(const RenderStyle* s, int margin)
 {
-    if (s->isVerticalBlockFlow()) {
-        if (s->direction() == LTR)
-            m_marginBottom = margin;
-        else
-            m_marginTop = margin;
-    } else {
-        if (s->direction() == LTR)
-            m_marginTop = margin;
-        else
-            m_marginBottom = margin;
+    switch (s->blockFlow()) {
+    case TopToBottomBlockFlow:
+        m_marginBottom = margin;
+        break;
+    case BottomToTopBlockFlow:
+        m_marginTop = margin;
+        break;
+    case LeftToRightBlockFlow:
+        m_marginRight = margin;
+        break;
+    case RightToLeftBlockFlow:
+        m_marginLeft = margin;
+        break;
     }
 }
 
@@ -1521,7 +1527,7 @@ void RenderBox::computeLogicalWidth()
         setMarginStart(style()->marginStart().calcMinValue(containerLogicalWidth));
         setMarginEnd(style()->marginEnd().calcMinValue(containerLogicalWidth));
     } else
-        computeMarginsInContainingBlockInlineDirection(cb, containerLogicalWidth, logicalWidth());
+        computeInlineDirectionMargins(cb, containerLogicalWidth, logicalWidth());
 
     if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (logicalWidth() + marginStart() + marginEnd())
             && !isFloating() && !isInline() && !cb->isFlexibleBox())
@@ -1598,12 +1604,12 @@ bool RenderBox::sizesToIntrinsicLogicalWidth(LogicalWidthType widthType) const
     return false;
 }
 
-void RenderBox::computeMarginsInContainingBlockInlineDirection(RenderBlock* containingBlock, int containerWidth, int childWidth)
+void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth)
 {
-    Length marginStartLength = style()->marginStartUsing(containingBlock->style());
-    Length marginEndLength = style()->marginEndUsing(containingBlock->style());
     const RenderStyle* containingBlockStyle = containingBlock->style();
-
+    Length marginStartLength = style()->marginStartUsing(containingBlockStyle);
+    Length marginEndLength = style()->marginEndUsing(containingBlockStyle);
+    
     // Case One: The object is being centered in the containing block's available logical width.
     if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth)
         || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containingBlock->style()->textAlign() == WEBKIT_CENTER)) {
@@ -1650,12 +1656,12 @@ void RenderBox::computeLogicalHeight()
         bool hasPerpendicularContainingBlock = cb->style()->isVerticalBlockFlow() != style()->isVerticalBlockFlow();
     
         if (!hasPerpendicularContainingBlock)
-            computeBlockDirectionMargins();
+            computeBlockDirectionMargins(cb);
 
         // For tables, calculate margins only.
         if (isTable()) {
             if (hasPerpendicularContainingBlock)
-                computeMarginsInContainingBlockInlineDirection(cb, containingBlockLogicalWidthForContent(), logicalHeight());
+                computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), logicalHeight());
             return;
         }
 
@@ -1710,7 +1716,7 @@ void RenderBox::computeLogicalHeight()
         setLogicalHeight(heightResult);
         
         if (hasPerpendicularContainingBlock)
-            computeMarginsInContainingBlockInlineDirection(cb, containingBlockLogicalWidthForContent(), heightResult);
+            computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), heightResult);
     }
 
     // WinIE quirk: The <html> block always fills the entire canvas in quirks mode.  The <body> always fills the
@@ -1954,7 +1960,7 @@ int RenderBox::availableLogicalHeightUsing(const Length& h) const
     return containingBlock()->availableLogicalHeight();
 }
 
-void RenderBox::computeBlockDirectionMargins()
+void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)
 {
     if (isTableCell()) {
         // FIXME: Not right if we allow cells to have different directionality than the table.  If we do allow this, though,
@@ -1968,8 +1974,9 @@ void RenderBox::computeBlockDirectionMargins()
     // the containing block (8.3)
     int cw = containingBlockLogicalWidthForContent();
 
-    setMarginBefore(style()->marginBefore().calcMinValue(cw));
-    setMarginAfter(style()->marginAfter().calcMinValue(cw));
+    RenderStyle* containingBlockStyle = containingBlock->style();
+    setMarginBeforeUsing(containingBlockStyle, style()->marginBeforeUsing(containingBlockStyle).calcMinValue(cw));
+    setMarginAfterUsing(containingBlockStyle, style()->marginAfterUsing(containingBlockStyle).calcMinValue(cw));
 }
 
 int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 3e0e848..54c4b87 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -235,7 +235,10 @@ public:
 
     // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
     // of the containing block.
-    void computeMarginsInContainingBlockInlineDirection(RenderBlock* containingBlock, int containerWidth, int childWidth);
+    void computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth);
+
+    // Used to resolve margins in the containing block's block-flow direction.
+    void computeBlockDirectionMargins(RenderBlock* containingBlock);
 
     void positionLineBox(InlineBox*);
 
@@ -296,8 +299,6 @@ public:
     int availableWidth() const { return style()->isVerticalBlockFlow() ? availableLogicalWidth() : availableLogicalHeight(); }
     int availableHeight() const { return style()->isVerticalBlockFlow() ? availableLogicalHeight() : availableLogicalWidth(); }
 
-    void computeBlockDirectionMargins();
-
     virtual int verticalScrollbarWidth() const;
     int horizontalScrollbarHeight() const;
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
diff --git a/WebCore/rendering/RenderFlexibleBox.cpp b/WebCore/rendering/RenderFlexibleBox.cpp
index 9f07a36..e7d3fb8 100644
--- a/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/WebCore/rendering/RenderFlexibleBox.cpp
@@ -364,7 +364,7 @@ void RenderFlexibleBox::layoutHorizontalBox(bool relayoutChildren)
             }
     
             // Compute the child's vertical margins.
-            child->computeBlockDirectionMargins();
+            child->computeBlockDirectionMargins(this);
     
             if (!child->needsLayout() && paginated && view()->layoutState()->m_pageHeight) {
                 RenderBlock* childRenderBlock = child->isRenderBlock() ? toRenderBlock(child) : 0;
@@ -705,7 +705,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
             } 
     
             // Compute the child's vertical margins.
-            child->computeBlockDirectionMargins();
+            child->computeBlockDirectionMargins(this);
     
             // Add in the child's marginTop to our height.
             setHeight(height() + child->marginTop());
diff --git a/WebCore/rendering/RenderObject.h b/WebCore/rendering/RenderObject.h
index aff0348..5997ac9 100644
--- a/WebCore/rendering/RenderObject.h
+++ b/WebCore/rendering/RenderObject.h
@@ -688,7 +688,6 @@ public:
      */
     virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
 
-    virtual void computeBlockDirectionMargins() { }
     bool isTopMarginQuirk() const { return m_topMarginQuirk; }
     bool isBottomMarginQuirk() const { return m_bottomMarginQuirk; }
     void setTopMarginQuirk(bool b = true) { m_topMarginQuirk = b; }
diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp
index 66f34f4..12319f8 100644
--- a/WebCore/rendering/RenderTable.cpp
+++ b/WebCore/rendering/RenderTable.cpp
@@ -231,7 +231,7 @@ void RenderTable::computeLogicalWidth()
     // Finally, with our true width determined, compute our margins for real.
     m_marginRight = 0;
     m_marginLeft = 0;
-    computeMarginsInContainingBlockInlineDirection(cb, availableWidth, width());
+    computeInlineDirectionMargins(cb, availableWidth, width());
 }
 
 void RenderTable::layout()
diff --git a/WebCore/rendering/RenderTableRow.cpp b/WebCore/rendering/RenderTableRow.cpp
index 74baa97..d0bd511 100644
--- a/WebCore/rendering/RenderTableRow.cpp
+++ b/WebCore/rendering/RenderTableRow.cpp
@@ -126,7 +126,7 @@ void RenderTableRow::layout()
                 cell->setChildNeedsLayout(true, false);
 
             if (child->needsLayout()) {
-                cell->computeBlockDirectionMargins();
+                cell->computeBlockDirectionMargins(table());
                 cell->layout();
             }
         }
diff --git a/WebCore/rendering/style/RenderStyle.cpp b/WebCore/rendering/style/RenderStyle.cpp
index 77984f4..9227b16 100644
--- a/WebCore/rendering/style/RenderStyle.cpp
+++ b/WebCore/rendering/style/RenderStyle.cpp
@@ -1184,6 +1184,38 @@ Length RenderStyle::marginAfter() const
     return marginBottom();
 }
 
+Length RenderStyle::marginBeforeUsing(const RenderStyle* otherStyle) const
+{
+    switch (otherStyle->blockFlow()) {
+    case TopToBottomBlockFlow:
+        return marginTop();
+    case BottomToTopBlockFlow:
+        return marginBottom();
+    case LeftToRightBlockFlow:
+        return marginLeft();
+    case RightToLeftBlockFlow:
+        return marginRight();
+    }
+    ASSERT_NOT_REACHED();
+    return marginTop();
+}
+
+Length RenderStyle::marginAfterUsing(const RenderStyle* otherStyle) const
+{
+    switch (otherStyle->blockFlow()) {
+    case TopToBottomBlockFlow:
+        return marginBottom();
+    case BottomToTopBlockFlow:
+        return marginTop();
+    case LeftToRightBlockFlow:
+        return marginRight();
+    case RightToLeftBlockFlow:
+        return marginLeft();
+    }
+    ASSERT_NOT_REACHED();
+    return marginBottom();
+}
+
 Length RenderStyle::marginStart() const
 {
     if (isVerticalBlockFlow())
diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h
index 4095346..b9dc446 100644
--- a/WebCore/rendering/style/RenderStyle.h
+++ b/WebCore/rendering/style/RenderStyle.h
@@ -600,6 +600,8 @@ public:
     Length marginEnd() const;
     Length marginStartUsing(const RenderStyle* otherStyle) const;
     Length marginEndUsing(const RenderStyle* otherStyle) const;
+    Length marginBeforeUsing(const RenderStyle* otherStyle) const;
+    Length marginAfterUsing(const RenderStyle* otherStyle) const;
 
     LengthBox paddingBox() const { return surround->padding; }
     Length paddingTop() const { return surround->padding.top(); }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list