[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:48:47 UTC 2010


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

    https://bugs.webkit.org/show_bug.cgi?id=46639, make computeLogicalHeight block-flow-aware.
    
    Reviewed by Sam Weinig.
    
    This patch does the following:
        (1) Makes computeLogicalHeight block-flow-aware (patching all helper functions as needed to make this work).
        (2) Makes block flow roots (blocks whose parent has a different block-flow directionality) establish new block formatting contexts.
        (This causes them to not collapse their margins with their children and to avoid floats).
        (3) Patch all occurrences of setHeight in block and line layout to setLogicalHeight so that height doesn't get incorrectly
        overwritten for lr/rl block-flow.  This is necessary to write tests that examine the width/height of the blocks.
    
    Added multiple new tests in fast/blockflow.
    fast/css/logical-property-resolution gives the correct results now.
    
    WebCore:
    
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::MarginInfo::MarginInfo):
    (WebCore::RenderBlock::layoutBlock):
    (WebCore::RenderBlock::expandsToEncloseOverhangingFloats):
    (WebCore::RenderBlock::adjustFloatingBlock):
    (WebCore::RenderBlock::collapseMargins):
    (WebCore::RenderBlock::clearFloatsIfNeeded):
    (WebCore::RenderBlock::determineHorizontalPosition):
    (WebCore::RenderBlock::handleBottomOfBlock):
    (WebCore::RenderBlock::layoutBlockChildren):
    (WebCore::RenderBlock::layoutBlockChild):
    (WebCore::RenderBlock::positionNewFloatOnLine):
    (WebCore::RenderBlock::newLine):
    (WebCore::RenderBlock::logicalLeftOffsetForLine):
    (WebCore::RenderBlock::logicalRightOffsetForContent):
    (WebCore::RenderBlock::logicalRightOffsetForLine):
    (WebCore::RenderBlock::getClearDelta):
    (WebCore::RenderBlock::layoutColumns):
    * rendering/RenderBlock.h:
    * rendering/RenderBlockLineLayout.cpp:
    (WebCore::RenderBlock::computeBlockDirectionPositionsForLine):
    (WebCore::RenderBlock::layoutInlineChildren):
    (WebCore::RenderBlock::determineStartPosition):
    (WebCore::RenderBlock::fitBelowFloats):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::marginBefore):
    (WebCore::RenderBox::marginBeforeUsing):
    (WebCore::RenderBox::marginAfter):
    (WebCore::RenderBox::marginAfterUsing):
    (WebCore::RenderBox::setMarginBefore):
    (WebCore::RenderBox::setMarginAfter):
    (WebCore::RenderBox::setMarginBeforeUsing):
    (WebCore::RenderBox::setMarginAfterUsing):
    (WebCore::RenderBox::computeLogicalHeight):
    (WebCore::RenderBox::computeLogicalHeightUsing):
    (WebCore::RenderBox::computePercentageLogicalHeight):
    (WebCore::RenderBox::computeReplacedHeightUsing):
    (WebCore::RenderBox::availableLogicalHeight):
    (WebCore::RenderBox::availableLogicalHeightUsing):
    (WebCore::RenderBox::computeBlockDirectionMargins):
    (WebCore::RenderBox::avoidsFloats):
    * rendering/RenderBox.h:
    (WebCore::RenderBox::contentLogicalWidth):
    (WebCore::RenderBox::contentLogicalHeight):
    (WebCore::RenderBox::stretchesToViewHeight):
    (WebCore::RenderBox::availableLogicalWidth):
    (WebCore::RenderBox::availableWidth):
    (WebCore::RenderBox::availableHeight):
    (WebCore::RenderBox::isBlockFlowRoot):
    * rendering/RenderTable.cpp:
    (WebCore::RenderTable::computeLogicalWidth):
    
    LayoutTests:
    
    * fast/blockflow/auto-margins-across-boundaries-expected.txt: Added.
    * fast/blockflow/auto-margins-across-boundaries.html: Added.
    * fast/blockflow/block-formatting-context-expected.txt: Added.
    * fast/blockflow/block-formatting-context.html: Added.
    * fast/blockflow/percentage-padding.html:
    * fast/blockflow/relative-positioning-percentages-expected.txt: Added.
    * fast/blockflow/relative-positioning-percentages.html: Added.
    * fast/css/logical-property-resolution-expected.txt:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68417 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1707c88..4193f63 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,28 @@
+2010-09-27  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46639, make computeLogicalHeight block-flow-aware.
+        
+        This patch does the following:
+            (1) Makes computeLogicalHeight block-flow-aware (patching all helper functions as needed to make this work).
+            (2) Makes block flow roots (blocks whose parent has a different block-flow directionality) establish new block formatting contexts.
+            (This causes them to not collapse their margins with their children and to avoid floats). 
+            (3) Patch all occurrences of setHeight in block and line layout to setLogicalHeight so that height doesn't get incorrectly
+            overwritten for lr/rl block-flow.  This is necessary to write tests that examine the width/height of the blocks.
+        
+        Added multiple new tests in fast/blockflow.
+        fast/css/logical-property-resolution gives the correct results now.
+
+        * fast/blockflow/auto-margins-across-boundaries-expected.txt: Added.
+        * fast/blockflow/auto-margins-across-boundaries.html: Added.
+        * fast/blockflow/block-formatting-context-expected.txt: Added.
+        * fast/blockflow/block-formatting-context.html: Added.
+        * fast/blockflow/percentage-padding.html:
+        * fast/blockflow/relative-positioning-percentages-expected.txt: Added.
+        * fast/blockflow/relative-positioning-percentages.html: Added.
+        * fast/css/logical-property-resolution-expected.txt:
+
 2010-09-27  Kinuko Yasuda  <kinuko at chromium.org>
 
         Unreviewed, updating chromium test_expectations for passing tests.
