From c4ed56660230a124fa3457cd5f789e78a3188515 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Wed, 20 May 2020 23:25:37 -0500 Subject: Revert "Merge pull request #1357 from athenian200/form-disabled-issue" This reverts commit ed88b99849156004c04e4a0c87ea9b2360ef19b6, reversing changes made to c4b0715baaffc541670fd1158557aa7e61e521d3. --- dom/html/HTMLLabelElement.h | 2 ++ dom/html/HTMLObjectElement.h | 2 ++ dom/html/HTMLOptGroupElement.cpp | 11 ++++++----- dom/html/HTMLOptGroupElement.h | 4 ++++ dom/html/HTMLOptionElement.h | 4 ++++ dom/html/HTMLOutputElement.h | 2 ++ dom/html/nsGenericHTMLElement.cpp | 21 +++++++++++++++------ dom/html/nsGenericHTMLElement.h | 6 ++++-- 8 files changed, 39 insertions(+), 13 deletions(-) (limited to 'dom/html') 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 -- cgit v1.2.3