RenderBox::backgroundIsKnownToBeOpaqueInRect may be wrong for theme-painted elements
authoralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Mar 2013 17:03:11 +0000 (17:03 +0000)
committeralokp@chromium.org <alokp@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Mar 2013 17:03:11 +0000 (17:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113419

Reviewed by Simon Fraser.

Source/WebCore:

Do not consider control elements as opaque. They are typically theme painted, and we cannot assume opaqueness on the behalf of theme. It can be improved by asking the theme if it paints opaque.

Test: compositing/contents-opaque/control-layer.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect):

LayoutTests:

* compositing/contents-opaque/control-layer-expected.txt: Added.
* compositing/contents-opaque/control-layer.html: Added.
* platform/chromium/compositing/contents-opaque/control-layer-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/contents-opaque/control-layer-expected.txt [new file with mode: 0644]
LayoutTests/compositing/contents-opaque/control-layer.html [new file with mode: 0755]
LayoutTests/platform/chromium/compositing/contents-opaque/control-layer-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp

index 0acd9ac..9882385 100644 (file)
@@ -1,3 +1,14 @@
+2013-03-28  Alok Priyadarshi  <alokp@chromium.org>
+
+        RenderBox::backgroundIsKnownToBeOpaqueInRect may be wrong for theme-painted elements
+        https://bugs.webkit.org/show_bug.cgi?id=113419
+
+        Reviewed by Simon Fraser.
+
+        * compositing/contents-opaque/control-layer-expected.txt: Added.
+        * compositing/contents-opaque/control-layer.html: Added.
+        * platform/chromium/compositing/contents-opaque/control-layer-expected.txt: Added.
+
 2013-03-28  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening. Adding failure expectation for a reftest added in r147111
diff --git a/LayoutTests/compositing/contents-opaque/control-layer-expected.txt b/LayoutTests/compositing/contents-opaque/control-layer-expected.txt
new file mode 100644 (file)
index 0000000..ec18502
--- /dev/null
@@ -0,0 +1,19 @@
+
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 5.00 6.00)
+          (anchor 0.50 0.46)
+          (bounds 129.00 28.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/contents-opaque/control-layer.html b/LayoutTests/compositing/contents-opaque/control-layer.html
new file mode 100755 (executable)
index 0000000..4d38611
--- /dev/null
@@ -0,0 +1,27 @@
+<html>
+    <head>
+        <style type="text/css">
+            .composited {
+                -webkit-transform: translateZ(0);
+            }
+        </style>
+        <script type="text/javascript">
+            if (window.testRunner)
+                testRunner.dumpAsText();
+
+            function doTest() {
+                if (window.testRunner && window.internals)
+                    document.getElementById('layertree').innerText = window.internals.layerTreeAsText(document);
+            }
+            window.addEventListener('load', doTest, false);
+        </script>
+    </head>
+    <body>
+        <!-- Composited control element. -->
+        <!-- Control elements are rendered by native theme. ->
+        <!-- GraphicsLayer::contentsOpaque for control element should be false. -->
+        <input class="composited" type="button" value="Composited Button">
+
+        <pre id="layertree"></pre>
+    </body>
+</html>
diff --git a/LayoutTests/platform/chromium/compositing/contents-opaque/control-layer-expected.txt b/LayoutTests/platform/chromium/compositing/contents-opaque/control-layer-expected.txt
new file mode 100644 (file)
index 0000000..86cfea0
--- /dev/null
@@ -0,0 +1,18 @@
+
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 10.00 10.00)
+          (bounds 127.00 22.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
index 9add366..3dbac06 100644 (file)
@@ -1,3 +1,17 @@
+2013-03-28  Alok Priyadarshi  <alokp@chromium.org>
+
+        RenderBox::backgroundIsKnownToBeOpaqueInRect may be wrong for theme-painted elements
+        https://bugs.webkit.org/show_bug.cgi?id=113419
+
+        Reviewed by Simon Fraser.
+
+        Do not consider control elements as opaque. They are typically theme painted, and we cannot assume opaqueness on the behalf of theme. It can be improved by asking the theme if it paints opaque.
+
+        Test: compositing/contents-opaque/control-layer.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect):
+
 2013-03-28  ChangSeok Oh  <changseok.oh@collabora.com>
 
         [GTK][AC] Animating layer disappears while running with clutter backend
index 60aa1d6..ce2991a 100644 (file)
@@ -1177,6 +1177,12 @@ bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
     if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
         return false;
 
+    // If the element has appearance, it might be painted by theme.
+    // We cannot be sure if theme paints the background opaque.
+    // In this case it is safe to not assume opaqueness.
+    // FIXME: May be ask theme if it paints opaque.
+    if (style()->hasAppearance())
+        return false;
     // FIXME: Check the opaqueness of background images.
 
     // FIXME: Use rounded rect if border radius is present.