Title: [125306] trunk
Revision
125306
Author
[email protected]
Date
2012-08-10 11:42:38 -0700 (Fri, 10 Aug 2012)

Log Message

[Transforms] Hit test issue with large scale() transform
https://bugs.webkit.org/show_bug.cgi?id=23170

Reviewed by Simon Fraser.

Source/WebCore:

By using normal rounding to determine the top-left corner of the
hit-tested rectangle, we end up offsetting the hit test by up to
half a pixel, once scaled to x60, this creates a 30px error.

Normal rounding is replaced with floored rounding which means the
hit-tested pixel will now always be the pixel containing the
point.

Test: fast/transforms/hit-test-large-scale.html

* rendering/HitTestResult.cpp:
(WebCore::HitTestPoint::HitTestPoint):
(WebCore::HitTestPoint::intersectsRect):
(WebCore::HitTestPoint::rectForPoint):

LayoutTests:

New test checking that we can hit the bottom-right part of an element with
a large scale transformation.

Modified test-input on perspective-clipped.html, since it was mathematically
0.1px inside the transformed target, but used to miss due to bad rounding.

* fast/transforms/hit-test-large-scale-expected.txt: Added.
* fast/transforms/hit-test-large-scale.html: Added.
* transforms/3d/hit-testing/perspective-clipped-expected.txt:
* transforms/3d/hit-testing/perspective-clipped.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125305 => 125306)


--- trunk/LayoutTests/ChangeLog	2012-08-10 18:40:46 UTC (rev 125305)
+++ trunk/LayoutTests/ChangeLog	2012-08-10 18:42:38 UTC (rev 125306)
@@ -1,3 +1,21 @@
+2012-08-10  Allan Sandfeld Jensen  <[email protected]>
+
+        [Transforms] Hit test issue with large scale() transform
+        https://bugs.webkit.org/show_bug.cgi?id=23170
+
+        Reviewed by Simon Fraser.
+
+        New test checking that we can hit the bottom-right part of an element with
+        a large scale transformation.
+
+        Modified test-input on perspective-clipped.html, since it was mathematically
+        0.1px inside the transformed target, but used to miss due to bad rounding.
+
+        * fast/transforms/hit-test-large-scale-expected.txt: Added.
+        * fast/transforms/hit-test-large-scale.html: Added.
+        * transforms/3d/hit-testing/perspective-clipped-expected.txt:
+        * transforms/3d/hit-testing/perspective-clipped.html:
+
 2012-08-10  Takashi Sakamoto  <[email protected]>
 
         box-shadow creates incorrect shadow when border-radius is too large.

Added: trunk/LayoutTests/fast/transforms/hit-test-large-scale-expected.txt (0 => 125306)


--- trunk/LayoutTests/fast/transforms/hit-test-large-scale-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/transforms/hit-test-large-scale-expected.txt	2012-08-10 18:42:38 UTC (rev 125306)
@@ -0,0 +1,3 @@
+The blue box only responds to hover over some of its area. It has a scale() transform
+
+PASS

Added: trunk/LayoutTests/fast/transforms/hit-test-large-scale.html (0 => 125306)


--- trunk/LayoutTests/fast/transforms/hit-test-large-scale.html	                        (rev 0)
+++ trunk/LayoutTests/fast/transforms/hit-test-large-scale.html	2012-08-10 18:42:38 UTC (rev 125306)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.testRunner)
+        window.testRunner.dumpAsText()
+
+    function runTest()
+    {
+        document.body.offsetWidth;
+        var elt = document.elementFromPoint(130, 130);
+        if (elt == document.getElementById('progress'))
+            document.getElementById('console').innerHTML = 'PASS';
+        else
+            document.getElementById('console').innerHTML = 'FAIL';
+    }
+</script>
+<style type="text/css">
+    #progress {
+        width: 2px;
+        height: 2px;
+        margin: 10px;
+        -webkit-transform: scale(60);
+        -webkit-transform-origin: 0 0;
+        background-color: blue;
+    }
+
+    #progress:hover {
+        background-color: red;
+    }
+</style>
+</head>
+<body _onload_="runTest()">
+    <p>The blue box only responds to hover over some of its area. It has a scale() transform</p>
+    <div id="progress"></div>
+
+    <div id="console"></div>
+</body>
+</html>

