From e068edea43568b2ab9671ea24d7f466383929bd0 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 21 Sep 2018 16:45:49 -0400 Subject: [PATCH] Bug 1492894 - part 3 - eliminate already_AddRefed variables in layout/; r=emilio We need to disallow these to fix our static analysis, which should have already been disallowing them. --- layout/base/nsCSSFrameConstructor.cpp | 24 ++++++++++-------------- layout/base/nsCSSFrameConstructor.h | 10 +++++----- layout/style/ServoBindings.cpp | 3 +-- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index e246fa20fec8..ec5d22bc0c82 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2505,10 +2505,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // function in general. // Use a null PendingBinding, since our binding is not in fact pending. static const FrameConstructionData rootSVGData = FCDATA_DECL(0, nullptr); - already_AddRefed extraRef = - RefPtr(computedStyle).forget(); AutoFrameConstructionItem item(this, &rootSVGData, aDocElement, - nullptr, extraRef, true); + nullptr, do_AddRef(computedStyle), true); nsFrameItems frameItems; contentFrame = static_cast( @@ -2555,10 +2553,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // function in general. // Use a null PendingBinding, since our binding is not in fact pending. static const FrameConstructionData rootTableData = FCDATA_DECL(0, nullptr); - already_AddRefed extraRef = - RefPtr(computedStyle).forget(); AutoFrameConstructionItem item(this, &rootTableData, aDocElement, - nullptr, extraRef, true); + nullptr, do_AddRef(computedStyle), true); nsFrameItems frameItems; // if the document is a table then just populate it. @@ -5527,10 +5523,10 @@ nsCSSFrameConstructor::FindElementTagData(const Element& aElement, } nsCSSFrameConstructor::XBLBindingLoadInfo::XBLBindingLoadInfo( - already_AddRefed aStyle, + already_AddRefed&& aStyle, mozilla::UniquePtr aPendingBinding, nsAtom* aTag) - : mStyle(aStyle) + : mStyle(std::move(aStyle)) , mPendingBinding(std::move(aPendingBinding)) , mTag(aTag) { @@ -9284,7 +9280,7 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems( : nsCSSAnonBoxes::anonymousGridItem(); ComputedStyle* parentStyle = aParentFrame->Style(); nsIContent* parentContent = aParentFrame->GetContent(); - already_AddRefed wrapperStyle = + RefPtr wrapperStyle = mPresShell->StyleSet()->ResolveInheritingAnonymousBoxStyle(pseudoType, parentStyle); @@ -9300,7 +9296,7 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems( parentContent, // no pending binding nullptr, - wrapperStyle, + wrapperStyle.forget(), true); newItem->mIsAllInline = @@ -9786,7 +9782,7 @@ nsCSSFrameConstructor::WrapItemsInPseudoParent(nsIContent* aParentContent, pseudoType = nsCSSAnonBoxes::inlineTable(); } - already_AddRefed wrapperStyle; + RefPtr wrapperStyle; if (pseudoData.mFCData.mBits & FCDATA_IS_WRAPPER_ANON_BOX) { wrapperStyle = mPresShell->StyleSet()->ResolveInheritingAnonymousBoxStyle(pseudoType, @@ -9802,7 +9798,7 @@ nsCSSFrameConstructor::WrapItemsInPseudoParent(nsIContent* aParentContent, aParentContent, // no pending binding nullptr, - wrapperStyle, + wrapperStyle.forget(), true); const nsStyleDisplay* disp = newItem->mComputedStyle->StyleDisplay(); @@ -9857,7 +9853,7 @@ nsCSSFrameConstructor::CreateNeededPseudoSiblings( const PseudoParentData& pseudoData = sPseudoParentData[eTypeRubyBaseContainer]; - already_AddRefed pseudoStyle = mPresShell->StyleSet()-> + RefPtr pseudoStyle = mPresShell->StyleSet()-> ResolveInheritingAnonymousBoxStyle(*pseudoData.mPseudoType, aParentFrame->Style()); FrameConstructionItem* newItem = @@ -9866,7 +9862,7 @@ nsCSSFrameConstructor::CreateNeededPseudoSiblings( aParentFrame->GetContent(), // no pending binding nullptr, - pseudoStyle, + pseudoStyle.forget(), true); newItem->mIsAllInline = true; newItem->mChildItems.SetParentHasNoXBLChildren(true); diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 7a204043882d..77c0fa316d2b 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -798,7 +798,7 @@ private: XBLBindingLoadInfo(nsIContent&, ComputedStyle&); // For the case we actually load an XBL binding. - XBLBindingLoadInfo(already_AddRefed aStyle, + XBLBindingLoadInfo(already_AddRefed&& aStyle, mozilla::UniquePtr aPendingBinding, nsAtom* aTag); @@ -901,7 +901,7 @@ private: { FrameConstructionItem* item = new (aFCtor) FrameConstructionItem(aFCData, aContent, - aPendingBinding, aComputedStyle, + aPendingBinding, std::move(aComputedStyle), aSuppressWhiteSpaceOptimizations); mItems.insertBack(item); ++mItemCount; @@ -919,7 +919,7 @@ private: { FrameConstructionItem* item = new (aFCtor) FrameConstructionItem(aFCData, aContent, - aPendingBinding, aComputedStyle, + aPendingBinding, std::move(aComputedStyle), aSuppressWhiteSpaceOptimizations); mItems.insertFront(item); ++mItemCount; @@ -1147,10 +1147,10 @@ private: FrameConstructionItem(const FrameConstructionData* aFCData, nsIContent* aContent, PendingBinding* aPendingBinding, - already_AddRefed& aComputedStyle, + already_AddRefed&& aComputedStyle, bool aSuppressWhiteSpaceOptimizations) : mFCData(aFCData), mContent(aContent), - mPendingBinding(aPendingBinding), mComputedStyle(aComputedStyle), + mPendingBinding(aPendingBinding), mComputedStyle(std::move(aComputedStyle)), mSuppressWhiteSpaceOptimizations(aSuppressWhiteSpaceOptimizations), mIsText(false), mIsGeneratedContent(false), mIsAnonymousContentCreatorContent(false), diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index a3c994fe60e4..e1547eff8fb6 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -2384,8 +2384,7 @@ Gecko_CSSValue_SetFontWeight(nsCSSValueBorrowedMut aCSSValue, void Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsAtom* aAtom) { - already_AddRefed atom = already_AddRefed(aAtom); - aFont->mLanguage = atom; + aFont->mLanguage = dont_AddRef(aAtom); aFont->mExplicitLanguage = true; }