Bug 376679 part.6 nsPluginInstanceOwner::ProcessEvent() should refer both deltaMode and system scroll amount settings when it generates WM_MOSUE*WHEEL messages r=jimm

This commit is contained in:
Masayuki Nakano 2015-10-16 13:19:27 +09:00
Родитель 41c2c97fb2
Коммит b65ae81de5
1 изменённых файлов: 62 добавлений и 13 удалений

Просмотреть файл

@ -72,6 +72,9 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#ifndef WM_MOUSEHWHEEL #ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL (0x020E) #define WM_MOUSEHWHEEL (0x020E)
#endif #endif
#ifndef SPI_GETWHEELSCROLLCHARS
#define SPI_GETWHEELSCROLLCHARS (0x006C)
#endif
#endif #endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
@ -2088,25 +2091,71 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// generate legacy resolution wheel messages. I.e., the delta value // generate legacy resolution wheel messages. I.e., the delta value
// should be WHEEL_DELTA * n. // should be WHEEL_DELTA * n.
case eWheel: { case eWheel: {
// XXX Currently assuming that users don't change system settings of
// wheel scroll amount. This is going to be fixed in following
// patch.
static const int32_t kLinesPerWheelDelta = 3;
static const int32_t kCharsPerWheelDelta = 3;
const WidgetWheelEvent* wheelEvent = anEvent.AsWheelEvent(); const WidgetWheelEvent* wheelEvent = anEvent.AsWheelEvent();
int32_t delta = 0; int32_t delta = 0;
if (wheelEvent->lineOrPageDeltaY) { if (wheelEvent->lineOrPageDeltaY) {
pluginEvent.event = WM_MOUSEWHEEL; switch (wheelEvent->deltaMode) {
delta = case nsIDOMWheelEvent::DOM_DELTA_PAGE:
-WHEEL_DELTA / kLinesPerWheelDelta * wheelEvent->lineOrPageDeltaY; pluginEvent.event = WM_MOUSEWHEEL;
delta = -WHEEL_DELTA * wheelEvent->lineOrPageDeltaY;
break;
case nsIDOMWheelEvent::DOM_DELTA_LINE: {
UINT linesPerWheelDelta = 0;
if (NS_WARN_IF(!::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
&linesPerWheelDelta, 0))) {
// Use system default scroll amount, 3, when
// SPI_GETWHEELSCROLLLINES isn't available.
linesPerWheelDelta = 3;
}
if (!linesPerWheelDelta) {
break;
}
pluginEvent.event = WM_MOUSEWHEEL;
delta = -WHEEL_DELTA / linesPerWheelDelta *
wheelEvent->lineOrPageDeltaY;
break;
}
case nsIDOMWheelEvent::DOM_DELTA_PIXEL:
default:
// We don't support WM_GESTURE with this path.
MOZ_ASSERT(!pluginEvent.event);
break;
}
} else if (wheelEvent->lineOrPageDeltaX) { } else if (wheelEvent->lineOrPageDeltaX) {
pluginEvent.event = WM_MOUSEHWHEEL; switch (wheelEvent->deltaMode) {
delta = case nsIDOMWheelEvent::DOM_DELTA_PAGE:
WHEEL_DELTA / kCharsPerWheelDelta * wheelEvent->lineOrPageDeltaX; pluginEvent.event = WM_MOUSEHWHEEL;
} else { delta = -WHEEL_DELTA * wheelEvent->lineOrPageDeltaX;
break;
case nsIDOMWheelEvent::DOM_DELTA_LINE: {
pluginEvent.event = WM_MOUSEHWHEEL;
UINT charsPerWheelDelta = 0;
// FYI: SPI_GETWHEELSCROLLCHARS is available on Vista or later.
if (::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
&charsPerWheelDelta, 0)) {
// Use system default scroll amount, 3, when
// SPI_GETWHEELSCROLLCHARS isn't available.
charsPerWheelDelta = 3;
}
if (!charsPerWheelDelta) {
break;
}
delta =
WHEEL_DELTA / charsPerWheelDelta * wheelEvent->lineOrPageDeltaX;
break;
}
case nsIDOMWheelEvent::DOM_DELTA_PIXEL:
default:
// We don't support WM_GESTURE with this path.
MOZ_ASSERT(!pluginEvent.event);
break;
}
}
if (!pluginEvent.event) {
break; break;
} }
initWParamWithCurrentState = false; initWParamWithCurrentState = false;
int32_t modifiers = int32_t modifiers =
(wheelEvent->IsControl() ? MK_CONTROL : 0) | (wheelEvent->IsControl() ? MK_CONTROL : 0) |