Title: [120362] trunk/Source
Revision
120362
Author
shawnsi...@chromium.org
Date
2012-06-14 14:45:21 -0700 (Thu, 14 Jun 2012)

Log Message

[chromium] For hit testing in CCLayerTreeHostCommon, need to check that the transform is invertible before inverting it.
https://bugs.webkit.org/show_bug.cgi?id=89049

Reviewed by Adrienne Walker.

Source/WebCore:

Unit test added to CCLayerTreeHostCommonTest.cpp:
  CCLayerTreeHostCommonTest.verifyHitTestingForUninvertibleTransform

* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::pointHitsRect):

Source/WebKit/chromium:

* tests/CCLayerTreeHostCommonTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120361 => 120362)


--- trunk/Source/WebCore/ChangeLog	2012-06-14 21:15:52 UTC (rev 120361)
+++ trunk/Source/WebCore/ChangeLog	2012-06-14 21:45:21 UTC (rev 120362)
@@ -1,3 +1,16 @@
+2012-06-14  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] For hit testing in CCLayerTreeHostCommon, need to check that the transform is invertible before inverting it.
+        https://bugs.webkit.org/show_bug.cgi?id=89049
+
+        Reviewed by Adrienne Walker.
+
+        Unit test added to CCLayerTreeHostCommonTest.cpp:
+          CCLayerTreeHostCommonTest.verifyHitTestingForUninvertibleTransform
+
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore::pointHitsRect):
+
 2012-06-14  Maciej Stachowiak  <m...@apple.com>
 
         The whole world rebuilds when you touch any IDL file

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp (120361 => 120362)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2012-06-14 21:15:52 UTC (rev 120361)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2012-06-14 21:45:21 UTC (rev 120362)
@@ -874,6 +874,10 @@
 
 static bool pointHitsRect(const IntPoint& viewportPoint, const WebTransformationMatrix& localSpaceToScreenSpaceTransform, FloatRect localSpaceRect)
 {
+    // If the transform is not invertible, then assume that this point doesn't hit this rect.
+    if (!localSpaceToScreenSpaceTransform.isInvertible())
+        return false;
+
     // Transform the hit test point from screen space to the local space of the given rect.
     bool clipped = false;
     FloatPoint hitTestPointInLocalSpace = CCMathUtil::projectPoint(localSpaceToScreenSpaceTransform.inverse(), FloatPoint(viewportPoint), clipped);

Modified: trunk/Source/WebKit/chromium/ChangeLog (120361 => 120362)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-14 21:15:52 UTC (rev 120361)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-14 21:45:21 UTC (rev 120362)
@@ -1,3 +1,12 @@
+2012-06-14  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] For hit testing in CCLayerTreeHostCommon, need to check that the transform is invertible before inverting it.
+        https://bugs.webkit.org/show_bug.cgi?id=89049
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostCommonTest.cpp:
+
 2012-06-14  Ian Vollick  <voll...@chromium.org>
 
         [chromium] Certain settings in CCSettings could be global

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp (120361 => 120362)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2012-06-14 21:15:52 UTC (rev 120361)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2012-06-14 21:45:21 UTC (rev 120362)
@@ -2970,6 +2970,72 @@
     EXPECT_EQ(12345, resultLayer->id());
 }
 
+TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
+{
+    DebugScopedSetImplThread thisScopeIsOnImplThread;
+
+    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345);
+    root->createRenderSurface();
+    root->renderSurface()->setContentRect(IntRect(IntPoint::zero(), IntSize(100, 100)));
+
+    WebTransformationMatrix uninvertibleTransform;
+    uninvertibleTransform.setM11(0);
+    uninvertibleTransform.setM22(0);
+    uninvertibleTransform.setM33(0);
+    uninvertibleTransform.setM44(0);
+    ASSERT_FALSE(uninvertibleTransform.isInvertible());
+
+    WebTransformationMatrix identityMatrix;
+    FloatPoint anchor(0, 0);
+    FloatPoint position(0, 0);
+    IntSize bounds(100, 100);
+    setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatrix, anchor, position, bounds, false);
+    root->setDrawsContent(true);
+
+    Vector<CCLayerImpl*> renderSurfaceLayerList;
+    Vector<CCLayerImpl*> dummyLayerList;
+    int dummyMaxTextureSize = 512;
+    renderSurfaceLayerList.append(root.get());
+    CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, 0, dummyMaxTextureSize);
+    CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+
+    // Sanity check the scenario we just created.
+    ASSERT_EQ(1u, renderSurfaceLayerList.size());
+    ASSERT_EQ(1u, root->renderSurface()->layerList().size());
+    ASSERT_FALSE(root->screenSpaceTransform().isInvertible());
+
+    // Hit testing any point should not hit the layer. If the invertible matrix is
+    // accidentally ignored and treated like an identity, then the hit testing will
+    // incorrectly hit the layer when it shouldn't.
+    IntPoint testPoint(1, 1);
+    CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(10, 10);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(10, 30);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(50, 50);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(67, 48);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(99, 99);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+
+    testPoint = IntPoint(-1, -1);
+    resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+    EXPECT_FALSE(resultLayer);
+}
+
 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
 {
     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to