diff --git a/LayoutTests/fast/blockflow/auto-margins-across-boundaries-expected.txt b/LayoutTests/fast/blockflow/auto-margins-across-boundaries-expected.txt
new file mode 100644
index 0000000..b8c2b82
--- /dev/null
+++ b/LayoutTests/fast/blockflow/auto-margins-across-boundaries-expected.txt
@@ -0,0 +1,2 @@
+The green LR block should be centered horizontally within the black-bordered block.
+PASS: The block is in the correct position.
diff --git a/LayoutTests/fast/blockflow/auto-margins-across-boundaries.html b/LayoutTests/fast/blockflow/auto-margins-across-boundaries.html
new file mode 100644
index 0000000..ac58fd6
--- /dev/null
+++ b/LayoutTests/fast/blockflow/auto-margins-across-boundaries.html
@@ -0,0 +1,26 @@
+<html>
+<head>
+<style>
+.lr { -webkit-block-flow: lr; block-flow: lr; background-color:green; margin-left:auto; margin-right:auto; width:100px; height:100px; }
+</style>
+</head>
+<body>
+The green LR block should be centered horizontally within the black-bordered block.
+<div style="width:300px; height:100px;border:2px solid black">
+<div class="lr" id="test"></div>
+</div>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+test = document.getElementById("test");
+rect = test.getBoundingClientRect();
+if (rect.left != 110) {
+  document.getElementById('console').innerHTML = "FAIL: The block should be at an x-offset of 100.";
+  test.style.backgroundColor = 'red';
+} else
+  document.getElementById('console').innerHTML = "PASS: The block is in the correct position.";
+</script>
+
+</body>
+
diff --git a/LayoutTests/fast/blockflow/block-formatting-context-expected.txt b/LayoutTests/fast/blockflow/block-formatting-context-expected.txt
new file mode 100644
index 0000000..9fdb561
--- /dev/null
+++ b/LayoutTests/fast/blockflow/block-formatting-context-expected.txt
@@ -0,0 +1,2 @@
+The green LR block should avoid the blue float.
+PASS: The floating block is in the correct position.
diff --git a/LayoutTests/fast/blockflow/block-formatting-context.html b/LayoutTests/fast/blockflow/block-formatting-context.html
new file mode 100644
index 0000000..4367180
--- /dev/null
+++ b/LayoutTests/fast/blockflow/block-formatting-context.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<style>
+.lr { -webkit-block-flow: lr; block-flow: lr; background-color:green; margin:10px; width:100px; height:100px; }
+.float { width:100px; height:100px; background-color:blue; float:left}
+body { margin: 0 }
+</style>
+</head>
+<body>
+The green LR block should avoid the blue float.
+<div class="float"></div>
+<div class="lr" id="test"></div>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+test = document.getElementById("test");
+rect = test.getBoundingClientRect();
+if (rect.left != 100) {
+  document.getElementById('console').innerHTML = "FAIL: The floating block should be at an x-offset of 100.";
+  test.style.backgroundColor = 'red';
+} else
+  document.getElementById('console').innerHTML = "PASS: The floating block is in the correct position.";
+</script>
+
+</body>
+
diff --git a/LayoutTests/fast/blockflow/percentage-padding-expected.txt b/LayoutTests/fast/blockflow/percentage-padding-expected.txt
index b4b5330..227b148 100644
--- a/LayoutTests/fast/blockflow/percentage-padding-expected.txt
+++ b/LayoutTests/fast/blockflow/percentage-padding-expected.txt
@@ -1 +1 @@
-FAIL: The floating block should be 300x400 pixels in size.
+PASS: The block is the correct size.
diff --git a/LayoutTests/fast/blockflow/percentage-padding.html b/LayoutTests/fast/blockflow/percentage-padding.html
index 7bb31dd..da8ae89 100644
--- a/LayoutTests/fast/blockflow/percentage-padding.html
+++ b/LayoutTests/fast/blockflow/percentage-padding.html
@@ -21,12 +21,12 @@ if (window.layoutTestController)
 test = document.getElementById("test");
 rect = test.getBoundingClientRect();
 width = rect.right - rect.left;
-height = rect.top - rect.bottom;
+height = rect.bottom - rect.top;
 if (width != 300 || height != 400) {
-  document.getElementById('console').innerHTML = "FAIL: The floating block should be 300x400 pixels in size.";
+  document.getElementById('console').innerHTML = "FAIL: The block should be 300x400 pixels in size.";
   test.style.backgroundColor = 'red';
 } else
-  document.getElementById('console').innerHTML = "PASS: The floating block is the correct size.";
+  document.getElementById('console').innerHTML = "PASS: The block is the correct size.";
 </script>
 </body>
 </html>
