osr: win: Implement page scroll mode (fixes #3849)

This commit is contained in:
Andrew Kurushin 2024-12-04 11:25:10 -05:00 committed by Marshall Greenblatt
parent 189b247282
commit 2dd1d1f94b
5 changed files with 28 additions and 9 deletions

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "3e3393f10c4b95f7516521c8643b9a735fd0c3f3"
#define CEF_API_HASH_UNIVERSAL "fc1554b64e963371717ccf0a2a5e686ef06dca88"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "aafe004dac5cf8b7f0b5ef12518c4a16e150f510"
#define CEF_API_HASH_PLATFORM "3df9884666f0de7427ab99cb64c85b0e303d071e"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "9cd794a0ab4506060ca2d7b3c335778d026337a4"
#define CEF_API_HASH_PLATFORM "031cd25d4dfccd19e70133c4ed0efb6b7441b503"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "fab73fe3fddb82c0f75a404fb464935592880803"
#define CEF_API_HASH_PLATFORM "9c32d35cea06c04ed0cff861ff873fea08bf5295"
#endif
#ifdef __cplusplus

View File

@ -2075,6 +2075,8 @@ typedef enum {
EVENTFLAG_IS_RIGHT = 1 << 11,
EVENTFLAG_ALTGR_DOWN = 1 << 12,
EVENTFLAG_IS_REPEAT = 1 << 13,
EVENTFLAG_PRECISION_SCROLLING_DELTA = 1 << 14,
EVENTFLAG_SCROLL_BY_PAGE = 1 << 15,
} cef_event_flags_t;
///

View File

@ -203,8 +203,7 @@ ui::MouseWheelEvent CefBrowserPlatformDelegateNativeAura::TranslateUiWheelEvent(
int changed_button_flags =
TranslateUiChangedButtonFlags(mouse_event.modifiers);
return ui::MouseWheelEvent(offset, location, root_location, time_stamp,
(ui::EF_PRECISION_SCROLLING_DELTA | flags),
return ui::MouseWheelEvent(offset, location, root_location, time_stamp, flags,
changed_button_flags);
}
@ -266,6 +265,13 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
if (cef_modifiers & EVENTFLAG_IS_REPEAT) {
result |= ui::EF_IS_REPEAT;
}
if (cef_modifiers & EVENTFLAG_PRECISION_SCROLLING_DELTA) {
result |= ui::EF_PRECISION_SCROLLING_DELTA;
}
if (cef_modifiers & EVENTFLAG_SCROLL_BY_PAGE) {
result |= ui::EF_SCROLL_BY_PAGE;
}
return result;
}

View File

@ -1644,6 +1644,7 @@ gint BrowserWindowOsrGtk::ScrollEvent(GtkWidget* widget,
self->ApplyPopupOffset(mouse_event.x, mouse_event.y);
DeviceToLogical(mouse_event, device_scale_factor);
mouse_event.modifiers = GetCefStateModifiers(event->state);
mouse_event.modifiers |= EVENTFLAG_PRECISION_SCROLLING_DELTA;
static const int scrollbarPixelsPerGtkTick = 40;
int deltaX = 0;

View File

@ -743,6 +743,8 @@ void OsrWindowWin::OnMouseEvent(UINT message, WPARAM wParam, LPARAM lParam) {
ScreenToClient(hwnd_, &screen_point);
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
int deltaX = IsKeyDown(VK_SHIFT) ? delta : 0;
int deltaY = !IsKeyDown(VK_SHIFT) ? delta : 0;
CefMouseEvent mouse_event;
mouse_event.x = screen_point.x;
@ -750,9 +752,17 @@ void OsrWindowWin::OnMouseEvent(UINT message, WPARAM wParam, LPARAM lParam) {
ApplyPopupOffset(mouse_event.x, mouse_event.y);
DeviceToLogical(mouse_event, device_scale_factor_);
mouse_event.modifiers = GetCefMouseModifiers(wParam);
browser_host->SendMouseWheelEvent(mouse_event,
IsKeyDown(VK_SHIFT) ? delta : 0,
!IsKeyDown(VK_SHIFT) ? delta : 0);
UINT sys_info_lines;
if (SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &sys_info_lines,
0) &&
sys_info_lines == WHEEL_PAGESCROLL) {
mouse_event.modifiers |= EVENTFLAG_SCROLL_BY_PAGE;
deltaX = 0;
deltaY = (delta > 0) ? 1 : -1;
}
browser_host->SendMouseWheelEvent(mouse_event, deltaX, deltaY);
}
break;
}