From a6ad7e8448e88e763fabd9cec6540d869cffd477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 10 Feb 2018 20:01:36 +0100 Subject: [PATCH] Bug 1405087: Make nsGenericHTMLElement::IsDisabled not virtual. r=bz The state bit is never added to object / output anyway (see the CanBeDisabled check). MozReview-Commit-ID: DBPpaHA2tME --- dom/html/HTMLObjectElement.h | 2 -- dom/html/HTMLOptGroupElement.h | 4 ---- dom/html/HTMLOptionElement.h | 4 ---- dom/html/HTMLOutputElement.h | 2 -- dom/html/nsGenericHTMLElement.cpp | 11 ++--------- dom/html/nsGenericHTMLElement.h | 7 ++++--- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/dom/html/HTMLObjectElement.h b/dom/html/HTMLObjectElement.h index 2a77f3c28a2b..77a3e7529265 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -62,8 +62,6 @@ 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.h b/dom/html/HTMLOptGroupElement.h index 16f8d012a6c1..b43928c3db86 100644 --- a/dom/html/HTMLOptGroupElement.h +++ b/dom/html/HTMLOptGroupElement.h @@ -48,10 +48,6 @@ public: virtual nsIDOMNode* AsDOMNode() override { return this; } - virtual bool IsDisabled() const override { - return State().HasState(NS_EVENT_STATE_DISABLED); - } - bool Disabled() const { return GetBoolAttr(nsGkAtoms::disabled); diff --git a/dom/html/HTMLOptionElement.h b/dom/html/HTMLOptionElement.h index 0e8a3d8aee4a..e440abafe4d2 100644 --- a/dom/html/HTMLOptionElement.h +++ b/dom/html/HTMLOptionElement.h @@ -90,10 +90,6 @@ public: nsresult CopyInnerTo(mozilla::dom::Element* aDest, bool aPreallocateChildren); - virtual bool IsDisabled() const override { - return State().HasState(NS_EVENT_STATE_DISABLED); - } - bool Disabled() const { return GetBoolAttr(nsGkAtoms::disabled); diff --git a/dom/html/HTMLOutputElement.h b/dom/html/HTMLOutputElement.h index e8cabce8627d..161010293cde 100644 --- a/dom/html/HTMLOutputElement.h +++ b/dom/html/HTMLOutputElement.h @@ -34,8 +34,6 @@ 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, bool aPreallocateChildren) const override; diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index e8ed9c4bbfb2..c30ffc72a2a5 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2034,13 +2034,6 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainVisitor& aVisitor) return nsGenericHTMLElement::PreHandleEvent(aVisitor); } -/* virtual */ -bool -nsGenericHTMLFormElement::IsDisabled() const -{ - return State().HasState(NS_EVENT_STATE_DISABLED); -} - void nsGenericHTMLFormElement::ForgetFieldSet(nsIContent* aFieldset) { @@ -2350,14 +2343,14 @@ nsGenericHTMLFormElement::UpdateFieldSet(bool aNotify) } } -void nsGenericHTMLFormElement::UpdateDisabledState(bool aNotify) +void +nsGenericHTMLFormElement::UpdateDisabledState(bool aNotify) { if (!CanBeDisabled()) { return; } bool isDisabled = HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); - if (!isDisabled && mFieldSet) { isDisabled = mFieldSet->IsDisabled(); } diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 9cdb5b03b51a..3aeb291a0cb1 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -646,9 +646,11 @@ public: /** * Returns the current disabled state of the element. + * + * TODO(emilio): Consider moving to Element? */ - virtual bool IsDisabled() const { - return false; + bool IsDisabled() const { + return State().HasState(NS_EVENT_STATE_DISABLED); } bool IsHidden() const @@ -1057,7 +1059,6 @@ public: mozilla::EventChainPreVisitor& aVisitor) override; 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