Modified: trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped-expected.txt (125305 => 125306)


--- trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped-expected.txt	2012-08-10 18:40:46 UTC (rev 125305)
+++ trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped-expected.txt	2012-08-10 18:42:38 UTC (rev 125306)
@@ -9,5 +9,5 @@
 Element at 35, 260 has id "bottomLayer": PASS
 Element at 370, 280 has id "bottomLayer": PASS
 Element at 35, 340 has id "backgroundLayer": PASS
-Element at 370, 340 has id "backgroundLayer": PASS
+Element at 371, 340 has id "backgroundLayer": PASS
 

Modified: trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped.html (125305 => 125306)


--- trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped.html	2012-08-10 18:40:46 UTC (rev 125305)
+++ trunk/LayoutTests/transforms/3d/hit-testing/perspective-clipped.html	2012-08-10 18:42:38 UTC (rev 125306)
@@ -79,7 +79,7 @@
 
         // Points within the axis-aligned bounding box of the bottom layer, but not actually on the layer itself
         { 'point': [35, 340], 'target' : 'backgroundLayer' },
-        { 'point': [370, 340], 'target' : 'backgroundLayer' },
+        { 'point': [371, 340], 'target' : 'backgroundLayer' },
       ];
 
       window.addEventListener('load', runTest, false);

Modified: trunk/Source/WebCore/ChangeLog (125305 => 125306)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 18:40:46 UTC (rev 125305)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 18:42:38 UTC (rev 125306)
@@ -1,3 +1,25 @@
+2012-08-10  Allan Sandfeld Jensen  <[email protected]>
+
+        [Transforms] Hit test issue with large scale() transform
+        https://bugs.webkit.org/show_bug.cgi?id=23170
+
+        Reviewed by Simon Fraser.
+
+        By using normal rounding to determine the top-left corner of the
+        hit-tested rectangle, we end up offsetting the hit test by up to
+        half a pixel, once scaled to x60, this creates a 30px error.
+
+        Normal rounding is replaced with floored rounding which means the
+        hit-tested pixel will now always be the pixel containing the
+        point.
+
+        Test: fast/transforms/hit-test-large-scale.html
+
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestPoint::HitTestPoint):
+        (WebCore::HitTestPoint::intersectsRect):
+        (WebCore::HitTestPoint::rectForPoint):
+
 2012-08-10  Florin Malita  <[email protected]>
 
         Unreviewed gardening: build fix for 32bit platforms after 125294.

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (125305 => 125306)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2012-08-10 18:40:46 UTC (rev 125305)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2012-08-10 18:42:38 UTC (rev 125306)
@@ -67,7 +67,7 @@
 }
 
 HitTestPoint::HitTestPoint(const FloatPoint& point)
-    : m_point(roundedLayoutPoint(point))
+    : m_point(flooredLayoutPoint(point))
     , m_boundingBox(rectForPoint(m_point, 0, 0, 0, 0))
     , m_transformedPoint(point)
     , m_transformedRect(m_boundingBox)
@@ -83,7 +83,7 @@
     , m_region(0)
     , m_isRectBased(true)
 {
-    m_point = roundedLayoutPoint(point);
+    m_point = flooredLayoutPoint(point);
     m_boundingBox = enclosingIntRect(quad.boundingBox());
     m_isRectilinear = quad.isRectilinear();
 }
@@ -181,7 +181,7 @@
 
 IntRect HitTestPoint::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
 {
-    IntPoint actualPoint(roundedIntPoint(point));
+    IntPoint actualPoint(flooredIntPoint(point));
     actualPoint -= IntSize(leftPadding, topPadding);
 
     IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to