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
--- a/dom/html/HTMLObjectElement.h
+++ b/dom/html/HTMLObjectElement.h
@@ -57,18 +57,16 @@ public:
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
virtual IMEState GetDesiredIMEState() override;
// Overriden nsIFormControl methods
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;
virtual bool ParseAttribute(int32_t aNamespaceID,
nsAtom *aAttribute,
const nsAString &aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue &aResult) override;
--- a/dom/html/HTMLOptGroupElement.h
+++ b/dom/html/HTMLOptGroupElement.h
@@ -43,20 +43,16 @@ public:
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) override;
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);
}
void SetDisabled(bool aValue, ErrorResult& aError)
{
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aError);
}
--- a/dom/html/HTMLOptionElement.h
+++ b/dom/html/HTMLOptionElement.h
@@ -85,20 +85,16 @@ public:
// nsIContent
virtual EventStates IntrinsicState() const override;
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
bool aPreallocateChildren) const override;
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);
}
void SetDisabled(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
--- a/dom/html/HTMLOutputElement.h
+++ b/dom/html/HTMLOutputElement.h
@@ -29,18 +29,16 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIFormControl
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;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2089,23 +2089,16 @@ nsGenericHTMLFormElement::PreHandleEvent
}
default:
break;
}
}
return nsGenericHTMLElement::PreHandleEvent(aVisitor);
}
-/* virtual */
-bool
-nsGenericHTMLFormElement::IsDisabled() const
-{
- return State().HasState(NS_EVENT_STATE_DISABLED);
-}
-
void
nsGenericHTMLFormElement::ForgetFieldSet(nsIContent* aFieldset)
{
if (mFieldSet == aFieldset) {
mFieldSet = nullptr;
}
}
@@ -2405,24 +2398,24 @@ nsGenericHTMLFormElement::UpdateFieldSet
if (mFieldSet) {
mFieldSet->RemoveElement(this);
mFieldSet = nullptr;
// The disabled state may have changed
FieldSetDisabledChanged(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();
}
EventStates disabledStates;
if (isDisabled) {
disabledStates |= NS_EVENT_STATE_DISABLED;
} else {
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -641,19 +641,21 @@ public:
* URIs in the attribute against the baseuri of the element. If a substring
* isn't a relative URI, the substring is returned as is. Only works for
* attributes in null namespace.
*/
bool GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr, nsIURI** aURI) const;
/**
* 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
{
return HasAttr(kNameSpaceID_None, nsGkAtoms::hidden);
}
virtual bool IsLabelable() const override;
@@ -1052,17 +1054,16 @@ public:
bool aNullParent = true) override;
virtual IMEState GetDesiredIMEState() override;
virtual mozilla::EventStates IntrinsicState() const override;
virtual nsresult GetEventTargetParent(
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
* disabled attribute is changed so the element knows its disabled state
* might have changed.
*
* @note Classes redefining this method should not do any content
* state updates themselves but should just make sure to call into