diff options
Diffstat (limited to 'dom/html')
-rw-r--r-- | dom/html/HTMLButtonElement.cpp | 6 | ||||
-rw-r--r-- | dom/html/HTMLButtonElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLFieldSetElement.cpp | 6 | ||||
-rw-r--r-- | dom/html/HTMLFieldSetElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLInputElement.cpp | 6 | ||||
-rw-r--r-- | dom/html/HTMLInputElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLSelectElement.cpp | 6 | ||||
-rw-r--r-- | dom/html/HTMLSelectElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLTextAreaElement.cpp | 6 | ||||
-rw-r--r-- | dom/html/HTMLTextAreaElement.h | 2 | ||||
-rw-r--r-- | dom/html/nsGenericHTMLElement.cpp | 14 | ||||
-rw-r--r-- | dom/html/nsGenericHTMLElement.h | 2 | ||||
-rw-r--r-- | dom/html/nsIFormControl.h | 2 |
13 files changed, 33 insertions, 25 deletions
diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 1a76aac10a..78db276798 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -199,18 +199,18 @@ HTMLButtonElement::ParseAttribute(int32_t aNamespaceID, } bool -HTMLButtonElement::IsDisabledForEvents(EventMessage aMessage) +HTMLButtonElement::IsDisabledForEvents(WidgetEvent* aEvent) { nsIFormControlFrame* formControlFrame = GetFormControlFrame(false); nsIFrame* formFrame = do_QueryFrame(formControlFrame); - return IsElementDisabledForEvents(aMessage, formFrame); + return IsElementDisabledForEvents(aEvent, formFrame); } nsresult HTMLButtonElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; - if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { + if (IsDisabledForEvents(aVisitor.mEvent)) { return NS_OK; } diff --git a/dom/html/HTMLButtonElement.h b/dom/html/HTMLButtonElement.h index 8bab9fd48e..34e5fd24da 100644 --- a/dom/html/HTMLButtonElement.h +++ b/dom/html/HTMLButtonElement.h @@ -52,7 +52,7 @@ public: NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; NS_IMETHOD SaveState() override; bool RestoreState(nsPresState* aState) override; - virtual bool IsDisabledForEvents(EventMessage aMessage) override; + virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override; virtual void FieldSetDisabledChanged(bool aNotify) override; diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp index f546cad5b4..e7fb124c7a 100644 --- a/dom/html/HTMLFieldSetElement.cpp +++ b/dom/html/HTMLFieldSetElement.cpp @@ -63,9 +63,9 @@ NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name) NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement) bool -HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage) +HTMLFieldSetElement::IsDisabledForEvents(WidgetEvent* aEvent) { - return IsElementDisabledForEvents(aMessage, nullptr); + return IsElementDisabledForEvents(aEvent, nullptr); } // nsIContent @@ -74,7 +74,7 @@ HTMLFieldSetElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { // Do not process any DOM events if the element is disabled. aVisitor.mCanHandle = false; - if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { + if (IsDisabledForEvents(aVisitor.mEvent)) { return NS_OK; } diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h index 2c0e9cc149..7f10e4a5b5 100644 --- a/dom/html/HTMLFieldSetElement.h +++ b/dom/html/HTMLFieldSetElement.h @@ -55,7 +55,7 @@ public: NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_FIELDSET; } NS_IMETHOD Reset() override; NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; - virtual bool IsDisabledForEvents(EventMessage aMessage) override; + virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override; const nsIContent* GetFirstLegend() const { return mFirstLegend; } diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 7708a60acf..f2c14ff2dc 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3712,9 +3712,9 @@ HTMLInputElement::NeedToInitializeEditorForEvent( } bool -HTMLInputElement::IsDisabledForEvents(EventMessage aMessage) +HTMLInputElement::IsDisabledForEvents(WidgetEvent* aEvent) { - return IsElementDisabledForEvents(aMessage, GetPrimaryFrame()); + return IsElementDisabledForEvents(aEvent, GetPrimaryFrame()); } nsresult @@ -3722,7 +3722,7 @@ HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { // Do not process any DOM events if the element is disabled aVisitor.mCanHandle = false; - if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { + if (IsDisabledForEvents(aVisitor.mEvent)) { return NS_OK; } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 55bb59ec98..d2aff5b1cd 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -169,7 +169,7 @@ public: NS_IMETHOD SaveState() override; virtual bool RestoreState(nsPresState* aState) override; virtual bool AllowDrop() override; - virtual bool IsDisabledForEvents(EventMessage aMessage) override; + virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override; virtual void FieldSetDisabledChanged(bool aNotify) override; diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp index 36dac0852b..022232d838 100644 --- a/dom/html/HTMLSelectElement.cpp +++ b/dom/html/HTMLSelectElement.cpp @@ -1419,21 +1419,21 @@ HTMLSelectElement::GetAttributeMappingFunction() const } bool -HTMLSelectElement::IsDisabledForEvents(EventMessage aMessage) +HTMLSelectElement::IsDisabledForEvents(WidgetEvent* aEvent) { nsIFormControlFrame* formControlFrame = GetFormControlFrame(false); nsIFrame* formFrame = nullptr; if (formControlFrame) { formFrame = do_QueryFrame(formControlFrame); } - return IsElementDisabledForEvents(aMessage, formFrame); + return IsElementDisabledForEvents(aEvent, formFrame); } nsresult HTMLSelectElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; - if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { + if (IsDisabledForEvents(aVisitor.mEvent)) { return NS_OK; } diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h index 298b1a8d16..0e23f56d44 100644 --- a/dom/html/HTMLSelectElement.h +++ b/dom/html/HTMLSelectElement.h @@ -294,7 +294,7 @@ public: NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; NS_IMETHOD SaveState() override; virtual bool RestoreState(nsPresState* aState) override; - virtual bool IsDisabledForEvents(EventMessage aMessage) override; + virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override; virtual void FieldSetDisabledChanged(bool aNotify) override; diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp index f25241d60e..0040f083b4 100644 --- a/dom/html/HTMLTextAreaElement.cpp +++ b/dom/html/HTMLTextAreaElement.cpp @@ -498,18 +498,18 @@ HTMLTextAreaElement::GetAttributeMappingFunction() const } bool -HTMLTextAreaElement::IsDisabledForEvents(EventMessage aMessage) +HTMLTextAreaElement::IsDisabledForEvents(WidgetEvent* aEvent) { nsIFormControlFrame* formControlFrame = GetFormControlFrame(false); nsIFrame* formFrame = do_QueryFrame(formControlFrame); - return IsElementDisabledForEvents(aMessage, formFrame); + return IsElementDisabledForEvents(aEvent, formFrame); } nsresult HTMLTextAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; - if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { + if (IsDisabledForEvents(aVisitor.mEvent)) { return NS_OK; } diff --git a/dom/html/HTMLTextAreaElement.h b/dom/html/HTMLTextAreaElement.h index 5ab58554ec..e5fef8263f 100644 --- a/dom/html/HTMLTextAreaElement.h +++ b/dom/html/HTMLTextAreaElement.h @@ -77,7 +77,7 @@ public: NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; NS_IMETHOD SaveState() override; virtual bool RestoreState(nsPresState* aState) override; - virtual bool IsDisabledForEvents(EventMessage aMessage) override; + virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override; virtual void FieldSetDisabledChanged(bool aNotify) override; diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index aa70f9cdfe..17dba6da98 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2285,10 +2285,17 @@ nsGenericHTMLFormElement::FormIdUpdated(Element* aOldElement, } bool -nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage, +nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent, nsIFrame* aFrame) { - switch (aMessage) { + MOZ_ASSERT(aEvent); + + // Allow dispatch of CustomEvent and untrusted Events. + if (!aEvent->IsTrusted()) { + return false; + } + + switch (aEvent->mMessage) { case eMouseMove: case eMouseOver: case eMouseOut: @@ -2454,8 +2461,9 @@ nsGenericHTMLFormElement::IsLabelable() const void nsGenericHTMLElement::Click() { - if (HandlingClick()) + if (IsDisabled() || HandlingClick()) { return; + } // Strong in case the event kills it nsCOMPtr<nsIDocument> doc = GetComposedDoc(); diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 9886e10f54..c9169df117 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -1307,7 +1307,7 @@ protected: void* aData); // Returns true if the event should not be handled from GetEventTargetParent - bool IsElementDisabledForEvents(mozilla::EventMessage aMessage, + bool IsElementDisabledForEvents(mozilla::WidgetEvent* aEvent, nsIFrame* aFrame); // The focusability state of this form control. eUnfocusable means that it diff --git a/dom/html/nsIFormControl.h b/dom/html/nsIFormControl.h index 34380bc679..22f1d08b3a 100644 --- a/dom/html/nsIFormControl.h +++ b/dom/html/nsIFormControl.h @@ -207,7 +207,7 @@ public: */ inline bool AllowDraggableChildren() const; - virtual bool IsDisabledForEvents(mozilla::EventMessage aMessage) + virtual bool IsDisabledForEvents(mozilla::WidgetEvent* aEvent) { return false; } |