diff --git a/LayoutTests/fast/blockflow/relative-positioning-percentages-expected.txt b/LayoutTests/fast/blockflow/relative-positioning-percentages-expected.txt
new file mode 100644
index 0000000..33f2cdb
--- /dev/null
+++ b/LayoutTests/fast/blockflow/relative-positioning-percentages-expected.txt
@@ -0,0 +1,2 @@
+This is a test that relative position percentages are computed with respect to physical dimensions.
+PASS: The block is in the correct position.
diff --git a/LayoutTests/fast/blockflow/relative-positioning-percentages.html b/LayoutTests/fast/blockflow/relative-positioning-percentages.html
new file mode 100644
index 0000000..7d433d0
--- /dev/null
+++ b/LayoutTests/fast/blockflow/relative-positioning-percentages.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<style>
+.lr { -webkit-block-flow: lr; block-flow: lr; background-color:green; width:100px; height:100px; position:relative; top:50%; }
+</style>
+</head>
+<body>
+This is a test that relative position percentages are computed with respect to physical dimensions.
+<div style="width:300px; height:100px;border:2px solid black">
+<div class="lr" id="test"></div>
+</div>
+<div id="console" style="position:relative;top:100px"></div>
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+test = document.getElementById("test");
+rect = test.getBoundingClientRect();
+parentRect = test.parentNode.getBoundingClientRect();
+if (rect.top - parentRect.top != 52) {
+  document.getElementById('console').innerHTML = "FAIL: The block should be at a y-offset of 52.";
+  test.style.backgroundColor = 'red';
+} else
+  document.getElementById('console').innerHTML = "PASS: The block is in the correct position.";
+</script>
+
+</body>
+
diff --git a/LayoutTests/fast/css/logical-property-resolution-expected.txt b/LayoutTests/fast/css/logical-property-resolution-expected.txt
index 06995bc..f4b2bb0 100644
--- a/LayoutTests/fast/css/logical-property-resolution-expected.txt
+++ b/LayoutTests/fast/css/logical-property-resolution-expected.txt
@@ -6,25 +6,25 @@ Borders: 1px solid rgb(0, 0, 0), 2px dotted rgb(0, 128, 0), 3px dashed rgb(255,
 Width: 100px
 Height: 50px
 Block #2:
-Margins: 3px 2px 1px 4px
+Margins: 1px 2px 3px 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
 Height: 50px
 Block #3:
-Margins: 4px 0px 2px 0px
+Margins: 4px 3px 2px 1px
 Padding: 1px 2px 3px 4px
 Borders: 4px double rgb(128, 0, 128), 3px dashed rgb(255, 255, 0), 2px dotted rgb(0, 128, 0), 1px solid rgb(0, 0, 0)
-Width: -10px
+Width: 50px
 Height: 100px
 Block #4:
-Margins: 4px 0px 2px 0px
+Margins: 4px 1px 2px 3px
 Padding: 1px 4px 3px 2px
 Borders: 4px double rgb(128, 0, 128), 1px solid rgb(0, 0, 0), 2px dotted rgb(0, 128, 0), 3px dashed rgb(255, 255, 0)
-Width: -10px
+Width: 50px
 Height: 100px
 Block #5:
-Margins: 1px 4px 3px 2px
+Margins: 3px 4px 1px 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
@@ -36,15 +36,15 @@ Borders: 3px dashed rgb(255, 255, 0), 4px double rgb(128, 0, 128), 1px solid rgb
 Width: 100px
 Height: 50px
 Block #7:
-Margins: 2px 0px 4px 0px
+Margins: 2px 3px 4px 1px
 Padding: 3px 2px 1px 4px
 Borders: 2px dotted rgb(0, 128, 0), 3px dashed rgb(255, 255, 0), 4px double rgb(128, 0, 128), 1px solid rgb(0, 0, 0)
-Width: -10px
+Width: 50px
 Height: 100px
 Block #8:
-Margins: 2px 0px 4px 0px
+Margins: 2px 1px 4px 3px
 Padding: 3px 4px 1px 2px
 Borders: 2px dotted rgb(0, 128, 0), 1px solid rgb(0, 0, 0), 4px double rgb(128, 0, 128), 3px dashed rgb(255, 255, 0)
-Width: -10px
+Width: 50px
 Height: 100px
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9272758..a6e0ce1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,71 @@
+2010-09-27  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46639, make computeLogicalHeight block-flow-aware.
+        
+        This patch does the following:
+            (1) Makes computeLogicalHeight block-flow-aware (patching all helper functions as needed to make this work).
+            (2) Makes block flow roots (blocks whose parent has a different block-flow directionality) establish new block formatting contexts.
+            (This causes them to not collapse their margins with their children and to avoid floats). 
+            (3) Patch all occurrences of setHeight in block and line layout to setLogicalHeight so that height doesn't get incorrectly
+            overwritten for lr/rl block-flow.  This is necessary to write tests that examine the width/height of the blocks.
+        
+        Added multiple new tests in fast/blockflow.
+        fast/css/logical-property-resolution gives the correct results now.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::MarginInfo::MarginInfo):
+        (WebCore::RenderBlock::layoutBlock):
+        (WebCore::RenderBlock::expandsToEncloseOverhangingFloats):
+        (WebCore::RenderBlock::adjustFloatingBlock):
+        (WebCore::RenderBlock::collapseMargins):
+        (WebCore::RenderBlock::clearFloatsIfNeeded):
+        (WebCore::RenderBlock::determineHorizontalPosition):
+        (WebCore::RenderBlock::handleBottomOfBlock):
+        (WebCore::RenderBlock::layoutBlockChildren):
+        (WebCore::RenderBlock::layoutBlockChild):
+        (WebCore::RenderBlock::positionNewFloatOnLine):
+        (WebCore::RenderBlock::newLine):
+        (WebCore::RenderBlock::logicalLeftOffsetForLine):
+        (WebCore::RenderBlock::logicalRightOffsetForContent):
+        (WebCore::RenderBlock::logicalRightOffsetForLine):
+        (WebCore::RenderBlock::getClearDelta):
+        (WebCore::RenderBlock::layoutColumns):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::computeBlockDirectionPositionsForLine):
+        (WebCore::RenderBlock::layoutInlineChildren):
+        (WebCore::RenderBlock::determineStartPosition):
+        (WebCore::RenderBlock::fitBelowFloats):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::marginBefore):
+        (WebCore::RenderBox::marginBeforeUsing):
+        (WebCore::RenderBox::marginAfter):
+        (WebCore::RenderBox::marginAfterUsing):
+        (WebCore::RenderBox::setMarginBefore):
+        (WebCore::RenderBox::setMarginAfter):
+        (WebCore::RenderBox::setMarginBeforeUsing):
+        (WebCore::RenderBox::setMarginAfterUsing):
+        (WebCore::RenderBox::computeLogicalHeight):
+        (WebCore::RenderBox::computeLogicalHeightUsing):
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        (WebCore::RenderBox::computeReplacedHeightUsing):
+        (WebCore::RenderBox::availableLogicalHeight):
+        (WebCore::RenderBox::availableLogicalHeightUsing):
+        (WebCore::RenderBox::computeBlockDirectionMargins):
+        (WebCore::RenderBox::avoidsFloats):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::contentLogicalWidth):
+        (WebCore::RenderBox::contentLogicalHeight):
+        (WebCore::RenderBox::stretchesToViewHeight):
+        (WebCore::RenderBox::availableLogicalWidth):
+        (WebCore::RenderBox::availableWidth):
+        (WebCore::RenderBox::availableHeight):
+        (WebCore::RenderBox::isBlockFlowRoot):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::computeLogicalWidth):
+
 2010-09-27  Mario Sanchez Prada  <msanchez at igalia.com>
 
         Reviewed by Chris Fleizach.
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 1ca881b..bc20b47 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -83,8 +83,9 @@ RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, int top, int bottom)
     // Whether or not we can collapse our own margins with our children.  We don't do this
     // if we had any border/padding (obviously), if we're the root or HTML elements, or if
     // we're positioned, floating, a table cell.
-    m_canCollapseWithChildren = !block->isRenderView() && !block->isRoot() && !block->isPositioned() &&
-        !block->isFloating() && !block->isTableCell() && !block->hasOverflowClip() && !block->isInlineBlockOrInlineTable();
+    m_canCollapseWithChildren = !block->isRenderView() && !block->isRoot() && !block->isPositioned()
+        && !block->isFloating() && !block->isTableCell() && !block->hasOverflowClip() && !block->isInlineBlockOrInlineTable()
+        && !block->isBlockFlowRoot();
 
     m_canCollapseTopWithChildren = m_canCollapseWithChildren && (top == 0) && block->style()->marginTopCollapse() != MSEPARATE;
 
@@ -1134,7 +1135,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, int pageHeight)
     clearFloats();
 
     int previousHeight = height();
-    setHeight(0);
+    setLogicalHeight(0);
     bool hasSpecifiedPageHeight = false;
     ColumnInfo* colInfo = columnInfo();
     if (hasColumns()) {
@@ -1147,7 +1148,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, int pageHeight)
                 pageHeight = columnHeight;
                 hasSpecifiedPageHeight = true;
             }
-            setHeight(0);
+            setLogicalHeight(0);
         }
         if (colInfo->columnHeight() != pageHeight && m_everHadLayout) {
             colInfo->setColumnHeight(pageHeight);
@@ -1208,7 +1209,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, int pageHeight)
     // Expand our intrinsic height to encompass floats.
     int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight();
     if (floatBottom() > (height() - toAdd) && expandsToEncloseOverhangingFloats())
-        setHeight(floatBottom() + toAdd);
+        setLogicalHeight(floatBottom() + toAdd);
     
     if (layoutColumns(hasSpecifiedPageHeight, pageHeight, statePusher))
         return;
@@ -1315,7 +1316,8 @@ void RenderBlock::addOverflowFromFloats()
 
 bool RenderBlock::expandsToEncloseOverhangingFloats() const
 {
-    return isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBox()) || hasColumns() || isTableCell() || isFieldset();
+    return isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBox())
+           || hasColumns() || isTableCell() || isFieldset() || isBlockFlowRoot();
 }
 
 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marginInfo)
