diff options
author | athenian200 <athenian200@outlook.com> | 2020-05-20 23:25:37 -0500 |
---|---|---|
committer | athenian200 <athenian200@outlook.com> | 2020-05-20 23:25:37 -0500 |
commit | a965486fcbf3f199b5c7564bfc0526df72c862d5 (patch) | |
tree | b6238d784e74ab2912a35ab14caabe96734bd469 /dom | |
parent | 3da22ea943f6e7840558ddd1e4b473bef5837873 (diff) | |
download | UXP-a965486fcbf3f199b5c7564bfc0526df72c862d5.tar UXP-a965486fcbf3f199b5c7564bfc0526df72c862d5.tar.gz UXP-a965486fcbf3f199b5c7564bfc0526df72c862d5.tar.lz UXP-a965486fcbf3f199b5c7564bfc0526df72c862d5.tar.xz UXP-a965486fcbf3f199b5c7564bfc0526df72c862d5.zip |
Revert "Merge pull request #1357 from athenian200/form-disabled-issue"
This reverts commit ed88b99849156004c04e4a0c87ea9b2360ef19b6, reversing
changes made to c4b0715baaffc541670fd1158557aa7e61e521d3.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/html/HTMLLabelElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLObjectElement.h | 2 | ||||
-rw-r--r-- | dom/html/HTMLOptGroupElement.cpp | 11 | ||||
-rw-r--r-- | dom/html/HTMLOptGroupElement.h | 4 | ||||
-rw-r--r-- | dom/html/HTMLOptionElement.h | 4 | ||||
-rw-r--r-- | dom/html/HTMLOutputElement.h | 2 | ||||
-rw-r--r-- | dom/html/nsGenericHTMLElement.cpp | 21 | ||||
-rw-r--r-- | dom/html/nsGenericHTMLElement.h | 6 | ||||
-rw-r--r-- | dom/interfaces/base/nsIDOMWindowUtils.idl | 2 |
9 files changed, 40 insertions, 14 deletions
diff --git a/dom/html/HTMLLabelElement.h b/dom/html/HTMLLabelElement.h index 4057ffef6..c8385fc53 100644 --- a/dom/html/HTMLLabelElement.h +++ b/dom/html/HTMLLabelElement.h @@ -59,6 +59,8 @@ public: using nsGenericHTMLElement::Focus; virtual void Focus(mozilla::ErrorResult& aError) override; + virtual bool IsDisabled() const override { return false; } + // nsIContent virtual nsresult PostHandleEvent( EventChainPostVisitor& aVisitor) override; diff --git a/dom/html/HTMLObjectElement.h b/dom/html/HTMLObjectElement.h index 6ce09e1cc..016743c2c 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -72,6 +72,8 @@ public: NS_IMETHOD Reset() override; NS_IMETHOD SubmitNamesValues(HTMLFormSubmission *aFormSubmission) override; + virtual bool IsDisabled() const override { return false; } + virtual void DoneAddingChildren(bool aHaveNotified) override; virtual bool IsDoneAddingChildren() override; diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp index 63af4e39f..7467c5da3 100644 --- a/dom/html/HTMLOptGroupElement.cpp +++ b/dom/html/HTMLOptGroupElement.cpp @@ -53,14 +53,15 @@ HTMLOptGroupElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) aVisitor.mCanHandle = false; // Do not process any DOM events if the element is disabled // XXXsmaug This is not the right thing to do. But what is? - if (IsDisabled()) { + if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) { return NS_OK; } - if (nsIFrame* frame = GetPrimaryFrame()) { - // FIXME(emilio): This poking at the style of the frame is broken unless we - // flush before every event handling, which we don't really want to. - if (frame->StyleUserInterface()->mUserInput == StyleUserInput::None) { + nsIFrame* frame = GetPrimaryFrame(); + if (frame) { + const nsStyleUserInterface* uiStyle = frame->StyleUserInterface(); + if (uiStyle->mUserInput == StyleUserInput::None || + uiStyle->mUserInput == StyleUserInput::Disabled) { return NS_OK; } } diff --git a/dom/html/HTMLOptGroupElement.h b/dom/html/HTMLOptGroupElement.h index 6853e51ed..d12f1c6d4 100644 --- a/dom/html/HTMLOptGroupElement.h +++ b/dom/html/HTMLOptGroupElement.h @@ -49,6 +49,10 @@ public: virtual nsIDOMNode* AsDOMNode() override { return this; } + virtual bool IsDisabled() const override { + return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); + } + bool Disabled() const { return GetBoolAttr(nsGkAtoms::disabled); diff --git a/dom/html/HTMLOptionElement.h b/dom/html/HTMLOptionElement.h index 965cdeb8f..de556b645 100644 --- a/dom/html/HTMLOptionElement.h +++ b/dom/html/HTMLOptionElement.h @@ -69,6 +69,10 @@ public: nsresult CopyInnerTo(mozilla::dom::Element* aDest); + virtual bool IsDisabled() const override { + return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); + } + bool Disabled() const { return GetBoolAttr(nsGkAtoms::disabled); diff --git a/dom/html/HTMLOutputElement.h b/dom/html/HTMLOutputElement.h index 6b6c3f66c..588262480 100644 --- a/dom/html/HTMLOutputElement.h +++ b/dom/html/HTMLOutputElement.h @@ -35,6 +35,8 @@ public: NS_IMETHOD Reset() override; NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; + virtual bool IsDisabled() const override { return false; } + nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override; bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 3cf19ea8f..aa70f9cdf 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2108,6 +2108,14 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainVisitor& aVisitor) return nsGenericHTMLElement::PreHandleEvent(aVisitor); } +/* virtual */ +bool +nsGenericHTMLFormElement::IsDisabled() const +{ + return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled) || + (mFieldSet && mFieldSet->IsDisabled()); +} + void nsGenericHTMLFormElement::ForgetFieldSet(nsIContent* aFieldset) { @@ -2299,13 +2307,14 @@ nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage, break; } - // FIXME(emilio): This poking at the style of the frame is slightly bogus - // unless we flush before every event, which we don't really want to do. - if (aFrame && - aFrame->StyleUserInterface()->mUserInput == StyleUserInput::None) { - return true; + bool disabled = IsDisabled(); + if (!disabled && aFrame) { + const nsStyleUserInterface* uiStyle = aFrame->StyleUserInterface(); + disabled = uiStyle->mUserInput == StyleUserInput::None || + uiStyle->mUserInput == StyleUserInput::Disabled; + } - return IsDisabled(); + return disabled; } void diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 1b0977fa2..9886e10f5 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -807,8 +807,8 @@ public: /** * Returns the current disabled state of the element. */ - bool IsDisabled() const { - return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); + virtual bool IsDisabled() const { + return false; } bool IsHidden() const @@ -1219,6 +1219,8 @@ public: virtual nsresult PreHandleEvent( mozilla::EventChainVisitor& aVisitor) override; + virtual bool IsDisabled() const override; + /** * This callback is called by a fieldest on all its elements whenever its * disabled attribute is changed so the element knows its disabled state diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index fcfe407e8..70ec7e0ae 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -1786,7 +1786,7 @@ interface nsIDOMWindowUtils : nsISupports { /** * In certain cases the event handling of nodes, form controls in practice, * may be disabled. Such cases are for example the existence of disabled - * attribute or -moz-user-input: none. + * attribute or -moz-user-input: none/disabled. */ boolean isNodeDisabledForEvents(in nsIDOMNode aNode); |