summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2020-05-21 01:31:48 -0500
committerathenian200 <athenian200@outlook.com>2020-05-21 01:31:48 -0500
commit4076a5d4b87a31e34681bd4d50dc0464365629f1 (patch)
treea718c93bec7faed8e7da1a11c5ecafac43b6d571
parent8f03d6a8ac10879defa3b300026dd5d55979b5d6 (diff)
downloadaura-central-4076a5d4b87a31e34681bd4d50dc0464365629f1.tar.gz
Issue mcp-graveyard/UXP%1557 - Allow event dispatch on disabled form controls.
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=329509 This seems to resolve %1356 without causing %1557. Also reverts previous changes as they no longer appear to serve a purpose.
-rw-r--r--dom/base/nsDOMWindowUtils.cpp3
-rw-r--r--dom/html/HTMLButtonElement.cpp6
-rw-r--r--dom/html/HTMLButtonElement.h2
-rw-r--r--dom/html/HTMLFieldSetElement.cpp6
-rw-r--r--dom/html/HTMLFieldSetElement.h2
-rw-r--r--dom/html/HTMLInputElement.cpp6
-rw-r--r--dom/html/HTMLInputElement.h2
-rw-r--r--dom/html/HTMLSelectElement.cpp6
-rw-r--r--dom/html/HTMLSelectElement.h2
-rw-r--r--dom/html/HTMLTextAreaElement.cpp6
-rw-r--r--dom/html/HTMLTextAreaElement.h2
-rw-r--r--dom/html/nsGenericHTMLElement.cpp14
-rw-r--r--dom/html/nsGenericHTMLElement.h2
-rw-r--r--dom/html/nsIFormControl.h2
14 files changed, 35 insertions, 26 deletions
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
index a923e8f70..5e9235f11 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 1a76aac10..78db27679 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 8bab9fd48..34e5fd24d 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 f546cad5b..e7fb124c7 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 2c0e9cc14..7f10e4a5b 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 7708a60ac..f2c14ff2d 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 55bb59ec9..d2aff5b1c 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 36dac0852..022232d83 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 298b1a8d1..0e23f56d4 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 f25241d60..0040f083b 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 5ab58554e..e5fef8263 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 aa70f9cdf..17dba6da9 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 9886e10f5..c9169df11 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 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;
}