diff options
author | athenian200 <athenian200@outlook.com> | 2020-05-20 23:25:37 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-05-23 16:10:40 +0200 |
commit | c4ed56660230a124fa3457cd5f789e78a3188515 (patch) | |
tree | 0edc55305d449c3851ecc2ad1df8961cc2df7a3b /dom/html | |
parent | 99c2e698d2a3c56649e42d8d2133706cd8c9501e (diff) | |
download | UXP-c4ed56660230a124fa3457cd5f789e78a3188515.tar UXP-c4ed56660230a124fa3457cd5f789e78a3188515.tar.gz UXP-c4ed56660230a124fa3457cd5f789e78a3188515.tar.lz UXP-c4ed56660230a124fa3457cd5f789e78a3188515.tar.xz UXP-c4ed56660230a124fa3457cd5f789e78a3188515.zip |
Revert "Merge pull request #1357 from athenian200/form-disabled-issue"
This reverts commit ed88b99849156004c04e4a0c87ea9b2360ef19b6, reversing
changes made to c4b0715baaffc541670fd1158557aa7e61e521d3.
Diffstat (limited to 'dom/html')
-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 |
8 files changed, 39 insertions, 13 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 5226154da..4041b78a3 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -77,6 +77,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 9e738961d..8a044fbf3 100644 --- a/dom/html/HTMLOptGroupElement.cpp +++ b/dom/html/HTMLOptGroupElement.cpp @@ -53,14 +53,15 @@ HTMLOptGroupElement::PreHandleEvent(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 e46a6a953..d53a2e32b 100644 --- a/dom/html/HTMLOptGroupElement.h +++ b/dom/html/HTMLOptGroupElement.h @@ -46,6 +46,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 4b5e192ff..e220b84df 100644 --- a/dom/html/HTMLOptionElement.h +++ b/dom/html/HTMLOptionElement.h @@ -67,6 +67,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 0c8bcc9c8..2f890325a 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2109,6 +2109,14 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) return nsGenericHTMLElement::PreHandleEvent(aVisitor); } +/* virtual */ +bool +nsGenericHTMLFormElement::IsDisabled() const +{ + return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled) || + (mFieldSet && mFieldSet->IsDisabled()); +} + void nsGenericHTMLFormElement::ForgetFieldSet(nsIContent* aFieldset) { @@ -2300,13 +2308,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 acbebe087..72039f266 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -817,8 +817,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 @@ -1222,6 +1222,8 @@ public: virtual nsresult PreHandleEvent( mozilla::EventChainPreVisitor& 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 |