зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1312997 - Store 'aTargetFrame' in 'mCurrentTarget' before doing anything else, then use 'mCurrentTarget' throughout PostHandleEvent. r=smaug
This is a safer way of accessing the target frame because 'mCurrentTarget' is a nsWeakFrame which will be nulled out in case the frame is destroyed.
This commit is contained in:
Родитель
3a6cd65871
Коммит
cd7a370a02
|
@ -2906,12 +2906,14 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
NS_ENSURE_ARG(aPresContext);
|
NS_ENSURE_ARG(aPresContext);
|
||||||
NS_ENSURE_ARG_POINTER(aStatus);
|
NS_ENSURE_ARG_POINTER(aStatus);
|
||||||
|
|
||||||
bool dispatchedToContentProcess = HandleCrossProcessEvent(aEvent,
|
|
||||||
aStatus);
|
|
||||||
|
|
||||||
mCurrentTarget = aTargetFrame;
|
mCurrentTarget = aTargetFrame;
|
||||||
mCurrentTargetContent = nullptr;
|
mCurrentTargetContent = nullptr;
|
||||||
|
|
||||||
|
bool dispatchedToContentProcess = HandleCrossProcessEvent(aEvent, aStatus);
|
||||||
|
// NOTE: the above call may have destroyed aTargetFrame, please use
|
||||||
|
// mCurrentTarget henceforth. This is to avoid using it accidentally:
|
||||||
|
aTargetFrame = nullptr;
|
||||||
|
|
||||||
// Most of the events we handle below require a frame.
|
// Most of the events we handle below require a frame.
|
||||||
// Add special cases here.
|
// Add special cases here.
|
||||||
if (!mCurrentTarget && aEvent->mMessage != eMouseUp &&
|
if (!mCurrentTarget && aEvent->mMessage != eMouseUp &&
|
||||||
|
@ -3168,7 +3170,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
ScrollbarsForWheel::MayInactivate();
|
ScrollbarsForWheel::MayInactivate();
|
||||||
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
|
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
|
||||||
nsIScrollableFrame* scrollTarget =
|
nsIScrollableFrame* scrollTarget =
|
||||||
do_QueryFrame(ComputeScrollTarget(aTargetFrame, wheelEvent,
|
do_QueryFrame(ComputeScrollTarget(mCurrentTarget, wheelEvent,
|
||||||
COMPUTE_DEFAULT_ACTION_TARGET));
|
COMPUTE_DEFAULT_ACTION_TARGET));
|
||||||
if (scrollTarget) {
|
if (scrollTarget) {
|
||||||
scrollTarget->ScrollSnap();
|
scrollTarget->ScrollSnap();
|
||||||
|
@ -3191,7 +3193,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
// because if the scroll target is a plugin, the default action should be
|
// because if the scroll target is a plugin, the default action should be
|
||||||
// chosen by the plugin rather than by our prefs.
|
// chosen by the plugin rather than by our prefs.
|
||||||
nsIFrame* frameToScroll =
|
nsIFrame* frameToScroll =
|
||||||
ComputeScrollTarget(aTargetFrame, wheelEvent,
|
ComputeScrollTarget(mCurrentTarget, wheelEvent,
|
||||||
COMPUTE_DEFAULT_ACTION_TARGET);
|
COMPUTE_DEFAULT_ACTION_TARGET);
|
||||||
nsPluginFrame* pluginFrame = do_QueryFrame(frameToScroll);
|
nsPluginFrame* pluginFrame = do_QueryFrame(frameToScroll);
|
||||||
|
|
||||||
|
@ -3211,7 +3213,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
// For scrolling of default action, we should honor the mouse wheel
|
// For scrolling of default action, we should honor the mouse wheel
|
||||||
// transaction.
|
// transaction.
|
||||||
|
|
||||||
ScrollbarsForWheel::PrepareToScrollText(this, aTargetFrame, wheelEvent);
|
ScrollbarsForWheel::PrepareToScrollText(this, mCurrentTarget, wheelEvent);
|
||||||
|
|
||||||
if (aEvent->mMessage != eWheel ||
|
if (aEvent->mMessage != eWheel ||
|
||||||
(!wheelEvent->mDeltaX && !wheelEvent->mDeltaY)) {
|
(!wheelEvent->mDeltaX && !wheelEvent->mDeltaY)) {
|
||||||
|
@ -3221,8 +3223,8 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(frameToScroll);
|
nsIScrollableFrame* scrollTarget = do_QueryFrame(frameToScroll);
|
||||||
ScrollbarsForWheel::SetActiveScrollTarget(scrollTarget);
|
ScrollbarsForWheel::SetActiveScrollTarget(scrollTarget);
|
||||||
|
|
||||||
nsIFrame* rootScrollFrame = !aTargetFrame ? nullptr :
|
nsIFrame* rootScrollFrame = !mCurrentTarget ? nullptr :
|
||||||
aTargetFrame->PresContext()->PresShell()->GetRootScrollFrame();
|
mCurrentTarget->PresContext()->PresShell()->GetRootScrollFrame();
|
||||||
nsIScrollableFrame* rootScrollableFrame = nullptr;
|
nsIScrollableFrame* rootScrollableFrame = nullptr;
|
||||||
if (rootScrollFrame) {
|
if (rootScrollFrame) {
|
||||||
rootScrollableFrame = do_QueryFrame(rootScrollFrame);
|
rootScrollableFrame = do_QueryFrame(rootScrollFrame);
|
||||||
|
@ -3259,7 +3261,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
if (!intDelta) {
|
if (!intDelta) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DoScrollZoom(aTargetFrame, intDelta);
|
DoScrollZoom(mCurrentTarget, intDelta);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WheelPrefs::ACTION_SEND_TO_PLUGIN:
|
case WheelPrefs::ACTION_SEND_TO_PLUGIN:
|
||||||
|
@ -3289,7 +3291,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
// by looking at the scroll overflow values on mCanTriggerSwipe
|
// by looking at the scroll overflow values on mCanTriggerSwipe
|
||||||
// events after they have been processed.
|
// events after they have been processed.
|
||||||
allDeltaOverflown =
|
allDeltaOverflown =
|
||||||
!ComputeScrollTarget(aTargetFrame, wheelEvent,
|
!ComputeScrollTarget(mCurrentTarget, wheelEvent,
|
||||||
COMPUTE_DEFAULT_ACTION_TARGET);
|
COMPUTE_DEFAULT_ACTION_TARGET);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче