Fix repainting of slow repaint objects in WK1 when page scale is applied
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Oct 2016 02:43:42 +0000 (02:43 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Oct 2016 02:43:42 +0000 (02:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163854

Reviewed by Zalan Bujtas.

Source/WebCore:

RenderObject::repaintSlowRepaintObject() always set the repaint container to the RenderView
if it was null. This is before the call to clippedOverflowRectForRepaint(). If that function
is called with a null repaintContainer, it maps the rect up through the RenderView's transform
(which represents page scale), which is what we want here. Passing the RenderView itself
stops the transform from being applied, which led to the bug.

WebKit2 doesn't suffer from this bug because containerForRepaint() always returns the
composited RenderView.

Test: fast/repaint/zoomed-fixed-background.html

* rendering/RenderObject.cpp:
(WebCore::RenderObject::repaintSlowRepaintObject):

LayoutTests:

Test that logs the repaint rect after scrolling a page with an element
with a fixed background. The WebKit1 result is the interesting one.

* fast/repaint/zoomed-fixed-background-expected.txt: Added.
* fast/repaint/zoomed-fixed-background.html: Added.
* platform/mac-wk1/fast/repaint/zoomed-fixed-background-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/repaint/zoomed-fixed-background-expected.txt [new file with mode: 0644]
LayoutTests/fast/repaint/zoomed-fixed-background.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/fast/repaint/zoomed-fixed-background-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderObject.cpp

index b9bdabe..e881f76 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-22  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix repainting of slow repaint objects in WK1 when page scale is applied
+        https://bugs.webkit.org/show_bug.cgi?id=163854
+
+        Reviewed by Zalan Bujtas.
+        
+        Test that logs the repaint rect after scrolling a page with an element
+        with a fixed background. The WebKit1 result is the interesting one.
+
+        * fast/repaint/zoomed-fixed-background-expected.txt: Added.
+        * fast/repaint/zoomed-fixed-background.html: Added.
+        * platform/mac-wk1/fast/repaint/zoomed-fixed-background-expected.txt: Added.
+
 2016-10-22  Darin Adler  <darin@apple.com>
 
         Move HTML canvas and tracks from ExceptionCode to Exception
diff --git a/LayoutTests/fast/repaint/zoomed-fixed-background-expected.txt b/LayoutTests/fast/repaint/zoomed-fixed-background-expected.txt
new file mode 100644 (file)
index 0000000..0a1a48b
--- /dev/null
@@ -0,0 +1 @@
+(repaint rects (rect 10 -200 100 100) )
diff --git a/LayoutTests/fast/repaint/zoomed-fixed-background.html b/LayoutTests/fast/repaint/zoomed-fixed-background.html
new file mode 100644 (file)
index 0000000..9816dd4
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+        .box {
+            position: absolute;
+            top: 200px;
+            left: 10px;
+            width: 100px;
+            height: 100px;
+            background-image: linear-gradient(green, green 200px, red 200px, red 1000px);
+            background-attachment: fixed;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function logRepaints() {
+            if (!window.internals)
+                return;
+
+            document.getElementById('repaints').textContent = window.internals.repaintRectsAsText();
+            window.internals.stopTrackingRepaints();
+        }
+
+        function doTest()
+        {
+            if (window.eventSender)
+                eventSender.scalePageBy(2, 0, 0);
+
+            window.internals.startTrackingRepaints();
+            window.scrollTo(0, 200);
+            logRepaints();
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<div class="box"></div>
+<div id="repaints"></div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac-wk1/fast/repaint/zoomed-fixed-background-expected.txt b/LayoutTests/platform/mac-wk1/fast/repaint/zoomed-fixed-background-expected.txt
new file mode 100644 (file)
index 0000000..97b8702
--- /dev/null
@@ -0,0 +1 @@
+(repaint rects (rect 20 0 200 200) )
index b149783..e14cecb 100644 (file)
@@ -1,3 +1,24 @@
+2016-10-22  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix repainting of slow repaint objects in WK1 when page scale is applied
+        https://bugs.webkit.org/show_bug.cgi?id=163854
+
+        Reviewed by Zalan Bujtas.
+        
+        RenderObject::repaintSlowRepaintObject() always set the repaint container to the RenderView
+        if it was null. This is before the call to clippedOverflowRectForRepaint(). If that function
+        is called with a null repaintContainer, it maps the rect up through the RenderView's transform
+        (which represents page scale), which is what we want here. Passing the RenderView itself
+        stops the transform from being applied, which led to the bug.
+        
+        WebKit2 doesn't suffer from this bug because containerForRepaint() always returns the
+        composited RenderView.
+
+        Test: fast/repaint/zoomed-fixed-background.html
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::repaintSlowRepaintObject):
+
 2016-10-22  Darin Adler  <darin@apple.com>
 
         Move HTML canvas and tracks from ExceptionCode to Exception
index f5f7a9b..502a776 100644 (file)
@@ -885,8 +885,6 @@ void RenderObject::repaintSlowRepaintObject() const
         return;
 
     const RenderLayerModelObject* repaintContainer = containerForRepaint();
-    if (!repaintContainer)
-        repaintContainer = &view;
 
     bool shouldClipToLayer = true;
     IntRect repaintRect;