Bug 1659231 - Treat defaultPrevented events as consumed r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D87171
This commit is contained in:
Kagami Sascha Rosylight 2020-08-18 10:39:41 +00:00
Родитель cc69602cf2
Коммит 85af441835
1 изменённых файлов: 5 добавлений и 2 удалений

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

@ -898,7 +898,10 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
// Create visitor object and start event dispatching.
// GetEventTargetParent for the original target.
nsEventStatus status = aEventStatus ? *aEventStatus : nsEventStatus_eIgnore;
nsEventStatus status =
aDOMEvent && aDOMEvent->DefaultPrevented()
? nsEventStatus_eConsumeNoDefault
: aEventStatus ? *aEventStatus : nsEventStatus_eIgnore;
nsCOMPtr<EventTarget> targetForPreVisitor = aEvent->mTarget;
EventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status,
isInAnon, targetForPreVisitor);
@ -1102,7 +1105,7 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
}
if (!externalDOMEvent && preVisitor.mDOMEvent) {
// An dom::Event was created while dispatching the event.
// A dom::Event was created while dispatching the event.
// Duplicate private data if someone holds a pointer to it.
nsrefcnt rc = 0;
NS_RELEASE2(preVisitor.mDOMEvent, rc);