зеркало из https://github.com/mozilla/gecko-dev.git
Bug 984271 part.1-3 Rename nsMouseWheelTransaction to mozilla::WheelTransaction r=smaug
This commit is contained in:
Родитель
4eed6134a2
Коммит
e870849231
|
@ -65,37 +65,33 @@ WheelHandlingUtils::CanScrollOn(nsIScrollableFrame* aScrollFrame,
|
|||
scrollRange.YMost(), aDirectionY));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/******************************************************************/
|
||||
/* nsMouseWheelTransaction */
|
||||
/* mozilla::WheelTransaction */
|
||||
/******************************************************************/
|
||||
|
||||
nsWeakFrame nsMouseWheelTransaction::sTargetFrame(nullptr);
|
||||
uint32_t nsMouseWheelTransaction::sTime = 0;
|
||||
uint32_t nsMouseWheelTransaction::sMouseMoved = 0;
|
||||
nsITimer* nsMouseWheelTransaction::sTimer = nullptr;
|
||||
int32_t nsMouseWheelTransaction::sScrollSeriesCounter = 0;
|
||||
bool nsMouseWheelTransaction::sOwnScrollbars = false;
|
||||
nsWeakFrame WheelTransaction::sTargetFrame(nullptr);
|
||||
uint32_t WheelTransaction::sTime = 0;
|
||||
uint32_t WheelTransaction::sMouseMoved = 0;
|
||||
nsITimer* WheelTransaction::sTimer = nullptr;
|
||||
int32_t WheelTransaction::sScrollSeriesCounter = 0;
|
||||
bool WheelTransaction::sOwnScrollbars = false;
|
||||
|
||||
bool
|
||||
nsMouseWheelTransaction::OutOfTime(uint32_t aBaseTime, uint32_t aThreshold)
|
||||
WheelTransaction::OutOfTime(uint32_t aBaseTime, uint32_t aThreshold)
|
||||
{
|
||||
uint32_t now = PR_IntervalToMilliseconds(PR_IntervalNow());
|
||||
return (now - aBaseTime > aThreshold);
|
||||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::OwnScrollbars(bool aOwn)
|
||||
WheelTransaction::OwnScrollbars(bool aOwn)
|
||||
{
|
||||
sOwnScrollbars = aOwn;
|
||||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::BeginTransaction(nsIFrame* aTargetFrame,
|
||||
WidgetWheelEvent* aEvent)
|
||||
WheelTransaction::BeginTransaction(nsIFrame* aTargetFrame,
|
||||
WidgetWheelEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(!sTargetFrame, "previous transaction is not finished!");
|
||||
MOZ_ASSERT(aEvent->message == NS_WHEEL_WHEEL,
|
||||
|
@ -110,7 +106,7 @@ nsMouseWheelTransaction::BeginTransaction(nsIFrame* aTargetFrame,
|
|||
}
|
||||
|
||||
bool
|
||||
nsMouseWheelTransaction::UpdateTransaction(WidgetWheelEvent* aEvent)
|
||||
WheelTransaction::UpdateTransaction(WidgetWheelEvent* aEvent)
|
||||
{
|
||||
nsIScrollableFrame* sf = GetTargetFrame()->GetScrollTargetFrame();
|
||||
NS_ENSURE_TRUE(sf, false);
|
||||
|
@ -138,7 +134,7 @@ nsMouseWheelTransaction::UpdateTransaction(WidgetWheelEvent* aEvent)
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::MayEndTransaction()
|
||||
WheelTransaction::MayEndTransaction()
|
||||
{
|
||||
if (!sOwnScrollbars && ScrollbarsForWheel::IsActive()) {
|
||||
ScrollbarsForWheel::OwnWheelTransaction(true);
|
||||
|
@ -148,7 +144,7 @@ nsMouseWheelTransaction::MayEndTransaction()
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::EndTransaction()
|
||||
WheelTransaction::EndTransaction()
|
||||
{
|
||||
if (sTimer)
|
||||
sTimer->Cancel();
|
||||
|
@ -162,7 +158,7 @@ nsMouseWheelTransaction::EndTransaction()
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::OnEvent(WidgetEvent* aEvent)
|
||||
WheelTransaction::OnEvent(WidgetEvent* aEvent)
|
||||
{
|
||||
if (!sTargetFrame)
|
||||
return;
|
||||
|
@ -224,13 +220,13 @@ nsMouseWheelTransaction::OnEvent(WidgetEvent* aEvent)
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::Shutdown()
|
||||
WheelTransaction::Shutdown()
|
||||
{
|
||||
NS_IF_RELEASE(sTimer);
|
||||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::OnFailToScrollTarget()
|
||||
WheelTransaction::OnFailToScrollTarget()
|
||||
{
|
||||
NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction");
|
||||
|
||||
|
@ -250,7 +246,7 @@ nsMouseWheelTransaction::OnFailToScrollTarget()
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
|
||||
WheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
if (!sTargetFrame) {
|
||||
// The transaction target was destroyed already
|
||||
|
@ -274,7 +270,7 @@ nsMouseWheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
|
|||
}
|
||||
|
||||
void
|
||||
nsMouseWheelTransaction::SetTimeout()
|
||||
WheelTransaction::SetTimeout()
|
||||
{
|
||||
if (!sTimer) {
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
|
@ -292,7 +288,7 @@ nsMouseWheelTransaction::SetTimeout()
|
|||
}
|
||||
|
||||
nsIntPoint
|
||||
nsMouseWheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
|
||||
WheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(aEvent, "aEvent is null");
|
||||
NS_ASSERTION(aEvent->widget, "aEvent-widget is null");
|
||||
|
@ -301,20 +297,20 @@ nsMouseWheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
|
|||
}
|
||||
|
||||
uint32_t
|
||||
nsMouseWheelTransaction::GetTimeoutTime()
|
||||
WheelTransaction::GetTimeoutTime()
|
||||
{
|
||||
return Preferences::GetUint("mousewheel.transaction.timeout", 1500);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsMouseWheelTransaction::GetIgnoreMoveDelayTime()
|
||||
WheelTransaction::GetIgnoreMoveDelayTime()
|
||||
{
|
||||
return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100);
|
||||
}
|
||||
|
||||
DeltaValues
|
||||
nsMouseWheelTransaction::AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride)
|
||||
WheelTransaction::AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride)
|
||||
{
|
||||
DeltaValues result(aEvent);
|
||||
|
||||
|
@ -341,8 +337,8 @@ nsMouseWheelTransaction::AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
|||
}
|
||||
|
||||
double
|
||||
nsMouseWheelTransaction::ComputeAcceleratedWheelDelta(double aDelta,
|
||||
int32_t aFactor)
|
||||
WheelTransaction::ComputeAcceleratedWheelDelta(double aDelta,
|
||||
int32_t aFactor)
|
||||
{
|
||||
if (aDelta == 0.0) {
|
||||
return 0;
|
||||
|
@ -352,19 +348,19 @@ nsMouseWheelTransaction::ComputeAcceleratedWheelDelta(double aDelta,
|
|||
}
|
||||
|
||||
int32_t
|
||||
nsMouseWheelTransaction::GetAccelerationStart()
|
||||
WheelTransaction::GetAccelerationStart()
|
||||
{
|
||||
return Preferences::GetInt("mousewheel.acceleration.start", -1);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsMouseWheelTransaction::GetAccelerationFactor()
|
||||
WheelTransaction::GetAccelerationFactor()
|
||||
{
|
||||
return Preferences::GetInt("mousewheel.acceleration.factor", -1);
|
||||
}
|
||||
|
||||
DeltaValues
|
||||
nsMouseWheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
|
||||
WheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
|
||||
{
|
||||
MOZ_ASSERT(sTargetFrame, "We don't have mouse scrolling transaction");
|
||||
MOZ_ASSERT(aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE);
|
||||
|
@ -395,8 +391,6 @@ nsMouseWheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
|
|||
return NS_FAILED(rv) ? DeltaValues(aEvent) : overriddenDeltaValues;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/******************************************************************/
|
||||
/* mozilla::ScrollbarsForWheel */
|
||||
/******************************************************************/
|
||||
|
@ -419,7 +413,7 @@ ScrollbarsForWheel::PrepareToScrollText(nsEventStateManager* aESM,
|
|||
WidgetWheelEvent* aEvent)
|
||||
{
|
||||
if (aEvent->message == NS_WHEEL_START) {
|
||||
nsMouseWheelTransaction::OwnScrollbars(false);
|
||||
WheelTransaction::OwnScrollbars(false);
|
||||
if (!IsActive()) {
|
||||
TemporarilyActivateAllPossibleScrollTargets(aESM, aTargetFrame, aEvent);
|
||||
sHadWheelStart = true;
|
||||
|
@ -447,8 +441,8 @@ ScrollbarsForWheel::SetActiveScrollTarget(nsIScrollableFrame* aScrollTarget)
|
|||
void
|
||||
ScrollbarsForWheel::MayInactivate()
|
||||
{
|
||||
if (!sOwnWheelTransaction && nsMouseWheelTransaction::GetTargetFrame()) {
|
||||
nsMouseWheelTransaction::OwnScrollbars(true);
|
||||
if (!sOwnWheelTransaction && WheelTransaction::GetTargetFrame()) {
|
||||
WheelTransaction::OwnScrollbars(true);
|
||||
} else {
|
||||
Inactivate();
|
||||
}
|
||||
|
@ -465,8 +459,8 @@ ScrollbarsForWheel::Inactivate()
|
|||
DeactivateAllTemporarilyActivatedScrollTargets();
|
||||
if (sOwnWheelTransaction) {
|
||||
sOwnWheelTransaction = false;
|
||||
nsMouseWheelTransaction::OwnScrollbars(false);
|
||||
nsMouseWheelTransaction::EndTransaction();
|
||||
WheelTransaction::OwnScrollbars(false);
|
||||
WheelTransaction::EndTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,40 +88,36 @@ protected:
|
|||
static void DeactivateAllTemporarilyActivatedScrollTargets();
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
class nsMouseWheelTransaction
|
||||
class WheelTransaction
|
||||
{
|
||||
public:
|
||||
static nsIFrame* GetTargetFrame() { return sTargetFrame; }
|
||||
static void BeginTransaction(nsIFrame* aTargetFrame,
|
||||
mozilla::WidgetWheelEvent* aEvent);
|
||||
WidgetWheelEvent* aEvent);
|
||||
// Be careful, UpdateTransaction may fire a DOM event, therefore, the target
|
||||
// frame might be destroyed in the event handler.
|
||||
static bool UpdateTransaction(mozilla::WidgetWheelEvent* aEvent);
|
||||
static bool UpdateTransaction(WidgetWheelEvent* aEvent);
|
||||
static void MayEndTransaction();
|
||||
static void EndTransaction();
|
||||
static void OnEvent(mozilla::WidgetEvent* aEvent);
|
||||
static void OnEvent(WidgetEvent* aEvent);
|
||||
static void Shutdown();
|
||||
static uint32_t GetTimeoutTime();
|
||||
|
||||
static void OwnScrollbars(bool aOwn);
|
||||
|
||||
static mozilla::DeltaValues
|
||||
AccelerateWheelDelta(mozilla::WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride);
|
||||
static DeltaValues AccelerateWheelDelta(WidgetWheelEvent* aEvent,
|
||||
bool aAllowScrollSpeedOverride);
|
||||
|
||||
protected:
|
||||
static const uint32_t kScrollSeriesTimeout = 80; // in milliseconds
|
||||
static nsIntPoint GetScreenPoint(mozilla::WidgetGUIEvent* aEvent);
|
||||
static nsIntPoint GetScreenPoint(WidgetGUIEvent* aEvent);
|
||||
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 mozilla::DeltaValues
|
||||
OverrideSystemScrollSpeed(mozilla::WidgetWheelEvent* aEvent);
|
||||
static DeltaValues OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent);
|
||||
static double ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor);
|
||||
static bool OutOfTime(uint32_t aBaseTime, uint32_t aThreshold);
|
||||
|
||||
|
@ -133,4 +129,6 @@ protected:
|
|||
static bool sOwnScrollbars;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_WheelHandlingHelper_h_
|
||||
|
|
|
@ -334,7 +334,7 @@ nsEventStateManager::~nsEventStateManager()
|
|||
|
||||
--sESMInstanceCount;
|
||||
if(sESMInstanceCount == 0) {
|
||||
nsMouseWheelTransaction::Shutdown();
|
||||
WheelTransaction::Shutdown();
|
||||
if (gUserInteractionTimerCallback) {
|
||||
gUserInteractionTimerCallback->Notify(nullptr);
|
||||
NS_RELEASE(gUserInteractionTimerCallback);
|
||||
|
@ -475,7 +475,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
*aStatus = nsEventStatus_eIgnore;
|
||||
|
||||
nsMouseWheelTransaction::OnEvent(aEvent);
|
||||
WheelTransaction::OnEvent(aEvent);
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_BUTTON_DOWN: {
|
||||
|
@ -2196,14 +2196,14 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|||
if (aOptions & PREFER_MOUSE_WHEEL_TRANSACTION) {
|
||||
// If the user recently scrolled with the mousewheel, then they probably
|
||||
// want to scroll the same view as before instead of the view under the
|
||||
// cursor. nsMouseWheelTransaction tracks the frame currently being
|
||||
// cursor. WheelTransaction tracks the frame currently being
|
||||
// scrolled with the mousewheel. We consider the transaction ended when the
|
||||
// mouse moves more than "mousewheel.transaction.ignoremovedelay"
|
||||
// milliseconds after the last scroll operation, or any time the mouse moves
|
||||
// out of the frame, or when more than "mousewheel.transaction.timeout"
|
||||
// milliseconds have passed after the last operation, even if the mouse
|
||||
// hasn't moved.
|
||||
nsIFrame* lastScrollFrame = nsMouseWheelTransaction::GetTargetFrame();
|
||||
nsIFrame* lastScrollFrame = WheelTransaction::GetTargetFrame();
|
||||
if (lastScrollFrame) {
|
||||
nsIScrollableFrame* frameToScroll =
|
||||
lastScrollFrame->GetScrollTargetFrame();
|
||||
|
@ -2328,14 +2328,14 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
MOZ_ASSERT(scrollFrame);
|
||||
nsWeakFrame scrollFrameWeak(scrollFrame);
|
||||
|
||||
nsIFrame* lastScrollFrame = nsMouseWheelTransaction::GetTargetFrame();
|
||||
nsIFrame* lastScrollFrame = WheelTransaction::GetTargetFrame();
|
||||
if (!lastScrollFrame) {
|
||||
nsMouseWheelTransaction::BeginTransaction(scrollFrame, aEvent);
|
||||
WheelTransaction::BeginTransaction(scrollFrame, aEvent);
|
||||
} else if (lastScrollFrame != scrollFrame) {
|
||||
nsMouseWheelTransaction::EndTransaction();
|
||||
nsMouseWheelTransaction::BeginTransaction(scrollFrame, aEvent);
|
||||
WheelTransaction::EndTransaction();
|
||||
WheelTransaction::BeginTransaction(scrollFrame, aEvent);
|
||||
} else {
|
||||
nsMouseWheelTransaction::UpdateTransaction(aEvent);
|
||||
WheelTransaction::UpdateTransaction(aEvent);
|
||||
}
|
||||
|
||||
// When the scroll event will not scroll any views, UpdateTransaction
|
||||
|
@ -2343,7 +2343,7 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
// In the event handler, the target frame might be destroyed. Then,
|
||||
// we should not try scrolling anything.
|
||||
if (!scrollFrameWeak.IsAlive()) {
|
||||
nsMouseWheelTransaction::EndTransaction();
|
||||
WheelTransaction::EndTransaction();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2891,7 +2891,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
if (scrollTarget) {
|
||||
DoScrollText(scrollTarget, wheelEvent);
|
||||
} else {
|
||||
nsMouseWheelTransaction::EndTransaction();
|
||||
WheelTransaction::EndTransaction();
|
||||
ScrollbarsForWheel::Inactivate();
|
||||
}
|
||||
break;
|
||||
|
@ -3930,7 +3930,7 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
|
|||
}
|
||||
|
||||
// Reset mouse wheel transaction
|
||||
nsMouseWheelTransaction::EndTransaction();
|
||||
WheelTransaction::EndTransaction();
|
||||
|
||||
// Deal with DnD events
|
||||
nsCOMPtr<nsIDragService> dragService =
|
||||
|
@ -4898,7 +4898,7 @@ nsEventStateManager::DeltaAccumulator::InitLineOrPageDelta(
|
|||
// Reset if the previous wheel event is too old.
|
||||
if (!mLastTime.IsNull()) {
|
||||
TimeDuration duration = TimeStamp::Now() - mLastTime;
|
||||
if (duration.ToMilliseconds() > nsMouseWheelTransaction::GetTimeoutTime()) {
|
||||
if (duration.ToMilliseconds() > WheelTransaction::GetTimeoutTime()) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
@ -5004,8 +5004,7 @@ nsEventStateManager::DeltaAccumulator::ComputeScrollAmountForDefaultAction(
|
|||
(!aEvent->customizedByUserPrefs &&
|
||||
aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE);
|
||||
DeltaValues acceleratedDelta =
|
||||
nsMouseWheelTransaction::AccelerateWheelDelta(aEvent,
|
||||
allowScrollSpeedOverride);
|
||||
WheelTransaction::AccelerateWheelDelta(aEvent, allowScrollSpeedOverride);
|
||||
|
||||
nsIntPoint result(0, 0);
|
||||
if (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL) {
|
||||
|
|
|
@ -28,10 +28,10 @@ class EnterLeaveDispatcher;
|
|||
class nsIMarkupDocumentViewer;
|
||||
class nsIScrollableFrame;
|
||||
class nsITimer;
|
||||
class nsMouseWheelTransaction;
|
||||
|
||||
namespace mozilla {
|
||||
class ScrollbarsForWheel;
|
||||
class WheelTransaction;
|
||||
namespace dom {
|
||||
class DataTransfer;
|
||||
class TabParent;
|
||||
|
@ -67,8 +67,9 @@ public:
|
|||
class nsEventStateManager : public nsSupportsWeakReference,
|
||||
public nsIObserver
|
||||
{
|
||||
friend class nsMouseWheelTransaction;
|
||||
friend class mozilla::ScrollbarsForWheel;
|
||||
friend class mozilla::WheelTransaction;
|
||||
|
||||
public:
|
||||
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
|
|
Загрузка…
Ссылка в новой задаче