diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 7a57325e240..e5f35106add 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -99,7 +99,6 @@ #include "nsIFrameDebug.h" #include "nsILayoutHistoryState.h" #include "nsLayoutAtoms.h" -#include "nsIFrameManager.h" #include "nsIParser.h" #include "nsIPrintContext.h" #include "nsGUIEvent.h" diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 09f0e0ab92f..210e1fa10c5 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -159,7 +159,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsIFrameDebug.h" #include "nsILayoutHistoryState.h" #include "nsLayoutAtoms.h" -#include "nsIFrameManager.h" +#include "nsFrameManager.h" #include "nsIParser.h" #include "nsIPrintContext.h" #include "nsGUIEvent.h" @@ -2690,11 +2690,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink) nsCOMPtr widget = mParentWidget; // the top nsPrintObject's widget will always have scrollbars if (aPO->mParent != nsnull && aPO->mContent) { - nsCOMPtr frameMan; - aPO->mParent->mPresShell->GetFrameManager(getter_AddRefs(frameMan)); - NS_ASSERTION(frameMan, "No Frame manager!"); - nsIFrame* frame; - frameMan->GetPrimaryFrameFor(aPO->mContent, &frame); + nsFrameManager *frameMan = aPO->mParent->mPresShell->FrameManager(); + nsIFrame* frame = frameMan->GetPrimaryFrameFor(aPO->mContent); if (frame) { nsIView* view = frame->GetView(); @@ -3057,35 +3054,31 @@ nsPrintEngine::PrintDocContent(nsPrintObject* aPO, nsresult& aStatus) static void GetIFramePosition(nsPrintObject * aPO, nscoord& aX, nscoord& aY) { if (aPO->mParent != nsnull) { - nsCOMPtr frameMan; // we would not have gotten here if any of these ptrs were null - aPO->mParent->mPresShell->GetFrameManager(getter_AddRefs(frameMan)); - NS_ASSERTION(frameMan, "No Frame manager!"); - if (frameMan) { - // This gets out HTMLIFrame - nsIFrame* frame; - frameMan->GetPrimaryFrameFor(aPO->mContent, &frame); - NS_ASSERTION(frame, "no primary frame for IFRAME"); - // find the offset to the content rect - if (!frame) - return; + nsFrameManager *frameMan = aPO->mParent->mPresShell->FrameManager(); - nsMargin borderPadding(0, 0, 0, 0); - frame->CalcBorderPadding(borderPadding); - aX += borderPadding.left; - aY += borderPadding.top; + // This gets our HTMLIFrame + nsIFrame* frame = frameMan->GetPrimaryFrameFor(aPO->mContent); + NS_ASSERTION(frame, "no primary frame for IFRAME"); + if (!frame) + return; - // traverse out to the pageContentFrame - do { - nsPoint pt = frame->GetPosition(); - aX += pt.x; - aY += pt.y; - if (nsLayoutAtoms::pageContentFrame == frame->GetType()) { - break; - } - frame = frame->GetParent(); - } while (frame); - } + // find the offset to the content rect + nsMargin borderPadding(0, 0, 0, 0); + frame->CalcBorderPadding(borderPadding); + aX += borderPadding.left; + aY += borderPadding.top; + + // traverse out to the pageContentFrame + do { + nsPoint pt = frame->GetPosition(); + aX += pt.x; + aY += pt.y; + if (nsLayoutAtoms::pageContentFrame == frame->GetType()) { + break; + } + frame = frame->GetParent(); + } while (frame); } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 7f4fb669c7a..90504745063 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -88,7 +88,6 @@ #include "nsIPresState.h" #include "nsILayoutHistoryState.h" -#include "nsIFrameManager.h" #include "nsHTMLParts.h" #include "nsContentUtils.h" diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index b891ca3e400..4b72a9c5a20 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -63,7 +63,6 @@ #include "nsIEnumerator.h" #include "nsCOMPtr.h" -#include "nsIFrameManager.h" #include "nsIPresShell.h" #include "nsIDocument.h" diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 18a1a8aed08..b5328a0ae21 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -57,7 +57,6 @@ #include "nsISupportsArray.h" #include "nsIFrame.h" #include "nsIDocShell.h" -#include "nsIFrameManager.h" #include "nsCOMPtr.h" #include "nsIView.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/content/shared/public/Makefile.in b/mozilla/content/shared/public/Makefile.in index db1607fe1d4..50285345b4c 100644 --- a/mozilla/content/shared/public/Makefile.in +++ b/mozilla/content/shared/public/Makefile.in @@ -43,6 +43,7 @@ nsCSSKeywords.h \ nsCSSPropList.h \ nsCSSProperty.h \ nsCSSProps.h \ +nsFrameManager.h \ nsHTMLAtomList.h \ nsHTMLAtoms.h \ nsHTMLValue.h \ diff --git a/mozilla/content/shared/public/nsFrameManager.h b/mozilla/content/shared/public/nsFrameManager.h new file mode 100644 index 00000000000..1cdb1a76971 --- /dev/null +++ b/mozilla/content/shared/public/nsFrameManager.h @@ -0,0 +1,328 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim:cindent:ts=2:et:sw=2: + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Pierre Phaneuf + * Brian Ryner + * + * This Original Code has been modified by IBM Corporation. Modifications made + * by IBM described herein are Copyright (c) International Business Machines + * Corporation, 2000. Modifications to Mozilla code or documentation identified + * per MPL Section 3.3 + * + * Date Modified by Description of modification + * 04/20/2000 IBM Corp. OS/2 VisualAge build. + */ + +#ifndef _nsFrameManager_h_ +#define _nsFrameManager_h_ + +#include "nsIFrame.h" +#include "nsIStatefulFrame.h" +#include "nsChangeHint.h" +#include "pldhash.h" + +class nsIPresShell; +class nsStyleSet; +class nsIContent; +class nsPlaceholderFrame; +class nsStyleContext; +class nsIAtom; +class nsStyleChangeList; +class nsILayoutHistoryState; + +// Option flags for GetFrameProperty() member function +#define NS_IFRAME_MGR_REMOVE_PROP 0x0001 + +/** + * Frame manager interface. The frame manager serves two purposes: + *
  • provides a service for mapping from content to frame and from + * out-of-flow frame to placeholder frame. + *
  • handles structural modifications to the frame model. If the frame model + * lock can be acquired, then the changes are processed immediately; otherwise, + * they're queued and processed later. + */ + +class nsFrameManager +{ +public: + nsFrameManager() NS_HIDDEN; + ~nsFrameManager() NS_HIDDEN; + + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + + // Initialization + NS_HIDDEN_(nsresult) Init(nsIPresShell* aPresShell, 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 + * manager is no longer being displayed. + */ + NS_HIDDEN_(void) Destroy(); + + /* + * Gets and sets the root frame (typically the viewport). The lifetime of the + * root frame is controlled by the frame manager. When the frame manager is + * destroyed, it destroys the entire frame hierarchy. + */ + NS_HIDDEN_(nsIFrame*) GetRootFrame() { return mRootFrame; } + NS_HIDDEN_(void) SetRootFrame(nsIFrame* aRootFrame) + { + NS_ASSERTION(!mRootFrame, "already have a root frame"); + mRootFrame = aRootFrame; + } + + /* + * Get the canvas frame, searching from the root frame down. + * The canvas frame may or may not exist, so this may return null. + */ + NS_HIDDEN_(nsIFrame*) GetCanvasFrame(); + + // Primary frame functions + NS_HIDDEN_(nsIFrame*) GetPrimaryFrameFor(nsIContent* aContent); + NS_HIDDEN_(nsresult) SetPrimaryFrameFor(nsIContent* aContent, + nsIFrame* aPrimaryFrame); + NS_HIDDEN_(void) ClearPrimaryFrameMap(); + + // Placeholder frame functions + NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame); + NS_HIDDEN_(nsresult) + RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); + + NS_HIDDEN_(void) + UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); + + NS_HIDDEN_(void) ClearPlaceholderFrameMap(); + + // Mapping undisplayed content + NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent); + NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent, + nsStyleContext* aStyleContext); + NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent, + nsStyleContext* aStyleContext); + NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent, + nsIContent* aParentContent); + NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent); + NS_HIDDEN_(void) ClearUndisplayedContentMap(); + + // Functions for manipulating the frame model + NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame, + nsIAtom* aListName, + nsIFrame* aFrameList) + { + return aParentFrame->AppendFrames(GetPresContext(), *GetPresShell(), + aListName, aFrameList); + } + + NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame, + nsIAtom* aListName, + nsIFrame* aPrevFrame, + nsIFrame* aFrameList); + + NS_HIDDEN_(nsresult) RemoveFrame(nsIFrame* aParentFrame, + nsIAtom* aListName, + nsIFrame* aOldFrame); + + NS_HIDDEN_(nsresult) ReplaceFrame(nsIFrame* aParentFrame, + nsIAtom* aListName, + nsIFrame* aOldFrame, + nsIFrame* aNewFrame) + { + return aParentFrame->ReplaceFrame(GetPresContext(), *GetPresShell(), + aListName, aOldFrame, aNewFrame); + } + + // Notification that we were unable to render a replaced element + NS_HIDDEN_(nsresult) CantRenderReplacedElement(nsIFrame* aFrame); + + /* + * Notification that a frame is about to be destroyed. This allows any + * outstanding references to the frame to be cleaned up. + */ + NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame); + + /* + * Reparent the style contexts of this frame subtree to live under the new + * given parent style context. The StyleContextParent of aFrame should be + * changed _before_ this method is called, so that style tree verification + * can take place correctly. + */ + NS_HIDDEN_(nsresult) ReParentStyleContext(nsIFrame* aFrame, + nsStyleContext* aNewParentContext); + + /* + * Re-resolve the style contexts for a frame tree. Returns the top-level + * change hint resulting from the style re-resolution. + */ + NS_HIDDEN_(nsChangeHint) + ComputeStyleChangeFor(nsIFrame* aFrame, + nsStyleChangeList* aChangeList, + nsChangeHint aMinChange); + + // Determine whether an attribute affects style + NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent, + nsIAtom *aAttribute, + PRInt32 aModType); + + /* + * Capture/restore frame state for the frame subtree rooted at aFrame. + * aState is the document state storage object onto which each frame + * stores its state. + */ + + NS_HIDDEN_(void) CaptureFrameState(nsIFrame* aFrame, + nsILayoutHistoryState* aState); + + NS_HIDDEN_(void) RestoreFrameState(nsIFrame* aFrame, + nsILayoutHistoryState* aState); + + /* + * Add/restore state for one frame + * (special, global type, like scroll position) + */ + NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame* aFrame, + nsILayoutHistoryState* aState, + nsIStatefulFrame::SpecialStateID aID = + nsIStatefulFrame::eNoID); + + NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame* aFrame, + nsILayoutHistoryState* aState, + nsIStatefulFrame::SpecialStateID aID = + nsIStatefulFrame::eNoID); + + /** + * Gets a property value for a given frame. + * + * @param aFrame the frame with the property + * @param aPropertyName property name as an atom + * @param aOptions optional flags + * NS_IFRAME_MGR_REMOVE_PROP removes the property + * @param aResult NS_OK if the property is set, + * NS_IFRAME_MGR_PROP_NOT_THERE is it is not set + * @param aPropertyValue the property value or 0 if the + property is not set + * @return The property value or 0 if the property is not set + */ + + NS_HIDDEN_(void*) GetFrameProperty(const nsIFrame* aFrame, + nsIAtom* aPropertyName, + PRUint32 aOptions, + nsresult* aResult = nsnull); + + /** + * Sets the property value for a given frame. + * + * A frame may only have one property value at a time for a given property + * name. The existing property value (if there is one) is overwritten, and + * the old value destroyed + * + * @param aFrame the frame to set the property on + * @param aPropertyName property name as an atom + * @param aPropertyValue the property value + * @param aPropertyDtorFunc when setting a property you can specify the + * dtor function (can be NULL) that will be used + * to destroy the property value. There can be + * only one dtor function for a given property + * name + * @return NS_OK if successful, + * NS_IFRAME_MGR_PROP_OVERWRITTEN if there is an existing property + * value that was overwritten, + * NS_ERROR_INVALID_ARG if the dtor function does not match the + * existing dtor function + */ + + NS_HIDDEN_(nsresult) SetFrameProperty(const nsIFrame* aFrame, + nsIAtom* aPropertyName, + void* aPropertyValue, + NSFramePropertyDtorFunc aPropDtorFunc); + + /** + * Removes a property and destroys its property value by calling the dtor + * function associated with the property name. + * + * When a frame is destroyed any remaining properties are automatically + * removed. + * + * @param aFrame the frame to set the property on + * @param aPropertyName property name as an atom + * @return NS_OK if the property is successfully removed, + * NS_IFRAME_MGR_PROP_NOT_THERE if the property is not set + */ + + NS_HIDDEN_(nsresult) RemoveFrameProperty(const nsIFrame* aFrame, + nsIAtom* aPropertyName); + +#ifdef NS_DEBUG + /** + * DEBUG ONLY method to verify integrity of style tree versus frame tree + */ + NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame); +#endif + + struct PropertyList; + +private: + + class UndisplayedMap; + friend struct CantRenderReplacedElementEvent; + + NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; } + NS_HIDDEN_(nsIPresContext*) GetPresContext() const { + return mPresShell->GetPresContext(); + } + + // weak link, because the pres shell owns us + nsIPresShell* mPresShell; + // the pres shell owns the style set + nsStyleSet* mStyleSet; + nsIFrame* mRootFrame; + PLDHashTable mPrimaryFrameMap; + PLDHashTable mPlaceholderMap; + UndisplayedMap* mUndisplayedMap; + CantRenderReplacedElementEvent* mPostedEvents; + PropertyList* mPropertyList; + PRBool mIsDestroyingFrames; + + NS_HIDDEN_(nsChangeHint) + ReResolveStyleContext(nsIPresContext *aPresContext, + nsIFrame *aFrame, + nsIContent *aParentContent, + nsStyleChangeList *aChangeList, + nsChangeHint aMinChange); + + NS_HIDDEN_(nsresult) RevokePostedEvents(); + NS_HIDDEN_(CantRenderReplacedElementEvent**) + FindPostedEventFor(nsIFrame* aFrame); + + NS_HIDDEN_(void) DequeuePostedEventFor(nsIFrame* aFrame); + NS_HIDDEN_(void) DestroyPropertyList(nsIPresContext* aPresContext); + NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom* aPropertyName) const; + NS_HIDDEN_(void) RemoveAllPropertiesFor(nsIPresContext *aPresContext, + nsIFrame *aFrame); + + static NS_HIDDEN_(void) + HandlePLEvent(CantRenderReplacedElementEvent* aEvent); + + static NS_HIDDEN_(void) + DestroyPLEvent(CantRenderReplacedElementEvent* aEvent); +}; + +#endif diff --git a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp index 776f4f0722a..81ccab09a55 100644 --- a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp +++ b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp @@ -54,7 +54,7 @@ #include "nsIURI.h" #include "nsNetUtil.h" #include "nsXBLAtoms.h" -#include "nsIFrameManager.h" +#include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsXBLPrototypeBinding.h" @@ -276,9 +276,9 @@ nsXBLResourceLoader::NotifyBoundElements() shell->GetPrimaryFrameFor(content, &childFrame); if (!childFrame) { // Check to see if it's in the undisplayed content map. - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); - nsStyleContext* sc = frameManager->GetUndisplayedContent(content); + nsStyleContext* sc = + shell->FrameManager()->GetUndisplayedContent(content); + if (!sc) { nsCOMPtr obs(do_QueryInterface(shell)); obs->ContentInserted(doc, parent, content, index); diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index b8b9f53cb50..4d67e9ea3ef 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -85,7 +85,7 @@ #include "nsIPresShell.h" #include "nsIDocumentObserver.h" -#include "nsIFrameManager.h" +#include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsIScriptSecurityManager.h" @@ -170,9 +170,9 @@ public: shell->GetPrimaryFrameFor(mBoundElement, &childFrame); if (!childFrame) { // Check to see if it's in the undisplayed content map. - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); - nsStyleContext* sc = frameManager->GetUndisplayedContent(mBoundElement); + nsStyleContext* sc = + shell->FrameManager()->GetUndisplayedContent(mBoundElement); + if (!sc) { nsCOMPtr obs(do_QueryInterface(shell)); obs->ContentInserted(doc, parent, mBoundElement, index); diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index f4248039168..07cb7da3f5d 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -46,7 +46,7 @@ #include "nsIPresContext.h" #include "nsIRenderingContext.h" #include "nsIServiceManager.h" -#include "nsIFrameManager.h" +#include "nsFrameManager.h" #include "nsBidiFrames.h" #include "nsBidiUtils.h" @@ -810,25 +810,24 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext, nsIFrame* thisFramesNextBidiFrame; nsIFrame* previousFramesNextBidiFrame; - nsIFrameManager* frameManager = presShell->GetFrameManager(); - if (frameManager) { - frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::nextBidi, - 0, (void**) &thisFramesNextBidiFrame); - if (thisFramesNextBidiFrame) { - // Remove nextBidi property, associated with the current frame - // and with all of its prev-in-flow. - frame = aFrame; - do { - frameManager->RemoveFrameProperty(frame, nsLayoutAtoms::nextBidi); - frame->GetPrevInFlow(&frame); - if (!frame) { - break; - } - frameManager->GetFrameProperty(frame, nsLayoutAtoms::nextBidi, - 0, (void**) &previousFramesNextBidiFrame); - } while (thisFramesNextBidiFrame == previousFramesNextBidiFrame); - } // if (thisFramesNextBidiFrame) - } // if (frameManager) + nsFrameManager* frameManager = presShell->FrameManager(); + thisFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*, + frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::nextBidi, 0)); + + if (thisFramesNextBidiFrame) { + // Remove nextBidi property, associated with the current frame + // and with all of its prev-in-flow. + frame = aFrame; + do { + frameManager->RemoveFrameProperty(frame, nsLayoutAtoms::nextBidi); + frame->GetPrevInFlow(&frame); + if (!frame) { + break; + } + previousFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*, + frameManager->GetFrameProperty(frame, nsLayoutAtoms::nextBidi, 0)); + } while (thisFramesNextBidiFrame == previousFramesNextBidiFrame); + } // if (thisFramesNextBidiFrame) } nsresult diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index fd360e97f34..e01464cdc2d 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -90,7 +90,7 @@ #include "nsTextFragment.h" #include "nsISupportsArray.h" #include "nsIAnonymousContentCreator.h" -#include "nsIFrameManager.h" +#include "nsFrameManager.h" #include "nsIPrefBranch.h" #include "nsIPrefService.h" #include "nsLegendFrame.h" @@ -368,19 +368,21 @@ IsFrameSpecial(nsIFrame* aFrame) } static void -GetSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aResult) +GetSpecialSibling(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aResult) { // We only store the "special sibling" annotation with the first // frame in the flow. Walk back to find that frame now. aFrame = aFrame->GetFirstInFlow(); - void* value; - aFrameManager->GetFrameProperty(aFrame, nsLayoutAtoms::IBSplitSpecialSibling, 0, &value); + void* value = + aFrameManager->GetFrameProperty(aFrame, + nsLayoutAtoms::IBSplitSpecialSibling, 0); + *aResult = NS_STATIC_CAST(nsIFrame*, value); } static nsIFrame* -GetLastSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame) +GetLastSpecialSibling(nsFrameManager* aFrameManager, nsIFrame* aFrame) { for (nsIFrame *frame = aFrame, *next; ; frame = next) { GetSpecialSibling(aFrameManager, frame, &next); @@ -394,7 +396,7 @@ GetLastSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame) // Get the frame's next-in-flow, or, if it doesn't have one, // its special sibling. static nsIFrame* -GetNifOrSpecialSibling(nsIFrameManager *aFrameManager, nsIFrame *aFrame) +GetNifOrSpecialSibling(nsFrameManager *aFrameManager, nsIFrame *aFrame) { nsIFrame *result; aFrame->GetNextInFlow(&result); @@ -407,7 +409,7 @@ GetNifOrSpecialSibling(nsIFrameManager *aFrameManager, nsIFrame *aFrame) } static void -SetFrameIsSpecial(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame* aSpecialSibling) +SetFrameIsSpecial(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame* aSpecialSibling) { NS_PRECONDITION(aFrameManager && aFrame, "bad args!"); @@ -555,7 +557,7 @@ FindLastBlock(nsIPresContext* aPresContext, nsIFrame* aKid) */ inline void MarkIBSpecialPrevSibling(nsIPresContext* aPresContext, - nsIFrameManager *aFrameManager, + nsFrameManager *aFrameManager, nsIFrame *aAnonymousFrame, nsIFrame *aSpecialParent) { @@ -737,7 +739,7 @@ private: class nsFrameConstructorState { public: nsCOMPtr mPresShell; - nsCOMPtr mFrameManager; + nsFrameManager *mFrameManager; // Containing block information for out-of-flow frammes nsAbsoluteItems mFixedItems; @@ -789,7 +791,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mPseudoFrames() { mPresShell = aPresContext->PresShell(); - mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); + mFrameManager = mPresShell->FrameManager(); } nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresContext, @@ -804,7 +806,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mPseudoFrames() { mPresShell = aPresContext->PresShell(); - mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); + mFrameManager = mPresShell->FrameManager(); nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) @@ -1038,8 +1040,8 @@ MoveChildrenTo(nsIPresContext* aPresContext, // anonymous block frame, but oddly they aren't -- need to // investigate that...) if (aNewParentSC) - aPresContext->GetFrameManager()->ReParentStyleContext(aFrameList, - aNewParentSC); + aPresContext->FrameManager()->ReParentStyleContext(aFrameList, + aNewParentSC); #endif aFrameList = aFrameList->GetNextSibling(); @@ -2758,7 +2760,7 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context if (aIsPseudoParent) { - aPresContext->GetFrameManager()-> + aPresContext->FrameManager()-> ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); } @@ -3901,7 +3903,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsresult nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, nsStyleContext* aStyleContext, @@ -5519,8 +5521,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::defaultz, defaultTooltip); if (defaultTooltip.EqualsIgnoreCase("true")) { // Locate the root frame and tell it about the tooltip. - nsIFrame* rootFrame = nsnull; - aState.mFrameManager->GetRootFrame(&rootFrame); + nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) rootFrame = rootFrame->GetFirstChild(nsnull); nsCOMPtr rootBox(do_QueryInterface(rootFrame)); @@ -5629,8 +5630,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, else if (isPopup) { // Locate the root popup set and add ourselves to the popup set's list // of popup frames. - nsIFrame* rootFrame; - aState.mFrameManager->GetRootFrame(&rootFrame); + nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) rootFrame = rootFrame->GetFirstChild(nsnull); nsCOMPtr rootBox(do_QueryInterface(rootFrame)); @@ -5666,8 +5666,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltip, value) != NS_CONTENT_ATTR_NOT_THERE) { - nsIFrame* rootFrame = nsnull; - aState.mFrameManager->GetRootFrame(&rootFrame); + nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame(); if (rootFrame) rootFrame = rootFrame->GetFirstChild(nsnull); nsCOMPtr rootBox(do_QueryInterface(rootFrame)); @@ -7141,11 +7140,11 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte nsFrameConstructorState state(aPresContext, mFixedContainingBlock, nsnull, nsnull, mTempFrameTreeState); - nsIFrame* docElementFrame; - - // Get the frame that corresponds to the document element - state.mFrameManager->GetPrimaryFrameFor(rootContent, &docElementFrame); + // Get the frame that corresponds to the document element + nsIFrame* docElementFrame = + state.mFrameManager->GetPrimaryFrameFor(rootContent); + // Clear the hash tables that map from content to frame and out-of-flow // frame to placeholder frame state.mFrameManager->ClearPrimaryFrameMap(); @@ -7406,7 +7405,7 @@ nsCSSFrameConstructor::GetFloatContainingBlock(nsIPresContext* aPresContext, nsresult nsCSSFrameConstructor::AppendFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContainer, nsIFrame* aParentFrame, nsIFrame* aFrameList) @@ -7534,9 +7533,8 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, // The frame may be a special frame (a split inline frame that // contains a block). Get the last part of that split. if (IsFrameSpecial(prevSibling)) { - nsCOMPtr fm; - aPresShell->GetFrameManager(getter_AddRefs(fm)); - prevSibling = GetLastSpecialSibling(fm, prevSibling); + prevSibling = GetLastSpecialSibling(aPresShell->FrameManager(), + prevSibling); } // The frame may have a continuation. If so, we want the @@ -7548,7 +7546,7 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, const nsStyleDisplay* display = prevSibling->GetStyleDisplay(); if (display->IsFloating() || display->IsAbsolutelyPositioned()) { - nsIFrame* placeholderFrame; + nsIFrame *placeholderFrame; aPresShell->GetPlaceholderFrameFor(prevSibling, &placeholderFrame); NS_ASSERTION(placeholderFrame, "no placeholder for out-of-flow frame"); prevSibling = placeholderFrame; @@ -7731,9 +7729,8 @@ nsCSSFrameConstructor::FindPreviousSibling(nsIPresShell* aPresShell, // The frame may be a special frame (a split inline frame that // contains a block). Get the last part of that split. if (IsFrameSpecial(prevSibling)) { - nsCOMPtr fm; - aPresShell->GetFrameManager(getter_AddRefs(fm)); - prevSibling = GetLastSpecialSibling(fm, prevSibling); + prevSibling = GetLastSpecialSibling(aPresShell->FrameManager(), + prevSibling); } // The frame may have a continuation. Get the last-in-flow @@ -8116,8 +8113,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, // Since we're appending, we'll walk to the last anonymous frame // that was created for the broken inline frame. - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = shell->FrameManager(); while (1) { nsIFrame* sibling; @@ -8364,11 +8360,8 @@ nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext, if (aChildItems) { aChildItems->AddChild(generatedFrame); } else { - nsCOMPtr frameManager; - aPresShell->GetFrameManager(getter_AddRefs(frameManager)); - if (frameManager) { - frameManager->AppendFrames(aParentFrame, nsnull, generatedFrame); - } + aPresShell->FrameManager()->AppendFrames(aParentFrame, nsnull, + generatedFrame); } listFrame->SetDummyFrame(generatedFrame); @@ -8385,7 +8378,7 @@ nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext, static nsresult DeletingFrameSubtree(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrame); nsresult @@ -8416,8 +8409,7 @@ nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext, // get the child's parent frame (which ought to be the list frame) nsIFrame* parentFrame = dummyFrame->GetParent(); - nsCOMPtr frameManager; - aPresShell->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = aPresShell->FrameManager(); DeletingFrameSubtree(aPresContext, aPresShell, frameManager, dummyFrame); frameManager->RemoveFrame(parentFrame, nsnull, dummyFrame); @@ -9021,7 +9013,7 @@ nsCSSFrameConstructor::ContentReplaced(nsIPresContext* aPresContext, static nsresult DoDeletingFrameSubtree(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsVoidArray& aDestroyQueue, nsIFrame* aRemovedFrame, nsIFrame* aFrame) @@ -9095,7 +9087,7 @@ DoDeletingFrameSubtree(nsIPresContext* aPresContext, static nsresult DeletingFrameSubtree(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrame) { // If there's no frame manager it's probably because the pres shell is @@ -9137,8 +9129,7 @@ DeletingFrameSubtree(nsIPresContext* aPresContext, if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) { // Locate the root popup set and remove ourselves from the popup set's list // of popup frames. - nsIFrame* rootFrame; - aFrameManager->GetRootFrame(&rootFrame); + nsIFrame* rootFrame = aFrameManager->GetRootFrame(); if (rootFrame) rootFrame = rootFrame->GetFirstChild(nsnull); nsCOMPtr rootBox(do_QueryInterface(rootFrame)); @@ -9181,13 +9172,12 @@ nsCSSFrameConstructor::RemoveMappingsForFrameSubtree(nsIPresContext* aPresContex nsILayoutHistoryState* aFrameState) { nsIPresShell *presShell = aPresContext->PresShell(); - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); // Save the frame tree's state before deleting it CaptureStateFor(aPresContext, aRemovedFrame, mTempFrameTreeState); - return DeletingFrameSubtree(aPresContext, presShell, frameManager, aRemovedFrame); + return DeletingFrameSubtree(aPresContext, presShell, + presShell->FrameManager(), aRemovedFrame); } nsresult @@ -9213,8 +9203,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, #endif nsIPresShell *shell = aPresContext->PresShell(); - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = shell->FrameManager(); nsresult rv = NS_OK; // Find the child frame that maps the content @@ -9360,130 +9349,128 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, nsPlaceholderFrame* placeholderFrame = nsnull; if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) // Get the placeholder frame - frameManager->GetPlaceholderFrameFor(childFrame, - (nsIFrame**)&placeholderFrame); - if (placeholderFrame) { - // Remove the mapping from the frame to its placeholder - frameManager->UnregisterPlaceholderFrame(placeholderFrame); + placeholderFrame = frameManager->GetPlaceholderFrameFor(childFrame); + if (placeholderFrame) { + // Remove the mapping from the frame to its placeholder + frameManager->UnregisterPlaceholderFrame(placeholderFrame); - // Locate the root popup set and remove ourselves from the popup set's list - // of popup frames. - nsIFrame* rootFrame; - frameManager->GetRootFrame(&rootFrame); - if (rootFrame) - rootFrame = rootFrame->GetFirstChild(nsnull); + // Locate the root popup set and remove ourselves from the popup set's list + // of popup frames. + nsIFrame* rootFrame = frameManager->GetRootFrame(); + if (rootFrame) + rootFrame = rootFrame->GetFirstChild(nsnull); #ifdef MOZ_XUL - nsCOMPtr rootBox(do_QueryInterface(rootFrame)); - if (rootBox) { - nsIFrame* popupSetFrame; - rootBox->GetPopupSetFrame(&popupSetFrame); - if (popupSetFrame) { - nsCOMPtr popupSet(do_QueryInterface(popupSetFrame)); - if (popupSet) - popupSet->RemovePopupFrame(childFrame); + nsCOMPtr rootBox(do_QueryInterface(rootFrame)); + if (rootBox) { + nsIFrame* popupSetFrame; + rootBox->GetPopupSetFrame(&popupSetFrame); + if (popupSetFrame) { + nsCOMPtr popupSet(do_QueryInterface(popupSetFrame)); + if (popupSet) + popupSet->RemovePopupFrame(childFrame); + } + } +#endif + + // Remove the placeholder frame first (XXX second for now) (so + // that it doesn't retain a dangling pointer to memory) + if (placeholderFrame) { + parentFrame = placeholderFrame->GetParent(); + DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame); + frameManager->RemoveFrame(parentFrame, nsnull, placeholderFrame); + return NS_OK; } } -#endif - - // Remove the placeholder frame first (XXX second for now) (so - // that it doesn't retain a dangling pointer to memory) - if (placeholderFrame) { - parentFrame = placeholderFrame->GetParent(); - DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame); - frameManager->RemoveFrame(parentFrame, nsnull, placeholderFrame); - return NS_OK; - } - } - else if (display->IsFloating()) { + else if (display->IsFloating()) { #ifdef NOISY_FIRST_LETTER - printf(" ==> child display is still floating!\n"); + printf(" ==> child display is still floating!\n"); #endif - // Get the placeholder frame - nsPlaceholderFrame* placeholderFrame; - frameManager->GetPlaceholderFrameFor(childFrame, - (nsIFrame**)&placeholderFrame); + // Get the placeholder frame + nsPlaceholderFrame* placeholderFrame = + frameManager->GetPlaceholderFrameFor(childFrame); - // Remove the mapping from the frame to its placeholder - if (placeholderFrame) - frameManager->UnregisterPlaceholderFrame(placeholderFrame); + // Remove the mapping from the frame to its placeholder + if (placeholderFrame) + frameManager->UnregisterPlaceholderFrame(placeholderFrame); - // Now we remove the floating frame + // Now we remove the floating frame - // XXX has to be done first for now: the blocks line list - // contains an array of pointers to the placeholder - we have to - // remove the float first (which gets rid of the lines - // reference to the placeholder and float) and then remove the - // placeholder - rv = frameManager->RemoveFrame(parentFrame, - nsLayoutAtoms::floatList, childFrame); - - // Remove the placeholder frame first (XXX second for now) (so - // that it doesn't retain a dangling pointer to memory) - if (placeholderFrame) { - parentFrame = placeholderFrame->GetParent(); - DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame); + // XXX has to be done first for now: the blocks line list + // contains an array of pointers to the placeholder - we have to + // remove the float first (which gets rid of the lines + // reference to the placeholder and float) and then remove the + // placeholder rv = frameManager->RemoveFrame(parentFrame, - nsnull, placeholderFrame); + nsLayoutAtoms::floatList, childFrame); + + // Remove the placeholder frame first (XXX second for now) (so + // that it doesn't retain a dangling pointer to memory) + if (placeholderFrame) { + parentFrame = placeholderFrame->GetParent(); + DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame); + rv = frameManager->RemoveFrame(parentFrame, + nsnull, placeholderFrame); + } } - } - // See if it's absolutely or fixed positioned - else if (display->IsAbsolutelyPositioned()) { - // Get the placeholder frame - nsPlaceholderFrame* placeholderFrame; - frameManager->GetPlaceholderFrameFor(childFrame, - (nsIFrame**)&placeholderFrame); + // See if it's absolutely or fixed positioned + else if (display->IsAbsolutelyPositioned()) { + // Get the placeholder frame + nsPlaceholderFrame* placeholderFrame = + frameManager->GetPlaceholderFrameFor(childFrame); - // Remove the mapping from the frame to its placeholder - if (placeholderFrame) - frameManager->UnregisterPlaceholderFrame(placeholderFrame); + // Remove the mapping from the frame to its placeholder + if (placeholderFrame) + frameManager->UnregisterPlaceholderFrame(placeholderFrame); - // Generate two notifications. First for the absolutely positioned - // frame - rv = frameManager->RemoveFrame(parentFrame, - (NS_STYLE_POSITION_FIXED == display->mPosition) ? - nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame); + // Generate two notifications. First for the absolutely positioned + // frame + rv = frameManager->RemoveFrame(parentFrame, + (NS_STYLE_POSITION_FIXED == display->mPosition) ? + nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame); - // Now the placeholder frame - if (placeholderFrame) { - parentFrame = placeholderFrame->GetParent(); - rv = frameManager->RemoveFrame(parentFrame, nsnull, placeholderFrame); + // Now the placeholder frame + if (placeholderFrame) { + parentFrame = placeholderFrame->GetParent(); + rv = frameManager->RemoveFrame(parentFrame, nsnull, + placeholderFrame); + } + + } else { + // Notify the parent frame that it should delete the frame + // check for a table caption which goes on an additional child list with a different parent + nsIFrame* outerTableFrame; + if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) { + rv = frameManager->RemoveFrame(outerTableFrame, + nsLayoutAtoms::captionList, + childFrame); + } + else { + rv = frameManager->RemoveFrame(insertionPoint, nsnull, childFrame); + } } - } else { - // Notify the parent frame that it should delete the frame - // check for a table caption which goes on an additional child list with a different parent - nsIFrame* outerTableFrame; - if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) { - rv = frameManager->RemoveFrame(outerTableFrame, - nsLayoutAtoms::captionList, childFrame); + if (mInitialContainingBlock == childFrame) { + mInitialContainingBlock = nsnull; } - else { - rv = frameManager->RemoveFrame(insertionPoint, nsnull, childFrame); + + if (haveFLS && mInitialContainingBlock) { + nsFrameConstructorState state(aPresContext, mFixedContainingBlock, + GetAbsoluteContainingBlock(aPresContext, + parentFrame), + GetFloatContainingBlock(aPresContext, + parentFrame)); + RecoverLetterFrames(shell, aPresContext, state, containingBlock); } - } - - if (mInitialContainingBlock == childFrame) { - mInitialContainingBlock = nsnull; - } - - if (haveFLS && mInitialContainingBlock) { - nsFrameConstructorState state(aPresContext, mFixedContainingBlock, - GetAbsoluteContainingBlock(aPresContext, - parentFrame), - GetFloatContainingBlock(aPresContext, - parentFrame)); - RecoverLetterFrames(shell, aPresContext, state, containingBlock); - } #ifdef DEBUG - if (gReallyNoisyContentUpdates && parentFrame) { - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(parentFrame, &fdbg); - if (fdbg) { - printf("nsCSSFrameConstructor::ContentRemoved: resulting frame model:\n"); - fdbg->List(aPresContext, stdout, 0); + if (gReallyNoisyContentUpdates && parentFrame) { + nsIFrameDebug* fdbg = nsnull; + CallQueryInterface(parentFrame, &fdbg); + if (fdbg) { + printf("nsCSSFrameConstructor::ContentRemoved: resulting frame model:\n"); + fdbg->List(aPresContext, stdout, 0); + } } - } #endif } @@ -9500,12 +9487,12 @@ static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIViewManager* aViewManager, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsChangeHint aChange); static void UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager, nsIFrameManager* aFrameManager, + nsIViewManager* aViewManager, nsFrameManager* aFrameManager, nsRect& aBoundsRect, nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, @@ -9561,7 +9548,7 @@ static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIViewManager* aViewManager, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, @@ -9643,14 +9630,11 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, viewManager->BeginUpdateViewBatch(); - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); - #ifdef DEBUG gInApplyRenderingChangeToTree = PR_TRUE; #endif DoApplyRenderingChangeToTree(aPresContext, aFrame, viewManager, - frameManager, aChange); + shell->FrameManager(), aChange); #ifdef DEBUG gInApplyRenderingChangeToTree = PR_FALSE; #endif @@ -9782,8 +9766,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (!count) return NS_OK; - nsCOMPtr frameManager; - aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = aPresContext->FrameManager(); // Mark frames so that we skip frames that die along the way, bug 123049. // A frame can be in the list multiple times with different hints. Further @@ -9807,9 +9790,13 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, // skip any frame that has been destroyed due to a ripple effect if (frame) { - void* dummy; - nsresult res = frameManager->GetFrameProperty(frame, - nsLayoutAtoms::changeListProperty, 0, &dummy); + nsresult res; + + void* dummy = + frameManager->GetFrameProperty(frame, + nsLayoutAtoms::changeListProperty, 0, + &res); + if (NS_IFRAME_MGR_PROP_NOT_THERE == res) continue; } @@ -9832,9 +9819,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, nsIPresShell *shell = aPresContext->PresShell(); shell->GetPrimaryFrameFor(content, &frame); if (frame) { - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); - frameManager->DebugVerifyStyleTree(frame); + shell->FrameManager()->DebugVerifyStyleTree(frame); } } else { NS_WARNING("Unable to test style tree integrity -- no content node"); @@ -9864,10 +9849,8 @@ nsCSSFrameConstructor::RestyleElement(nsIPresContext *aPresContext, { if (aPrimaryFrame) { nsStyleChangeList changeList; - nsChangeHint frameChange = NS_STYLE_HINT_NONE; - aPresContext->GetPresShell()->GetFrameManager()-> - ComputeStyleChangeFor(aPrimaryFrame, changeList, - NS_STYLE_HINT_NONE, frameChange); + nsChangeHint frameChange = aPresContext->GetPresShell()->FrameManager()-> + ComputeStyleChangeFor(aPrimaryFrame, &changeList, NS_STYLE_HINT_NONE); if (frameChange & nsChangeHint_ReconstructFrame) { RecreateFramesForContent(aPresContext, aContent); @@ -10037,10 +10020,11 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, } } - nsIFrameManager *frameManager = shell->GetFrameManager(); - nsReStyleHint rshint = nsReStyleHint(0); - frameManager->HasAttributeDependentStyle(aContent, - aAttribute, aModType, &rshint); + nsFrameManager *frameManager = shell->FrameManager(); + nsReStyleHint rshint = frameManager->HasAttributeDependentStyle(aContent, + aAttribute, + aModType); + if (reframe) { result = RecreateFramesForContent(aPresContext, aContent); } else if (primaryFrame) { @@ -10050,8 +10034,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // there is an effect, so compute it if (rshint & eReStyle_Self) { - frameManager->ComputeStyleChangeFor(primaryFrame, - changeList, hint, hint); + hint = frameManager->ComputeStyleChangeFor(primaryFrame, &changeList, + hint); } // hint is for primary only @@ -10263,7 +10247,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, nsPlaceholderFrame* placeholderFrame = nsnull; nsIPresShell *presShell = aPresContext->PresShell(); if (listName) { - presShell->GetPlaceholderFrameFor(aFrame, (nsIFrame**)&placeholderFrame); + presShell->GetPlaceholderFrameFor(aFrame, (nsIFrame**) &placeholderFrame); } // Get the previous sibling frame @@ -10281,8 +10265,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, parentFrame, nsnull, newFrame); if (NS_SUCCEEDED(rv)) { - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = presShell->FrameManager(); // Replace the old frame with the new frame @@ -10745,10 +10728,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, if (!oofContFrame) return NS_ERROR_NULL_POINTER; // create a continuing placeholder frame - nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); - NS_ASSERTION(frameManager, "no frame manager"); - CreatePlaceholderFrameFor(shell, aPresContext, frameManager, content, + CreatePlaceholderFrameFor(shell, aPresContext, + shell->FrameManager(), content, oofContFrame, styleContext, aParentFrame, &newFrame); if (!newFrame) return NS_ERROR_NULL_POINTER; @@ -10850,7 +10831,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, // for a frame that maps the specified content object nsIFrame* nsCSSFrameConstructor::FindFrameWithContent(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aParentFrame, nsIContent* aParentContent, nsIContent* aContent, @@ -10884,7 +10865,7 @@ nsCSSFrameConstructor::FindFrameWithContent(nsIPresContext* aPresContext, kidFrame = aHint->mPrimaryFrameForPrevSibling; // But if it's out of flow, start from its placeholder. if (kidFrame && (kidFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) { - aFrameManager->GetPlaceholderFrameFor(kidFrame, &kidFrame); + kidFrame = aFrameManager->GetPlaceholderFrameFor(kidFrame); } if (kidFrame) { @@ -10999,7 +10980,7 @@ nsCSSFrameConstructor::FindFrameWithContent(nsIPresContext* aPresContext, // the pres shell hash table nsresult nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContent, nsIFrame** aFrame, nsFindFrameHint* aHint) @@ -11024,7 +11005,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext, // call us back if there is no mapping in the hash table nsCOMPtr parentContent = aContent->GetParent(); // Get this once if (parentContent) { - aFrameManager->GetPrimaryFrameFor(parentContent, &parentFrame); + parentFrame = aFrameManager->GetPrimaryFrameFor(parentContent); while (parentFrame) { // Search the child frames for a match *aFrame = FindFrameWithContent(aPresContext, aFrameManager, parentFrame, @@ -11189,19 +11170,13 @@ nsCSSFrameConstructor::CaptureStateFor(nsIPresContext* aPresContext, nsIFrame* aFrame, nsILayoutHistoryState* aHistoryState) { - nsresult rv = NS_OK; - if (aFrame && aPresContext && aHistoryState) { nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { - nsCOMPtr frameManager; - rv = presShell->GetFrameManager(getter_AddRefs(frameManager)); - if (NS_SUCCEEDED(rv) && frameManager) { - rv = frameManager->CaptureFrameState(aFrame, aHistoryState); - } + presShell->FrameManager()->CaptureFrameState(aFrame, aHistoryState); } } - return rv; + return NS_OK; } nsresult @@ -11210,7 +11185,7 @@ nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIPresContext* aPresContex { nsresult result = NS_OK; nsIPresShell *shell = aPresContext->PresShell(); - nsIFrameManager *frameManager = shell->GetFrameManager(); + nsFrameManager *frameManager = shell->FrameManager(); nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent); if (oldContext) { @@ -11478,8 +11453,8 @@ ReparentFrame(nsIPresContext* aPresContext, nsIFrame* aFrame) { aFrame->SetParent(aNewParentFrame); - aPresContext->GetFrameManager()->ReParentStyleContext(aFrame, - aParentStyleContext); + aPresContext->FrameManager()->ReParentStyleContext(aFrame, + aParentStyleContext); } // Special routine to handle placing a list of frames into a block @@ -12130,7 +12105,7 @@ nsresult nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aBlockFrame, PRBool* aStopLooking) { @@ -12157,9 +12132,9 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( // Discover the placeholder frame for the letter frame nsIFrame* parentFrame; - nsPlaceholderFrame* placeholderFrame; - aFrameManager->GetPlaceholderFrameFor(floatFrame, - (nsIFrame**)&placeholderFrame); + nsPlaceholderFrame* placeholderFrame = + aFrameManager->GetPlaceholderFrameFor(floatFrame); + if (!placeholderFrame) { // Somethings really wrong return NS_OK; @@ -12244,7 +12219,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( nsresult nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrame, PRBool* aStopLooking) { @@ -12278,7 +12253,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, textFrame->Init(aPresContext, textContent, aFrame, newSC, nsnull); // Next rip out the kid and replace it with the text frame - nsIFrameManager* frameManager = aFrameManager; + nsFrameManager* frameManager = aFrameManager; DeletingFrameSubtree(aPresContext, aPresShell, frameManager, kid); frameManager->RemoveFrame(aFrame, nsnull, kid); @@ -12308,7 +12283,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, nsresult nsCSSFrameConstructor::RemoveLetterFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aBlockFrame) { PRBool stopLooking = PR_FALSE; @@ -12822,7 +12797,7 @@ nsCSSFrameConstructor::ProcessInlineChildren(nsIPresShell* aPresShell, // added to the frame hierarchy static void DoCleanupFrameReferences(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrameIn) { nsIContent* content = aFrameIn->GetContent(); @@ -12853,7 +12828,7 @@ DoCleanupFrameReferences(nsIPresContext* aPresContext, // Helper function that walks a frame list and calls DoCleanupFrameReference() static void CleanupFrameReferences(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrameList) { while (aFrameList) { @@ -12888,10 +12863,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, return PR_FALSE; // Ok, reverse tracks: wipe out the frames we just created - nsCOMPtr presShell; - nsCOMPtr frameManager; - - aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); + nsFrameManager *frameManager = aPresContext->FrameManager(); // Destroy the frames. As we do make sure any content to frame mappings // or entries in the undisplayed content map are removed @@ -13260,9 +13232,9 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF return ReconstructDocElementHierarchy(aPresContext); } -nsresult nsCSSFrameConstructor::RemoveFixedItems(nsIPresContext* aPresContext, - nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager) +nsresult nsCSSFrameConstructor::RemoveFixedItems(nsIPresContext* aPresContext, + nsIPresShell* aPresShell, + nsFrameManager* aFrameManager) { nsresult rv=NS_OK; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index 003c4be94ec..350a8e967af 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -51,7 +51,7 @@ struct nsStyleContent; struct nsStyleDisplay; class nsIPresShell; class nsVoidArray; -class nsIFrameManager; +class nsFrameManager; class nsFrameConstructorState; class nsIDOMHTMLSelectElement; class nsIPresContext; @@ -148,7 +148,7 @@ public: // This is typically called by the pres shell when there is no mapping in // the pres shell hash table nsresult FindPrimaryFrameFor(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContent, nsIFrame** aFrame, nsFindFrameHint* aHint); @@ -248,7 +248,7 @@ protected: nsresult AppendFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContainer, nsIFrame* aParentFrame, nsIFrame* aFrameList); @@ -453,7 +453,7 @@ protected: nsresult CreatePlaceholderFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, nsStyleContext* aStyleContext, @@ -657,7 +657,7 @@ protected: PRBool IsScrollable(nsIPresContext* aPresContext, const nsStyleDisplay* aDisplay); - nsIFrame* GetFrameFor(nsIPresShell* aFrameManager, + nsIFrame* GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIContent* aContent); @@ -876,7 +876,7 @@ protected: * @param aHint an optional hint used to make the search for aFrame faster */ nsIFrame* FindFrameWithContent(nsIPresContext* aPresContext, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aParentFrame, nsIContent* aParentContent, nsIContent* aContent, @@ -933,20 +933,20 @@ protected: // nsresult RemoveLetterFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aBlockFrame); // Recursive helper for RemoveLetterFrames nsresult RemoveFirstLetterFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aFrame, PRBool* aStopLooking); // Special remove method for those pesky floating first-letter frames nsresult RemoveFloatingFirstLetterFrames(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager, + nsFrameManager* aFrameManager, nsIFrame* aBlockFrame, PRBool* aStopLooking); @@ -989,7 +989,7 @@ protected: nsresult RemoveFixedItems(nsIPresContext* aPresContext, nsIPresShell* aPresShell, - nsIFrameManager* aFrameManager); + nsFrameManager* aFrameManager); // Find the ``rightmost'' frame for the content immediately preceding // aIndexInContainer, following continuations if necessary. If aChild is diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 7a57325e240..e5f35106add 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -99,7 +99,6 @@ #include "nsIFrameDebug.h" #include "nsILayoutHistoryState.h" #include "nsLayoutAtoms.h" -#include "nsIFrameManager.h" #include "nsIParser.h" #include "nsIPrintContext.h" #include "nsGUIEvent.h" diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 48b57258a08..792063c56bc 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -29,8 +29,6 @@ * 04/20/2000 IBM Corp. OS/2 VisualAge build. */ #include "nscore.h" -#include "nsIFrameManager.h" -#include "nsIFrame.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsStyleSet.h" @@ -42,7 +40,6 @@ #include "nsCOMPtr.h" #include "prthread.h" #include "plhash.h" -#include "pldhash.h" #include "nsPlaceholderFrame.h" #include "nsLayoutAtoms.h" #include "nsCSSAnonBoxes.h" @@ -53,7 +50,6 @@ #include "nsIStyleRule.h" #endif #include "nsILayoutHistoryState.h" -#include "nsIStatefulFrame.h" #include "nsIPresState.h" #include "nsIContent.h" #include "nsINameSpaceManager.h" @@ -79,6 +75,7 @@ #include "nsLayoutUtils.h" #include "nsAutoPtr.h" +#include "nsFrameManager.h" #ifdef DEBUG //#define NOISY_DEBUG @@ -141,8 +138,8 @@ static PLDHashTableOps PlaceholderMapOps = { //---------------------------------------------------------------------- struct PropertyListMapEntry : public PLDHashEntryHdr { - nsIFrame *key; - void *value; + const nsIFrame *key; + void *value; }; //---------------------------------------------------------------------- @@ -204,7 +201,7 @@ public: MOZ_COUNT_CTOR(UndisplayedNode); } - ~UndisplayedNode() + NS_HIDDEN ~UndisplayedNode() { MOZ_COUNT_DTOR(UndisplayedNode); delete mNext; @@ -215,24 +212,28 @@ public: UndisplayedNode* mNext; }; -class UndisplayedMap { +class nsFrameManager::UndisplayedMap { public: - UndisplayedMap(PRUint32 aNumBuckets = 16); - ~UndisplayedMap(void); + UndisplayedMap(PRUint32 aNumBuckets = 16) NS_HIDDEN; + ~UndisplayedMap(void) NS_HIDDEN; - UndisplayedNode* GetFirstNode(nsIContent* aParentContent); + NS_HIDDEN_(UndisplayedNode*) GetFirstNode(nsIContent* aParentContent); - nsresult AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, nsStyleContext* aStyle); + NS_HIDDEN_(nsresult) AddNodeFor(nsIContent* aParentContent, + nsIContent* aChild, nsStyleContext* aStyle); - nsresult RemoveNodeFor(nsIContent* aParentContent, UndisplayedNode* aNode); - nsresult RemoveNodesFor(nsIContent* aParentContent); + NS_HIDDEN_(void) RemoveNodeFor(nsIContent* aParentContent, + UndisplayedNode* aNode); + + NS_HIDDEN_(void) RemoveNodesFor(nsIContent* aParentContent); // Removes all entries from the hash table - void Clear(void); + NS_HIDDEN_(void) Clear(void); protected: - PLHashEntry** GetEntryFor(nsIContent* aParentContent); - nsresult AppendNodeFor(UndisplayedNode* aNode, nsIContent* aParentContent); + NS_HIDDEN_(PLHashEntry**) GetEntryFor(nsIContent* aParentContent); + NS_HIDDEN_(void) AppendNodeFor(UndisplayedNode* aNode, + nsIContent* aParentContent); PLHashTable* mTable; PLHashEntry** mLastLookup; @@ -240,20 +241,18 @@ protected: //---------------------------------------------------------------------- -class FrameManager; - // A CantRenderReplacedElementEvent has a weak pointer to the frame // manager, and the frame manager has a weak pointer to the event. // The event queue owns the event and the FrameManager will delete // the event if it's going to go away. struct CantRenderReplacedElementEvent : public PLEvent { - CantRenderReplacedElementEvent(FrameManager* aFrameManager, nsIFrame* aFrame, nsIPresShell* aPresShell); - ~CantRenderReplacedElementEvent(); + CantRenderReplacedElementEvent(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIPresShell* aPresShell) NS_HIDDEN; + ~CantRenderReplacedElementEvent() NS_HIDDEN; // XXXldb Should the pres shell maintain a reference count on a single // dummy layout request instead of doing creation of a separate one // here (and per-event!)? - nsresult AddLoadGroupRequest(nsIPresShell* aPresShell); - nsresult RemoveLoadGroupRequest(); + NS_HIDDEN_(nsresult) AddLoadGroupRequest(nsIPresShell* aPresShell); + NS_HIDDEN_(nsresult) RemoveLoadGroupRequest(); nsIFrame* mFrame; // the frame that can't be rendered CantRenderReplacedElementEvent* mNext; // next event in the list @@ -261,207 +260,58 @@ struct CantRenderReplacedElementEvent : public PLEvent { nsWeakPtr mPresShell; // for removing load group request later }; -class FrameManager : public nsIFrameManager -{ -public: - FrameManager(); - virtual ~FrameManager(); +struct nsFrameManager::PropertyList { + nsCOMPtr mName; // property name + PLDHashTable mFrameValueMap; // map of frame/value pairs + NSFramePropertyDtorFunc mDtorFunc; // property specific value dtor function + PropertyList* mNext; - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + PropertyList(nsIAtom* aName, + NSFramePropertyDtorFunc aDtorFunc) NS_HIDDEN; + ~PropertyList() NS_HIDDEN; - // nsISupports - NS_DECL_ISUPPORTS + // Removes the property associated with the given frame, and destroys + // the property value + NS_HIDDEN_(PRBool) RemovePropertyForFrame(nsIPresContext* aPresContext, + const nsIFrame* aFrame); - // nsIFrameManager - NS_IMETHOD Init(nsIPresShell* aPresShell, nsStyleSet* aStyleSet); - NS_IMETHOD Destroy(); - - // Gets and sets the root frame - NS_IMETHOD GetRootFrame(nsIFrame** aRootFrame) const; - NS_IMETHOD SetRootFrame(nsIFrame* aRootFrame); - - // Get the canvas frame: searches from the Root frame down, may be null - NS_IMETHOD GetCanvasFrame(nsIFrame** aCanvasFrame) const; - - // Primary frame functions - NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, - nsIFrame** aPrimaryFrame); - NS_IMETHOD SetPrimaryFrameFor(nsIContent* aContent, - nsIFrame* aPrimaryFrame); - NS_IMETHOD ClearPrimaryFrameMap(); - - // Placeholder frame functions - NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, - nsIFrame** aPlaceholderFrame) const; - NS_IMETHOD RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); - NS_IMETHOD UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); - NS_IMETHOD ClearPlaceholderFrameMap(); - - // Undisplayed content functions - virtual nsStyleContext* GetUndisplayedContent(nsIContent* aContent); - virtual void SetUndisplayedContent(nsIContent* aContent, - nsStyleContext* aStyleContext); - virtual void ChangeUndisplayedContent(nsIContent* aContent, - nsStyleContext* aStyleContext); - NS_IMETHOD ClearUndisplayedContentIn(nsIContent* aContent, - nsIContent* aParentContent); - NS_IMETHOD ClearAllUndisplayedContentIn(nsIContent* aParentContent); - NS_IMETHOD ClearUndisplayedContentMap(); - - // Functions for manipulating the frame model - NS_IMETHOD AppendFrames(nsIFrame* aParentFrame, - nsIAtom* aListName, - nsIFrame* aFrameList); - NS_IMETHOD InsertFrames(nsIFrame* aParentFrame, - nsIAtom* aListName, - nsIFrame* aPrevFrame, - nsIFrame* aFrameList); - NS_IMETHOD RemoveFrame(nsIFrame* aParentFrame, - nsIAtom* aListName, - nsIFrame* aOldFrame); - NS_IMETHOD ReplaceFrame(nsIFrame* aParentFrame, - nsIAtom* aListName, - nsIFrame* aOldFrame, - nsIFrame* aNewFrame); - - NS_IMETHOD CantRenderReplacedElement(nsIFrame* aFrame); - - NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame); - - NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext); - NS_IMETHOD ComputeStyleChangeFor(nsIFrame* aFrame, - nsStyleChangeList& aChangeList, - nsChangeHint aMinChange, - nsChangeHint& aTopLevelChange); - NS_IMETHOD HasAttributeDependentStyle(nsIContent *aContent, - nsIAtom *aAttribute, - PRInt32 aModType, - nsReStyleHint *aResult); - - // Capture state from the entire frame heirarchy and store in aState - NS_IMETHOD CaptureFrameState(nsIFrame* aFrame, - nsILayoutHistoryState* aState); - NS_IMETHOD RestoreFrameState(nsIFrame* aFrame, - nsILayoutHistoryState* aState); - // Add/restore state for one frame (special, global type, like scroll position) - NS_IMETHOD CaptureFrameStateFor(nsIFrame* aFrame, - nsILayoutHistoryState* aState, - nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID); - NS_IMETHOD RestoreFrameStateFor(nsIFrame* aFrame, - nsILayoutHistoryState* aState, - nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID); - // Gets and sets properties on a given frame - NS_IMETHOD GetFrameProperty(nsIFrame* aFrame, - nsIAtom* aPropertyName, - PRUint32 aOptions, - void** aPropertyValue); - NS_IMETHOD SetFrameProperty(nsIFrame* aFrame, - nsIAtom* aPropertyName, - void* aPropertyValue, - NSFramePropertyDtorFunc aPropDtorFunc); - NS_IMETHOD RemoveFrameProperty(nsIFrame* aFrame, - nsIAtom* aPropertyName); - -#ifdef NS_DEBUG - NS_IMETHOD DebugVerifyStyleTree(nsIFrame* aFrame); -#endif - - struct PropertyList { - nsCOMPtr mName; // property name - PLDHashTable mFrameValueMap; // map of frame/value pairs - NSFramePropertyDtorFunc mDtorFunc; // property specific value dtor function - PropertyList* mNext; - - PropertyList(nsIAtom* aName, - NSFramePropertyDtorFunc aDtorFunc); - ~PropertyList(); - - // Removes the property associated with the given frame, and destroys - // the property value - PRBool RemovePropertyForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame); - - // Destroy all remaining properties (without removing them) - void Destroy(nsIPresContext* aPresContext); - }; -private: - - nsIPresShell* GetPresShell() const { return mPresShell; } - nsIPresContext* GetPresContext() const { - return mPresShell->GetPresContext(); - } - - nsIPresShell* mPresShell; // weak link, because the pres shell owns us - nsStyleSet* mStyleSet; // weak link. pres shell holds a reference - nsIFrame* mRootFrame; - PLDHashTable mPrimaryFrameMap; - PLDHashTable mPlaceholderMap; - UndisplayedMap* mUndisplayedMap; - CantRenderReplacedElementEvent* mPostedEvents; - PropertyList* mPropertyList; - PRBool mIsDestroyingFrames; - - void ReResolveStyleContext(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIContent* aParentContent, - nsStyleChangeList& aChangeList, - nsChangeHint aMinChange, - nsChangeHint& aResultChange); - - nsresult RevokePostedEvents(); - CantRenderReplacedElementEvent** FindPostedEventFor(nsIFrame* aFrame); - void DequeuePostedEventFor(nsIFrame* aFrame); - void DestroyPropertyList(nsIPresContext* aPresContext); - PropertyList* GetPropertyListFor(nsIAtom* aPropertyName) const; - void RemoveAllPropertiesFor(nsIPresContext* aPresContext, nsIFrame* aFrame); - - friend struct CantRenderReplacedElementEvent; - static void HandlePLEvent(CantRenderReplacedElementEvent* aEvent); - static void DestroyPLEvent(CantRenderReplacedElementEvent* aEvent); + // Destroy all remaining properties (without removing them) + NS_HIDDEN_(void) Destroy(nsIPresContext* aPresContext); }; + //---------------------------------------------------------------------- +nsFrameManager::nsFrameManager() +{ +} + +nsFrameManager::~nsFrameManager() +{ + NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called"); +} + nsresult -NS_NewFrameManager(nsIFrameManager** aInstancePtrResult) +nsFrameManager::Init(nsIPresShell* aPresShell, + nsStyleSet* aStyleSet) { - NS_ENSURE_ARG_POINTER(aInstancePtrResult); - if (!aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; + if (!aPresShell) { + NS_ERROR("null pres shell"); + return NS_ERROR_FAILURE; } - FrameManager* it = new FrameManager; - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; + + if (!aStyleSet) { + NS_ERROR("null style set"); + return NS_ERROR_FAILURE; } - return it->QueryInterface(NS_GET_IID(nsIFrameManager), (void **)aInstancePtrResult); -} - -FrameManager::FrameManager() -{ -} - -FrameManager::~FrameManager() -{ - NS_ASSERTION(!mPresShell, "FrameManager::Destroy never called"); -} - -NS_IMPL_ISUPPORTS1(FrameManager, nsIFrameManager) - -NS_IMETHODIMP -FrameManager::Init(nsIPresShell* aPresShell, - nsStyleSet* aStyleSet) -{ - NS_ASSERTION(aPresShell, "null aPresShell"); - NS_ASSERTION(aStyleSet, "null aStyleSet"); mPresShell = aPresShell; mStyleSet = aStyleSet; - return NS_OK; } -NS_IMETHODIMP -FrameManager::Destroy() +void +nsFrameManager::Destroy() { NS_ASSERTION(mPresShell, "Frame manager already shut down."); @@ -493,46 +343,18 @@ FrameManager::Destroy() // If we're not going to be used anymore, we should revoke the // pending |CantRenderReplacedElementEvent|s being sent to us. - nsresult rv = RevokePostedEvents(); +#ifdef DEBUG + nsresult rv = +#endif + RevokePostedEvents(); NS_ASSERTION(NS_SUCCEEDED(rv), "RevokePostedEvents failed: might crash"); - mPresShell = nsnull; // mPresShell isn't valid anymore. We - // won't use it, either, but we check it - // at the start of every function so that we'll - // be OK when nsIPresShell is converted to IDL. - - return rv; + mPresShell = nsnull; } -NS_IMETHODIMP -FrameManager::GetRootFrame(nsIFrame** aRootFrame) const +nsIFrame* +nsFrameManager::GetCanvasFrame() { - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); - NS_ENSURE_ARG_POINTER(aRootFrame); - *aRootFrame = mRootFrame; - return NS_OK; -} - -NS_IMETHODIMP -FrameManager::SetRootFrame(nsIFrame* aRootFrame) -{ - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); - NS_PRECONDITION(!mRootFrame, "already have a root frame"); - if (mRootFrame) { - return NS_ERROR_UNEXPECTED; - } - - mRootFrame = aRootFrame; - return NS_OK; -} - -NS_IMETHODIMP -FrameManager::GetCanvasFrame(nsIFrame** aCanvasFrame) const -{ - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); - NS_PRECONDITION(aCanvasFrame, "aCanvasFrame argument cannot be null"); - - *aCanvasFrame = nsnull; if (mRootFrame) { // walk the children of the root frame looking for a frame with type==canvas // start at the root @@ -542,9 +364,8 @@ FrameManager::GetCanvasFrame(nsIFrame** aCanvasFrame) const nsIFrame *siblingFrame = childFrame; while (siblingFrame) { if (siblingFrame->GetType() == nsLayoutAtoms::canvasFrame) { - // this is it: set the out-arg and stop looking - *aCanvasFrame = siblingFrame; - break; + // this is it + return siblingFrame; } else { siblingFrame = siblingFrame->GetNextSibling(); } @@ -553,99 +374,98 @@ FrameManager::GetCanvasFrame(nsIFrame** aCanvasFrame) const childFrame = childFrame->GetFirstChild(nsnull); } } - return NS_OK; + return nsnull; } //---------------------------------------------------------------------- // Primary frame functions -NS_IMETHODIMP -FrameManager::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aResult) +nsIFrame* +nsFrameManager::GetPrimaryFrameFor(nsIContent* aContent) { - NS_ASSERTION(aResult, "null out-param not supported"); - *aResult = nsnull; // initialize out param (before possibly returning due to null args/members) - - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); - NS_ENSURE_ARG_POINTER(aContent); + NS_ENSURE_TRUE(aContent, nsnull); if (mIsDestroyingFrames) { #ifdef DEBUG - printf("GetPrimaryFrameFor() called while FrameManager is being destroyed!\n"); + printf("GetPrimaryFrameFor() called while nsFrameManager is being destroyed!\n"); #endif - return NS_ERROR_FAILURE; + return nsnull; } if (mPrimaryFrameMap.ops) { PrimaryFrameMapEntry *entry = NS_STATIC_CAST(PrimaryFrameMapEntry*, PL_DHashTableOperate(&mPrimaryFrameMap, aContent, PL_DHASH_LOOKUP)); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { - *aResult = entry->frame; - } else { - // XXX: todo: Add a lookup into the undisplay map to skip searches - // if we already know the content has no frame. - // nsCSSFrameConstructor calls SetUndisplayedContent() for every - // content node that has display: none. - // Today, the undisplay map doesn't quite support what we need. - // We need to see if we can add a method to make a search for aContent - // very fast in the embedded hash table. - // This would almost completely remove the lookup penalty for things - // like