Absolute child is not repainted when parent opacity changes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 23:53:20 +0000 (23:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 23:53:20 +0000 (23:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68777

Patch by Konstantin Scheglov <scheglov@google.com> on 2011-11-17
Reviewed by Simon Fraser.

Source/WebCore:

First time when we change opacity for parent we don't have layer, so
diff=StyleDifferenceRepaint is used instead of diff=StyleDifferenceRepaintLayer.
Layer is created later, in styleDidChange().
So, when we recalculate later diff, we now check for diff=StyleDifferenceRepaintLayer and
performs repaintIncludingDescendants().

Test: fast/layers/layer-absolute-parent-opacity.html

* rendering/RenderObject.cpp:
(WebCore::RenderObject::setStyle): Call repaintIncludingDescendants() instead of repaint().
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff): Add ContextSensitivePropertyOpacity when change opacity.

LayoutTests:

* fast/layers/layer-absolute-parent-opacity-expected.png: Added.
* fast/layers/layer-absolute-parent-opacity-expected.txt: Added.
* fast/layers/layer-absolute-parent-opacity.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.png [new file with mode: 0644]
LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.txt [new file with mode: 0644]
LayoutTests/fast/layers/layer-absolute-parent-opacity.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/style/RenderStyle.cpp

index 6a18bd332af57fd7339243ee31853a6228661027..6b48c02269a72483c648b5a8f2c11c315678e89f 100755 (executable)
@@ -1,3 +1,14 @@
+2011-11-17  Konstantin Scheglov  <scheglov@google.com>
+
+        Absolute child is not repainted when parent opacity changes
+        https://bugs.webkit.org/show_bug.cgi?id=68777
+
+        Reviewed by Simon Fraser.
+
+        * fast/layers/layer-absolute-parent-opacity-expected.png: Added.
+        * fast/layers/layer-absolute-parent-opacity-expected.txt: Added.
+        * fast/layers/layer-absolute-parent-opacity.html: Added.
+
 2011-11-17  Adrienne Walker  <enne@google.com>
 
         [chromium] Unreviewed, rebaseline tests after r100545.
diff --git a/LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.png b/LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.png
new file mode 100644 (file)
index 0000000..f387e23
Binary files /dev/null and b/LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.png differ
diff --git a/LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.txt b/LayoutTests/fast/layers/layer-absolute-parent-opacity-expected.txt
new file mode 100644 (file)
index 0000000..f1cf0cf
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 100x100
+  RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#00FF00]
+layer at (80,0) size 200x50
+  RenderBlock (positioned) {DIV} at (80,0) size 200x50 [bgcolor=#0000FF]
diff --git a/LayoutTests/fast/layers/layer-absolute-parent-opacity.html b/LayoutTests/fast/layers/layer-absolute-parent-opacity.html
new file mode 100644 (file)
index 0000000..132021b
--- /dev/null
@@ -0,0 +1,43 @@
+<!--
+Test for https://bugs.webkit.org/show_bug.cgi?id=68777
+When we change opacity for parent DIV, this should change also opacity for absolute child, which is
+on its own layer. Before fixing this worked only second time, when parent DIV already has its own
+layer.
+-->
+<html>
+    <head>
+        <style>
+        #parentDiv {
+            background: #0f0;
+            width: 100px;
+            height: 100px;
+        }
+        #childDiv {
+            position: absolute;
+            background: #00f;
+            top: 0px;
+            left: 80px;
+            width: 200px;
+            height: 50px;
+    }
+  </style>
+        <script type="text/javascript">
+            function test() {
+                if (window.layoutTestController) {
+                    layoutTestController.display();
+                    setTimeout(function() {
+                        document.getElementById("parentDiv").style.opacity = 0.5;
+                        layoutTestController.notifyDone();
+                    }, 0);
+                    layoutTestController.waitUntilDone();
+                }
+            }
+        </script>
+    </head>
+    <body onload="test()">
+        <div id="parentDiv">
+            <div id="childDiv"/>
+        </div>
+    </body>
+</html>
+
index 09ade44c82c0c5223295293fc9cca58f19221fe7..332889e28e5b82c7af6f7d28b3df891b2ce3ed00 100644 (file)
@@ -1,3 +1,23 @@
+2011-11-17  Konstantin Scheglov  <scheglov@google.com>
+
+        Absolute child is not repainted when parent opacity changes
+        https://bugs.webkit.org/show_bug.cgi?id=68777
+
+        Reviewed by Simon Fraser.
+
+        First time when we change opacity for parent we don't have layer, so
+        diff=StyleDifferenceRepaint is used instead of diff=StyleDifferenceRepaintLayer.
+        Layer is created later, in styleDidChange().
+        So, when we recalculate later diff, we now check for diff=StyleDifferenceRepaintLayer and
+        performs repaintIncludingDescendants().
+
+        Test: fast/layers/layer-absolute-parent-opacity.html
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setStyle): Call repaintIncludingDescendants() instead of repaint().
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff): Add ContextSensitivePropertyOpacity when change opacity.
+
 2011-11-17  Nate Chapin  <japhet@chromium.org>
 
         r100311 dropped a RefPtr that is very
index 0f9d839939e73424c39e455f8f2625023e1cd85b..14dd4e80db19c8a222c4a7daa2cc6df1333e2c6d 100755 (executable)
@@ -1772,7 +1772,11 @@ void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
             setNeedsSimplifiedNormalFlowLayout();
     }
     
-    if (updatedDiff == StyleDifferenceRepaintLayer || updatedDiff == StyleDifferenceRepaint) {
+    if (diff == StyleDifferenceRepaint && updatedDiff == StyleDifferenceRepaintLayer) {
+        // If there was no layer, we ignored StyleDifferenceRepaintLayer and processed it as
+        // StyleDifferenceRepaint, so do layers repaint now.
+        toRenderBoxModelObject(this)->layer()->repaintIncludingDescendants();
+    } else if (updatedDiff == StyleDifferenceRepaintLayer || updatedDiff == StyleDifferenceRepaint) {
         // Do a repaint with the new style now, e.g., for example if we go from
         // not having an outline to having an outline.
         repaint();
index c7429eb82fc5560ee4acfde9790886a24a41e808..57b4c023c1c8d5b6db93ff09ea801294d427daca 100644 (file)
@@ -563,6 +563,7 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
         // to add a selfNeedsSimplifiedLayout bit in order to not get confused and taint every line).
         // In addition we need to solve the floating object issue when layers come and go. Right now
         // a full layout is necessary to keep floating object lists sane.
+        changedContextSensitiveProperties |= ContextSensitivePropertyOpacity;
         return StyleDifferenceLayout;
     }