From 8a324dc194f4602641f4e348c421236665782827 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Sun, 31 Mar 2013 18:43:04 -0400 Subject: [PATCH] bug 856779 - remove nsFrameManager::Init() r=dholbert --- layout/base/nsCSSFrameConstructor.cpp | 5 +++-- layout/base/nsCSSFrameConstructor.h | 3 ++- layout/base/nsFrameManager.cpp | 17 ----------------- layout/base/nsFrameManager.h | 8 ++++---- layout/base/nsPresShell.cpp | 14 +------------- 5 files changed, 10 insertions(+), 37 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 3edc190ae0c..910b352ec5c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1399,8 +1399,9 @@ MoveChildrenTo(nsPresContext* aPresContext, //---------------------------------------------------------------------- nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument, - nsIPresShell *aPresShell) - : nsFrameManager(aPresShell) + nsIPresShell *aPresShell, + nsStyleSet* aStyleSet) + : nsFrameManager(aPresShell, aStyleSet) , mDocument(aDocument) , mRootElementFrame(nullptr) , mRootElementStyleFrame(nullptr) diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 26b6db9ecf5..7a8db6e2285 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -55,7 +55,8 @@ public: typedef mozilla::css::RestyleTracker RestyleTracker; typedef mozilla::css::OverflowChangedTracker OverflowChangedTracker; - nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell); + nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell, + nsStyleSet* aStyleSet); ~nsCSSFrameConstructor(void) { NS_ASSERTION(mUpdateCount == 0, "Dying in the middle of our own update?"); } diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index f96fed2307d..f137e68e7db 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -188,23 +188,6 @@ nsFrameManager::~nsFrameManager() NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called"); } -nsresult -nsFrameManager::Init(nsStyleSet* aStyleSet) -{ - if (!mPresShell) { - NS_ERROR("null pres shell"); - return NS_ERROR_FAILURE; - } - - if (!aStyleSet) { - NS_ERROR("null style set"); - return NS_ERROR_FAILURE; - } - - mStyleSet = aStyleSet; - return NS_OK; -} - void nsFrameManager::Destroy() { diff --git a/layout/base/nsFrameManager.h b/layout/base/nsFrameManager.h index 283dab9a115..62014eeea80 100644 --- a/layout/base/nsFrameManager.h +++ b/layout/base/nsFrameManager.h @@ -49,14 +49,14 @@ class nsFrameManager : public nsFrameManagerBase typedef nsIFrame::ChildListID ChildListID; public: - nsFrameManager(nsIPresShell *aPresShell) NS_HIDDEN { + nsFrameManager(nsIPresShell *aPresShell, nsStyleSet* aStyleSet) NS_HIDDEN { mPresShell = aPresShell; + mStyleSet = aStyleSet; + MOZ_ASSERT(mPresShell, "need a pres shell"); + MOZ_ASSERT(mStyleSet, "need a style set"); } ~nsFrameManager() NS_HIDDEN; - // Initialization - NS_HIDDEN_(nsresult) Init(nsStyleSet* aStyleSet); - /* * After Destroy is called, it is an error to call any FrameManager methods. * Destroy should be called when the frame tree managed by the frame diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index b7de7fbb697..31d8d05fb30 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -781,7 +781,6 @@ PresShell::Init(nsIDocument* aDocument, NS_PRECONDITION(nullptr != aDocument, "null ptr"); NS_PRECONDITION(nullptr != aPresContext, "null ptr"); NS_PRECONDITION(nullptr != aViewManager, "null ptr"); - nsresult result; if ((nullptr == aDocument) || (nullptr == aPresContext) || (nullptr == aViewManager)) { @@ -799,7 +798,7 @@ PresShell::Init(nsIDocument* aDocument, mViewManager = aViewManager; // Create our frame constructor. - mFrameConstructor = new nsCSSFrameConstructor(mDocument, this); + mFrameConstructor = new nsCSSFrameConstructor(mDocument, this, aStyleSet); mFrameManager = mFrameConstructor; @@ -831,17 +830,6 @@ PresShell::Init(nsIDocument* aDocument, NS_ADDREF(mSelection = new nsFrameSelection()); - // Create and initialize the frame manager - // XXXjwatt it would be better if we did this right after creating - // mFrameConstructor, since the frame constructor and frame manager - // are now the same object. - result = mFrameConstructor->Init(mStyleSet); - if (NS_FAILED(result)) { - NS_WARNING("Frame manager initialization failed"); - mStyleSet = nullptr; - return result; - } - mSelection->Init(this, nullptr); // Important: this has to happen after the selection has been set up