@@ -1367,9 +1369,9 @@ void RenderBlock::adjustFloatingBlock(const MarginInfo& marginInfo)
     // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html for
     // an example of this scenario.
     int marginOffset = marginInfo.canCollapseWithTop() ? 0 : marginInfo.margin();
-    setHeight(height() + marginOffset);
+    setLogicalHeight(height() + marginOffset);
     positionNewFloats();
-    setHeight(height() - marginOffset);
+    setLogicalHeight(height() - marginOffset);
 }
 
 bool RenderBlock::handleSpecialChild(RenderBox* child, const MarginInfo& marginInfo)
@@ -1529,7 +1531,7 @@ int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
     }
     else {
         if (child->style()->marginTopCollapse() == MSEPARATE) {
-            setHeight(height() + marginInfo.margin() + child->marginTop());
+            setLogicalHeight(height() + marginInfo.margin() + child->marginTop());
             ypos = height();
         }
         else if (!marginInfo.atTopOfBlock() ||
@@ -1537,7 +1539,7 @@ int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
              && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.topQuirk()))) {
             // We're collapsing with a previous sibling's margins and not
             // with the top of the block.
-            setHeight(height() + max(marginInfo.posMargin(), posTop) - max(marginInfo.negMargin(), negTop));
+            setLogicalHeight(height() + max(marginInfo.posMargin(), posTop) - max(marginInfo.negMargin(), negTop));
             ypos = height();
         }
 
@@ -1554,7 +1556,7 @@ int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
     if (paginated && ypos > beforeCollapseY) {
         int oldY = ypos;
         ypos = min(ypos, nextPageTop(beforeCollapseY));
-        setHeight(height() + (ypos - oldY));
+        setLogicalHeight(height() + (ypos - oldY));
     }
     return ypos;
 }
@@ -1588,10 +1590,10 @@ int RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& marginInfo, i
         
         // Adjust our height such that we are ready to be collapsed with subsequent siblings (or the bottom
         // of the parent block).
-        setHeight(child->y() - max(0, marginInfo.margin()));
+        setLogicalHeight(child->y() - max(0, marginInfo.margin()));
     } else
         // Increase our height by the amount we had to clear.
-        setHeight(height() + heightIncrease);
+        setLogicalHeight(height() + heightIncrease);
     
     if (marginInfo.canCollapseWithTop()) {
         // We can no longer collapse with the top of the block since a clear
@@ -1668,7 +1670,7 @@ void RenderBlock::determineHorizontalPosition(RenderBox* child)
         view()->addLayoutDelta(IntSize(child->x() - chPos, 0));
         child->setLocation(chPos, child->y());
     } else {
-        xPos += availableWidth();
+        xPos += availableLogicalWidth();
         int chPos = xPos - (child->width() + child->marginRight());
         if (child->avoidsFloats()) {
             int rightOff = logicalRightOffsetForLine(height(), false);
@@ -1716,14 +1718,14 @@ void RenderBlock::handleBottomOfBlock(int top, int bottom, MarginInfo& marginInf
     // If we can't collapse with children then go ahead and add in the bottom margin.
     if (!marginInfo.canCollapseWithBottom() && !marginInfo.canCollapseWithTop()
         && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.bottomQuirk()))
-        setHeight(height() + marginInfo.margin());
+        setLogicalHeight(height() + marginInfo.margin());
         
     // Now add in our bottom border/padding.
-    setHeight(height() + bottom);
+    setLogicalHeight(height() + bottom);
 
     // Negative margins can cause our height to shrink below our minimal height (border/padding).
     // If this happens, ensure that the computed height is increased to the minimal height.
-    setHeight(max(height(), top + bottom));
+    setLogicalHeight(max(height(), top + bottom));
 
     // Update our bottom collapsed margin info.
     setCollapsedBottomMargin(marginInfo);
@@ -1752,7 +1754,7 @@ void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom
     int top = borderTop() + paddingTop();
     int bottom = borderBottom() + paddingBottom() + horizontalScrollbarHeight();
 
-    setHeight(top);
+    setLogicalHeight(top);
 
     // The margin struct caches all our current margin collapsing state.  The compact struct caches state when we encounter compacts,
     MarginInfo marginInfo(this, top, bottom);
@@ -1894,7 +1896,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
         }
 
         // Similar to how we apply clearance.  Go ahead and boost height() to be the place where we're going to position the child.
-        setHeight(height() + (yAfterClear - oldY));
+        setLogicalHeight(height() + (yAfterClear - oldY));
     }
 
     view()->addLayoutDelta(IntSize(0, yPosEstimate - yAfterClear));
@@ -1929,9 +1931,9 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
     determineHorizontalPosition(child);
 
     // Update our height now that the child has been placed in the correct position.
-    setHeight(height() + child->height());
+    setLogicalHeight(height() + child->height());
     if (child->style()->marginBottomCollapse() == MSEPARATE) {
-        setHeight(height() + child->marginBottom());
+        setLogicalHeight(height() + child->marginBottom());
         marginInfo.clearMargin();
     }
     // If the child has overhanging floats that intrude into following siblings (or possibly out
@@ -1959,7 +1961,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
         // Check for an after page/column break.
         int newHeight = applyAfterBreak(child, height(), marginInfo);
         if (newHeight != height())
-            setHeight(newHeight);
+            setLogicalHeight(newHeight);
     }
 
     ASSERT(oldLayoutDelta == view()->layoutDelta());
@@ -3114,7 +3116,7 @@ bool RenderBlock::positionNewFloatOnLine(FloatingObject* newFloat, FloatingObjec
         }
     }
         
-    setHeight(height() + paginationStrut);
+    setLogicalHeight(height() + paginationStrut);
     
     return didPosition;
 }
@@ -3138,7 +3140,7 @@ void RenderBlock::newLine(EClear clear)
             break;
     }
     if (height() < newY)
-        setHeight(newY);
+        setLogicalHeight(newY);
 }
 
 void RenderBlock::addPercentHeightDescendant(RenderBox* descendant)
