From 6456b9db4fcd0e2c27fa7411e5792970e03c3dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 27 Nov 2019 20:12:43 +0000 Subject: [PATCH] Bug 1599843 - Element::SetSMILOverrideStyleDeclaration is infallible. r=boris Differential Revision: https://phabricator.services.mozilla.com/D54996 --HG-- extra : moz-landing-system : lando --- dom/base/Element.cpp | 9 ++------- dom/base/Element.h | 2 +- layout/style/nsDOMCSSAttrDeclaration.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index c24a88d958b0..cd4bd09e0875 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1835,11 +1835,8 @@ DeclarationBlock* Element::GetSMILOverrideStyleDeclaration() { return slots ? slots->mSMILOverrideStyleDeclaration.get() : nullptr; } -nsresult Element::SetSMILOverrideStyleDeclaration( - DeclarationBlock* aDeclaration) { - Element::nsExtendedDOMSlots* slots = ExtendedDOMSlots(); - - slots->mSMILOverrideStyleDeclaration = aDeclaration; +void Element::SetSMILOverrideStyleDeclaration(DeclarationBlock& aDeclaration) { + ExtendedDOMSlots()->mSMILOverrideStyleDeclaration = &aDeclaration; // Only need to request a restyle if we're in a document. (We might not // be in a document, if we're clearing animation effects on a target node @@ -1849,8 +1846,6 @@ nsresult Element::SetSMILOverrideStyleDeclaration( presShell->RestyleForAnimation(this, StyleRestyleHint_RESTYLE_SMIL); } } - - return NS_OK; } bool Element::IsLabelable() const { return false; } diff --git a/dom/base/Element.h b/dom/base/Element.h index 598f8a718953..e07e06a5b9e5 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -336,7 +336,7 @@ class Element : public FragmentOrElement { * notify the document's pres context, so that the style changes will be * noticed. */ - nsresult SetSMILOverrideStyleDeclaration(DeclarationBlock* aDeclaration); + void SetSMILOverrideStyleDeclaration(DeclarationBlock&); /** * Returns a new SMILAttr that allows the caller to animate the given diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index b131e9d87aa4..9b5d52728d3b 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -79,9 +79,11 @@ nsresult nsDOMCSSAttributeDeclaration::SetCSSDeclaration( MOZ_ASSERT_IF(aClosureData, !aClosureData->mClosure); aDecl->SetDirty(); - return mIsSMILOverride - ? mElement->SetSMILOverrideStyleDeclaration(aDecl) - : mElement->SetInlineStyleDeclaration(*aDecl, *aClosureData); + if (mIsSMILOverride) { + mElement->SetSMILOverrideStyleDeclaration(*aDecl); + return NS_OK; + } + return mElement->SetInlineStyleDeclaration(*aDecl, *aClosureData); } Document* nsDOMCSSAttributeDeclaration::DocToUpdate() {