Bug 1653949 - Part 1: Change mExitFrom in WidgetMouseEvent to be Maybe<ExitFrom>; r=smaug

mExitFrom now contains a value only when mMessage is eMouseExitFromWidget

Differential Revision: https://phabricator.services.mozilla.com/D88225
This commit is contained in:
Edgar Chen 2020-08-26 14:19:46 +00:00
Родитель 9a9397ca2d
Коммит 363e80d673
8 изменённых файлов: 34 добавлений и 26 удалений

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

@ -7820,7 +7820,7 @@ nsresult nsContentUtils::SendMouseEvent(
if (!widget) return NS_ERROR_FAILURE;
EventMessage msg;
WidgetMouseEvent::ExitFrom exitFrom = WidgetMouseEvent::eChild;
Maybe<WidgetMouseEvent::ExitFrom> exitFrom;
bool contextMenuKey = false;
if (aType.EqualsLiteral("mousedown")) {
msg = eMouseDown;
@ -7832,9 +7832,10 @@ nsresult nsContentUtils::SendMouseEvent(
msg = eMouseEnterIntoWidget;
} else if (aType.EqualsLiteral("mouseout")) {
msg = eMouseExitFromWidget;
exitFrom = Some(WidgetMouseEvent::eChild);
} else if (aType.EqualsLiteral("mousecancel")) {
msg = eMouseExitFromWidget;
exitFrom = WidgetMouseEvent::eTopLevel;
exitFrom = Some(WidgetMouseEvent::eTopLevel);
} else if (aType.EqualsLiteral("mouselongtap")) {
msg = eMouseLongTap;
} else if (aType.EqualsLiteral("contextmenu")) {

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

@ -649,7 +649,7 @@ nsresult EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// If the event is not a top-level window exit, then it's not
// really an exit --- we may have traversed widget boundaries but
// we're still in our toplevel window.
if (mouseEvent->mExitFrom != WidgetMouseEvent::eTopLevel) {
if (mouseEvent->mExitFrom.value() != WidgetMouseEvent::eTopLevel) {
// Treat it as a synthetic move so we don't generate spurious
// "exit" or "move" events. Any necessary "out" or "over" events
// will be generated by GenerateMouseEnterExit
@ -1327,6 +1327,7 @@ void EventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
UniquePtr<WidgetMouseEvent> mouseExitEvent =
CreateMouseOrPointerWidgetEvent(mouseEvent, eMouseExitFromWidget,
mouseEvent->mRelatedTarget);
mouseExitEvent->mExitFrom = Some(WidgetMouseEvent::eChild);
oldRemote->SendRealMouseEvent(*mouseExitEvent);
}
@ -4223,7 +4224,7 @@ nsIFrame* EventStateManager::DispatchMouseOrPointerEvent(
UniquePtr<WidgetMouseEvent> remoteEvent =
CreateMouseOrPointerWidgetEvent(aMouseEvent, eMouseExitFromWidget,
relatedContent);
remoteEvent->mExitFrom = WidgetMouseEvent::eTopLevel;
remoteEvent->mExitFrom = Some(WidgetMouseEvent::eTopLevel);
// mCurrentTarget is set to the new target, so we must reset it to the
// old target and then dispatch a cross-process event. (mCurrentTarget

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

@ -6980,9 +6980,9 @@ nsresult PresShell::EventHandler::HandleEventUsingCoordinates(
}
WidgetMouseEvent* mouseEvent = aGUIEvent->AsMouseEvent();
bool isWindowLevelMouseExit =
(aGUIEvent->mMessage == eMouseExitFromWidget) &&
(mouseEvent && mouseEvent->mExitFrom == WidgetMouseEvent::eTopLevel);
bool isWindowLevelMouseExit = (aGUIEvent->mMessage == eMouseExitFromWidget) &&
(mouseEvent && mouseEvent->mExitFrom.value() ==
WidgetMouseEvent::eTopLevel);
// Get the frame at the event point. However, don't do this if we're
// capturing and retargeting the event because the captured frame will

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

@ -197,7 +197,6 @@ class WidgetMouseEvent : public WidgetMouseEventBase,
WidgetMouseEvent()
: mReason(eReal),
mContextMenuTrigger(eNormal),
mExitFrom(eChild),
mIgnoreRootScrollFrame(false),
mClickCount(0),
mUseLegacyNonPrimaryDispatch(false) {}
@ -207,7 +206,6 @@ class WidgetMouseEvent : public WidgetMouseEventBase,
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID),
mReason(aReason),
mContextMenuTrigger(eNormal),
mExitFrom(eChild),
mIgnoreRootScrollFrame(false),
mClickCount(0),
mUseLegacyNonPrimaryDispatch(false) {}
@ -221,7 +219,6 @@ class WidgetMouseEvent : public WidgetMouseEventBase,
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass),
mReason(aReason),
mContextMenuTrigger(aContextMenuTrigger),
mExitFrom(eChild),
mIgnoreRootScrollFrame(false),
mClickCount(0),
mUseLegacyNonPrimaryDispatch(false) {
@ -269,10 +266,10 @@ class WidgetMouseEvent : public WidgetMouseEventBase,
// other reasons (typically, a click of right mouse button).
ContextMenuTrigger mContextMenuTrigger;
// mExitFrom is valid only when mMessage is eMouseExitFromWidget.
// mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
// This indicates if the mouse cursor exits from a top level widget or
// a child widget.
ExitFrom mExitFrom;
Maybe<ExitFrom> mExitFrom;
// Whether the event should ignore scroll frame bounds during dispatch.
bool mIgnoreRootScrollFrame;

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

@ -3159,9 +3159,9 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong]
EventMessage msg = aEnter ? eMouseEnterIntoWidget : eMouseExitFromWidget;
WidgetMouseEvent event(true, msg, mGeckoChild, WidgetMouseEvent::eReal);
event.mRefPoint = mGeckoChild->CocoaPointsToDevPixels(localEventLocation);
event.mExitFrom = aExitFrom;
if (event.mMessage == eMouseExitFromWidget) {
event.mExitFrom = Some(aExitFrom);
}
nsEventStatus status; // ignored
mGeckoChild->DispatchEvent(&event, status);
}

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

@ -3199,9 +3199,9 @@ void nsWindow::OnLeaveNotifyEvent(GdkEventCrossing* aEvent) {
event.mRefPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
event.AssignEventTime(GetWidgetEventTime(aEvent->time));
event.mExitFrom = is_top_level_mouse_exit(mGdkWindow, aEvent)
? WidgetMouseEvent::eTopLevel
: WidgetMouseEvent::eChild;
event.mExitFrom = Some(is_top_level_mouse_exit(mGdkWindow, aEvent)
? WidgetMouseEvent::eTopLevel
: WidgetMouseEvent::eChild);
LOG(("OnLeaveNotify: %p\n", (void*)this));

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

@ -244,7 +244,11 @@ struct ParamTraits<mozilla::WidgetMouseEvent> {
WriteParam(aMsg, static_cast<paramType::ReasonType>(aParam.mReason));
WriteParam(aMsg, static_cast<paramType::ContextMenuTriggerType>(
aParam.mContextMenuTrigger));
WriteParam(aMsg, static_cast<paramType::ExitFromType>(aParam.mExitFrom));
WriteParam(aMsg, aParam.mExitFrom.isSome());
if (aParam.mExitFrom.isSome()) {
WriteParam(
aMsg, static_cast<paramType::ExitFromType>(aParam.mExitFrom.value()));
}
WriteParam(aMsg, aParam.mClickCount);
}
@ -253,20 +257,24 @@ struct ParamTraits<mozilla::WidgetMouseEvent> {
bool rv;
paramType::ReasonType reason = 0;
paramType::ContextMenuTriggerType contextMenuTrigger = 0;
paramType::ExitFromType exitFrom = 0;
bool hasExitFrom = false;
rv = ReadParam(aMsg, aIter,
static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
ReadParam(aMsg, aIter,
static_cast<mozilla::WidgetPointerHelper*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->mIgnoreRootScrollFrame) &&
ReadParam(aMsg, aIter, &reason) &&
ReadParam(aMsg, aIter, &contextMenuTrigger) &&
ReadParam(aMsg, aIter, &exitFrom) &&
ReadParam(aMsg, aIter, &aResult->mClickCount);
ReadParam(aMsg, aIter, &contextMenuTrigger);
aResult->mReason = static_cast<paramType::Reason>(reason);
aResult->mContextMenuTrigger =
static_cast<paramType::ContextMenuTrigger>(contextMenuTrigger);
aResult->mExitFrom = static_cast<paramType::ExitFrom>(exitFrom);
rv = rv && ReadParam(aMsg, aIter, &hasExitFrom);
if (hasExitFrom) {
paramType::ExitFromType exitFrom = 0;
rv = rv && ReadParam(aMsg, aIter, &exitFrom);
aResult->mExitFrom = Some(static_cast<paramType::ExitFrom>(exitFrom));
}
rv = rv && ReadParam(aMsg, aIter, &aResult->mClickCount);
return rv;
}
};

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

@ -4555,8 +4555,9 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
}
break;
case eMouseExitFromWidget:
event.mExitFrom = IsTopLevelMouseExit(mWnd) ? WidgetMouseEvent::eTopLevel
: WidgetMouseEvent::eChild;
event.mExitFrom =
Some(IsTopLevelMouseExit(mWnd) ? WidgetMouseEvent::eTopLevel
: WidgetMouseEvent::eChild);
break;
default:
break;