[iOS WK1] CSS viewport units use the wrong viewport size in WebKit1
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jul 2014 01:05:14 +0000 (01:05 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jul 2014 01:05:14 +0000 (01:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135254
<rdar://problem/17781423>

Reviewed by Tim Horton.

Source/WebCore:

Test: fast/css/viewport-units-dynamic.html

In WebKit1 on iOS, we want to resolve viewport units against the visible
viewport, not the legacy WK1 notion of the "viewport" which is the entire document.

Fixes rendering of medium.com articles in WK1 views on iPad.

* page/FrameView.cpp:
(WebCore::FrameView::viewportSizeForCSSViewportUnits):

LayoutTests:

New test that ensures that viewport units are resolved against the correct
viewport size after the first style recalc.

* fast/css/viewport-units-dynamic.html: Added.
* platform/mac/fast/css/viewport-units-dynamic-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/viewport-units-dynamic.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/viewport-units-dynamic-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp

index a2b1278dc2e0d4ecd2b9478f022ffab86760db95..e36e7f113beed49fe51778ca3c6780f37e62fed9 100644 (file)
@@ -1,3 +1,17 @@
+2014-07-24  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK1] CSS viewport units use the wrong viewport size in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=135254
+        <rdar://problem/17781423>
+
+        Reviewed by Tim Horton.
+        
+        New test that ensures that viewport units are resolved against the correct
+        viewport size after the first style recalc.
+
+        * fast/css/viewport-units-dynamic.html: Added.
+        * platform/mac/fast/css/viewport-units-dynamic-expected.txt: Added.
+
 2014-07-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Crash when measuring a glyphs from a fallback SVG font
diff --git a/LayoutTests/fast/css/viewport-units-dynamic.html b/LayoutTests/fast/css/viewport-units-dynamic.html
new file mode 100644 (file)
index 0000000..adf2e3e
--- /dev/null
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 10000px;
+            width: 10000px;
+            margin: 0;
+        }
+        .box {
+            position: absolute;
+            background-color: rgba(0, 0, 0, 0.5);
+            border: 5px solid black;
+            box-sizing: border-box;
+        }
+        
+        .width {
+            width: 100px;
+            height: 100px;
+            padding-left: 100px;
+        }
+
+        .height {
+            height: 100px;
+            width: 100px;
+            padding-top: 100px;
+        }
+        
+        body.changed .height {
+            height: 100vh;
+        }
+
+        body.changed .width {
+            width: 100vw;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        function doTest()
+        {
+            window.setTimeout(function() {
+                document.body.classList.add('changed');
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, 0);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<div class="box width">
+    This should be as wide as the CSS viewport.
+</div>
+
+<div id="vertical" class="box height">
+    This should be as tall as the CSS viewport.
+</div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/css/viewport-units-dynamic-expected.txt b/LayoutTests/platform/mac/fast/css/viewport-units-dynamic-expected.txt
new file mode 100644 (file)
index 0000000..297bedf
--- /dev/null
@@ -0,0 +1,16 @@
+layer at (0,0) size 10000x10000
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x10000
+  RenderBlock {HTML} at (0,0) size 785x10000
+    RenderBody {BODY} at (0,0) size 10000x10000
+layer at (0,0) size 800x100
+  RenderBlock (positioned) {DIV} at (0,0) size 800x100 [bgcolor=#0000007F] [border: (5px solid #000000)]
+    RenderText {#text} at (105,5) size 282x18
+      text run at (105,5) width 282: "This should be as wide as the CSS viewport."
+layer at (0,0) size 100x600
+  RenderBlock (positioned) {DIV} at (0,0) size 100x600 [bgcolor=#0000007F] [border: (5px solid #000000)]
+    RenderText {#text} at (5,105) size 74x72
+      text run at (5,105) width 74: "This should"
+      text run at (5,123) width 72: "be as tall as"
+      text run at (5,141) width 52: "the CSS"
+      text run at (5,159) width 60: "viewport."
index 1970b45b53023bc8a745b1eefd064e802355a0f2..2aafc0f0f9b5efbcc8af8501209e958254e0cceb 100644 (file)
@@ -1,3 +1,21 @@
+2014-07-24  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK1] CSS viewport units use the wrong viewport size in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=135254
+        <rdar://problem/17781423>
+
+        Reviewed by Tim Horton.
+
+        Test: fast/css/viewport-units-dynamic.html
+        
+        In WebKit1 on iOS, we want to resolve viewport units against the visible
+        viewport, not the legacy WK1 notion of the "viewport" which is the entire document.
+        
+        Fixes rendering of medium.com articles in WK1 views on iPad.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::viewportSizeForCSSViewportUnits):
+
 2014-07-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Crash when measuring a glyphs from a fallback SVG font
index e94969ebce1ecafb035a3eb555d531d7221804e5..c3d0889a674c1a4c0b1c75ed3533dd88dad7843a 100644 (file)
@@ -4522,7 +4522,7 @@ IntSize FrameView::viewportSizeForCSSViewportUnits() const
     if (m_hasOverrideViewportSize)
         return m_overrideViewportSize;
     
-    return visibleContentRectIncludingScrollbars(ScrollableArea::LegacyIOSDocumentVisibleRect).size();
+    return visibleContentRectIncludingScrollbars().size();
 }
     
 } // namespace WebCore