Bug 1466208 - part 26: Create PresShell::EventHandler::EventTargetData::UpdateTouchEventTarget() r=smaug

After dispatching pointer events, `PresShell::EventHandler::HandleEvent()`
updates event target only when the event is a touch event.  We should do it in
a new method of `EventTargetData`.

Although I don't know why this is done in
`PresShell::EventHandler::DispatchPrecedingPointerEvent()`.

Differential Revision: https://phabricator.services.mozilla.com/D21192

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-03-02 00:02:10 +00:00
Родитель 8d156cc59b
Коммит fcb0072133
2 изменённых файлов: 42 добавлений и 16 удалений

Просмотреть файл

@ -6659,22 +6659,10 @@ nsresult PresShell::EventHandler::HandleEvent(nsIFrame* aFrame,
}
// frame could be null after dispatching pointer events.
if (aGUIEvent->mClass == eTouchEventClass) {
if (aGUIEvent->mMessage == eTouchStart) {
WidgetTouchEvent* touchEvent = aGUIEvent->AsTouchEvent();
if (nsIFrame* newFrame =
TouchManager::SuppressInvalidPointsAndGetTargetedFrame(
touchEvent)) {
eventTargetData.SetFrameAndComputePresShellAndContent(newFrame,
aGUIEvent);
}
} else if (PresShell* newShell =
PresShell::GetShellForTouchEvent(aGUIEvent)) {
// Touch events (except touchstart) are dispatching to the captured
// element. Get correct shell from it.
eventTargetData.mPresShell = newShell;
}
}
// XXX Despite of this comment, we update the event target data outside
// DispatchPrecedingPointerEvent(). Can we make it call
// UpdateTouchEventTarget()?
eventTargetData.UpdateTouchEventTarget(aGUIEvent);
// Handle the event in the correct shell.
// We pass the subshell's root frame as the frame to start from. This is
@ -10865,3 +10853,32 @@ bool PresShell::EventHandler::EventTargetData::ComputeElementFromFrame(
// If we found an element, target it. Otherwise, target *nothing*.
return !!mContent;
}
void PresShell::EventHandler::EventTargetData::UpdateTouchEventTarget(
WidgetGUIEvent* aGUIEvent) {
MOZ_ASSERT(aGUIEvent);
if (aGUIEvent->mClass != eTouchEventClass) {
return;
}
if (aGUIEvent->mMessage == eTouchStart) {
WidgetTouchEvent* touchEvent = aGUIEvent->AsTouchEvent();
nsIFrame* newFrame =
TouchManager::SuppressInvalidPointsAndGetTargetedFrame(touchEvent);
if (!newFrame) {
return; // XXX Why don't we stop handling the event in this case?
}
SetFrameAndComputePresShellAndContent(newFrame, aGUIEvent);
return;
}
PresShell* newPresShell = PresShell::GetShellForTouchEvent(aGUIEvent);
if (!newPresShell) {
return; // XXX Why don't we stop handling the event in this case?
}
// Touch events (except touchstart) are dispatching to the captured
// element. Get correct shell from it.
mPresShell = newPresShell;
}

Просмотреть файл

@ -639,6 +639,15 @@ class PresShell final : public nsIPresShell,
*/
bool ComputeElementFromFrame(WidgetGUIEvent* aGUIEvent);
/**
* UpdateTouchEventTarget() updates mFrame, mPresShell and mContent if
* aGUIEvent is a touch event and there is new proper target.
*
* @param aGUIEvent The handled event. If it's not a touch event,
* this method does nothing.
*/
void UpdateTouchEventTarget(WidgetGUIEvent* aGUIEvent);
RefPtr<PresShell> mPresShell;
nsIFrame* mFrame;
nsCOMPtr<nsIContent> mContent;