mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1153156 part.1 Move nsBaseWidget::OverrideSystemMouseScrollSpeed() to WidgetWheelEvent r=smaug, sr=smaug
This commit is contained in:
parent
647125db4c
commit
3b90838075
@ -419,18 +419,8 @@ WheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
|
||||
return DeltaValues(aEvent);
|
||||
}
|
||||
|
||||
// Compute the overridden speed to nsIWidget. The widget can check the
|
||||
// conditions (e.g., checking the prefs, and also whether the user customized
|
||||
// the system settings of the mouse wheel scrolling or not), and can limit
|
||||
// the speed for preventing the unexpected high speed scrolling.
|
||||
nsCOMPtr<nsIWidget> widget(sTargetFrame->GetNearestWidget());
|
||||
NS_ENSURE_TRUE(widget, DeltaValues(aEvent));
|
||||
DeltaValues overriddenDeltaValues(0.0, 0.0);
|
||||
nsresult rv =
|
||||
widget->OverrideSystemMouseScrollSpeed(aEvent->deltaX, aEvent->deltaY,
|
||||
overriddenDeltaValues.deltaX,
|
||||
overriddenDeltaValues.deltaY);
|
||||
return NS_FAILED(rv) ? DeltaValues(aEvent) : overriddenDeltaValues;
|
||||
return DeltaValues(aEvent->OverriddenDeltaX(),
|
||||
aEvent->OverriddenDeltaY());
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
@ -619,6 +619,24 @@ public:
|
||||
mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled;
|
||||
mCanTriggerSwipe = aEvent.mCanTriggerSwipe;
|
||||
}
|
||||
|
||||
// System scroll speed settings may be too slow at using Gecko. In such
|
||||
// case, we should override the scroll speed computed with system settings.
|
||||
// Following methods return preferred delta values which are multiplied by
|
||||
// factors specified by prefs. If system scroll speed shouldn't be
|
||||
// overridden (e.g., this feature is disabled by pref), they return raw
|
||||
// delta values.
|
||||
double OverriddenDeltaX() const;
|
||||
double OverriddenDeltaY() const;
|
||||
|
||||
private:
|
||||
static bool sInitialized;
|
||||
static bool sIsSystemScrollSpeedOverrideEnabled;
|
||||
static int32_t sOverrideFactorX;
|
||||
static int32_t sOverrideFactorY;
|
||||
static void Initialize();
|
||||
|
||||
static double ComputeOverriddenDelta(double aDelta, bool aIsForVertical);
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -339,6 +339,60 @@ WidgetInputEvent::AccelModifier()
|
||||
return sAccelModifier;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::WidgetWheelEvent (MouseEvents.h)
|
||||
******************************************************************************/
|
||||
|
||||
bool WidgetWheelEvent::sInitialized = false;
|
||||
bool WidgetWheelEvent::sIsSystemScrollSpeedOverrideEnabled = false;
|
||||
int32_t WidgetWheelEvent::sOverrideFactorX = 0;
|
||||
int32_t WidgetWheelEvent::sOverrideFactorY = 0;
|
||||
|
||||
/* static */ void
|
||||
WidgetWheelEvent::Initialize()
|
||||
{
|
||||
if (sInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
Preferences::AddBoolVarCache(&sIsSystemScrollSpeedOverrideEnabled,
|
||||
"mousewheel.system_scroll_override_on_root_content.enabled", false);
|
||||
Preferences::AddIntVarCache(&sOverrideFactorX,
|
||||
"mousewheel.system_scroll_override_on_root_content.horizontal.factor", 0);
|
||||
Preferences::AddIntVarCache(&sOverrideFactorY,
|
||||
"mousewheel.system_scroll_override_on_root_content.vertical.factor", 0);
|
||||
sInitialized = true;
|
||||
}
|
||||
|
||||
/* static */ double
|
||||
WidgetWheelEvent::ComputeOverriddenDelta(double aDelta, bool aIsForVertical)
|
||||
{
|
||||
Initialize();
|
||||
if (!sIsSystemScrollSpeedOverrideEnabled) {
|
||||
return aDelta;
|
||||
}
|
||||
int32_t intFactor = aIsForVertical ? sOverrideFactorY : sOverrideFactorX;
|
||||
// Making the scroll speed slower doesn't make sense. So, ignore odd factor
|
||||
// which is less than 1.0.
|
||||
if (intFactor <= 100) {
|
||||
return aDelta;
|
||||
}
|
||||
double factor = static_cast<double>(intFactor) / 100;
|
||||
return aDelta * factor;
|
||||
}
|
||||
|
||||
double
|
||||
WidgetWheelEvent::OverriddenDeltaX() const
|
||||
{
|
||||
return ComputeOverriddenDelta(deltaX, false);
|
||||
}
|
||||
|
||||
double
|
||||
WidgetWheelEvent::OverriddenDeltaY() const
|
||||
{
|
||||
return ComputeOverriddenDelta(deltaY, true);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::WidgetKeyboardEvent (TextEvents.h)
|
||||
******************************************************************************/
|
||||
|
@ -1527,51 +1527,6 @@ nsBaseWidget::ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect)
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
double aOriginalDeltaY,
|
||||
double& aOverriddenDeltaX,
|
||||
double& aOverriddenDeltaY)
|
||||
{
|
||||
aOverriddenDeltaX = aOriginalDeltaX;
|
||||
aOverriddenDeltaY = aOriginalDeltaY;
|
||||
|
||||
static bool sInitialized = false;
|
||||
static bool sIsOverrideEnabled = false;
|
||||
static int32_t sIntFactorX = 0;
|
||||
static int32_t sIntFactorY = 0;
|
||||
|
||||
if (!sInitialized) {
|
||||
Preferences::AddBoolVarCache(&sIsOverrideEnabled,
|
||||
"mousewheel.system_scroll_override_on_root_content.enabled", false);
|
||||
Preferences::AddIntVarCache(&sIntFactorX,
|
||||
"mousewheel.system_scroll_override_on_root_content.horizontal.factor", 0);
|
||||
Preferences::AddIntVarCache(&sIntFactorY,
|
||||
"mousewheel.system_scroll_override_on_root_content.vertical.factor", 0);
|
||||
sIntFactorX = std::max(sIntFactorX, 0);
|
||||
sIntFactorY = std::max(sIntFactorY, 0);
|
||||
sInitialized = true;
|
||||
}
|
||||
|
||||
if (!sIsOverrideEnabled) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The pref value must be larger than 100, otherwise, we don't override the
|
||||
// delta value.
|
||||
if (sIntFactorX > 100) {
|
||||
double factor = static_cast<double>(sIntFactorX) / 100;
|
||||
aOverriddenDeltaX *= factor;
|
||||
}
|
||||
if (sIntFactorY > 100) {
|
||||
double factor = static_cast<double>(sIntFactorY) / 100;
|
||||
aOverriddenDeltaY *= factor;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifies aFile to point at an icon file with the given name and suffix. The
|
||||
* suffix may correspond to a file extension with leading '.' if appropriate.
|
||||
|
@ -238,10 +238,6 @@ public:
|
||||
virtual bool ComputeShouldAccelerate();
|
||||
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override { return nsIMEUpdatePreference(); }
|
||||
NS_IMETHOD OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
double aOriginalDeltaY,
|
||||
double& aOverriddenDeltaX,
|
||||
double& aOverriddenDeltaY) override;
|
||||
virtual already_AddRefed<nsIWidget>
|
||||
CreateChild(const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr,
|
||||
|
@ -133,8 +133,8 @@ typedef void* nsNativeWidget;
|
||||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0x6dc8ce1f, 0xbb55, 0x47c1, \
|
||||
{ 0xa1, 0x6f, 0x4e, 0x12, 0x37, 0xa1, 0xc2, 0xf4 } }
|
||||
{ 0x06396bf6, 0x2dd8, 0x45e5, \
|
||||
{ 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 } }
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
@ -1896,32 +1896,6 @@ public:
|
||||
*/
|
||||
NS_IMETHOD OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) = 0;
|
||||
|
||||
/**
|
||||
* Compute the overridden system mouse scroll speed on the root content of
|
||||
* web pages. The widget may set the same value as aOriginalDelta. E.g.,
|
||||
* when the system scrolling settings were customized, widget can respect
|
||||
* the will of the user.
|
||||
*
|
||||
* This is called only when the mouse wheel event scrolls the root content
|
||||
* of the web pages by line. In other words, this isn't called when the
|
||||
* mouse wheel event is used for zoom, page scroll and other special
|
||||
* actions. And also this isn't called when the user doesn't use the
|
||||
* system wheel speed settings.
|
||||
*
|
||||
* @param aOriginalDeltaX The X delta value of the current mouse wheel
|
||||
* scrolling event.
|
||||
* @param aOriginalDeltaX The Y delta value of the current mouse wheel
|
||||
* scrolling event.
|
||||
* @param aOverriddenDeltaX The overridden mouse scrolling speed along X
|
||||
* axis. This value may be same as aOriginalDeltaX.
|
||||
* @param aOverriddenDeltaY The overridden mouse scrolling speed along Y
|
||||
* axis. This value may be same as aOriginalDeltaY.
|
||||
*/
|
||||
NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
double aOriginalDeltaY,
|
||||
double& aOverriddenDeltaX,
|
||||
double& aOverriddenDeltaY) = 0;
|
||||
|
||||
/**
|
||||
* Return true if this process shouldn't use platform widgets, and
|
||||
* so should use PuppetWidgets instead. If this returns true, the
|
||||
|
@ -3715,6 +3715,7 @@ nsWindow::OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsWindow::OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
double aOriginalDeltaY,
|
||||
@ -3800,6 +3801,7 @@ nsWindow::OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<mozilla::gfx::DrawTarget>
|
||||
nsWindow::StartRemoteDrawing()
|
||||
|
@ -172,11 +172,6 @@ public:
|
||||
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
||||
bool* aAllowRetaining = nullptr) override;
|
||||
NS_IMETHOD OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) override;
|
||||
NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
||||
double aOriginalDeltaY,
|
||||
double& aOverriddenDeltaX,
|
||||
double& aOverriddenDeltaY) override;
|
||||
|
||||
virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
||||
int32_t aNativeKeyCode,
|
||||
uint32_t aModifierFlags,
|
||||
|
Loading…
Reference in New Issue
Block a user