REGRESSION(r128517): Percentage heights in quirks mode collapse when printing
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 20:00:12 +0000 (20:00 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 20:00:12 +0000 (20:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108382

Reviewed by David Hyatt.

Source/WebCore:

r128517 clean up our containing block finding logic, but broke percentage
heights in quirks mode during printing since the RenderView would have 0 height.
Turns out we already had a long-standing bug where we'd incorrectly
treat collapse percentage heights on the body when printing as well.

Fix both bugs by changing the way we grab the logical height on the RenderView.
RenderView::computeLogicalHeight returns 0 when printing. For the purposes of
stretching and percentage heights, we instead need to return the pageLogicalHeight.

Tests: printing/quirks-percentage-height-body.html
       printing/quirks-percentage-height.html
       printing/standards-percentage-heights.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight):
This FIXME is outdated and already fixed. Also, call viewLogicalHeightForPercentages
which does the same logic except also correctly handles column RenderViews.
(WebCore::RenderBox::viewLogicalHeightForPercentages):
(WebCore::RenderBox::computePercentageLogicalHeight):
* rendering/RenderBox.h:

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight):
(WebCore::RenderBox::viewLogicalHeightForPercentages):
(WebCore):
(WebCore::RenderBox::computePercentageLogicalHeight):
* rendering/RenderBox.h:
(RenderBox):

LayoutTests:

* platform/chromium/fast/multicol/shrink-to-column-height-for-pagination-expected.txt:
We're just clipping more content that you can't scroll to anyways. This looks
like an improvement to me.
* printing/css2.1/page-break-inside-000-expected.txt:
We pass this test now!
* printing/quirks-percentage-height-body-expected.html: Added.
* printing/quirks-percentage-height-body.html: Added.
* printing/quirks-percentage-height-expected.html: Added.
* printing/quirks-percentage-height.html: Added.
* printing/standards-percentage-heights-expected.html: Added.
* printing/standards-percentage-heights.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141459 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/fast/multicol/shrink-to-column-height-for-pagination-expected.txt
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/printing/css2.1/page-break-inside-000-expected.txt
LayoutTests/printing/quirks-percentage-height-body-expected.html [new file with mode: 0644]
LayoutTests/printing/quirks-percentage-height-body.html [new file with mode: 0644]
LayoutTests/printing/quirks-percentage-height-expected.html [new file with mode: 0644]
LayoutTests/printing/quirks-percentage-height.html [new file with mode: 0644]
LayoutTests/printing/standards-percentage-heights-expected.html [new file with mode: 0644]
LayoutTests/printing/standards-percentage-heights.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h

index 06a0eaf..b5a247c 100644 (file)
@@ -1,3 +1,22 @@
+2013-01-31  Ojan Vafai  <ojan@chromium.org>
+
+        REGRESSION(r128517): Percentage heights in quirks mode collapse when printing
+        https://bugs.webkit.org/show_bug.cgi?id=108382
+
+        Reviewed by David Hyatt.
+
+        * platform/chromium/fast/multicol/shrink-to-column-height-for-pagination-expected.txt:
+        We're just clipping more content that you can't scroll to anyways. This looks
+        like an improvement to me.
+        * printing/css2.1/page-break-inside-000-expected.txt:
+        We pass this test now!
+        * printing/quirks-percentage-height-body-expected.html: Added.
+        * printing/quirks-percentage-height-body.html: Added.
+        * printing/quirks-percentage-height-expected.html: Added.
+        * printing/quirks-percentage-height.html: Added.
+        * printing/standards-percentage-heights-expected.html: Added.
+        * printing/standards-percentage-heights.html: Added.
+
 2013-01-31  Jessie Berlin  <jberlin@apple.com>
 
         inspector/editor/text-editor-ctrl-movements.html was renamed to
index c93a3f3..ded30a7 100644 (file)
@@ -1,7 +1,7 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 400x600
-layer at (-400,0) size 800x600 backgroundClip at (0,0) size 800x600 clip at (0,0) size 800x600 outlineClip at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
+layer at (-16,0) size 416x600 backgroundClip at (0,0) size 800x600 clip at (0,0) size 800x600 outlineClip at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 416x600
     RenderBody {BODY} at (8,8) size 400x600
       RenderBlock {DIV} at (0,0) size 400x600
         RenderImage {IMG} at (392,0) size 400x600
