зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1466208 - part 23: Create PresShell::EventHandler::ComputeEventTargetFrameAndPresShellAtEventPoint() r=smaug
We cannot move each block into separated methods while computing EventTargetData because we need to check capturing contents, etc. Therefore, only each block should be moved to separated methods for now. This moves a block which computes event target from point of the event. If this can be moved to EventTargetData, it might be easier to understand, but its helper method GetFrameToHandleNonTouchEvent() requires to access members of EventHandler. Therefore, we need to treat EventTargetData as an out param of the new method. Differential Revision: https://phabricator.services.mozilla.com/D21189 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d05d4927fc
Коммит
1a1542b28c
|
@ -6592,16 +6592,10 @@ nsresult PresShell::EventHandler::HandleEvent(nsIFrame* aFrame,
|
|||
EventTargetData eventTargetData(mPresShell, rootFrameToHandleEvent);
|
||||
if (!isCaptureRetargeted && !isWindowLevelMouseExit &&
|
||||
!pointerCapturingContent) {
|
||||
if (aGUIEvent->mClass == eTouchEventClass) {
|
||||
eventTargetData.SetFrameAndComputePresShell(TouchManager::SetupTarget(
|
||||
aGUIEvent->AsTouchEvent(), rootFrameToHandleEvent));
|
||||
} else {
|
||||
eventTargetData.SetFrameAndComputePresShell(
|
||||
GetFrameToHandleNonTouchEvent(rootFrameToHandleEvent, aGUIEvent));
|
||||
if (!eventTargetData.mFrame) {
|
||||
*aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
if (!ComputeEventTargetFrameAndPresShellAtEventPoint(
|
||||
rootFrameToHandleEvent, aGUIEvent, &eventTargetData)) {
|
||||
*aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6925,6 +6919,26 @@ nsIFrame* PresShell::EventHandler::GetFrameToHandleNonTouchEvent(
|
|||
return targetFrame ? targetFrame : aRootFrameToHandleEvent;
|
||||
}
|
||||
|
||||
bool PresShell::EventHandler::ComputeEventTargetFrameAndPresShellAtEventPoint(
|
||||
nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
|
||||
EventTargetData* aEventTargetData) {
|
||||
MOZ_ASSERT(aRootFrameToHandleEvent);
|
||||
MOZ_ASSERT(aGUIEvent);
|
||||
MOZ_ASSERT(aEventTargetData);
|
||||
|
||||
if (aGUIEvent->mClass == eTouchEventClass) {
|
||||
nsIFrame* targetFrameAtTouchEvent = TouchManager::SetupTarget(
|
||||
aGUIEvent->AsTouchEvent(), aRootFrameToHandleEvent);
|
||||
aEventTargetData->SetFrameAndComputePresShell(targetFrameAtTouchEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
nsIFrame* targetFrame =
|
||||
GetFrameToHandleNonTouchEvent(aRootFrameToHandleEvent, aGUIEvent);
|
||||
aEventTargetData->SetFrameAndComputePresShell(targetFrame);
|
||||
return !!aEventTargetData->mFrame;
|
||||
}
|
||||
|
||||
bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret(
|
||||
WidgetGUIEvent* aGUIEvent, nsEventStatus* aEventStatus) {
|
||||
MOZ_ASSERT(aGUIEvent);
|
||||
|
|
|
@ -670,6 +670,23 @@ class PresShell final : public nsIPresShell,
|
|||
nsIFrame* GetFrameToHandleNonTouchEvent(nsIFrame* aRootFrameToHandleEvent,
|
||||
WidgetGUIEvent* aGUIEvent);
|
||||
|
||||
/**
|
||||
* ComputeEventTargetFrameAndPresShellAtEventPoint() computes event
|
||||
* target frame at the event point of aGUIEvent and set it to
|
||||
* aEventTargetData.
|
||||
*
|
||||
* @param aRootFrameToHandleEvent The root frame to handle aGUIEvent.
|
||||
* @param aGUIEvent The handling event.
|
||||
* @param aEventTargetData [out] Its frame and PresShell will
|
||||
* be set.
|
||||
* @return true if the caller can handle the
|
||||
* event. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
bool ComputeEventTargetFrameAndPresShellAtEventPoint(
|
||||
nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
|
||||
EventTargetData* aEventTargetData);
|
||||
|
||||
/**
|
||||
* MaybeDiscardEvent() checks whether it's safe to handle aGUIEvent right
|
||||
* now. If it's not safe, this may notify somebody of discarding event if
|
||||
|
|
Загрузка…
Ссылка в новой задаче