2008-05-14 David Hyatt <hyatt@apple.com>
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 22:07:56 +0000 (22:07 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 22:07:56 +0000 (22:07 +0000)
        Fix for bug https://bugs.webkit.org/show_bug.cgi?id=16130.

        Opacity, transforms, reflections and masks should not honor z-index unless the element is also
        positioned.  Always reset to auto if the element is not positioned (and then the following code will
        adjust auto to 0 as needed).

        Reviewed by Dan Bernstein

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle):

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

LayoutTests/fast/layers/opacity-stacking.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/layers/opacity-stacking-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp

diff --git a/LayoutTests/fast/layers/opacity-stacking.html b/LayoutTests/fast/layers/opacity-stacking.html
new file mode 100644 (file)
index 0000000..71229bd
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <title></title>
+       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<style type="text/css">
+
+
+#stackA {
+       opacity: 0.66; 
+       z-index: 2; 
+       background: red; 
+       width: 300px; 
+       height: 300px;
+       }
+
+#stackB {
+       opacity: 0.90; 
+       background: blue; 
+       margin-top: -150px; 
+       width: 150px; 
+       height: 300px;
+       }
+
+</style>
+</head>
+
+<body>
+       <div id="stackA"></div>
+
+       <div id="stackB"></div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/layers/opacity-stacking-expected.txt b/LayoutTests/platform/mac/fast/layers/opacity-stacking-expected.txt
new file mode 100644 (file)
index 0000000..370662a
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x466
+  RenderBlock {HTML} at (0,0) size 800x466
+    RenderBody {BODY} at (8,8) size 784x450
+layer at (8,8) size 300x300
+  RenderBlock {DIV} at (0,0) size 300x300 [bgcolor=#FF0000]
+layer at (8,158) size 150x300
+  RenderBlock {DIV} at (0,150) size 150x300 [bgcolor=#0000FF]
index 9a7e357..b949cf3 100644 (file)
@@ -1,3 +1,16 @@
+2008-05-14  David Hyatt  <hyatt@apple.com>
+
+        Fix for bug https://bugs.webkit.org/show_bug.cgi?id=16130.
+
+        Opacity, transforms, reflections and masks should not honor z-index unless the element is also
+        positioned.  Always reset to auto if the element is not positioned (and then the following code will
+        adjust auto to 0 as needed).
+
+        Reviewed by Dan Bernstein
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::adjustRenderStyle):
+
 2008-05-14  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Brady.
index 515a1e6..b9a53a1 100644 (file)
@@ -1181,9 +1181,8 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
             style->setPosition(StaticPosition);
     }
 
-    // Make sure our z-index value is only applied if the object is positioned,
-    // relatively positioned, transparent, or has a transform/mask/reflection.
-    if (style->position() == StaticPosition && style->opacity() == 1.0f && !style->hasTransform() && !style->hasMask() && !style->boxReflect())
+    // Make sure our z-index value is only applied if the object is positioned.
+    if (style->position() == StaticPosition)
         style->setHasAutoZIndex();
 
     // Auto z-index becomes 0 for the root element and transparent objects.  This prevents