diff options
author | athenian200 <athenian200@outlook.com> | 2020-05-21 01:31:48 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-05-23 16:12:59 +0200 |
commit | a3124c55a13fba4877e0eaa7a6b31f17832b6ce1 (patch) | |
tree | ed44abb0edc3aa974e7bb933da244409c985ced5 | |
parent | c4ed56660230a124fa3457cd5f789e78a3188515 (diff) | |
download | UXP-a3124c55a13fba4877e0eaa7a6b31f17832b6ce1.tar UXP-a3124c55a13fba4877e0eaa7a6b31f17832b6ce1.tar.gz UXP-a3124c55a13fba4877e0eaa7a6b31f17832b6ce1.tar.lz UXP-a3124c55a13fba4877e0eaa7a6b31f17832b6ce1.tar.xz UXP-a3124c55a13fba4877e0eaa7a6b31f17832b6ce1.zip |
Issue #1557 - Allow event dispatch on disabled form controls. (uplift)
-rw-r--r-- | dom/base/nsDOMWindowUtils.cpp | 3 | ||||
-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 |
14 files changed, 35 insertions, 26 deletions
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 2ab5937ac..adb407a04 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3577,7 +3577,8 @@ nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal) while (node) { if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) { nsCOMPtr<nsIFormControl> fc = do_QueryInterface(node); - if (fc && fc->IsDisabledForEvents(eVoidEvent)) { + WidgetEvent event(true, eVoidEvent); + if (fc && fc->IsDisabledForEvents(&event)) { *aRetVal = true; break; } diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 435aa9f7f..609eb7a66 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::PreHandleEvent(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 ecd9e03d7..d15d11b6d 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 d72fd1061..788d88791 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::PreHandleEvent(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 96fff4582..4a4ab71e4 100644 --- a/dom/html/HTMLFieldSetElement.h +++ b/dom/html/HTMLFieldSetElement.h @@ -52,7 +52,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 0b879bb9b..7a07994f7 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3732,9 +3732,9 @@ HTMLInputElement::NeedToInitializeEditorForEvent( } bool -HTMLInputElement::IsDisabledForEvents(EventMessage aMessage) +HTMLInputElement::IsDisabledForEvents(WidgetEvent* aEvent) { - return IsElementDisabledForEvents(aMessage, GetPrimaryFrame()); + return IsElementDisabledForEvents(aEvent, GetPrimaryFrame()); } nsresult @@ -3742,7 +3742,7 @@ HTMLInputElement::PreHandleEvent(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 98a590443..a000aa21d 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 9ba0a1efe..e1bc0ca62 100644 --- a/dom/html/HTMLSelectElement.cpp +++ b/dom/html/HTMLSelectElement.cpp @@ -1431,21 +1431,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::PreHandleEvent(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 dc1075cd7..b9041c885 100644 --- a/dom/html/HTMLSelectElement.h +++ b/dom/html/HTMLSelectElement.h @@ -293,7 +293,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 42bc02435..4c40c16f3 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::PreHandleEvent(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 039082818..90fb680c5 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 2f890325a..1e2f1c186 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2286,10 +2286,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: @@ -2455,8 +2462,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 72039f266..23fabc4e8 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -1308,7 +1308,7 @@ protected: void* aData); // Returns true if the event should not be handled from PreHandleEvent - 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 34380bc67..22f1d08b3 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; } |