Commit 9046f7bc authored by Sahir Vellani's avatar Sahir Vellani Committed by Commit Bot

Ensure cursor hover state is recomputed every frame for OOPIFs

Currently, the cursor/hover doesn't update after scroll or layout
changes in an OOPIF, unless a subsequent mouse move is sent. Therefore,
we should check to see whether the mouse hover state should be updated
at BeginMainFrame.

Bug: 1126198
Change-Id: I3bea312d0687a3b7f125eb35553ea58d3dda9247
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2406669Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Reviewed-by: default avatarOlga Gerchikov <gerchiko@microsoft.com>
Commit-Queue: Sahir Vellani <sahir.vellani@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#810337}
parent 516d9c40
...@@ -300,8 +300,16 @@ void WebFrameWidgetImpl::BeginMainFrame(base::TimeTicks last_frame_time) { ...@@ -300,8 +300,16 @@ void WebFrameWidgetImpl::BeginMainFrame(base::TimeTicks last_frame_time) {
if (!LocalRootImpl()) if (!LocalRootImpl())
return; return;
// Dirty bit on MouseEventManager is not cleared in OOPIFs after scroll
// or layout changes. Ensure the hover state is recomputed if necessary.
LocalRootImpl()
->GetFrame()
->GetEventHandler()
.RecomputeMouseHoverStateIfNeeded();
DocumentLifecycle::AllowThrottlingScope throttling_scope( DocumentLifecycle::AllowThrottlingScope throttling_scope(
LocalRootImpl()->GetFrame()->GetDocument()->Lifecycle()); LocalRootImpl()->GetFrame()->GetDocument()->Lifecycle());
if (WidgetBase::ShouldRecordBeginMainFrameMetrics()) { if (WidgetBase::ShouldRecordBeginMainFrameMetrics()) {
SCOPED_UMA_AND_UKM_TIMER( SCOPED_UMA_AND_UKM_TIMER(
LocalRootImpl()->GetFrame()->View()->EnsureUkmAggregator(), LocalRootImpl()->GetFrame()->View()->EnsureUkmAggregator(),
......
...@@ -6369,6 +6369,7 @@ crbug.com/1053861 http/tests/devtools/network/network-initiator-chain.js [ Pass ...@@ -6369,6 +6369,7 @@ crbug.com/1053861 http/tests/devtools/network/network-initiator-chain.js [ Pass
crbug.com/1057822 http/tests/misc/synthetic-gesture-initiated-in-cross-origin-frame.html [ Pass Failure Crash ] crbug.com/1057822 http/tests/misc/synthetic-gesture-initiated-in-cross-origin-frame.html [ Pass Failure Crash ]
crbug.com/1057807 http/tests/misc/destroy-middle-click-locked-target-crash.html [ Pass Timeout ] crbug.com/1057807 http/tests/misc/destroy-middle-click-locked-target-crash.html [ Pass Timeout ]
crbug.com/1131977 [ Mac ] http/tests/misc/hover-state-recomputed-on-main-frame.html [ Timeout ]
crbug.com/1057351 virtual/threaded-no-composited-antialiasing/animations/responsive/interpolation/offset-rotate-responsive.html [ Pass Failure ] crbug.com/1057351 virtual/threaded-no-composited-antialiasing/animations/responsive/interpolation/offset-rotate-responsive.html [ Pass Failure ]
crbug.com/1057351 virtual/threaded-no-composited-antialiasing/animations/stability/empty-keyframes.html [ Pass Failure ] crbug.com/1057351 virtual/threaded-no-composited-antialiasing/animations/stability/empty-keyframes.html [ Pass Failure ]
......
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
.oop-iframe {
width: 300px;
height: 300px;
}
</style>
<iframe id="target-iframe" class="oop-iframe"
src="http://localhost:8080/misc/resources/cross-origin-iframe-for-hover-state-refresh.html">
</iframe>
<script>
// Check that cursor hover state is updated after changes to layout or scroll
// in OOPIFs.
var hover_test = async_test("Verify that cursor/hover updates after"
+ " scroll/layout changes in OOPIF");
var iframe = document.getElementById("target-iframe");
iframe.onload = startTest;
let state = 0;
function startTest() {
if (!internals.isSiteIsolated(iframe)) {
hover_test.name = "No site isolation - test skipped"
hover_test.done();
return;
}
else {
window.addEventListener("message", handleMessage);
iframe.contentWindow.postMessage("clickiframe", "*");
}
}
function handleMessage(event) {
if (state == 0) {
assert_equals("mouseover", event.data);
state++;
} else if (state == 1) {
assert_equals("mouseout", event.data);
hover_test.done();
}
}
</script>
<html>
<script src='/js-test-resources/gesture-util.js'></script>
<style>
.cursor_holder {
cursor: pointer;
height: 150px;
width: 150px;
background-color: green;
}
</style>
<body onclick="changeCursor()">
<div class="cursor_holder" id="cursor_holder" style="margin-left: 0px;">
I am iframe
</div>
<script>
var element = document.getElementById("cursor_holder");
var port;
element.addEventListener('mouseover', function (e) {
if (port) {
port.postMessage("mouseover", "*");
} else{
parent.postMessage("mouseover", "*");
}
});
element.addEventListener('mouseout', function (e) {
if (port) {
port.postMessage("mouseout", "*");
} else{
parent.postMessage("mouseout", "*");
}
});
function changeCursor() {
document.getElementById("cursor_holder").style.marginLeft = "200px";
}
window.addEventListener("message", async (event) => {
port = event.source;
if (event.data == "clickiframe") {
await mouseMoveTo(30, 30);
await mouseClickOn(30, 30);
}
});
</script>
</body>
</html>
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