@@ -3227,7 +3229,7 @@ int RenderBlock::logicalLeftOffsetForLine(int y, int fixedOffset, bool applyText
     if (applyTextIndent && style()->direction() == LTR) {
         int cw = 0;
         if (style()->textIndent().isPercent())
-            cw = containingBlock()->availableWidth();
+            cw = containingBlock()->availableLogicalWidth();
         left += style()->textIndent().calcMinValue(cw);
     }
 
@@ -3236,7 +3238,7 @@ int RenderBlock::logicalLeftOffsetForLine(int y, int fixedOffset, bool applyText
 
 int RenderBlock::logicalRightOffsetForContent() const
 {
-    return borderLeft() + paddingLeft() + availableWidth();
+    return borderLeft() + paddingLeft() + availableLogicalWidth();
 }
 
 int RenderBlock::logicalRightOffsetForLine(int y, int fixedOffset, bool applyTextIndent, int* heightRemaining) const
@@ -3261,7 +3263,7 @@ int RenderBlock::logicalRightOffsetForLine(int y, int fixedOffset, bool applyTex
     if (applyTextIndent && style()->direction() == RTL) {
         int cw = 0;
         if (style()->textIndent().isPercent())
-            cw = containingBlock()->availableWidth();
+            cw = containingBlock()->availableLogicalWidth();
         right -= style()->textIndent().calcMinValue(cw);
     }
     
@@ -3932,7 +3934,7 @@ int RenderBlock::getClearDelta(RenderBox* child, int yPos)
     // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default).
     int result = clearSet ? max(0, bottom - yPos) : 0;
     if (!result && child->avoidsFloats()) {
-        int availableWidth = this->availableWidth();
+        int availableWidth = availableLogicalWidth();
         if (child->minPreferredLogicalWidth() > availableWidth)
             return 0;
 
@@ -4297,14 +4299,6 @@ void RenderBlock::offsetForContents(int& tx, int& ty) const
     ty = contentsPoint.y();
 }
 
-int RenderBlock::availableWidth() const
-{
-    // If we have multiple columns, then the available width is reduced to our column width.
-    if (hasColumns())
-        return desiredColumnWidth();
-    return RenderBox::availableWidth();
-}
-
 int RenderBlock::availableLogicalWidth() const
 {
     // If we have multiple columns, then the available logical width is reduced to our column width.
@@ -4478,7 +4472,7 @@ bool RenderBlock::layoutColumns(bool hasSpecifiedPageHeight, int pageHeight, Lay
             int overflowRight = style()->direction() == LTR ? max(width(), lastRect.x() + lastRect.width()) : 0;
             int overflowHeight = borderTop() + paddingTop() + colInfo->columnHeight();
             
-            setHeight(overflowHeight + borderBottom() + paddingBottom() + horizontalScrollbarHeight());
+            setLogicalHeight(overflowHeight + borderBottom() + paddingBottom() + horizontalScrollbarHeight());
 
             m_overflow.clear();
             addLayoutOverflow(IntRect(overflowLeft, 0, overflowRight - overflowLeft, overflowHeight));
diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h
index 87cae1d..2b4123c 100644
--- a/WebCore/rendering/RenderBlock.h
+++ b/WebCore/rendering/RenderBlock.h
@@ -113,7 +113,6 @@ public:
     virtual VisiblePosition positionForPoint(const IntPoint&);
     
     // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
-    virtual int availableWidth() const; // FIXME: Should be possible to remove this. See https://bugs.webkit.org/show_bug.cgi?id=46127
     virtual int availableLogicalWidth() const;
 
     RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp
index 81788db..30b0cac 100644
--- a/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -490,7 +490,7 @@ void RenderBlock::computeInlineDirectionPositionsForLine(RootInlineBox* lineBox,
 
 void RenderBlock::computeBlockDirectionPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap)
 {
-    setHeight(lineBox->alignBoxesInBlockDirection(height(), textBoxDataMap));
+    setLogicalHeight(lineBox->alignBoxesInBlockDirection(height(), textBoxDataMap));
     lineBox->setBlockHeight(height());
 
     // Now make sure we place replaced render objects correctly.
@@ -533,7 +533,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
     
     m_overflow.clear();
         
-    setHeight(borderTop() + paddingTop());
+    setLogicalHeight(borderTop() + paddingTop());
     int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight();
 
     // Figure out if we should clear out our line boxes.
@@ -811,13 +811,13 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
                                 // We have to delete this line, remove all floats that got added, and let line layout re-run.
                                 lineBox->deleteLine(renderArena());
                                 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldHeight);
-                                setHeight(oldHeight + adjustment);
+                                setLogicalHeight(oldHeight + adjustment);
                                 resolver.setPosition(oldEnd);
                                 end = oldEnd;
                                 continue;
                             }
 
-                            setHeight(lineBox->blockHeight());
+                            setLogicalHeight(lineBox->blockHeight());
                         }
                     }
                 }
@@ -868,12 +868,12 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
                         for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
                             int floatTop = (*f)->y() - (*f)->marginTop();
                             insertFloatingObject(*f);
-                            setHeight(floatTop + delta);
+                            setLogicalHeight(floatTop + delta);
                             positionNewFloats();
                         }
                     }
                 }
-                setHeight(lastRootBox()->blockHeight());
+                setLogicalHeight(lastRootBox()->blockHeight());
             } else {
                 // Delete all the remaining lines.
                 RootInlineBox* line = endLine;
@@ -926,10 +926,10 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
     }
 
     // Now add in the bottom border/padding.
-    setHeight(height() + toAdd);
+    setLogicalHeight(height() + toAdd);
 
     if (!firstLineBox() && hasLineIfEmpty())
-        setHeight(height() + lineHeight(true, true));
+        setLogicalHeight(height() + lineHeight(true, true));
 
     // See if we have any lines that spill out of our block.  If we do, then we will possibly need to
     // truncate text.
@@ -1044,7 +1044,7 @@ RootInlineBox* RenderBlock::determineStartPosition(bool& firstLine, bool& fullLa
                 Vector<RenderBox*>::iterator end = cleanLineFloats->end();
                 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
                     insertFloatingObject(*f);
-                    setHeight((*f)->y() - (*f)->marginTop());
+                    setLogicalHeight((*f)->y() - (*f)->marginTop());
                     positionNewFloats();
                     ASSERT(floats[numCleanFloats].object == *f);
                     numCleanFloats++;
@@ -1052,7 +1052,7 @@ RootInlineBox* RenderBlock::determineStartPosition(bool& firstLine, bool& fullLa
             }
             line = line->nextRootBox();
         }
-        setHeight(savedHeight);
+        setLogicalHeight(savedHeight);
     }
 
     firstLine = !last;
@@ -1061,7 +1061,7 @@ RootInlineBox* RenderBlock::determineStartPosition(bool& firstLine, bool& fullLa
     RenderObject* startObj;
     int pos = 0;
     if (last) {
-        setHeight(last->blockHeight());
+        setLogicalHeight(last->blockHeight());
         startObj = last->lineBreakObj();
         pos = last->lineBreakPos();
         resolver.setStatus(last->lineBreakBidiStatus());
@@ -1372,7 +1372,7 @@ void RenderBlock::fitBelowFloats(int widthToFit, bool firstLine, int& availableW
     }
 
     if (newLineWidth > availableWidth) {
-        setHeight(lastFloatBottom);
+        setLogicalHeight(lastFloatBottom);
         availableWidth = newLineWidth;
     }
 }
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index 00398f7..14d0270 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -111,7 +111,12 @@ void RenderBox::setLogicalHeight(int size)
 
 int RenderBox::marginBefore() const
 {
-    switch (style()->blockFlow()) {
+    return marginBeforeUsing(style());
+}
+
+int RenderBox::marginBeforeUsing(const RenderStyle* s) const
+{
+    switch (s->blockFlow()) {
     case TopToBottomBlockFlow:
         return m_marginTop;
     case BottomToTopBlockFlow:
@@ -127,7 +132,12 @@ int RenderBox::marginBefore() const
 
 int RenderBox::marginAfter() const
 {
-    switch (style()->blockFlow()) {
+    return marginAfterUsing(style());
+}
+
+int RenderBox::marginAfterUsing(const RenderStyle* s) const
+{
+    switch (s->blockFlow()) {
     case TopToBottomBlockFlow:
         return m_marginBottom;
     case BottomToTopBlockFlow:
@@ -205,6 +215,46 @@ void RenderBox::setMarginEndUsing(const RenderStyle* s, int margin)
     }
 }
 
+void RenderBox::setMarginBefore(int margin)
+{
+    setMarginBeforeUsing(style(), margin);
+}
+
+void RenderBox::setMarginAfter(int margin)
+{
+    setMarginAfterUsing(style(), 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;
+    }
+}
+
+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;
+    }
+}
+
 void RenderBox::destroy()
 {
     // A lot of the code in this function is just pasted into
@@ -1617,15 +1667,26 @@ void RenderBox::computeLogicalHeight()
         return;
 
     Length h;
-    if (isPositioned())
+    if (isPositioned()) {
+        // FIXME: This calculation is not patched for block-flow yet.
+        // https://bugs.webkit.org/show_bug.cgi?id=46500
         computePositionedLogicalHeight();
-    else {
-        computeBlockDirectionMargins();
+    } else {
+        RenderBlock* cb = containingBlock();
+        bool hasPerpendicularContainingBlock = cb->style()->isVerticalBlockFlow() != style()->isVerticalBlockFlow();
+    
+        if (!hasPerpendicularContainingBlock)
+            computeBlockDirectionMargins();
 
         // For tables, calculate margins only.
-        if (isTable())
+        if (isTable()) {
+            if (hasPerpendicularContainingBlock)
+                computeMarginsInContainingBlockInlineDirection(cb, containingBlockLogicalWidthForContent(), logicalHeight());
             return;
+        }
 
+        // FIXME: Account for block-flow in flexible boxes.
+        // https://bugs.webkit.org/show_bug.cgi?id=46418
         bool inHorizontalBox = parent()->isFlexibleBox() && parent()->style()->boxOrient() == HORIZONTAL;
         bool stretching = parent()->style()->boxAlign() == BSTRETCH;
         bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBox || !stretching);
@@ -1633,30 +1694,34 @@ void RenderBox::computeLogicalHeight()
 
         // The parent box is flexing us, so it has increased or decreased our height.  We have to
         // grab our cached flexible height.
+        // FIXME: Account for block-flow in flexible boxes.
+        // https://bugs.webkit.org/show_bug.cgi?id=46418
         if (hasOverrideSize() && parent()->isFlexibleBox() && parent()->style()->boxOrient() == VERTICAL
                 && parent()->isFlexingChildren())
-            h = Length(overrideSize() - borderAndPaddingHeight(), Fixed);
+            h = Length(overrideSize() - borderAndPaddingLogicalHeight(), Fixed);
         else if (treatAsReplaced)
             h = Length(computeReplacedHeight(), Fixed);
         else {
-            h = style()->height();
+            h = style()->logicalHeight();
             checkMinMaxHeight = true;
         }
 
         // Block children of horizontal flexible boxes fill the height of the box.
+        // FIXME: Account for block-flow in flexible boxes.
+        // https://bugs.webkit.org/show_bug.cgi?id=46418
         if (h.isAuto() && parent()->isFlexibleBox() && parent()->style()->boxOrient() == HORIZONTAL
                 && parent()->isStretchingChildren()) {
-            h = Length(parentBox()->contentHeight() - marginTop() - marginBottom() - borderAndPaddingHeight(), Fixed);
+            h = Length(parentBox()->contentLogicalHeight() - marginBefore() - marginAfter() - borderAndPaddingLogicalHeight(), Fixed);
             checkMinMaxHeight = false;
         }
 
         int heightResult;
         if (checkMinMaxHeight) {
-            heightResult = computeLogicalHeightUsing(style()->height());
+            heightResult = computeLogicalHeightUsing(style()->logicalHeight());
             if (heightResult == -1)
-                heightResult = height();
-            int minH = computeLogicalHeightUsing(style()->minHeight()); // Leave as -1 if unset.
-            int maxH = style()->maxHeight().isUndefined() ? heightResult : computeLogicalHeightUsing(style()->maxHeight());
+                heightResult = logicalHeight();
+            int minH = computeLogicalHeightUsing(style()->logicalMinHeight()); // Leave as -1 if unset.
+            int maxH = style()->logicalMaxHeight().isUndefined() ? heightResult : computeLogicalHeightUsing(style()->logicalMaxHeight());
             if (maxH == -1)
                 maxH = heightResult;
             heightResult = min(maxH, heightResult);
@@ -1665,10 +1730,13 @@ void RenderBox::computeLogicalHeight()
             // The only times we don't check min/max height are when a fixed length has
             // been given as an override.  Just use that.  The value has already been adjusted
             // for box-sizing.
-            heightResult = h.value() + borderAndPaddingHeight();
+            heightResult = h.value() + borderAndPaddingLogicalHeight();
         }
 
-        setHeight(heightResult);
+        setLogicalHeight(heightResult);
+        
+        if (hasPerpendicularContainingBlock)
+            computeMarginsInContainingBlockInlineDirection(cb, containingBlockLogicalWidthForContent(), heightResult);
     }
 
     // WinIE quirk: The <html> block always fills the entire canvas in quirks mode.  The <body> always fills the
@@ -1677,33 +1745,43 @@ void RenderBox::computeLogicalHeight()
     // height since we don't set a height in RenderView when we're printing. So without this quirk, the 
     // height has nothing to be a percentage of, and it ends up being 0. That is bad.
     bool paginatedContentNeedsBaseHeight = document()->printing() && h.isPercent()
-        && (isRoot() || (isBody() && document()->documentElement()->renderer()->style()->height().isPercent()));
+        && (isRoot() || (isBody() && document()->documentElement()->renderer()->style()->logicalHeight().isPercent()));
     if (stretchesToViewHeight() || paginatedContentNeedsBaseHeight) {
+        // FIXME: Finish accounting for block flow here.
+        // https://bugs.webkit.org/show_bug.cgi?id=46603
         int margins = collapsedMarginTop() + collapsedMarginBottom();
-        int visHeight = document()->printing() ? static_cast<int>(view()->pageHeight()) : view()->viewHeight();
+        int visHeight;
+        if (document()->printing())
+            visHeight = static_cast<int>(view()->pageHeight());
+        else  {
+            if (style()->isVerticalBlockFlow())
+                visHeight = view()->viewHeight();
+            else
+                visHeight = view()->viewWidth();
+        }
         if (isRoot())
-            setHeight(max(height(), visHeight - margins));
+            setLogicalHeight(max(logicalHeight(), visHeight - margins));
         else {
-            int marginsBordersPadding = margins + parentBox()->marginTop() + parentBox()->marginBottom() + parentBox()->borderAndPaddingHeight();
-            setHeight(max(height(), visHeight - marginsBordersPadding));
+            int marginsBordersPadding = margins + parentBox()->marginBefore() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight();
+            setLogicalHeight(max(logicalHeight(), visHeight - marginsBordersPadding));
         }
     }
 }
 
 int RenderBox::computeLogicalHeightUsing(const Length& h)
 {
-    int height = -1;
+    int logicalHeight = -1;
     if (!h.isAuto()) {
         if (h.isFixed())
-            height = h.value();
+            logicalHeight = h.value();
         else if (h.isPercent())
-            height = computePercentageLogicalHeight(h);
-        if (height != -1) {
-            height = computeBorderBoxLogicalHeight(height);
-            return height;
+            logicalHeight = computePercentageLogicalHeight(h);
+        if (logicalHeight != -1) {
+            logicalHeight = computeBorderBoxLogicalHeight(logicalHeight);
+            return logicalHeight;
         }
     }
-    return height;
+    return logicalHeight;
 }
 
 int RenderBox::computePercentageLogicalHeight(const Length& height)
@@ -1716,7 +1794,7 @@ int RenderBox::computePercentageLogicalHeight(const Length& height)
         // block that may have a specified height and then use it.  In strict mode, this violates the
         // specification, which states that percentage heights just revert to auto if the containing
         // block has an auto height.
-        while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->isPositioned() && cb->style()->height().isAuto()) {
+        while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->isPositioned() && cb->style()->logicalHeight().isAuto()) {
             skippedAutoHeightContainingBlock = true;
             cb = cb->containingBlock();
             cb->addPercentHeightDescendant(this);
@@ -1725,7 +1803,9 @@ int RenderBox::computePercentageLogicalHeight(const Length& height)
 
     // A positioned element that specified both top/bottom or that specifies height should be treated as though it has a height
     // explicitly specified that can be used for any percentage computations.
-    bool isPositionedWithSpecifiedHeight = cb->isPositioned() && (!cb->style()->height().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto()));
+    // FIXME: We can't just check top/bottom here.
+    // https://bugs.webkit.org/show_bug.cgi?id=46500
+    bool isPositionedWithSpecifiedHeight = cb->isPositioned() && (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto()));
 
     bool includeBorderPadding = isTable();
 
@@ -1744,7 +1824,7 @@ int RenderBox::computePercentageLogicalHeight(const Length& height)
                 // to grow to fill the space.  This could end up being wrong in some cases, but it is
                 // preferable to the alternative (sizing intrinsically and making the row end up too big).
                 RenderTableCell* cell = toRenderTableCell(cb);
-                if (scrollsOverflowY() && (!cell->style()->height().isAuto() || !cell->table()->style()->height().isAuto()))
+                if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAuto() || !cell->table()->style()->logicalHeight().isAuto()))
                     return 0;
                 return -1;
             }
