From d6ac03b76bd3a73b79e41ad594c33168e6570061 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2017 00:35:19 -0400 Subject: [PATCH] Bug 1357646 part 1. Move the setting of mType from HTMLButtonElement::ParseAttribute to HTMLButtonElement::AfterSetAttr. r=mystor ParseAttribute should generally not mutate the element. --- dom/html/HTMLButtonElement.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index f9a8ca630262..eacaa05f5573 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -173,16 +173,8 @@ HTMLButtonElement::ParseAttribute(int32_t aNamespaceID, { if (aNamespaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::type) { - // XXX ARG!! This is major evilness. ParseAttribute - // shouldn't set members. Override SetAttr instead - bool success = aResult.ParseEnumValue(aValue, kButtonTypeTable, false); - if (success) { - mType = aResult.GetEnumValue(); - } else { - mType = kButtonDefaultType->value; - } - - return success; + return aResult.ParseEnumValue(aValue, kButtonTypeTable, false, + kButtonDefaultType); } if (aAttribute == nsGkAtoms::formmethod) { @@ -440,7 +432,9 @@ HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::type) { - if (!aValue) { + if (aValue) { + mType = aValue->GetEnumValue(); + } else { mType = kButtonDefaultType->value; } }