Issue #12 Part 5: WidgetEvent shouldn't mark event as consumed if it's not cancelable.

Currently, EventListenerManager calls WidgetEvent::PreventDefault() when the status is nsEventStatus_eConsumeNoDefault.
That causes an unexpected state of events.
To solve this, WidgetEvent should do nothing when it's not cancelable but PreventDefault() is called.
This commit is contained in:
wolfbeast 2018-06-26 14:07:51 +02:00 • committed by Roy Tam
commit ea3ff24118

View file

@ -161,6 +161,9 @@ public:
} }
inline void PreventDefault(bool aCalledByDefaultHandler = true) inline void PreventDefault(bool aCalledByDefaultHandler = true)
{ {
if (!mCancelable) {
return;
}
mDefaultPrevented = true; mDefaultPrevented = true;
// Note that even if preventDefault() has already been called by chrome, // Note that even if preventDefault() has already been called by chrome,
// a call of preventDefault() by content needs to overwrite // a call of preventDefault() by content needs to overwrite
@ -175,6 +178,9 @@ public:
// This should be used only before dispatching events into the DOM tree. // This should be used only before dispatching events into the DOM tree.
inline void PreventDefaultBeforeDispatch() inline void PreventDefaultBeforeDispatch()
{ {
if (!mCancelable) {
return;
}
mDefaultPrevented = true; mDefaultPrevented = true;
} }
inline bool DefaultPrevented() const inline bool DefaultPrevented() const