@@ -1753,24 +1833,24 @@ int RenderBox::computePercentageLogicalHeight(const Length& height)
     }
     // Otherwise we only use our percentage height if our containing block had a specified
     // height.
-    else if (cb->style()->height().isFixed())
-        result = cb->computeContentBoxLogicalHeight(cb->style()->height().value());
-    else if (cb->style()->height().isPercent() && !isPositionedWithSpecifiedHeight) {
+    else if (cb->style()->logicalHeight().isFixed())
+        result = cb->computeContentBoxLogicalHeight(cb->style()->logicalHeight().value());
+    else if (cb->style()->logicalHeight().isPercent() && !isPositionedWithSpecifiedHeight) {
         // We need to recur and compute the percentage height for our containing block.
-        result = cb->computePercentageLogicalHeight(cb->style()->height());
+        result = cb->computePercentageLogicalHeight(cb->style()->logicalHeight());
         if (result != -1)
             result = cb->computeContentBoxLogicalHeight(result);
     } else if (cb->isRenderView() || (cb->isBody() && document()->inQuirksMode()) || isPositionedWithSpecifiedHeight) {
         // Don't allow this to affect the block' height() member variable, since this
         // can get called while the block is still laying out its kids.
-        int oldHeight = cb->height();
+        int oldHeight = cb->logicalHeight();
         cb->computeLogicalHeight();
-        result = cb->contentHeight();
-        cb->setHeight(oldHeight);
+        result = cb->contentLogicalHeight();
+        cb->setLogicalHeight(oldHeight);
     } else if (cb->isRoot() && isPositioned())
         // Match the positioned objects behavior, which is that positioned objects will fill their viewport
         // always.  Note we could only hit this case by recurring into computePercentageLogicalHeight on a positioned containing block.
-        result = cb->computeContentBoxLogicalHeight(cb->availableHeight());
+        result = cb->computeContentBoxLogicalHeight(cb->availableLogicalHeight());
 
     if (result != -1) {
         result = height.calcValue(result);
@@ -1778,7 +1858,7 @@ int RenderBox::computePercentageLogicalHeight(const Length& height)
             // It is necessary to use the border-box to match WinIE's broken
             // box model.  This is essential for sizing inside
             // table cells using percentage heights.
-            result -= borderAndPaddingHeight();
+            result -= borderAndPaddingLogicalHeight();
             result = max(0, result);
         }
     }
@@ -1845,7 +1925,7 @@ int RenderBox::computeReplacedHeightUsing(Length height) const
                 return computeContentBoxLogicalHeight(height.calcValue(newHeight));
             }
             
-            int availableHeight = isPositioned() ? containingBlockHeightForPositioned(toRenderBoxModelObject(cb)) : toRenderBox(cb)->availableHeight();
+            int availableHeight = isPositioned() ? containingBlockHeightForPositioned(toRenderBoxModelObject(cb)) : toRenderBox(cb)->availableLogicalHeight();
 
             // It is necessary to use the border-box to match WinIE's broken
             // box model.  This is essential for sizing inside
@@ -1864,61 +1944,58 @@ int RenderBox::computeReplacedHeightUsing(Length height) const
     }
 }
 
-int RenderBox::availableHeight() const
+int RenderBox::availableLogicalHeight() const
 {
-    return availableHeightUsing(style()->height());
+    return availableLogicalHeightUsing(style()->logicalHeight());
 }
 
