<rdar://problem/9095366> With a non-1 page scale, scrolling to reveal selection fails
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2011 02:13:10 +0000 (02:13 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2011 02:13:10 +0000 (02:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=59046

Reviewed by Maciej Stachowiak.

Source/WebCore:

Test: fast/transforms/selection-bounds-in-transformed-view.html

* rendering/RenderObject.cpp:
(WebCore::RenderObject::repaintUsingContainer): If the repaint container is the RenderView, and
it has a composited layer that paints straight to the window, then translate from view coordinates
to window coordinates here.
* rendering/RenderView.cpp:
(WebCore::RenderView::mapLocalToContainer): Do not apply our transform if we are the painting root.
(WebCore::RenderView::computeRectForRepaint): Ditto. Applying the transform here was compensating
for not applying it in RenderObject::repaintUsingContainer(), but for purposes other than repainting,
such as computing selection bounds, this function was returning the wrong results.

LayoutTests:

* fast/transforms/selection-bounds-in-transformed-view-expected.txt: Added.
* fast/transforms/selection-bounds-in-transformed-view.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/transforms/selection-bounds-in-transformed-view-expected.txt [new file with mode: 0644]
LayoutTests/fast/transforms/selection-bounds-in-transformed-view.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderView.cpp

index 4a87819..b80bd56 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-20  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        <rdar://problem/9095366> With a non-1 page scale, scrolling to reveal selection fails
+        https://bugs.webkit.org/show_bug.cgi?id=59046
+
+        * fast/transforms/selection-bounds-in-transformed-view-expected.txt: Added.
+        * fast/transforms/selection-bounds-in-transformed-view.html: Added.
+
 2011-04-20  Dirk Pranke  <dpranke@chromium.org>
 
         Unreviewed, expectations change.
diff --git a/LayoutTests/fast/transforms/selection-bounds-in-transformed-view-expected.txt b/LayoutTests/fast/transforms/selection-bounds-in-transformed-view-expected.txt
new file mode 100644 (file)
index 0000000..a0335dc
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+target
+
diff --git a/LayoutTests/fast/transforms/selection-bounds-in-transformed-view.html b/LayoutTests/fast/transforms/selection-bounds-in-transformed-view.html
new file mode 100644 (file)
index 0000000..a10a4d1
--- /dev/null
@@ -0,0 +1,16 @@
+<body style="font: 20px ahem; margin: 0;">
+    <div id="result" style="outline: solid blue; height: 100px; width: 100px; -webkit-transform: translatez(0)"></div>
+    <div style="height: 900px"></div>
+    <div style="height: 100px;">target</div>
+    <div style="height: 1000px;"></div>
+    <script>
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText();
+
+            eventSender.scalePageBy(2, 0, 0);
+        }
+
+        document.execCommand("FindString", false, "target");
+        document.getElementById("result").innerText = document.body.scrollTop === 864 ? "PASS" : "FAIL";
+    </script>
+</body>
index 902816d..ca5e4c9 100644 (file)
@@ -1,5 +1,24 @@
 2011-04-20  Dan Bernstein  <mitz@apple.com>
 
+        Reviewed by Maciej Stachowiak.
+
+        <rdar://problem/9095366> With a non-1 page scale, scrolling to reveal selection fails
+        https://bugs.webkit.org/show_bug.cgi?id=59046
+
+        Test: fast/transforms/selection-bounds-in-transformed-view.html
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::repaintUsingContainer): If the repaint container is the RenderView, and
+        it has a composited layer that paints straight to the window, then translate from view coordinates
+        to window coordinates here.
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::mapLocalToContainer): Do not apply our transform if we are the painting root.
+        (WebCore::RenderView::computeRectForRepaint): Ditto. Applying the transform here was compensating
+        for not applying it in RenderObject::repaintUsingContainer(), but for purposes other than repainting,
+        such as computing selection bounds, this function was returning the wrong results.
+
+2011-04-20  Dan Bernstein  <mitz@apple.com>
+
         Reviewed by Eric Carlson.
 
         <rdar://problem/9304956> media/broken-video.html crashes
index 5fa0243..860a9bb 100644 (file)
@@ -1157,8 +1157,12 @@ void RenderObject::repaintUsingContainer(RenderBoxModelObject* repaintContainer,
     RenderView* v = view();
     if (repaintContainer->isRenderView()) {
         ASSERT(repaintContainer == v);
-        if (!v->hasLayer() || !v->layer()->isComposited() || v->layer()->backing()->paintingGoesToWindow()) {
-            v->repaintViewRectangle(r, immediate);
+        bool viewHasCompositedLayer = v->hasLayer() && v->layer()->isComposited();
+        if (!viewHasCompositedLayer || v->layer()->backing()->paintingGoesToWindow()) {
+            IntRect repaintRectangle = r;
+            if (viewHasCompositedLayer &&  v->layer()->transform())
+                repaintRectangle = v->layer()->transform()->mapRect(r);
+            v->repaintViewRectangle(repaintRectangle, immediate);
             return;
         }
     }
index cf5cd76..ed221a5 100644 (file)
@@ -140,9 +140,9 @@ void RenderView::mapLocalToContainer(RenderBoxModelObject* repaintContainer, boo
 {
     // If a container was specified, and was not 0 or the RenderView,
     // then we should have found it by now.
-    ASSERT_UNUSED(repaintContainer, !repaintContainer || repaintContainer == this);
+    ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
 
-    if (useTransforms && shouldUseTransformFromContainer(0)) {
+    if (!repaintContainer && useTransforms && shouldUseTransformFromContainer(0)) {
         TransformationMatrix t;
         getTransformFromContainer(0, IntSize(), t);
         transformState.applyTransform(t);
@@ -299,7 +299,7 @@ void RenderView::computeRectForRepaint(RenderBoxModelObject* repaintContainer, I
 {
     // If a container was specified, and was not 0 or the RenderView,
     // then we should have found it by now.
-    ASSERT_UNUSED(repaintContainer, !repaintContainer || repaintContainer == this);
+    ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
 
     if (printing())
         return;
@@ -317,7 +317,7 @@ void RenderView::computeRectForRepaint(RenderBoxModelObject* repaintContainer, I
         rect.move(m_frameView->scrollXForFixedPosition(), m_frameView->scrollYForFixedPosition());
         
     // Apply our transform if we have one (because of full page zooming).
-    if (m_layer && m_layer->transform())
+    if (!repaintContainer && m_layer && m_layer->transform())
         rect = m_layer->transform()->mapRect(rect);
 }