index f4dc6d5..3398fd2 100644 (file)
@@ -308,6 +308,10 @@ webkit.org/b/106405 http/tests/xmlhttprequest/basic-auth-nouser.html [ Failure ]
 webkit.org/b/106405 http/tests/xmlhttprequest/failed-auth.html [ Failure ]
 webkit.org/b/106405 http/tests/xmlhttprequest/remember-bad-password.html [ Failure ]
 
+webkit.org/b/108507 printing/quirks-percentage-height-body.html [ Skip ]
+webkit.org/b/108507 printing/quirks-percentage-height.html [ Skip ]
+webkit.org/b/108507 printing/standards-percentage-heights.html [ Skip ]
+
 webkit.org/b/107356 fast/css/sticky/sticky-top-zoomed.html [ ImageOnlyFailure ]
 
 ### END OF (1) Classified failures with bug reports
index dc28776..b353f06 100644 (file)
@@ -1,5 +1,6 @@
 There must be a page break below between "FIRST" and "LAST"
 FIRST dummy dummy dummy dummy dummy dummy dummy dummy dummy FIRST
 
-FAIL: expected page number of "test1" is 0. Was -1
-FAIL: expected page number of "test2" is 1. Was 0
+PASS: page number of "test1" is 0
+PASS: page number of "test2" is 1
+All tests passed
diff --git a/LayoutTests/printing/quirks-percentage-height-body-expected.html b/LayoutTests/printing/quirks-percentage-height-body-expected.html
new file mode 100644 (file)
index 0000000..9f5e391
--- /dev/null
@@ -0,0 +1,2 @@
+<!-- We page zoom scale down the page by 1.25 when printing. -->
+<body style="margin: 0; height: 50%; width: 50%; border: 5px solid salmon; zoom: 80%;"></body>
diff --git a/LayoutTests/printing/quirks-percentage-height-body.html b/LayoutTests/printing/quirks-percentage-height-body.html
new file mode 100644 (file)
index 0000000..b3d05d9
--- /dev/null
@@ -0,0 +1,5 @@
+<script>
+if (window.testRunner)
+    testRunner.setPrinting();
+</script>
+<body style="margin: 0; height: 50%; width: 50%; border: 5px solid salmon;"></body>
diff --git a/LayoutTests/printing/quirks-percentage-height-expected.html b/LayoutTests/printing/quirks-percentage-height-expected.html
new file mode 100644 (file)
index 0000000..3bc88ca
--- /dev/null
@@ -0,0 +1,4 @@
+<!-- We page zoom scale down the page by 1.25 when printing. -->
+<body style="margin: 0; zoom: 80%;">
+    <div style="height: 50%; width: 50%; border: 5px solid salmon;"></div>
+</body>
diff --git a/LayoutTests/printing/quirks-percentage-height.html b/LayoutTests/printing/quirks-percentage-height.html
new file mode 100644 (file)
index 0000000..a60fd6e
--- /dev/null
@@ -0,0 +1,7 @@
+<script>
+if (window.testRunner)
+    testRunner.setPrinting();
+</script>
+<body style="margin: 0;">
+    <div style="height: 50%; width: 50%; border: 5px solid salmon;"></div>
+</body>
diff --git a/LayoutTests/printing/standards-percentage-heights-expected.html b/LayoutTests/printing/standards-percentage-heights-expected.html
new file mode 100644 (file)
index 0000000..fc94742
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<!-- We page zoom scale down the page by 1.25 when printing. -->
+<html style="overflow: hidden; height: 500px; width: 500px; border: 5px solid pink; zoom: 80%;">
+<body style="margin: 0; height: 50%; width: 50%; border: 5px solid salmon;"></body>
diff --git a/LayoutTests/printing/standards-percentage-heights.html b/LayoutTests/printing/standards-percentage-heights.html
new file mode 100644 (file)
index 0000000..09bea6f
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html style="overflow: hidden; height: 500px; width: 500px; border: 5px solid pink">
+<script>
+if (window.testRunner)
+    testRunner.setPrinting();
+</script>
+<body style="margin: 0; height: 50%; width: 50%; border: 5px solid salmon;"></body>
index 024f670..bab035e 100644 (file)
@@ -1,3 +1,39 @@
+2013-01-31  Ojan Vafai  <ojan@chromium.org>
+
+        REGRESSION(r128517): Percentage heights in quirks mode collapse when printing
+        https://bugs.webkit.org/show_bug.cgi?id=108382
+
+        Reviewed by David Hyatt.
+
+        r128517 clean up our containing block finding logic, but broke percentage
+        heights in quirks mode during printing since the RenderView would have 0 height.
+        Turns out we already had a long-standing bug where we'd incorrectly
+        treat collapse percentage heights on the body when printing as well.
+
+        Fix both bugs by changing the way we grab the logical height on the RenderView.
+        RenderView::computeLogicalHeight returns 0 when printing. For the purposes of
+        stretching and percentage heights, we instead need to return the pageLogicalHeight.
+
+        Tests: printing/quirks-percentage-height-body.html
+               printing/quirks-percentage-height.html
+               printing/standards-percentage-heights.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeLogicalHeight):
+        This FIXME is outdated and already fixed. Also, call viewLogicalHeightForPercentages
+        which does the same logic except also correctly handles column RenderViews.
+        (WebCore::RenderBox::viewLogicalHeightForPercentages):
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        * rendering/RenderBox.h:
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeLogicalHeight):
+        (WebCore::RenderBox::viewLogicalHeightForPercentages):
+        (WebCore):
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        * rendering/RenderBox.h:
+        (RenderBox):
+
 2013-01-31  Dirk Schulze  <krit@webkit.org>
 
         [canvas] Implement currentPath to get and set the current path of the context
index d21e408..1fd1ad9 100644 (file)
@@ -2416,27 +2416,24 @@ void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica
     bool paginatedContentNeedsBaseHeight = document()->printing() && h.isPercent()
         && (isRoot() || (isBody() && document()->documentElement()->renderer()->style()->logicalHeight().isPercent()));
     if (stretchesToViewport() || paginatedContentNeedsBaseHeight) {
-        // FIXME: Finish accounting for block flow here.
-        // https://bugs.webkit.org/show_bug.cgi?id=46603
         LayoutUnit margins = collapsedMarginBefore() + collapsedMarginAfter();
-        LayoutUnit visHeight;
-        if (document()->printing())
-            visHeight = static_cast<LayoutUnit>(view()->pageLogicalHeight());
-        else  {
-            if (isHorizontalWritingMode())
-                visHeight = view()->viewHeight();
-            else
-                visHeight = view()->viewWidth();
-        }
+        LayoutUnit visibleHeight = viewLogicalHeightForPercentages();
         if (isRoot())
-            computedValues.m_extent = max(computedValues.m_extent, visHeight - margins);
+            computedValues.m_extent = max(computedValues.m_extent, visibleHeight - margins);
         else {
             LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefore() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight();
-            computedValues.m_extent = max(computedValues.m_extent, visHeight - marginsBordersPadding);
+            computedValues.m_extent = max(computedValues.m_extent, visibleHeight - marginsBordersPadding);
         }
     }
 }
 
+LayoutUnit RenderBox::viewLogicalHeightForPercentages() const
+{
+    if (document()->printing())
+        return static_cast<LayoutUnit>(view()->pageLogicalHeight());
+    return view()->viewLogicalHeight();
+}
+
 LayoutUnit RenderBox::computeLogicalHeightUsing(SizeType heightType, const Length& height) const
 {
     LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heightType, height);
@@ -2542,13 +2539,14 @@ LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
             LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
             availableHeight = max<LayoutUnit>(0, contentBoxHeight);
         }
-    } else if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight) {
+    } else if (isOutOfFlowPositionedWithSpecifiedHeight) {
         // 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.
         LogicalExtentComputedValues computedValues;
         cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues);
         availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalHeight() - cb->scrollbarLogicalHeight();
-    }
+    } else if (cb->isRenderView())
+        availableHeight = viewLogicalHeightForPercentages();
 
     if (availableHeight == -1)
         return availableHeight;
index cad21ff..ba8340e 100644 (file)
@@ -641,6 +641,8 @@ private:
         LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const;
     LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
 
+    LayoutUnit viewLogicalHeightForPercentages() const;
+
     void computePositionedLogicalHeight(LogicalExtentComputedValues&) const;
     void computePositionedLogicalWidthUsing(SizeType, Length logicalWidth, const RenderBoxModelObject* containerBlock, TextDirection containerDirection,
                                             LayoutUnit containerLogicalWidth, LayoutUnit bordersPlusPadding,