Bug 824481 - Cleanup style attribute getters; r=bz
authorMs2ger <ms2ger@gmail.com>
Fri, 11 Jan 2013 09:42:59 +0100
changeset 118353 c5cb5c111ea5e24ebc484c45dffba15a78ebd77f
parent 118352 8592c41069c206e8d522b4ed3734163ce01617d1
child 118354 c55caac4f6a7fa7e8362883dbe0a907694de2425
push id24164
push userMs2ger@gmail.com
push dateFri, 11 Jan 2013 08:45:25 +0000
treeherdermozilla-central@5b3c75e859d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs824481
milestone21.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 824481 - Cleanup style attribute getters; r=bz
content/base/src/nsStyledElement.cpp
content/base/src/nsStyledElement.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
content/svg/content/src/nsSVGElement.cpp
content/svg/content/src/nsSVGElement.h
content/xul/content/src/nsXULElement.cpp
dom/webidl/HTMLElement.webidl
dom/webidl/SVGElement.webidl
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -186,29 +186,28 @@ nsStyledElementNotElementCSSInlineStyle:
 
   return nullptr;
 }
 
 // ---------------------------------------------------------------
 // Others and helpers
 
 nsICSSDeclaration*
-nsStyledElementNotElementCSSInlineStyle::GetStyle(nsresult* retval)
+nsStyledElementNotElementCSSInlineStyle::Style()
 {
   Element::nsDOMSlots *slots = DOMSlots();
 
   if (!slots->mStyle) {
     // Just in case...
     ReparseStyleAttribute(true);
 
     slots->mStyle = new nsDOMCSSAttributeDeclaration(this, false);
     SetMayHaveStyle();
   }
 
-  *retval = NS_OK;
   return slots->mStyle;
 }
 
 nsresult
 nsStyledElementNotElementCSSInlineStyle::ReparseStyleAttribute(bool aForceInDataDoc)
 {
   if (!MayHaveStyle()) {
     return NS_OK;
--- a/content/base/src/nsStyledElement.h
+++ b/content/base/src/nsStyledElement.h
@@ -45,17 +45,17 @@ public:
                                       const nsAString* aSerialized,
                                       bool aNotify);
 
   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                              bool aNotify);
   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                                 const nsAttrValue* aValue, bool aNotify);
 
