Correct FrameView::scrollableAreaBoundingBox() calculation in the presence of transforms
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 00:51:30 +0000 (00:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 00:51:30 +0000 (00:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105075

Patch by Tien-Ren Chen <trchen@chromium.org> on 2013-01-14
Reviewed by Simon Fraser.

As mentioned by the FIXME comment, we need to ask the renderer for the
absolute bounding box of a frame for correct transformation.
This fixes the bug that iframe cannot be scrolled properly when it is
transformed.

Source/WebCore:

Tests: scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html
       scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html

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

LayoutTests:

* platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png: Added.
* platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt: Added.
* platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png: Added.
* platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt: Added.
* scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png: Added.
* scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt: Added.
* scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html: Added.
* scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png: Added.
* scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt: Added.
* scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html: Added.
* scrollingcoordinator/resources/non-fast-scrollable-region-testing.js: Added.
(runNonFastScrollableRegionTest):

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt [new file with mode: 0644]
LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/resources/non-fast-scrollable-region-testing.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp

index cad4cb8..27536fb 100644 (file)
@@ -1,3 +1,28 @@
+2013-01-14  Tien-Ren Chen  <trchen@chromium.org>
+
+        Correct FrameView::scrollableAreaBoundingBox() calculation in the presence of transforms
+        https://bugs.webkit.org/show_bug.cgi?id=105075
+
+        Reviewed by Simon Fraser.
+
+        As mentioned by the FIXME comment, we need to ask the renderer for the
+        absolute bounding box of a frame for correct transformation.
+        This fixes the bug that iframe cannot be scrolled properly when it is
+        transformed.
+
+        * platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png: Added.
+        * platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt: Added.
+        * platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png: Added.
+        * platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt: Added.
+        * scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html: Added.
+        * scrollingcoordinator/resources/non-fast-scrollable-region-testing.js: Added.
+        (runNonFastScrollableRegionTest):
+
 2013-01-14  Levi Weintraub  <leviw@chromium.org>
 
         Unreviewed gardening. Fixing Mac results for fast/repaint/overhanging-float-detach-repaint.html.
diff --git a/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png
new file mode 100644 (file)
index 0000000..2c448bc
Binary files /dev/null and b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png differ
diff --git a/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt
new file mode 100644 (file)
index 0000000..b085a7b
--- /dev/null
@@ -0,0 +1,12 @@
+layer at (0,0) size 785x585
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x8
+  RenderBlock {HTML} at (0,0) size 785x8
+    RenderBody {BODY} at (8,8) size 769x0
+layer at (50,50) size 324x224
+  RenderPartObject {IFRAME} at (50,50) size 324x224 [border: (2px inset #000000)]
+    layer at (0,0) size 1008x1016
+      RenderView at (0,0) size 285x185
+    layer at (0,0) size 285x1016
+      RenderBlock {HTML} at (0,0) size 285x1016
+        RenderBody {BODY} at (8,8) size 1000x1000
diff --git a/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png
new file mode 100644 (file)
index 0000000..6649d2e
Binary files /dev/null and b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png differ
diff --git a/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt b/LayoutTests/platform/mac/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt
new file mode 100644 (file)
index 0000000..3e9ba0e
--- /dev/null
@@ -0,0 +1,12 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x8
+  RenderBlock {HTML} at (0,0) size 800x8
+    RenderBody {BODY} at (8,8) size 784x0
+layer at (200,150) size 324x224
+  RenderPartObject {IFRAME} at (200,150) size 324x224 [border: (2px inset #000000)]
+    layer at (0,0) size 1008x1016
+      RenderView at (0,0) size 285x185
+    layer at (0,0) size 285x1016
+      RenderBlock {HTML} at (0,0) size 285x1016
+        RenderBody {BODY} at (8,8) size 1000x1000
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png
new file mode 100644 (file)
index 0000000..6f64ead
Binary files /dev/null and b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.png differ
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe-expected.txt
new file mode 100644 (file)
index 0000000..cbc2d68
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 785x585
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x8
+  RenderBlock {HTML} at (0,0) size 785x8
+    RenderBody {BODY} at (8,8) size 769x0
+layer at (50,50) size 324x224
+  RenderPartObject {IFRAME} at (50,50) size 324x224 [border: (2px inset #000000)]
+    layer at (0,0) size 1008x1016
+      RenderView at (0,0) size 285x185
+    layer at (0,0) size 285x1016
+      RenderBlock {HTML} at (0,0) size 285x1016
+        RenderBody {BODY} at (8,8) size 1000x1000
+layer at (62,62) size 300x200
+  RenderBlock (positioned) {DIV} at (62,62) size 300x200 [bgcolor=#00FF00]
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html
new file mode 100644 (file)
index 0000000..b70bdcc
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/non-fast-scrollable-region-testing.js"></script>
+</head>
+<body onload="runNonFastScrollableRegionTest(2);">
+<iframe src="data:text/html;charset=utf-8,<html><body style='width:1000px;height:1000px;'></body></html>" style="position:absolute;left:50px;top:50px;width;150px;height:200px;padding:10px;"></iframe>
+</body>
+</html>
+
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png
new file mode 100644 (file)
index 0000000..8fe34c3
Binary files /dev/null and b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.png differ
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe-expected.txt
new file mode 100644 (file)
index 0000000..bfbe306
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x8
+  RenderBlock {HTML} at (0,0) size 800x8
+    RenderBody {BODY} at (8,8) size 784x0
+layer at (200,150) size 324x224
+  RenderPartObject {IFRAME} at (200,150) size 324x224 [border: (2px inset #000000)]
+    layer at (0,0) size 1008x1016
+      RenderView at (0,0) size 285x185
+    layer at (0,0) size 285x1016
+      RenderBlock {HTML} at (0,0) size 285x1016
+        RenderBody {BODY} at (8,8) size 1000x1000
+layer at (62,62) size 600x400
+  RenderBlock (positioned) {DIV} at (62,62) size 600x400 [bgcolor=#00FF00]
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html b/LayoutTests/scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html
new file mode 100644 (file)
index 0000000..79ca12f
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/non-fast-scrollable-region-testing.js"></script>
+</head>
+<body onload="runNonFastScrollableRegionTest();">
+<iframe src="data:text/html;charset=utf-8,<html><body style='width:1000px;height:1000px;'></body></html>" style="position:absolute;left:200px;top:150px;width;150px;height:200px;-webkit-transform:scale(2);padding:10px;"></iframe>
+</body>
+</html>
+
diff --git a/LayoutTests/scrollingcoordinator/resources/non-fast-scrollable-region-testing.js b/LayoutTests/scrollingcoordinator/resources/non-fast-scrollable-region-testing.js
new file mode 100644 (file)
index 0000000..fbdb548
--- /dev/null
@@ -0,0 +1,34 @@
+function runNonFastScrollableRegionTest(scale) {
+    var invScale;
+    window.internals.settings.setMockScrollbarsEnabled(true);
+    if (scale != undefined) {
+        window.internals.setPageScaleFactor(scale, 0, 0);
+        // FIXME: This is a hack for applyPageScaleFactorInCompositor() == false.
+        invScale = 1 / scale;
+    } else {
+        invScale = 1;
+    }
+
+    var overlay = document.createElement("div");
+    overlay.style.position = "absolute";
+    overlay.style.left = 0;
+    overlay.style.top = 0;
+    overlay.style.opacity = 0.5;
+
+    var rects = window.internals.nonFastScrollableRects(document);
+    for (var i = 0; i < rects.length; i++) {
+        var rect = rects[i];
+        var patch = document.createElement("div");
+        patch.style.position = "absolute";
+        patch.style.backgroundColor = "#00ff00";
+        patch.style.left = rect.left * invScale + "px";
+        patch.style.top = rect.top * invScale + "px";
+        patch.style.width = rect.width * invScale + "px";
+        patch.style.height = rect.height * invScale + "px";
+
+        overlay.appendChild(patch);
+    }
+
+    document.body.appendChild(overlay);
+}
+
index 445d2d8..88d6d4c 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-14  Tien-Ren Chen  <trchen@chromium.org>
+
+        Correct FrameView::scrollableAreaBoundingBox() calculation in the presence of transforms
+        https://bugs.webkit.org/show_bug.cgi?id=105075
+
+        Reviewed by Simon Fraser.
+
+        As mentioned by the FIXME comment, we need to ask the renderer for the
+        absolute bounding box of a frame for correct transformation.
+        This fixes the bug that iframe cannot be scrolled properly when it is
+        transformed.
+
+        Tests: scrollingcoordinator/non-fast-scrollable-region-scaled-iframe.html
+               scrollingcoordinator/non-fast-scrollable-region-transformed-iframe.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollableAreaBoundingBox):
+
 2013-01-14  Nate Chapin  <japhet@chromium.org>
 
         Enable reuse of cached main resources
index de53615..08abd81 100644 (file)
@@ -2839,8 +2839,11 @@ ScrollableArea* FrameView::enclosingScrollableArea() const
 
 IntRect FrameView::scrollableAreaBoundingBox() const
 {
-    // FIXME: This isn't correct for transformed frames. We probably need to ask the renderer instead.
-    return frameRect();
+    RenderPart* ownerRenderer = frame()->ownerRenderer();
+    if (!ownerRenderer)
+        return frameRect();
+
+    return ownerRenderer->absoluteContentQuad().enclosingBoundingBox();
 }
 
 bool FrameView::isScrollable()