Commit 5e7eacc6 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Reset hover dirty flag before RecomputeMouseHoverState function

MouseEventManager::RecomputeMouseHoverState may change the hover dirty
flag because it sends mouse boundary events such as mouseover,
mouseout, mouseenter and mouseleave, which may change the layout. We
need to reset |hover_state_dirty_| before we call
RecomputeMouseHoverState, so that we make sure that the hover is
updated for all the layout change.

Bug: 877132
Change-Id: Id6ec90e8f6ced06a68dffa1a31cd34b92294af37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1689959
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676033}
parent eb06b271
......@@ -393,9 +393,10 @@ void MouseEventManager::FakeMouseMoveEventTimerFired(TimerBase* timer) {
}
void MouseEventManager::RecomputeMouseHoverStateIfNeeded() {
// |RecomputeMouseHoverState| may set |hover_state_dirty_| to be true.
if (HoverStateDirty()) {
RecomputeMouseHoverState();
hover_state_dirty_ = false;
RecomputeMouseHoverState();
}
}
......
<!DOCTYPE html>
<script src='../../resources/gesture-util.js'></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
#blue {
background-color: rgb(0, 0, 255);
position: absolute;
left: 75px;
top: 75px;
height: 100px;
width: 100px;
}
#blue:hover {
top: 500px;
}
</style>
<div id="blue"></div>
<script>
const x = 100;
const y = 100;
var blue = document.getElementById('blue');
window.onload = async () => {
if (window.internals) {
internals.runtimeFlags.updateHoverFromLayoutChangeAtBeginFrameEnabled = true;
}
promise_test(async () => {
await mouseMoveTo(x, y);
// Move the blue element away when it is hovered, so the blue element will oscillates
// between 75px and 500px at each animation frame.
assert_true(blue.matches(':hover'), "Hover on the blue element");
assert_equals(blue.offsetTop, 500, "Check that the blue element is moved to 500px from the top");
await raf();
assert_false(blue.matches(':hover'), "The blue element is moved away from the mouse cursor after a begin frame");
assert_equals(blue.offsetTop, 75, "The blue element is moved back to 75px from the top");
await raf();
assert_true(blue.matches(':hover'), "Hover on the blue element");
assert_equals(blue.offsetTop, 500, "Check that the blue element is moved to 500px from the top");
await raf();
assert_false(blue.matches(':hover'), "The blue element is moved away from the mouse cursor after a begin frame");
assert_equals(blue.offsetTop, 75, "The blue element is moved back to 75px from the top");
}, 'The hover state is updated at the begin frame after the layout changes which is caused by hover update.');
}
</script>
\ No newline at end of file
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