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
This commit is contained in:
Eric Seidel 2014-12-12 09:25:48 -08:00
parent e55c96e96a
commit 870da02623
3 changed files with 33 additions and 2 deletions

View File

@ -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())) {

View File

@ -0,0 +1,5 @@
Running 1 tests
ok 1 elementFromPoint should hit test
1 tests
1 pass
0 fail

View File

@ -0,0 +1,26 @@
<sky>
<import src="../resources/chai.sky" />
<import src="../resources/mocha.sky" />
<style>
foo { width: 100px; height: 100px; background: blue; }
bar { width: 100px; height: 100px; background: purple; }
</style>
<foo /><bar />
<script>
describe("elementFromPoint", function() {
it("should hit test", function() {
// FIXME: We should have much better hit-testing coverage, at least:
// inline content (both sections of a wrapped run)
// text node
// flex box
// display: paragraph
// position: absolute
// position: relative
// z-order (missing, zero, positive and negative)
assert.equal(document.elementFromPoint(50, 50).tagName, 'foo')
assert.equal(document.elementFromPoint(50, 150).tagName, 'bar')
assert.equal(document.elementFromPoint(50, 250).tagName, 'sky')
});
});
</script>
</sky>