зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1355548 - Using cached perference values in WheelTransaction. r=masayuki
EventStateManager uses preferences of WheelTransaction frequently. Caches them to reduce overheads. MozReview-Commit-ID: HhuCKu5QVsh
This commit is contained in:
Родитель
51b34f2689
Коммит
d6d397a215
|
@ -331,6 +331,7 @@ EventStateManager::EventStateManager()
|
|||
"dom.w3c_pointer_events.enabled", false);
|
||||
sAddedPointerEventEnabled = true;
|
||||
}
|
||||
WheelTransaction::InitializeStatics();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -281,7 +281,7 @@ WheelTransaction::OnFailToScrollTarget()
|
|||
{
|
||||
NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction");
|
||||
|
||||
if (Preferences::GetBool("test.mousescroll", false)) {
|
||||
if (Prefs::sTestMouseScroll) {
|
||||
// This event is used for automated tests, see bug 442774.
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
sTargetFrame->GetContent()->OwnerDoc(),
|
||||
|
@ -310,7 +310,7 @@ WheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
|
|||
// the next DOM event might create strange situation for us.
|
||||
MayEndTransaction();
|
||||
|
||||
if (Preferences::GetBool("test.mousescroll", false)) {
|
||||
if (Prefs::sTestMouseScroll) {
|
||||
// This event is used for automated tests, see bug 442774.
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
frame->GetContent()->OwnerDoc(),
|
||||
|
@ -346,18 +346,6 @@ WheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
|
|||
return aEvent->mRefPoint + aEvent->mWidget->WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
/* static */ uint32_t
|
||||
WheelTransaction::GetTimeoutTime()
|
||||
{
|
||||
return Preferences::GetUint("mousewheel.transaction.timeout", 1500);
|
||||
}
|
||||
|
||||
/* static */ uint32_t
|
||||
WheelTransaction::GetIgnoreMoveDelayTime()
|
||||
{
|
||||
return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100);
|
||||
}
|
||||
|
||||
/* static */ DeltaValues
|
||||
WheelTransaction::AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride)
|
||||
|
@ -392,18 +380,6 @@ WheelTransaction::ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor)
|
|||
return mozilla::ComputeAcceleratedWheelDelta(aDelta, sScrollSeriesCounter, aFactor);
|
||||
}
|
||||
|
||||
/* static */ int32_t
|
||||
WheelTransaction::GetAccelerationStart()
|
||||
{
|
||||
return Preferences::GetInt("mousewheel.acceleration.start", -1);
|
||||
}
|
||||
|
||||
/* static */ int32_t
|
||||
WheelTransaction::GetAccelerationFactor()
|
||||
{
|
||||
return Preferences::GetInt("mousewheel.acceleration.factor", -1);
|
||||
}
|
||||
|
||||
/* static */ DeltaValues
|
||||
WheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
|
||||
{
|
||||
|
@ -550,4 +526,31 @@ ScrollbarsForWheel::DeactivateAllTemporarilyActivatedScrollTargets()
|
|||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* mozilla::WheelTransaction */
|
||||
/******************************************************************/
|
||||
int32_t WheelTransaction::Prefs::sMouseWheelAccelerationStart = -1;
|
||||
int32_t WheelTransaction::Prefs::sMouseWheelAccelerationFactor = -1;
|
||||
uint32_t WheelTransaction::Prefs::sMouseWheelTransactionTimeout = 1500;
|
||||
uint32_t WheelTransaction::Prefs::sMouseWheelTransactionIgnoreMoveDelay = 100;
|
||||
bool WheelTransaction::Prefs::sTestMouseScroll = false;
|
||||
|
||||
/* static */ void
|
||||
WheelTransaction::Prefs::InitializeStatics()
|
||||
{
|
||||
static bool sIsInitialized = false;
|
||||
if (!sIsInitialized) {
|
||||
Preferences::AddIntVarCache(&sMouseWheelAccelerationStart,
|
||||
"mousewheel.acceleration.start", -1);
|
||||
Preferences::AddIntVarCache(&sMouseWheelAccelerationFactor,
|
||||
"mousewheel.acceleration.factor", -1);
|
||||
Preferences::AddUintVarCache(&sMouseWheelTransactionTimeout,
|
||||
"mousewheel.transaction.timeout", 1500);
|
||||
Preferences::AddUintVarCache(&sMouseWheelTransactionIgnoreMoveDelay,
|
||||
"mousewheel.transaction.ignoremovedelay", 100);
|
||||
Preferences::AddBoolVarCache(&sTestMouseScroll, "test.mousescroll", false);
|
||||
sIsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -143,12 +143,19 @@ public:
|
|||
}
|
||||
static void OnEvent(WidgetEvent* aEvent);
|
||||
static void Shutdown();
|
||||
static uint32_t GetTimeoutTime();
|
||||
static uint32_t GetTimeoutTime()
|
||||
{
|
||||
return Prefs::sMouseWheelTransactionTimeout;
|
||||
}
|
||||
|
||||
static void OwnScrollbars(bool aOwn);
|
||||
|
||||
static DeltaValues AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride);
|
||||
static void InitializeStatics()
|
||||
{
|
||||
Prefs::InitializeStatics();
|
||||
}
|
||||
|
||||
protected:
|
||||
static void BeginTransaction(nsIFrame* aTargetFrame,
|
||||
|
@ -162,9 +169,18 @@ protected:
|
|||
static void OnFailToScrollTarget();
|
||||
static void OnTimeout(nsITimer* aTimer, void* aClosure);
|
||||
static void SetTimeout();
|
||||
static uint32_t GetIgnoreMoveDelayTime();
|
||||
static int32_t GetAccelerationStart();
|
||||
static int32_t GetAccelerationFactor();
|
||||
static uint32_t GetIgnoreMoveDelayTime()
|
||||
{
|
||||
return Prefs::sMouseWheelTransactionIgnoreMoveDelay;
|
||||
}
|
||||
static int32_t GetAccelerationStart()
|
||||
{
|
||||
return Prefs::sMouseWheelAccelerationStart;
|
||||
}
|
||||
static int32_t GetAccelerationFactor()
|
||||
{
|
||||
return Prefs::sMouseWheelAccelerationFactor;
|
||||
}
|
||||
static DeltaValues OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent);
|
||||
static double ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor);
|
||||
static bool OutOfTime(uint32_t aBaseTime, uint32_t aThreshold);
|
||||
|
@ -175,6 +191,17 @@ protected:
|
|||
static nsITimer* sTimer;
|
||||
static int32_t sScrollSeriesCounter;
|
||||
static bool sOwnScrollbars;
|
||||
|
||||
class Prefs
|
||||
{
|
||||
public:
|
||||
static void InitializeStatics();
|
||||
static int32_t sMouseWheelAccelerationStart;
|
||||
static int32_t sMouseWheelAccelerationFactor;
|
||||
static uint32_t sMouseWheelTransactionTimeout;
|
||||
static uint32_t sMouseWheelTransactionIgnoreMoveDelay;
|
||||
static bool sTestMouseScroll;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче