diff --git a/accessible/windows/sdn/sdnAccessible.cpp b/accessible/windows/sdn/sdnAccessible.cpp index b248edbbfab4..6c6089a1cd12 100644 --- a/accessible/windows/sdn/sdnAccessible.cpp +++ b/accessible/windows/sdn/sdnAccessible.cpp @@ -229,8 +229,7 @@ sdnAccessible::get_computedStyle(unsigned short aMaxStyleProperties, nsWinUtils::GetComputedStyleDeclaration(mNode->AsContent()); NS_ENSURE_TRUE(cssDecl, E_FAIL); - uint32_t length = 0; - cssDecl->GetLength(&length); + uint32_t length = cssDecl->Length(); uint32_t index = 0, realIndex = 0; for (index = realIndex = 0; index < length && realIndex < aMaxStyleProperties; diff --git a/editor/libeditor/CSSEditUtils.cpp b/editor/libeditor/CSSEditUtils.cpp index 4e57f497cbab..a8331570e6c1 100644 --- a/editor/libeditor/CSSEditUtils.cpp +++ b/editor/libeditor/CSSEditUtils.cpp @@ -1325,7 +1325,7 @@ CSSEditUtils::GetInlineStyles(Element* aElement, MOZ_ASSERT(cssDecl); cssDecl.forget(aCssDecl); - (*aCssDecl)->GetLength(aLength); + *aLength = (*aCssDecl)->Length(); return NS_OK; } diff --git a/editor/libeditor/ChangeStyleTransaction.cpp b/editor/libeditor/ChangeStyleTransaction.cpp index 547245d62053..0896405cd7fa 100644 --- a/editor/libeditor/ChangeStyleTransaction.cpp +++ b/editor/libeditor/ChangeStyleTransaction.cpp @@ -220,9 +220,7 @@ ChangeStyleTransaction::DoTransaction() } // Let's be sure we don't keep an empty style attribute - uint32_t length; - rv = cssDecl->GetLength(&length); - NS_ENSURE_SUCCESS(rv, rv); + uint32_t length = cssDecl->Length(); if (!length) { rv = mElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::style, true); NS_ENSURE_SUCCESS(rv, rv); diff --git a/layout/style/nsCSSFontFaceRule.cpp b/layout/style/nsCSSFontFaceRule.cpp index 8ca0eb6421ef..9e7ffd47326a 100644 --- a/layout/style/nsCSSFontFaceRule.cpp +++ b/layout/style/nsCSSFontFaceRule.cpp @@ -225,18 +225,19 @@ nsCSSFontFaceStyleDecl::SetProperty(const nsAString& propertyName, return NS_ERROR_NOT_IMPLEMENTED; // bug 443978 } -NS_IMETHODIMP -nsCSSFontFaceStyleDecl::GetLength(uint32_t *aLength) +uint32_t +nsCSSFontFaceStyleDecl::Length() { uint32_t len = 0; for (nsCSSFontDesc id = nsCSSFontDesc(eCSSFontDesc_UNKNOWN + 1); id < eCSSFontDesc_COUNT; - id = nsCSSFontDesc(id + 1)) - if (mDescriptors.Get(id).GetUnit() != eCSSUnit_Null) + id = nsCSSFontDesc(id + 1)) { + if (mDescriptors.Get(id).GetUnit() != eCSSUnit_Null) { len++; + } + } - *aLength = len; - return NS_OK; + return len; } void diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 8ffca315da71..a4d0b5f3e7bd 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -439,11 +439,9 @@ nsComputedDOMStyle::SetCssText(const nsAString& aCssText, aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); } -NS_IMETHODIMP -nsComputedDOMStyle::GetLength(uint32_t* aLength) +uint32_t +nsComputedDOMStyle::Length() { - NS_PRECONDITION(aLength, "Null aLength! Prepare to die!"); - uint32_t length = GetComputedStyleMap()->Length(); // Make sure we have up to date style so that we can include custom @@ -455,11 +453,9 @@ nsComputedDOMStyle::GetLength(uint32_t* aLength) : StyleVariables()->mVariables.Count(); } - *aLength = length; - ClearCurrentStyleSources(); - return NS_OK; + return length; } css::Rule* diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index ec9d2b86a377..a98f30c7d58c 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -161,18 +161,16 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText, aRv = SetCSSDeclaration(newdecl); } -NS_IMETHODIMP -nsDOMCSSDeclaration::GetLength(uint32_t* aLength) +uint32_t +nsDOMCSSDeclaration::Length() { DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read); if (decl) { - *aLength = decl->Count(); - } else { - *aLength = 0; + return decl->Count(); } - return NS_OK; + return 0; } already_AddRefed diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h index 89cc4b6dfe7c..04cdf39c7e4d 100644 --- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -43,8 +43,6 @@ public: NS_IMETHOD_(MozExternalRefCountType) AddRef() override = 0; NS_IMETHOD_(MozExternalRefCountType) Release() override = 0; - using nsICSSDeclaration::GetLength; - /** * Method analogous to CSSStyleDeclaration::GetPropertyValue, * which obeys all the same restrictions. @@ -81,7 +79,7 @@ public: const nsAString& value, const nsAString& priority, nsIPrincipal* aSubjectPrincipal) override; - NS_IMETHOD GetLength(uint32_t *aLength) override; + uint32_t Length() override; // WebIDL interface for CSS2Properties #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_ diff --git a/layout/style/nsICSSDeclaration.h b/layout/style/nsICSSDeclaration.h index aaf6de097f90..5ca4675633bc 100644 --- a/layout/style/nsICSSDeclaration.h +++ b/layout/style/nsICSSDeclaration.h @@ -62,7 +62,6 @@ public: const nsAString& aValue, const nsAString& aPriority, nsIPrincipal* aSubjectPrincipal = nullptr) = 0; - NS_IMETHOD GetLength(uint32_t* aLength) = 0; void Item(uint32_t aIndex, nsAString& aReturn) { bool found; @@ -77,11 +76,7 @@ public: nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& rv) = 0; virtual void GetCssText(nsAString& aString) = 0; - uint32_t Length() { - uint32_t length; - GetLength(&length); - return length; - } + virtual uint32_t Length() = 0; void Item(uint32_t aIndex, nsString& aPropName) { Item(aIndex, static_cast(aPropName)); } @@ -122,7 +117,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID) const nsAString& value, \ const nsAString& priority, \ nsIPrincipal* aSubjectPrincipal = nullptr) override; \ - NS_IMETHOD GetLength(uint32_t *aLength) override; \ + uint32_t Length() override; \ mozilla::css::Rule* GetParentRule() override; #endif // nsICSSDeclaration_h__