Bug 376679 part.3 Compute default action target frame for wheel event before deciding the action because plugin should decide what is the default action when the target is a plugin frame r=smaug

This commit is contained in:
Masayuki Nakano 2015-10-16 13:19:27 +09:00
parent ecb6a84bd2
commit 0dbe5e4421
2 changed files with 25 additions and 18 deletions

View File

@ -3121,13 +3121,27 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
// Check if the frame to scroll before checking the default action
// because if the scroll target is a plugin, the default action should be
// chosen by the plugin rather than by our prefs.
nsIFrame* frameToScroll = nullptr;
nsPluginFrame* pluginFrame = nullptr;
// When APZ is enabled, the actual scroll animation might be handled by
// the compositor.
WheelPrefs::Action action;
if (wheelEvent->mFlags.mHandledByAPZ) {
action = WheelPrefs::ACTION_NONE;
} else {
action = WheelPrefs::GetInstance()->ComputeActionFor(wheelEvent);
frameToScroll = ComputeScrollTarget(aTargetFrame, wheelEvent,
COMPUTE_DEFAULT_ACTION_TARGET);
pluginFrame = do_QueryFrame(frameToScroll);
if (pluginFrame) {
MOZ_ASSERT(pluginFrame->WantsToHandleWheelEventAsDefaultAction());
action = WheelPrefs::ACTION_SEND_TO_PLUGIN;
} else {
action = WheelPrefs::GetInstance()->ComputeActionFor(wheelEvent);
}
}
switch (action) {
case WheelPrefs::ACTION_SCROLL: {
@ -3141,22 +3155,6 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
break;
}
nsIFrame* frameToScroll =
ComputeScrollTarget(aTargetFrame, wheelEvent,
COMPUTE_DEFAULT_ACTION_TARGET);
// XXX Temporarily, we should check if the target is a plugin frame
// here. In the following patch, this should be checked before
// checking wheel action since if the default action handler is
// a plugin, our pref shouldn't decide the default action.
nsPluginFrame* pluginFrame = do_QueryFrame(frameToScroll);
if (pluginFrame) {
// XXX Needs to work with WheelTransaction, will be fixed in
// the following patch.
pluginFrame->HandleWheelEventAsDefaultAction(wheelEvent);
break;
}
nsIScrollableFrame* scrollTarget = do_QueryFrame(frameToScroll);
ScrollbarsForWheel::SetActiveScrollTarget(scrollTarget);
@ -3201,6 +3199,12 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
DoScrollZoom(aTargetFrame, intDelta);
break;
}
case WheelPrefs::ACTION_SEND_TO_PLUGIN:
MOZ_ASSERT(pluginFrame);
// XXX Needs to work with WheelTransaction, will be fixed in
// the following patch.
pluginFrame->HandleWheelEventAsDefaultAction(wheelEvent);
break;
case WheelPrefs::ACTION_NONE:
default:
bool allDeltaOverflown = false;

View File

@ -461,7 +461,10 @@ protected:
ACTION_SCROLL,
ACTION_HISTORY,
ACTION_ZOOM,
ACTION_LAST = ACTION_ZOOM
ACTION_LAST = ACTION_ZOOM,
// Following actions are used only by internal processing. So, cannot
// specified by prefs.
ACTION_SEND_TO_PLUGIN
};
Action ComputeActionFor(WidgetWheelEvent* aEvent);