Bug 1423490 part 2. Stop overriding SetAttr in SVGStyleElement. r=bytesized
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 03 Jan 2018 14:21:23 -0500
changeset 449412 3384659645d329570b8b3a70391a43584d1930cd
parent 449411 1427408aa3667b889eb8ff076e761411e868ff8a
child 449413 ae502b906e56c100eb2f447549d7c11dd6a738d3
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbytesized
bugs1423490
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1423490 part 2. Stop overriding SetAttr in SVGStyleElement. r=bytesized This aligns the behavior with HTMLStyleElement. There are no more overrides, so SetAttr can become non-virtual. MozReview-Commit-ID: 9PFrHg7x0nY
dom/base/Element.h
dom/svg/SVGStyleElement.cpp
dom/svg/SVGStyleElement.h
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -909,20 +909,20 @@ public:
    *        for setting the attribute, or null if no scripted caller can be
    *        determined. A null value here does not guarantee that there is no
    *        scripted caller, but a non-null value does guarantee that a scripted
    *        caller with the given principal is directly responsible for the
    *        attribute change.
    * @param aNotify specifies how whether or not the document should be
    *        notified of the attribute change.
    */
-  virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName,
-                           nsAtom* aPrefix, const nsAString& aValue,
-                           nsIPrincipal* aMaybeScriptedPrincipal,
-                           bool aNotify);
+  nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName,
+                   nsAtom* aPrefix, const nsAString& aValue,
+                   nsIPrincipal* aMaybeScriptedPrincipal,
+                   bool aNotify);
 
   /**
    * Remove an attribute so that it is no longer explicitly specified.
    *
    * @param aNameSpaceID the namespace id of the attribute
    * @param aAttr the name of the attribute to unset
    * @param aNotify specifies whether or not the document should be
    * notified of the attribute change
--- a/dom/svg/SVGStyleElement.cpp
+++ b/dom/svg/SVGStyleElement.cpp
@@ -85,55 +85,36 @@ SVGStyleElement::UnbindFromTree(bool aDe
 {
   nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
   ShadowRoot* oldShadow = GetContainingShadow();
   SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
   UpdateStyleSheetInternal(oldDoc, oldShadow);
 }
 
 nsresult
-SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsAtom* aName,
-                         nsAtom* aPrefix, const nsAString& aValue,
-                         nsIPrincipal* aSubjectPrincipal,
-                         bool aNotify)
+SVGStyleElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
+                              const nsAttrValue* aValue,
+                              const nsAttrValue* aOldValue,
+                              nsIPrincipal* aMaybeScriptedPrincipal,
+                              bool aNotify)
 {
-  nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
-                                             aValue, aSubjectPrincipal, aNotify);
-  if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None) {
+  if (aNameSpaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::title ||
         aName == nsGkAtoms::media ||
         aName == nsGkAtoms::type) {
       UpdateStyleSheetInternal(nullptr, nullptr, true);
     } else if (aName == nsGkAtoms::scoped &&
                OwnerDoc()->IsScopedStyleEnabled()) {
-      UpdateStyleSheetScopedness(true);
+      UpdateStyleSheetScopedness(!!aValue);
     }
   }
 
-  return rv;
-}
-
-nsresult
-SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute,
-                           bool aNotify)
-{
-  nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
-                                               aNotify);
-  if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None) {
-    if (aAttribute == nsGkAtoms::title ||
-        aAttribute == nsGkAtoms::media ||
-        aAttribute == nsGkAtoms::type) {
-      UpdateStyleSheetInternal(nullptr, nullptr, true);
-    } else if (aAttribute == nsGkAtoms::scoped &&
-               OwnerDoc()->IsScopedStyleEnabled()) {
-      UpdateStyleSheetScopedness(false);
-    }
-  }
-
-  return rv;
+  return SVGStyleElementBase::AfterSetAttr(aNameSpaceID, aName, aValue,
+                                           aOldValue, aMaybeScriptedPrincipal,
+                                           aNotify);
 }
 
 bool
 SVGStyleElement::ParseAttribute(int32_t aNamespaceID,
                                 nsAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsIPrincipal* aMaybeScriptedPrincipal,
                                 nsAttrValue& aResult)
--- a/dom/svg/SVGStyleElement.h
+++ b/dom/svg/SVGStyleElement.h
@@ -39,23 +39,21 @@ public:
                                            SVGStyleElementBase)
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) override;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) override;
-  using Element::SetAttr;
-  virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName,
-                           nsAtom* aPrefix, const nsAString& aValue,
-                           nsIPrincipal* aSubjectPrincipal,
-                           bool aNotify) override;
-  virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute,
-                             bool aNotify) override;
+  virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
+                                const nsAttrValue* aValue,
+                                const nsAttrValue* aOldValue,
+                                nsIPrincipal* aMaybeScriptedPrincipal,
+                                bool aNotify) override;
   virtual bool ParseAttribute(int32_t aNamespaceID,
                               nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
                               nsAttrValue& aResult) override;
 
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                          bool aPreallocateChildren) const override;