Commit f2bba0c6 authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

point-base hit-test after touch adjustment in root frame

On touch adjustment, we do a point-base hit test after the rect-base one
to make sure we find the correct target. This cl changes the point-base
hit test from the iframe to the root frame. Because when we have iframe
overlap by other elements, rect-base hit test might result an incorrect
target in the iframe. In-frame hit-test cannot find the correct target
that is outside the iframe. So, we should do the point-base hit-test on
root-frame to find the correct target.

Bug: 864849
Change-Id: Ib176a68e5c51eba40c504ad90190bec7fb66dccb
Reviewed-on: https://chromium-review.googlesource.com/1145477Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577946}
parent b85b6cdd
<!DOCTYPE html>
<html>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<style type="text/css">
body {
margin: 0;
}
#box1{
position: fixed;
bottom: 96px;
left: 0;
right: 0;
height: 100px;
background-color: #1976D2;
z-index: 101;
}
#box2 {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 100px;
background-color: #03A9F4;
z-index: 100;
}
</style>
<body>
<div id="box1"></div>
<div id="box2"></div>
<script>
var outerCount = 0;
var innerCount = 0;
document.addEventListener("click", function(event) {
outerCount++;
})
function createIframe() {
var fr = document.createElement('iframe');
fr.frameborder="0";
fr.style.height = (window.innerHeight - 50) + "px";
fr.style.width = "100%";
document.body.appendChild(fr);
fr.contentDocument.body.innerHTML = '<div id="target" style="margin: 0px; width: 100%; height: ' + window.innerHeight + 'px; background-color:red"></div>';
fr.contentDocument.getElementById("target").addEventListener("click", function(event) {
innerCount++;
})
}
promise_test (async() => {
createIframe();
await touchTapOn(innerWidth / 2, window.innerHeight - 100);
assert_equals(innerCount, 0);
assert_equals(outerCount, 1);
})
</script>
</body>
</html>
...@@ -236,6 +236,21 @@ function mouseDragAndDrop(start_x, start_y, end_x, end_y, button = 'left') { ...@@ -236,6 +236,21 @@ function mouseDragAndDrop(start_x, start_y, end_x, end_y, button = 'left') {
}); });
} }
function touchTapOn(xPosition, yPosition) {
return new Promise(function(resolve, reject) {
if (window.chrome && chrome.gpuBenchmarking) {
chrome.gpuBenchmarking.pointerActionSequence( [
{source: 'touch',
actions: [
{ name: 'pointerDown', x: xPosition, y: yPosition },
{ name: 'pointerUp' }
]}], resolve);
} else {
reject();
}
});
}
function approx_equals(actual, expected, epsilon) { function approx_equals(actual, expected, epsilon) {
return actual >= expected - epsilon && actual <= expected + epsilon; return actual >= expected - epsilon && actual <= expected + epsilon;
} }
\ No newline at end of file
...@@ -1766,10 +1766,9 @@ GestureEventWithHitTestResults EventHandler::HitTestResultForGestureEvent( ...@@ -1766,10 +1766,9 @@ GestureEventWithHitTestResults EventHandler::HitTestResultForGestureEvent(
LocalFrame* hit_frame = hit_test_result.InnerNodeFrame(); LocalFrame* hit_frame = hit_test_result.InnerNodeFrame();
if (!hit_frame) if (!hit_frame)
hit_frame = frame_; hit_frame = frame_;
location = HitTestLocation(hit_frame->View()->ConvertFromRootFrame( location = HitTestLocation(adjusted_event.PositionInRootFrame());
LayoutPoint(adjusted_event.PositionInRootFrame()))); hit_test_result = root_frame.GetEventHandler().HitTestResultAtLocation(
hit_test_result = EventHandlingUtil::HitTestResultInFrame( location,
hit_frame, location,
(hit_type | HitTestRequest::kReadOnly) & ~HitTestRequest::kListBased); (hit_type | HitTestRequest::kReadOnly) & ~HitTestRequest::kListBased);
} }
// If we did a rect-based hit test it must be resolved to the best single node // If we did a rect-based hit test it must be resolved to the best single node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment