From effe119b3dd8e1c34c2df1a2633c0f78bb9b78d1 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 11 Jan 2013 09:42:59 +0100 Subject: [PATCH] Bug 824481 - Cleanup style attribute getters; r=bz --- content/base/src/nsStyledElement.cpp | 3 +-- content/base/src/nsStyledElement.h | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 5 ++--- .../html/content/src/nsGenericHTMLElement.h | 9 --------- content/svg/content/src/nsSVGElement.cpp | 18 ++---------------- content/svg/content/src/nsSVGElement.h | 1 - content/xul/content/src/nsXULElement.cpp | 6 ++---- dom/webidl/HTMLElement.webidl | 2 +- dom/webidl/SVGElement.webidl | 1 - js/xpconnect/src/dom_quickstubs.qsconf | 4 ++-- 10 files changed, 11 insertions(+), 40 deletions(-) diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 8992b9f660f..c76a6e6a55f 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -191,7 +191,7 @@ nsStyledElementNotElementCSSInlineStyle::GetInlineStyleRule() // Others and helpers nsICSSDeclaration* -nsStyledElementNotElementCSSInlineStyle::GetStyle(nsresult* retval) +nsStyledElementNotElementCSSInlineStyle::Style() { Element::nsDOMSlots *slots = DOMSlots(); @@ -203,7 +203,6 @@ nsStyledElementNotElementCSSInlineStyle::GetStyle(nsresult* retval) SetMayHaveStyle(); } - *retval = NS_OK; return slots->mStyle; } diff --git a/content/base/src/nsStyledElement.h b/content/base/src/nsStyledElement.h index cf0d2b7aa78..9806a52fa31 100644 --- a/content/base/src/nsStyledElement.h +++ b/content/base/src/nsStyledElement.h @@ -50,7 +50,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, const nsAttrValue* aValue, bool aNotify); - nsICSSDeclaration* GetStyle(nsresult* retval); + nsICSSDeclaration* Style(); protected: diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 1106d1ec072..f94a4821375 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -233,9 +233,8 @@ class nsGenericHTMLElementTearoff : public nsIDOMElementCSSInlineStyle 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, diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index ae08966c068..5ff1bde4a4b 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -229,15 +229,6 @@ public: : 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.) diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 58524d1bfcf..53c85747aa9 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -102,22 +102,8 @@ nsSVGElement::GetClassName(nsIDOMSVGAnimatedString** aClassName) 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; } //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index 48759fc8ae9..c96a890bdd6 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -301,7 +301,6 @@ public: mozilla::dom::SVGSVGElement* GetOwnerSVGElement(mozilla::ErrorResult& rv); nsSVGElement* GetViewportElement(); already_AddRefed ClassName(); - nsICSSDeclaration* GetStyle(mozilla::ErrorResult& rv); already_AddRefed GetPresentationAttribute(const nsAString& aName, mozilla::ErrorResult& rv); protected: virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index c87be6820af..49d33f06320 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -136,10 +136,8 @@ public: NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle) { - nsresult rv; - *aStyle = static_cast(mElement.get())->GetStyle(&rv); - NS_ENSURE_SUCCESS(rv, rv); - NS_ADDREF(*aStyle); + nsXULElement* element = static_cast(mElement.get()); + NS_ADDREF(*aStyle = element->Style()); return NS_OK; } NS_FORWARD_NSIFRAMELOADEROWNER(static_cast(mElement.get())->) diff --git a/dom/webidl/HTMLElement.webidl b/dom/webidl/HTMLElement.webidl index 1d581de29f2..72d89505245 100644 --- a/dom/webidl/HTMLElement.webidl +++ b/dom/webidl/HTMLElement.webidl @@ -73,7 +73,7 @@ interface HTMLElement : Element { //readonly attribute boolean? commandChecked; // styling - [Throws, Constant] + [Constant] readonly attribute CSSStyleDeclaration style; // event handler IDL attributes diff --git a/dom/webidl/SVGElement.webidl b/dom/webidl/SVGElement.webidl index 550a3e771a7..e5d7f2fd795 100644 --- a/dom/webidl/SVGElement.webidl +++ b/dom/webidl/SVGElement.webidl @@ -18,7 +18,6 @@ interface SVGElement : Element { attribute DOMString xmlbase; */ readonly attribute SVGAnimatedString className; - [Throws] readonly attribute CSSStyleDeclaration style; // The CSSValue interface has been deprecated by the CSS WG. diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 73451a53440..00d995fa8f5 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -360,8 +360,8 @@ customMethodCalls = { ' 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',