diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index c4382c2cea17..d539e7154a91 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -113,7 +113,6 @@ #include "nsIXPConnect.h" #include "nsIXULAppInfo.h" #include "nsIXULRuntime.h" -#include "nsPresShellIterator.h" #define UILOCALE_CMD_LINE_ARG "UILocale" @@ -956,9 +955,8 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow, return NS_OK; // Deal with the agent sheets first. Have to do all the style sets by hand. - nsPresShellIterator iter(document); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = document->GetPrimaryShell(); + if (shell) { // Reload only the chrome URL agent style sheets. nsCOMArray agentSheets; rv = shell->GetAgentStyleSheets(agentSheets); diff --git a/content/base/public/Makefile.in b/content/base/public/Makefile.in index acfb7aca87fb..cb90f36fdf24 100644 --- a/content/base/public/Makefile.in +++ b/content/base/public/Makefile.in @@ -75,7 +75,6 @@ nsCopySupport.h \ nsContentCreatorFunctions.h \ nsDOMFile.h \ nsLineBreaker.h \ -nsPresShellIterator.h \ nsReferencedElement.h \ nsXMLNameSpaceMap.h \ $(NULL) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index e7c6eb5c60f0..b6dce0601329 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -105,8 +105,8 @@ class nsIBoxObject; // IID for the nsIDocument interface #define NS_IDOCUMENT_IID \ -{ 0xd16d73c1, 0xe0f7, 0x415c, \ - { 0xbd, 0x68, 0x9c, 0x1f, 0x93, 0xb8, 0x73, 0x7a } } +{ 0x1539ada4, 0x753f, 0x48a9, \ + { 0x83, 0x11, 0x71, 0xb9, 0xbd, 0xa6, 0x41, 0xc6 } } // Flag for AddStyleSheet(). #define NS_STYLESHEET_FROM_CATALOG (1 << 0) @@ -409,10 +409,15 @@ public: nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) = 0; - virtual PRBool DeleteShell(nsIPresShell* aShell) = 0; - virtual nsIPresShell *GetPrimaryShell() const = 0; - void SetShellsHidden(PRBool aHide) { mShellsAreHidden = aHide; } - PRBool ShellsAreHidden() const { return mShellsAreHidden; } + void DeleteShell() { mPresShell = nsnull; } + + nsIPresShell* GetPrimaryShell() const + { + return mShellIsHidden ? nsnull : mPresShell; + } + + void SetShellHidden(PRBool aHide) { mShellIsHidden = aHide; } + PRBool ShellIsHidden() const { return mShellIsHidden; } /** * Return the parent document of this document. Will return null @@ -1247,7 +1252,6 @@ protected: virtual void WillDispatchMutationEvent(nsINode* aTarget) = 0; virtual void MutationEventDispatched(nsINode* aTarget) = 0; friend class mozAutoSubtreeModified; - friend class nsPresShellIterator; nsCOMPtr mDocumentURI; nsCOMPtr mDocumentBaseURI; @@ -1296,7 +1300,7 @@ protected: // document in it. PRPackedBool mIsInitialDocumentInWindow; - PRPackedBool mShellsAreHidden; + PRPackedBool mShellIsHidden; PRPackedBool mIsRegularHTML; @@ -1355,7 +1359,7 @@ protected: // won't be collected PRUint32 mMarkedCCGeneration; - nsTObserverArray mPresShells; + nsIPresShell* mPresShell; nsCOMArray mSubtreeModifiedTargets; PRUint32 mSubtreeModifiedDepth; diff --git a/content/base/public/nsPresShellIterator.h b/content/base/public/nsPresShellIterator.h deleted file mode 100644 index 1234f3e9c5e0..000000000000 --- a/content/base/public/nsPresShellIterator.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Olli Pettay (Original Author) - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPresShellIterato_h___ -#define nsPresShellIterato_h___ - -#include "nsIPresShell.h" -#include "nsIDocument.h" - -class nsPresShellIterator : - private nsTObserverArray::ForwardIterator -{ -public: - nsPresShellIterator(nsIDocument* aDoc) - : nsTObserverArray::ForwardIterator(aDoc->mPresShells), - mDoc(aDoc) {} - - already_AddRefed GetNextShell() - { - nsIPresShell* shell = nsnull; - if (!mDoc->ShellsAreHidden() && HasMore()) { - shell = GetNext(); - NS_IF_ADDREF(shell); - } - return shell; - } - - PRBool HasMoreThanOneShell() { - return mDoc->mPresShells.Length() > 1; - } - -private: - static void* operator new(size_t) CPP_THROW_NEW { return 0; } - static void operator delete(void*, size_t) {} - - nsCOMPtr mDoc; -}; - -#endif diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 3a43f34e5bae..23656f990e0c 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -95,7 +95,6 @@ #include "nsNodeUtils.h" #include "nsIDOMNode.h" #include "nsThreadUtils.h" -#include "nsPresShellIterator.h" #include "nsPIDOMWindow.h" #include "mozAutoDocUpdate.h" #include "nsIWebNavigation.h" @@ -1229,9 +1228,8 @@ nsContentSink::ScrollToRef() // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1 NS_ConvertUTF8toUTF16 ref(unescapedRef); - nsPresShellIterator iter(mDocument); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = mDocument->GetPrimaryShell(); + if (shell) { // Check an empty string which might be caused by the UTF-8 conversion if (!ref.IsEmpty()) { // Note that GoToAnchor will handle flushing layout as needed. @@ -1309,24 +1307,13 @@ nsContentSink::StartLayout(PRBool aIgnorePendingSheets) mLastNotificationTime = PR_Now(); mDocument->SetMayStartLayout(PR_TRUE); - nsPresShellIterator iter(mDocument); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { - // Make sure we don't call InitialReflow() for a shell that has - // already called it. This can happen when the layout frame for - // an iframe is constructed *between* the Embed() call for the - // docshell in the iframe, and the content sink's call to OpenBody(). - // (Bug 153815) - - if (shell->DidInitialReflow()) { - // XXX: The assumption here is that if something already - // called InitialReflow() on this shell, it also did some of - // the setup below, so we do nothing and just move on to the - // next shell in the list. - - continue; - } - + nsCOMPtr shell = mDocument->GetPrimaryShell(); + // Make sure we don't call InitialReflow() for a shell that has + // already called it. This can happen when the layout frame for + // an iframe is constructed *between* the Embed() call for the + // docshell in the iframe, and the content sink's call to OpenBody(). + // (Bug 153815) + if (shell && !shell->DidInitialReflow()) { nsRect r = shell->GetPresContext()->GetVisibleArea(); nsCOMPtr shellGrip = shell; nsresult rv = shell->InitialReflow(r.width, r.height); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 573602824e52..9194bb390046 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2084,9 +2084,8 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI) PRBool applicable; sheet->GetApplicable(applicable); if (applicable) { - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()->RemoveStyleSheet(nsStyleSet::eAgentSheet, sheet); } } @@ -2106,9 +2105,8 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI) nsStyleSet::sheetType attrSheetType = GetAttrSheetType(); if (mAttrStyleSheet) { // Remove this sheet from all style sets - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()->RemoveStyleSheet(attrSheetType, mAttrStyleSheet); } rv = mAttrStyleSheet->Reset(aURI); @@ -2123,9 +2121,8 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI) if (mStyleAttrStyleSheet) { // Remove this sheet from all style sets - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()-> RemoveStyleSheet(nsStyleSet::eStyleAttrSheet, mStyleAttrStyleSheet); } @@ -2142,9 +2139,8 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI) mStyleAttrStyleSheet->SetOwningDocument(this); // Now set up our style sets - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { FillStyleSet(shell->StyleSet()); } @@ -3045,7 +3041,9 @@ nsDocument::doCreateShell(nsPresContext* aContext, { *aInstancePtrResult = nsnull; - NS_ENSURE_FALSE(mShellsAreHidden, NS_ERROR_FAILURE); + NS_ASSERTION(!mPresShell, "We have a presshell already!"); + + NS_ENSURE_FALSE(mShellIsHidden, NS_ERROR_FAILURE); FillStyleSet(aStyleSet); @@ -3059,29 +3057,13 @@ nsDocument::doCreateShell(nsPresContext* aContext, NS_ENSURE_SUCCESS(rv, rv); // Note: we don't hold a ref to the shell (it holds a ref to us) - NS_ENSURE_TRUE(mPresShells.AppendElementUnlessExists(shell), - NS_ERROR_OUT_OF_MEMORY); - - NS_WARN_IF_FALSE(mPresShells.Length() == 1, "More than one presshell!"); + mPresShell = shell; shell.swap(*aInstancePtrResult); return NS_OK; } -PRBool -nsDocument::DeleteShell(nsIPresShell* aShell) -{ - return mPresShells.RemoveElement(aShell); -} - - -nsIPresShell * -nsDocument::GetPrimaryShell() const -{ - return mShellsAreHidden ? nsnull : mPresShells.SafeElementAt(0, nsnull); -} - static void SubDocClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry) { @@ -3341,9 +3323,8 @@ nsDocument::GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const void nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet) { - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()->AddDocStyleSheet(aSheet, this); } } @@ -3368,9 +3349,8 @@ nsDocument::AddStyleSheet(nsIStyleSheet* aSheet) void nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet) { - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()->RemoveStyleSheet(nsStyleSet::eDocSheet, aSheet); } } @@ -3507,9 +3487,8 @@ nsDocument::AddCatalogStyleSheet(nsIStyleSheet* aSheet) if (applicable) { // This is like |AddStyleSheetToStyleSets|, but for an agent sheet. - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->StyleSet()->AppendStyleSheet(nsStyleSet::eAgentSheet, aSheet); } } @@ -5083,18 +5062,15 @@ nsDocument::DoNotifyPossibleTitleChange() nsAutoString title; GetTitle(title); - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { nsCOMPtr container = shell->GetPresContext()->GetContainer(); - if (!container) - continue; - - nsCOMPtr docShellWin = do_QueryInterface(container); - if (!docShellWin) - continue; - - docShellWin->SetTitle(PromiseFlatString(title).get()); + if (container) { + nsCOMPtr docShellWin = do_QueryInterface(container); + if (docShellWin) { + docShellWin->SetTitle(PromiseFlatString(title).get()); + } + } } // Fire a DOM event for the title change. @@ -6361,9 +6337,8 @@ nsDocument::FlushPendingNotifications(mozFlushType aType) mParentDocument->FlushPendingNotifications(parentType); } - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->FlushPendingNotifications(aType); } } @@ -6773,10 +6748,8 @@ PRBool nsDocument::IsSafeToFlush() const { PRBool isSafeToFlush = PR_TRUE; - nsPresShellIterator iter(const_cast - (static_cast(this))); - nsCOMPtr shell; - while ((shell = iter.GetNextShell()) && isSafeToFlush) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { shell->IsSafeToFlush(isSafeToFlush); } return isSafeToFlush; @@ -7731,9 +7704,8 @@ FireOrClearDelayedEvents(nsTArray >& aDocuments, for (PRUint32 i = 0; i < aDocuments.Length(); ++i) { if (!aDocuments[i]->EventHandlingSuppressed()) { fm->FireDelayedEvents(aDocuments[i]); - nsPresShellIterator iter(aDocuments[i]); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = aDocuments[i]->GetPrimaryShell(); + if (shell) { shell->FireOrClearDelayedEvents(aFireEvents); } } diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index edf089a2b0dc..9286e2d3b594 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -106,7 +106,6 @@ #include "pldhash.h" #include "nsAttrAndChildArray.h" #include "nsDOMAttributeMap.h" -#include "nsPresShellIterator.h" #include "nsContentUtils.h" #include "nsThreadUtils.h" #include "nsIDocumentViewer.h" @@ -666,8 +665,6 @@ public: nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); - virtual PRBool DeleteShell(nsIPresShell* aShell); - virtual nsIPresShell *GetPrimaryShell() const; virtual nsresult SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc); diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index 405123c9282f..de30d354e0ae 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -71,7 +71,6 @@ #include "nsIFrame.h" #include "nsIFrameFrame.h" #include "nsDOMError.h" -#include "nsPresShellIterator.h" #include "nsGUIEvent.h" #include "nsEventDispatcher.h" #include "nsISHistory.h" @@ -722,12 +721,6 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, NS_ASSERTION(ourDoc == ourParentDocument, "Unexpected parent document"); NS_ASSERTION(otherDoc == otherParentDocument, "Unexpected parent document"); - nsPresShellIterator iter1(ourDoc); - nsPresShellIterator iter2(otherDoc); - if (iter1.HasMoreThanOneShell() || iter2.HasMoreThanOneShell()) { - return NS_ERROR_NOT_IMPLEMENTED; - } - nsIPresShell* ourShell = ourDoc->GetPrimaryShell(); nsIPresShell* otherShell = otherDoc->GetPrimaryShell(); if (!ourShell || !otherShell) { diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 79af36bd6371..fe4d4778f9f5 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3007,9 +3007,8 @@ nsGenericElement::SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, // be in a document, if we're clearing animation effects on a target node // that's been detached since the previous animation sample.) if (doc) { - nsPresShellIterator iter(doc); - nsCOMPtr shell; - while (shell = iter.GetNextShell()) { + nsCOMPtr shell = doc->GetPrimaryShell(); + if (shell) { nsPresContext* presContext = shell->GetPresContext(); presContext->SMILOverrideStyleChanged(this); } diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 6b9f6165606c..6861fad1ed7e 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -77,7 +77,6 @@ #include "nsGkAtoms.h" #include "nsThreadUtils.h" #include "nsNetUtil.h" -#include "nsPresShellIterator.h" #include "nsMimeTypes.h" #include "nsStyleUtil.h" @@ -761,9 +760,8 @@ nsObjectLoadingContent::EnsureInstantiation(nsIPluginInstance** aInstance) return NS_OK; } - nsPresShellIterator iter(doc); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = doc->GetPrimaryShell(); + if (shell) { shell->RecreateFramesFor(thisContent); } @@ -1543,10 +1541,8 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType, } else if (aOldType != mType) { // If our state changed, then we already recreated frames // Otherwise, need to do that here - - nsPresShellIterator iter(doc); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = doc->GetPrimaryShell(); + if (shell) { shell->RecreateFramesFor(thisContent); } } diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index ebcfb30d727c..33aeab2bfc60 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -139,7 +139,6 @@ #include "nsIProperties.h" #include "nsISupportsPrimitives.h" #include "nsEventDispatcher.h" -#include "nsPresShellIterator.h" #include "nsServiceManagerUtils.h" #include "nsITimer.h" @@ -2751,13 +2750,11 @@ nsEventStateManager::GetParentScrollingView(nsInputEvent *aEvent, } nsIPresShell *pPresShell = nsnull; - nsPresShellIterator iter(parentDoc); - nsCOMPtr tmpPresShell; - while ((tmpPresShell = iter.GetNextShell())) { + nsIPresShell *tmpPresShell = parentDoc->GetPrimaryShell(); + if (tmpPresShell) { NS_ENSURE_TRUE(tmpPresShell->GetPresContext(), NS_ERROR_FAILURE); if (tmpPresShell->GetPresContext()->Type() == aPresContext->Type()) { pPresShell = tmpPresShell; - break; } } if (!pPresShell) diff --git a/content/html/document/src/nsMediaDocument.cpp b/content/html/document/src/nsMediaDocument.cpp index 6c9333f21525..21a304477833 100644 --- a/content/html/document/src/nsMediaDocument.cpp +++ b/content/html/document/src/nsMediaDocument.cpp @@ -276,15 +276,10 @@ nsresult nsMediaDocument::StartLayout() { mMayStartLayout = PR_TRUE; - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { - if (shell->DidInitialReflow()) { - // Don't mess with this presshell: someone has already handled - // its initial reflow. - continue; - } - + nsCOMPtr shell = GetPrimaryShell(); + // Don't mess with the presshell if someone has already handled + // its initial reflow. + if (shell && !shell->DidInitialReflow()) { nsRect visibleArea = shell->GetPresContext()->GetVisibleArea(); nsresult rv = shell->InitialReflow(visibleArea.width, visibleArea.height); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp index 087179a37176..20a1f215c8fc 100644 --- a/content/mathml/content/src/nsMathMLElement.cpp +++ b/content/mathml/content/src/nsMathMLElement.cpp @@ -47,7 +47,6 @@ #include "nsStyleConsts.h" #include "nsIDocument.h" #include "nsIEventStateManager.h" -#include "nsPresShellIterator.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsDOMClassInfoID.h" @@ -87,15 +86,11 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, aDocument->SetMathMLEnabled(); aDocument->EnsureCatalogStyleSheet(kMathMLStyleSheetURI); - // Rebuild style data for all the presshells, because style system + // Rebuild style data for the presshell, because style system // optimizations may have taken place assuming MathML was disabled. // (See nsRuleNode::CheckSpecifiedProperties.) - // nsPresShellIterator skips hidden presshells, but that's OK because - // if we're changing the document for one of those presshells the whole - // presshell will be torn down. - nsPresShellIterator iter(aDocument); - nsCOMPtr shell; - while ((shell = iter.GetNextShell()) != nsnull) { + nsCOMPtr shell = aDocument->GetPrimaryShell(); + if (shell) { shell->GetPresContext()->PostRebuildAllStyleDataEvent(nsChangeHint(0)); } } diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 158cfc376ae6..61be93b1fc56 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -151,7 +151,6 @@ #include "nsNodeInfoManager.h" #include "nsXBLBinding.h" #include "nsEventDispatcher.h" -#include "nsPresShellIterator.h" #include "mozAutoDocUpdate.h" #include "nsIDOMXULCommandEvent.h" #include "nsIDOMNSEvent.h" @@ -2119,9 +2118,8 @@ nsXULElement::Click() nsCOMPtr doc = GetCurrentDoc(); // Strong just in case if (doc) { - nsPresShellIterator iter(doc); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = doc->GetPrimaryShell(); + if (shell) { // strong ref to PresContext so events don't destroy it nsCOMPtr context = shell->GetPresContext(); diff --git a/content/xul/document/src/nsXULCommandDispatcher.cpp b/content/xul/document/src/nsXULCommandDispatcher.cpp index 209bf20f0e1a..8a2fdae8270f 100644 --- a/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -70,7 +70,6 @@ #include "nsCRT.h" #include "nsDOMError.h" #include "nsEventDispatcher.h" -#include "nsPresShellIterator.h" #ifdef PR_LOGGING static PRLogModuleInfo* gLog; @@ -437,9 +436,8 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) } #endif - nsPresShellIterator iter(document); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = document->GetPrimaryShell(); + if (shell) { // Retrieve the context in which our DOM event will fire. nsCOMPtr context = shell->GetPresContext(); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index f288afabee22..e0fa8f5d7232 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -949,9 +949,8 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, // |onbroadcast| event handler nsEvent event(PR_TRUE, NS_XUL_BROADCAST); - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { nsCOMPtr aPresContext = shell->GetPresContext(); @@ -2018,9 +2017,8 @@ nsXULDocument::Init() nsresult nsXULDocument::StartLayout(void) { - nsPresShellIterator iter(this); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { + nsCOMPtr shell = GetPrimaryShell(); + if (shell) { // Resize-reflow this time nsPresContext *cx = shell->GetPresContext(); @@ -2064,9 +2062,6 @@ nsXULDocument::StartLayout(void) // above can flush reflows, which can cause a parent document to be flushed, // calling ResizeReflow on our document which does SetVisibleArea. nsRect r = cx->GetVisibleArea(); - // Make sure we're holding a strong ref to |shell| before we call - // InitialReflow() - nsCOMPtr shellGrip = shell; rv = shell->InitialReflow(r.width, r.height); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp index c47e10bb546b..99ba2bee0c4a 100644 --- a/docshell/shistory/src/nsSHEntry.cpp +++ b/docshell/shistory/src/nsSHEntry.cpp @@ -246,7 +246,7 @@ nsSHEntry::SetContentViewer(nsIContentViewer *aViewer) // the contentviewer mDocument = do_QueryInterface(domDoc); if (mDocument) { - mDocument->SetShellsHidden(PR_TRUE); + mDocument->SetShellHidden(PR_TRUE); mDocument->AddMutationObserver(this); } } @@ -685,7 +685,7 @@ nsSHEntry::DropPresentationState() nsRefPtr kungFuDeathGrip = this; if (mDocument) { - mDocument->SetShellsHidden(PR_FALSE); + mDocument->SetShellHidden(PR_FALSE); mDocument->RemoveMutationObserver(this); mDocument = nsnull; } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 54201b741894..e434a5e52224 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -188,7 +188,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset #include "nsIWebNavigation.h" #include "nsWeakPtr.h" #include "nsEventDispatcher.h" -#include "nsPresShellIterator.h" //paint forcing #include "prenv.h" diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 7dca144919f0..d3236d8d75c7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1814,7 +1814,8 @@ PresShell::Destroy() // hierarchy is torn down to avoid finding deleted frames through // this presshell while the frames are being torn down if (mDocument) { - mDocument->DeleteShell(this); + NS_ASSERTION(mDocument->GetPrimaryShell() == this, "Wrong shell?"); + mDocument->DeleteShell(); } // Revoke any pending reflow event. We need to do this and cancel diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 71abe986e402..63dbe0188dd7 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -44,7 +44,6 @@ #include "nsDisplayList.h" #include "nsStubMutationObserver.h" #include "gfxContext.h" -#include "nsPresShellIterator.h" #include "nsIContentViewer.h" #include "nsIDocShell.h" #include "nsIDOMDocument.h" @@ -92,23 +91,19 @@ nsSVGMutationObserver::AttributeChanged(nsIDocument *aDocument, return; } - nsPresShellIterator iter(aDocument); - nsCOMPtr shell; - while ((shell = iter.GetNextShell())) { - nsIFrame *frame = aContent->GetPrimaryFrame(); - if (!frame) { - continue; - } - - // is the content a child of a text element - nsSVGTextContainerFrame *containerFrame = do_QueryFrame(frame); - if (containerFrame) { - containerFrame->NotifyGlyphMetricsChange(); - continue; - } - // if not, are there text elements amongst its descendents - UpdateTextFragmentTrees(frame); + nsIFrame* frame = aContent->GetPrimaryFrame(); + if (!frame) { + return; } + + // is the content a child of a text element + nsSVGTextContainerFrame* containerFrame = do_QueryFrame(frame); + if (containerFrame) { + containerFrame->NotifyGlyphMetricsChange(); + return; + } + // if not, are there text elements amongst its descendents + UpdateTextFragmentTrees(frame); } //----------------------------------------------------------------------