Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Unified Diff: third_party/WebKit/Source/core/input/MouseEventManager.cpp

Issue 2956023004: Add a flag to update hover effect when a layout is changed (Closed)
Patch Set: hover layout Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/MouseEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/MouseEventManager.cpp b/third_party/WebKit/Source/core/input/MouseEventManager.cpp
index e4a1ec7df78bfad490fc49ea7b359e7fa48cdcce..5d9f2b465a39681309c10be8cc00add88f7e823d 100644
--- a/third_party/WebKit/Source/core/input/MouseEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/MouseEventManager.cpp
@@ -56,7 +56,11 @@ String CanvasRegionId(Node* node, const WebMouseEvent& mouse_event) {
// The amount of time to wait before sending a fake mouse event triggered
// during a scroll.
-const double kFakeMouseMoveInterval = 0.1;
+const double kFakeMouseMoveIntervalDuringScroll = 0.1;
+
+// The amount of time to wait before sending a fake mouse event on style and
+// layout changes sets to 50Hz, same as common screen refresh rate.
+const double kFakeMouseMoveIntervalPerFrame = 0.02;
dtapuska 2017/06/28 19:15:17 I believe constexpr is preferred
lanwei 2017/07/04 18:37:15 Done.
// TODO(crbug.com/653490): Read these values from the OS.
#if OS(MACOSX)
@@ -581,7 +585,8 @@ void MouseEventManager::SetLastKnownMousePosition(const WebMouseEvent& event) {
last_known_mouse_global_position_ = event.PositionInScreen();
}
-void MouseEventManager::DispatchFakeMouseMoveEventSoon() {
+void MouseEventManager::DispatchFakeMouseMoveEventSoon(
+ DispatchInterval dispatch_interval) {
if (mouse_pressed_)
dtapuska 2017/06/28 19:15:18 So if mouse is pressed or cursor isn't known then
lanwei 2017/07/04 18:37:15 We should update hover states and mouse cursor whe
return;
@@ -590,8 +595,12 @@ void MouseEventManager::DispatchFakeMouseMoveEventSoon() {
// Reschedule the timer, to prevent dispatching mouse move events
// during a scroll. This avoids a potential source of scroll jank.
- fake_mouse_move_event_timer_.StartOneShot(kFakeMouseMoveInterval,
- BLINK_FROM_HERE);
+ // Or dispatch a fake mouse move to update hover states when the layout
+ // changes.
+ double interval = dispatch_interval == DispatchInterval::kDuringScroll
+ ? kFakeMouseMoveIntervalDuringScroll
+ : kFakeMouseMoveIntervalPerFrame;
+ fake_mouse_move_event_timer_.StartOneShot(interval, BLINK_FROM_HERE);
}
void MouseEventManager::DispatchFakeMouseMoveEventSoonInQuad(
@@ -604,7 +613,7 @@ void MouseEventManager::DispatchFakeMouseMoveEventSoonInQuad(
view->RootFrameToContents(last_known_mouse_position_)))
return;
- DispatchFakeMouseMoveEventSoon();
+ DispatchFakeMouseMoveEventSoon(DispatchInterval::kDuringScroll);
}
WebInputEventResult MouseEventManager::HandleMousePressEvent(
@@ -1097,4 +1106,8 @@ bool MouseEventManager::MouseDownMayStartDrag() {
return mouse_down_may_start_drag_;
}
+bool MouseEventManager::FakeMouseMovePending() {
+ return fake_mouse_move_event_timer_.IsActive();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698