From 870da02623d20de2df1664685edd45be80904b73 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 12 Dec 2014 09:25:48 -0800 Subject: [PATCH] Fix hit-testing It was broken during removal of RenderLayer::collectFragments: https://codereview.chromium.org/778043005/ R=esprehn@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/791933004 --- engine/core/rendering/RenderLayer.cpp | 4 +-- .../document-elementFromPoint-expected.txt | 5 ++++ tests/layout/document-elementFromPoint.sky | 26 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/layout/document-elementFromPoint-expected.txt create mode 100644 tests/layout/document-elementFromPoint.sky diff --git a/engine/core/rendering/RenderLayer.cpp b/engine/core/rendering/RenderLayer.cpp index 4a2072f0435..640076b6cd2 100644 --- a/engine/core/rendering/RenderLayer.cpp +++ b/engine/core/rendering/RenderLayer.cpp @@ -1511,7 +1511,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont clipper().calculateRects(clipRectsContext, hitTestRect, layerBounds, backgroundRect, foregroundRect, outlineRect); // Next we want to see if the mouse pos is inside the child RenderObjects of the layer. - if (isSelfPaintingLayer() && !foregroundRect.intersects(hitTestLocation)) { + if (isSelfPaintingLayer() && foregroundRect.intersects(hitTestLocation)) { // Hit test with a temporary HitTestResult, because we only want to commit to 'result' if we know we're frontmost. HitTestResult tempResult(result.hitTestLocation()); if (hitTestContents(request, tempResult, layerBounds, hitTestLocation, HitTestDescendants) @@ -1542,7 +1542,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont if (candidateLayer) return candidateLayer; - if (isSelfPaintingLayer() && !backgroundRect.intersects(hitTestLocation)) { + if (isSelfPaintingLayer() && backgroundRect.intersects(hitTestLocation)) { HitTestResult tempResult(result.hitTestLocation()); if (hitTestContents(request, tempResult, layerBounds, hitTestLocation, HitTestSelf) && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) { diff --git a/tests/layout/document-elementFromPoint-expected.txt b/tests/layout/document-elementFromPoint-expected.txt new file mode 100644 index 00000000000..3f433590790 --- /dev/null +++ b/tests/layout/document-elementFromPoint-expected.txt @@ -0,0 +1,5 @@ +Running 1 tests +ok 1 elementFromPoint should hit test +1 tests +1 pass +0 fail diff --git a/tests/layout/document-elementFromPoint.sky b/tests/layout/document-elementFromPoint.sky new file mode 100644 index 00000000000..e4c12af9e23 --- /dev/null +++ b/tests/layout/document-elementFromPoint.sky @@ -0,0 +1,26 @@ + + + + + + +