-int RenderBox::availableHeightUsing(const Length& h) const
+int RenderBox::availableLogicalHeightUsing(const Length& h) const
 {
     if (h.isFixed())
         return computeContentBoxLogicalHeight(h.value());
 
     if (isRenderView())
-        return toRenderView(this)->frameView()->visibleHeight();
+        return style()->isVerticalBlockFlow() ? toRenderView(this)->frameView()->visibleHeight() : toRenderView(this)->frameView()->visibleWidth();
 
     // We need to stop here, since we don't want to increase the height of the table
     // artificially.  We're going to rely on this cell getting expanded to some new
     // height, and then when we lay out again we'll use the calculation below.
     if (isTableCell() && (h.isAuto() || h.isPercent()))
-        return overrideSize() - borderAndPaddingWidth();
+        return overrideSize() - borderAndPaddingLogicalWidth();
 
     if (h.isPercent())
-       return computeContentBoxLogicalHeight(h.calcValue(containingBlock()->availableHeight()));
+       return computeContentBoxLogicalHeight(h.calcValue(containingBlock()->availableLogicalHeight()));
 
+    // FIXME: We can't just check top/bottom here.
+    // https://bugs.webkit.org/show_bug.cgi?id=46500
     if (isRenderBlock() && isPositioned() && style()->height().isAuto() && !(style()->top().isAuto() || style()->bottom().isAuto())) {
         RenderBlock* block = const_cast<RenderBlock*>(toRenderBlock(this));
-        int oldHeight = block->height();
+        int oldHeight = block->logicalHeight();
         block->computeLogicalHeight();
-        int newHeight = block->computeContentBoxLogicalHeight(block->contentHeight());
-        block->setHeight(oldHeight);
+        int newHeight = block->computeContentBoxLogicalHeight(block->contentLogicalHeight());
+        block->setLogicalHeight(oldHeight);
         return computeContentBoxLogicalHeight(newHeight);
     }
 
-    return containingBlock()->availableHeight();
-}
-
-int RenderBox::availableLogicalWidth() const
-{
-    if (style()->isVerticalBlockFlow())
-        return contentWidth();
-    return contentHeight();
+    return containingBlock()->availableLogicalHeight();
 }
 
 void RenderBox::computeBlockDirectionMargins()
 {
     if (isTableCell()) {
-        m_marginTop = 0;
-        m_marginBottom = 0;
+        // 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);
         return;
     }
 
-    // margins are calculated with respect to the _width_ of
+    // Margins are calculated with respect to the logical width of
     // the containing block (8.3)
-    int cw = containingBlock()->contentWidth();
+    int cw = containingBlockLogicalWidthForContent();
 
-    m_marginTop = style()->marginTop().calcMinValue(cw);
-    m_marginBottom = style()->marginBottom().calcMinValue(cw);
+    setMarginBefore(style()->marginBefore().calcMinValue(cw));
+    setMarginAfter(style()->marginAfter().calcMinValue(cw));
 }
 
 int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const
@@ -3008,7 +3085,7 @@ bool RenderBox::shrinkToAvoidFloats() const
 
 bool RenderBox::avoidsFloats() const
 {
-    return isReplaced() || hasOverflowClip() || isHR();
+    return isReplaced() || hasOverflowClip() || isHR() || isBlockFlowRoot();
 }
 
 void RenderBox::addShadowOverflow()
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 91fbab9..10d9b45 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -115,6 +115,8 @@ public:
 
     int contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
     int contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
+    int contentLogicalWidth() const { return style()->isVerticalBlockFlow() ? contentWidth() : contentHeight(); }
+    int contentLogicalHeight() const { return style()->isVerticalBlockFlow() ? contentHeight() : contentWidth(); }
 
     // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
     // to return the remaining width on a given line (and the height of a single line).
@@ -150,6 +152,8 @@ public:
     virtual int marginEnd() const;
     void setMarginStart(int);
     void setMarginEnd(int);
+    void setMarginBefore(int);
+    void setMarginAfter(int);
 
     // The following five functions are used to implement collapsing margins.
     // All objects know their maximal positive and negative margins.  The
@@ -227,7 +231,7 @@ public:
 
     bool stretchesToViewHeight() const
     {
-        return document()->inQuirksMode() && style()->height().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody());
+        return document()->inQuirksMode() && style()->height().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody()) && !isBlockFlowRoot();
     }
 
     virtual IntSize intrinsicSize() const { return IntSize(); }
@@ -248,10 +252,14 @@ public:
     int computePercentageLogicalHeight(const Length& height);
 
     // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
-    virtual int availableWidth() const { return contentWidth(); } // FIXME: Investigate removing eventually. https://bugs.webkit.org/show_bug.cgi?id=46127
-    virtual int availableHeight() const;
-    int availableHeightUsing(const Length&) const;
-    virtual int availableLogicalWidth() const;
+    virtual int availableLogicalWidth() const { return contentLogicalWidth(); }
+    int availableLogicalHeight() const;
+    int availableLogicalHeightUsing(const Length&) const;
+    
+    // There are a few cases where we need to refer specifically to the available physical width and available physical height.
+    // Relative positioning is one of those cases, since left/top offsets are physical.
+    int availableWidth() const { return style()->isVerticalBlockFlow() ? availableLogicalWidth() : availableLogicalHeight(); }
+    int availableHeight() const { return style()->isVerticalBlockFlow() ? availableLogicalHeight() : availableLogicalWidth(); }
 
     void computeBlockDirectionMargins();
 
@@ -310,6 +318,8 @@ public:
 
     virtual void markDescendantBlocksAndLinesForLayout(bool inLayout = true);
     
+    bool isBlockFlowRoot() const { return !parent() || parent()->style()->blockFlow() != style()->blockFlow(); }
+
 protected:
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
@@ -363,8 +373,13 @@ private:
 
     void setMarginStartUsing(const RenderStyle*, int);
     void setMarginEndUsing(const RenderStyle*, int);
+    void setMarginBeforeUsing(const RenderStyle*, int);
+    void setMarginAfterUsing(const RenderStyle*, int);
+
     int marginStartUsing(const RenderStyle*) const;
     int marginEndUsing(const RenderStyle*) const;
+    int marginBeforeUsing(const RenderStyle*) const;
+    int marginAfterUsing(const RenderStyle*) const;
 
 private:
     // The width/height of the contents + borders + padding.  The x/y location is relative to our container (which is not always our parent).
diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp
index 5962f59..66f34f4 100644
--- a/WebCore/rendering/RenderTable.cpp
+++ b/WebCore/rendering/RenderTable.cpp
@@ -200,7 +200,7 @@ void RenderTable::computeLogicalWidth()
         computePositionedLogicalWidth();
 
     RenderBlock* cb = containingBlock();
-    int availableWidth = cb->availableWidth();
+    int availableWidth = cb->availableLogicalWidth();
 
     LengthType widthType = style()->width().type();
     if (widthType > Relative && style()->width().isPositive()) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list