-  nsICSSDeclaration* GetStyle(nsresult* retval);
+  nsICSSDeclaration* Style();
 
 protected:
 
   /**
    * Parse a style attr value into a CSS rulestruct (or, if there is no
    * document, leave it as a string) and return as nsAttrValue.
    *
    * @param aValue the value to parse
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -228,19 +228,18 @@ class nsGenericHTMLElementTearoff : publ
   }
 
   virtual ~nsGenericHTMLElementTearoff()
   {
   }
 
   NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
   {
-    mozilla::ErrorResult rv;
-    NS_IF_ADDREF(*aStyle = mElement->GetStyle(rv));
-    return rv.ErrorCode();
+    NS_ADDREF(*aStyle = mElement->Style());
+    return NS_OK;
   }
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff,
                                            nsIDOMElementCSSInlineStyle)
 
 private:
   nsRefPtr<nsGenericHTMLElement> mElement;
 };
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -224,25 +224,16 @@ public:
   bool Spellcheck();
   void SetSpellcheck(bool aSpellcheck, mozilla::ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::spellcheck,
                 aSpellcheck ? NS_LITERAL_STRING("true")
                             : NS_LITERAL_STRING("false"),
                 aError);
   }
-  nsICSSDeclaration* GetStyle(mozilla::ErrorResult& aError)
-  {
-    nsresult rv;
-    nsICSSDeclaration* style = nsMappedAttributeElement::GetStyle(&rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-    }
-    return style;
-  }
 
   /**
    * Determine whether an attribute is an event (onclick, etc.)
    * @param aName the attribute
    * @return whether the name is an event handler name
    */
   virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
 
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -97,32 +97,18 @@ nsSVGElement::GetClassName(nsIDOMSVGAnim
   *aClassName = ClassName().get();
   return NS_OK;
 }
 
 /* readonly attribute nsIDOMCSSStyleDeclaration style; */
 NS_IMETHODIMP
 nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
 {
-  ErrorResult rv;
-  NS_ADDREF(*aStyle = GetStyle(rv));
-  return rv.ErrorCode();
-}
-
-nsICSSDeclaration*
-nsSVGElement::GetStyle(ErrorResult& rv)
-{
-  nsresult res;
-  nsICSSDeclaration* style = nsSVGElementBase::GetStyle(&res);
-  if (NS_FAILED(res)) {
-    rv.Throw(res);
-    return nullptr;
-  }
-
-  return style;
+  NS_ADDREF(*aStyle = Style());
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 void
 nsSVGElement::DidAnimateClass()
 {
--- a/content/svg/content/src/nsSVGElement.h
+++ b/content/svg/content/src/nsSVGElement.h
@@ -296,17 +296,16 @@ public:
   virtual nsIAtom* GetTransformListAttrName() const {
     return nullptr;
   }
 
   // WebIDL
   mozilla::dom::SVGSVGElement* GetOwnerSVGElement(mozilla::ErrorResult& rv);
   nsSVGElement* GetViewportElement();
   already_AddRefed<nsIDOMSVGAnimatedString> ClassName();
-  nsICSSDeclaration* GetStyle(mozilla::ErrorResult& rv);
   already_AddRefed<mozilla::dom::CSSValue> GetPresentationAttribute(const nsAString& aName, mozilla::ErrorResult& rv);
 protected:
   virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap);
 
 #ifdef DEBUG
   // We define BeforeSetAttr here and mark it MOZ_FINAL to ensure it is NOT used
   // by SVG elements.
   // This is because we're not currently passing the correct value for aValue to
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -131,20 +131,18 @@ public:
 
   nsXULElementTearoff(nsXULElement *aElement)
     : mElement(aElement)
   {
   }
 
   NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
   {
-    nsresult rv;
-    *aStyle = static_cast<nsXULElement*>(mElement.get())->GetStyle(&rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ADDREF(*aStyle);
+    nsXULElement* element = static_cast<nsXULElement*>(mElement.get());
+    NS_ADDREF(*aStyle = element->Style());
     return NS_OK;
   }
   NS_FORWARD_NSIFRAMELOADEROWNER(static_cast<nsXULElement*>(mElement.get())->)
 private:
   nsCOMPtr<nsIDOMXULElement> mElement;
 };
 
 NS_IMPL_CYCLE_COLLECTION_1(nsXULElementTearoff, mElement)
--- a/dom/webidl/HTMLElement.webidl
+++ b/dom/webidl/HTMLElement.webidl
@@ -68,17 +68,17 @@ interface HTMLElement : Element {
   //readonly attribute DOMString? commandType;
   //readonly attribute DOMString? commandLabel;
   //readonly attribute DOMString? commandIcon;
   //readonly attribute boolean? commandHidden;
   //readonly attribute boolean? commandDisabled;
   //readonly attribute boolean? commandChecked;
 
   // styling
-  [Throws, Constant]
+  [Constant]
   readonly attribute CSSStyleDeclaration style;
 
   // event handler IDL attributes
   [SetterThrows]
            attribute EventHandler onabort;
   [SetterThrows]
            attribute EventHandler onblur;
   //[SetterThrows]
--- a/dom/webidl/SVGElement.webidl
+++ b/dom/webidl/SVGElement.webidl
@@ -13,17 +13,16 @@
 interface SVGAnimatedString;
 
 interface SVGElement : Element {
            attribute DOMString id;
 /*           [SetterThrows]
            attribute DOMString xmlbase; */
 
   readonly attribute SVGAnimatedString className;
-  [Throws]
   readonly attribute CSSStyleDeclaration style;
 
   // The CSSValue interface has been deprecated by the CSS WG.
   // http://lists.w3.org/Archives/Public/www-style/2003Oct/0347.html
   // CSSValue? getPresentationAttribute(DOMString name);
 
   /*[SetterThrows]
   attribute DOMString xmllang;
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -355,18 +355,18 @@ customMethodCalls = {
         'code': nsIDOMStorage_Clear_customMethodCallCode
         },
     'nsIDOMElementCSSInlineStyle_GetStyle': {
         'thisType': 'nsStyledElement',
         'code': '    /* XXXbz MathML elements inherit from nsStyledElement but\n'
                 '       don\'t actually implement GetStyle. */\n'
                 '    if (self->GetNameSpaceID() == kNameSpaceID_MathML)\n'
                 '      return xpc_qsThrow(cx, NS_ERROR_XPC_BAD_CONVERT_JS);\n'
-                '    nsIDOMCSSStyleDeclaration* result = '
-                'self->GetStyle(&rv);'
+                '    nsIDOMCSSStyleDeclaration* result = self->Style();',
+        'canFail': False
         },
     'nsIDOMWindow_GetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMWindow_SetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False