提交 e0c039e0 编写于 作者: O Ojan Vafai

Get rid of HitTestChildBlockBackground walk.

I'm not 100% what this was for, but looking at Blink,
it appears that HitTestChildBlockBackground being different
from HitTestBlockBackground had something to do with
multi-column/regions, which we don't have. I believe
this patch doesn't change any behavior.

Also added to the elementFromPoint test in order to
get more test coverage of the hitTesting code.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/924263002
上级 eca61b61
......@@ -1079,7 +1079,7 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
}
// Now hit test our background
if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) {
if (hitTestAction == HitTestBlockBackground) {
LayoutRect boundsRect(adjustedLocation, size());
if (visibleToHitTestRequest(request) && locationInContainer.intersects(boundsRect)) {
updateHitTestResult(result, locationInContainer.point() - localOffset);
......@@ -1093,12 +1093,8 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
{
// Hit test our children.
HitTestAction childHitTest = hitTestAction;
if (hitTestAction == HitTestChildBlockBackgrounds)
childHitTest = HitTestChildBlockBackground;
for (RenderBox* child = lastChildBox(); child; child = child->previousSiblingBox()) {
if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, childHitTest))
if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction))
return true;
}
......
......@@ -996,6 +996,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont
}
// Now check our overflow objects.
// TODO(ojan): This call has no test coverage.
hitLayer = hitTestChildren(NormalFlowChildren, rootLayer, request, result, hitTestRect, hitTestLocation,
localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattenedTransformState.get(), depthSortDescendants);
if (hitLayer) {
......
......@@ -1680,10 +1680,6 @@ bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result,
if (hitTestFilter != HitTestSelf) {
// First test the foreground layer (lines and inlines).
inside = nodeAtPoint(request, result, locationInContainer, accumulatedOffset, HitTestForeground);
// Finally test to see if the mouse is in the background (within a child block's background).
if (!inside)
inside = nodeAtPoint(request, result, locationInContainer, accumulatedOffset, HitTestChildBlockBackgrounds);
}
// See if the mouse is inside us but not any of our descendants
......
......@@ -76,8 +76,6 @@ enum HitTestFilter {
enum HitTestAction {
HitTestBlockBackground,
HitTestChildBlockBackground,
HitTestChildBlockBackgrounds,
HitTestForeground
};
......
CONSOLE: unittest-suite-wait-for-done
CONSOLE: PASS: should hit test
CONSOLE: PASS: should hit test child and parent
CONSOLE: PASS: should hit test child with layered parent
CONSOLE:
CONSOLE: All 1 tests passed.
CONSOLE: All 3 tests passed.
CONSOLE: unittest-suite-success
DONE
<sky>
<style>
foo { width: 100px; height: 100px; background: blue; }
foo, parent { width: 100px; height: 100px; background: blue; }
bar { width: 100px; height: 100px; background: purple; }
parent { display: paragraph; }
child { background: salmon; }
</style>
<foo /><bar />
<parent>
<child>Foo bar</child>
</parent>
<script>
import "../resources/third_party/unittest/unittest.dart";
import "../resources/unit.dart";
......@@ -24,7 +29,24 @@ void main() {
// z-order (missing, zero, positive and negative)
expect(document.elementFromPoint(50, 50).tagName, equals('foo'));
expect(document.elementFromPoint(50, 150).tagName, equals('bar'));
expect(document.elementFromPoint(50, 250).tagName, equals('sky'));
expect(document.elementFromPoint(150, 50).tagName, equals('sky'));
});
void hitTestWithChildren() {
expect(document.elementFromPoint(50, 210).tagName, equals('child'));
// Right of the <child> inline.
expect(document.elementFromPoint(95, 210).tagName, equals('parent'));
// Below the <child> inline.
expect(document.elementFromPoint(50, 275).tagName, equals('parent'));
}
test("should hit test child and parent", () {
hitTestWithChildren();
});
test("should hit test child with layered parent", () {
document.querySelector('parent').style.setProperty("transform", "translate3d(0, 0, 0)");
hitTestWithChildren();
});
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册