2009-03-09 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2009 17:01:29 +0000 (17:01 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2009 17:01:29 +0000 (17:01 +0000)
        Reviewed by Dave Hyatt

        https://bugs.webkit.org/show_bug.cgi?id=24433

        During hit testing with transforms, if a layer has backface-visibility: hidden,
        we need to check for it whether or not the layer has a transform, because it
        might be an ancestor that is transformed.

        Test: transforms/3d/hit-testing/backface-no-transform-hit-test.html

        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::hitTestLayer):

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/transforms/3d/hit-testing/backface-no-transform-hit-test-expected.txt [new file with mode: 0644]
LayoutTests/transforms/3d/hit-testing/backface-no-transform-hit-test.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderLayer.cpp

index 89963fb..3dbba11 100644 (file)
@@ -1,3 +1,15 @@
+2009-03-09  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dave Hyatt
+
+        https://bugs.webkit.org/show_bug.cgi?id=24433
+
+        Test hit testing with backface-visibility: hidden, and a transform on
+        the parent element.
+
+        * platform/mac/transforms/3d/hit-testing/backface-no-transform-hit-test-expected.txt: Added.
+        * transforms/3d/hit-testing/backface-no-transform-hit-test.html: Added.
+
 2009-03-08  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Rubber-stamped by Mark Rowe.
diff --git a/LayoutTests/platform/mac/transforms/3d/hit-testing/backface-no-transform-hit-test-expected.txt b/LayoutTests/platform/mac/transforms/3d/hit-testing/backface-no-transform-hit-test-expected.txt
new file mode 100644 (file)
index 0000000..1e266ac
--- /dev/null
@@ -0,0 +1,28 @@
+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
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 755x18
+          text run at (0,0) width 755: "There are two boxes inside a container that is rotated 180\x{B0} in Y. box2 has backface-visibility: hidden, so you can't see it."
+      RenderBlock {DIV} at (0,236) size 784x36
+        RenderText {#text} at (0,0) size 194x18
+          text run at (0,0) width 194: "Found container on left: PASS"
+        RenderBR {BR} at (194,14) size 0x0
+        RenderText {#text} at (0,18) size 177x18
+          text run at (0,18) width 177: "Found box1 on right: PASS"
+        RenderBR {BR} at (177,32) size 0x0
+layer at (8,42) size 402x202
+  RenderBlock {DIV} at (0,34) size 402x202 [bgcolor=#EEEEEE] [border: (1px solid #000000)]
+    RenderText {#text} at (197,34) size 4x18
+      text run at (197,34) width 4: " "
+    RenderText {#text} at (0,0) size 0x0
+layer at (27,61) size 160x160
+  RenderBlock (relative positioned) {DIV} at (19,19) size 160x160 [bgcolor=#808080]
+    RenderText {#text} at (48,0) size 64x37
+      text run at (48,0) width 64: "box1"
+layer at (227,61) size 160x160
+  RenderBlock (relative positioned) {DIV} at (219,19) size 160x160 [bgcolor=#808080]
+    RenderText {#text} at (48,0) size 64x37
+      text run at (48,0) width 64: "box2"
diff --git a/LayoutTests/transforms/3d/hit-testing/backface-no-transform-hit-test.html b/LayoutTests/transforms/3d/hit-testing/backface-no-transform-hit-test.html
new file mode 100644 (file)
index 0000000..4b5d79a
--- /dev/null
@@ -0,0 +1,71 @@
+<html>
+<head>
+  <title>Hit testing on backface</title>
+  <style type="text/css" media="screen">
+  
+  div:hover {
+    outline: 4px solid orange;
+  }
+    #container {
+      width: 400px;
+      height: 200px;
+      background-color: #EEE;
+      border: 1px solid black;
+      -webkit-transform-style: preserve-3d;
+      -webkit-transform: translateZ(1px) rotateY(180deg);
+    }
+    
+    .box {
+      position: relative;
+      display: inline-block;
+      width: 160px;
+      height: 160px;
+      background-color: gray;
+      margin: 18px;
+      font-size: 200%;
+      text-align: center;
+    }
+    
+  </style>
+  <script type="text/javascript" charset="utf-8">
+    function log(s)
+    {
+      var results = document.getElementById('results');
+      results.innerHTML += s + '<br>';
+    }
+
+    function runTest()
+    {
+      var firstHit = document.elementFromPoint(120, 150);
+      var secondHit = document.elementFromPoint(300, 150);
+      
+      var box1 = document.getElementById('box1');
+      var box2 = document.getElementById('box1');
+      var container = document.getElementById('container');
+
+      if (firstHit == container)
+        log('Found container on left: PASS');
+      else
+        log('Found ' + firstHit.id + ' on left: FAIL');
+
+        if (secondHit == box1)
+          log('Found box1 on right: PASS');
+        else
+          log('Found ' + secondHit.id + ' on right: FAIL');
+    }
+    
+  </script>
+</head>
+<body onload="runTest()">
+
+<p>There are two boxes inside a container that is rotated 180&deg; in Y. box2 has backface-visibility: hidden, so you can't see it.</p>
+<div id="container">
+  <div class="box" id="box1">box1</div>
+  <div class="box" id="box2" style="-webkit-backface-visibility: hidden;">box2</div>
+</div>
+
+<div id="results">
+</div>
+
+</body>
+</html>
index 659a8c2..9ef1d9a 100644 (file)
@@ -1,3 +1,18 @@
+2009-03-09  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dave Hyatt
+
+        https://bugs.webkit.org/show_bug.cgi?id=24433
+        
+        During hit testing with transforms, if a layer has backface-visibility: hidden,
+        we need to check for it whether or not the layer has a transform, because it
+        might be an ancestor that is transformed.
+
+        Test: transforms/3d/hit-testing/backface-no-transform-hit-test.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::hitTestLayer):
+
 2009-03-09  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by George Staikos.
index 0c702e9..65239a7 100644 (file)
@@ -2220,14 +2220,6 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont
         if (!newTransformState->m_accumulatedTransform.isInvertible())
             return 0;
 
-        // Check for hit test on backface if backface-visibility is 'hidden'
-        if (renderer()->style()->backfaceVisibility() == BackfaceVisibilityHidden) {
-            TransformationMatrix invertedMatrix = newTransformState->m_accumulatedTransform.inverse();
-            // If the z-vector of the matrix is negative, the back is facing towards the viewer.
-            if (invertedMatrix.m33() < 0)
-                return 0;
-        }
-
         // Compute the point and the hit test rect in the coords of this layer by using the values
         // from the transformState, which store the point and quad in the coords of the last flattened
         // layer, and the accumulated transform which lets up map through preserve-3d layers.
@@ -2255,6 +2247,14 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont
         localTransformState = createLocalTransformState(rootLayer, containerLayer, hitTestRect, hitTestPoint, transformState);
     }
 
+    // Check for hit test on backface if backface-visibility is 'hidden'
+    if (localTransformState && renderer()->style()->backfaceVisibility() == BackfaceVisibilityHidden) {
+        TransformationMatrix invertedMatrix = localTransformState->m_accumulatedTransform.inverse();
+        // If the z-vector of the matrix is negative, the back is facing towards the viewer.
+        if (invertedMatrix.m33() < 0)
+            return 0;
+    }
+
     RefPtr<HitTestingTransformState> unflattenedTransformState = localTransformState;
     if (localTransformState && !preserves3D()) {
         // Keep a copy of the pre-flattening state, for computing z-offsets for the container