Bug 235335. Make nsFrameManager a direct member of nsIPresShell. r+sr=bryner

This commit is contained in:
roc+%cs.cmu.edu 2004-03-06 04:46:11 +00:00
Родитель 4c855e9760
Коммит 3367d05d49
12 изменённых файлов: 284 добавлений и 172 удалений

Просмотреть файл

@ -44,6 +44,7 @@ nsCSSPropList.h \
nsCSSProperty.h \
nsCSSProps.h \
nsFrameManager.h \
nsFrameManagerBase.h \
nsHTMLAtomList.h \
nsHTMLAtoms.h \
nsHTMLValue.h \

Просмотреть файл

@ -37,18 +37,7 @@
#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;
struct CantRenderReplacedElementEvent;
#include "nsFrameManagerBase.h"
// Option flags for GetFrameProperty() member function
#define NS_IFRAME_MGR_REMOVE_PROP 0x0001
@ -62,12 +51,19 @@ struct CantRenderReplacedElementEvent;
* they're queued and processed later.
*/
class nsFrameManager
class nsFrameManager : public nsFrameManagerBase
{
public:
nsFrameManager() NS_HIDDEN;
~nsFrameManager() NS_HIDDEN;
void* operator new(size_t aSize, nsIPresShell* aHost) {
NS_ASSERTION(aSize == sizeof(nsFrameManager), "Unexpected subclass");
NS_ASSERTION(aSize == sizeof(nsFrameManagerBase),
"Superclass/subclass mismatch");
return aHost->FrameManager();
}
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
// Initialization
@ -279,11 +275,8 @@ public:
NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
#endif
struct PropertyList;
private:
class UndisplayedMap;
friend struct CantRenderReplacedElementEvent;
NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
@ -291,18 +284,6 @@ private:
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,

Просмотреть файл

@ -0,0 +1,75 @@
/* -*- 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 <pp@ludusdesign.com>
* Brian Ryner <bryner@brianryner.com>
*
* 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 _nsFrameManagerBase_h_
#define _nsFrameManagerBase_h_
#include "pldhash.h"
class nsIPresShell;
class nsStyleSet;
class nsIContent;
class nsPlaceholderFrame;
class nsIFrame;
class nsStyleContext;
class nsIAtom;
class nsStyleChangeList;
class nsILayoutHistoryState;
struct CantRenderReplacedElementEvent;
class nsFrameManagerBase
{
public:
// force a vtable entry
virtual ~nsFrameManagerBase() {}
struct PropertyList;
protected:
class UndisplayedMap;
// 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;
};
#endif

Просмотреть файл

@ -42,6 +42,7 @@ REQUIRES = xpcom \
shistory \
necko \
gfx \
content \
layout \
webshell \
widget \

Просмотреть файл

@ -212,7 +212,7 @@ public:
UndisplayedNode* mNext;
};
class nsFrameManager::UndisplayedMap {
class nsFrameManagerBase::UndisplayedMap {
public:
UndisplayedMap(PRUint32 aNumBuckets = 16) NS_HIDDEN;
~UndisplayedMap(void) NS_HIDDEN;
@ -1863,7 +1863,7 @@ nsFrameManager::DestroyPropertyList(nsIPresContext* aPresContext)
}
}
nsFrameManager::PropertyList*
nsFrameManagerBase::PropertyList*
nsFrameManager::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
@ -1990,9 +1990,9 @@ nsFrameManager::RemoveFrameProperty(const nsIFrame* aFrame,
MOZ_DECL_CTOR_COUNTER(UndisplayedMap)
nsFrameManager::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
nsFrameManagerBase::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
{
MOZ_COUNT_CTOR(nsFrameManager::UndisplayedMap);
MOZ_COUNT_CTOR(nsFrameManagerBase::UndisplayedMap);
mTable = PL_NewHashTable(aNumBuckets, (PLHashFunction)HashKey,
(PLHashComparator)CompareKeys,
(PLHashComparator)nsnull,
@ -2000,15 +2000,15 @@ nsFrameManager::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
mLastLookup = nsnull;
}
nsFrameManager::UndisplayedMap::~UndisplayedMap(void)
nsFrameManagerBase::UndisplayedMap::~UndisplayedMap(void)
{
MOZ_COUNT_DTOR(nsFrameManager::UndisplayedMap);
MOZ_COUNT_DTOR(nsFrameManagerBase::UndisplayedMap);
Clear();
PL_HashTableDestroy(mTable);
}
PLHashEntry**
nsFrameManager::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
{
if (mLastLookup && (aParentContent == (*mLastLookup)->key)) {
return mLastLookup;
@ -2022,7 +2022,7 @@ nsFrameManager::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
}
UndisplayedNode*
nsFrameManager::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
if (*entry) {
@ -2032,8 +2032,8 @@ nsFrameManager::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
}
void
nsFrameManager::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
if (*entry) {
@ -2059,9 +2059,9 @@ nsFrameManager::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
}
nsresult
nsFrameManager::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
nsIContent* aChild,
nsStyleContext* aStyle)
nsFrameManagerBase::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
nsIContent* aChild,
nsStyleContext* aStyle)
{
UndisplayedNode* node = new UndisplayedNode(aChild, aStyle);
if (! node) {
@ -2073,8 +2073,8 @@ nsFrameManager::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
}
void
nsFrameManager::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
UndisplayedNode* aNode)
nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
UndisplayedNode* aNode)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
NS_ASSERTION(*entry, "content not in map");
@ -2105,7 +2105,7 @@ nsFrameManager::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
}
void
nsFrameManager::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
NS_ASSERTION(entry, "content not in map");
@ -2128,7 +2128,7 @@ RemoveUndisplayedEntry(PLHashEntry* he, PRIntn i, void* arg)
}
void
nsFrameManager::UndisplayedMap::Clear(void)
nsFrameManagerBase::UndisplayedMap::Clear(void)
{
mLastLookup = nsnull;
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
@ -2136,15 +2136,15 @@ nsFrameManager::UndisplayedMap::Clear(void)
//----------------------------------------------------------------------
nsFrameManager::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
nsFrameManagerBase::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mNext(nsnull)
{
PL_DHashTableInit(&mFrameValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsFrameManager::PropertyList::~PropertyList()
nsFrameManagerBase::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mFrameValueMap);
}
@ -2153,8 +2153,8 @@ PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsFrameManager::PropertyList *propList =
NS_STATIC_CAST(nsFrameManager::PropertyList*, table->data);
nsFrameManagerBase::PropertyList *propList =
NS_STATIC_CAST(nsFrameManagerBase::PropertyList*, table->data);
nsIPresContext *presContext = NS_STATIC_CAST(nsIPresContext*, arg);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
@ -2164,7 +2164,7 @@ DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
void
nsFrameManager::PropertyList::Destroy(nsIPresContext* aPresContext)
nsFrameManagerBase::PropertyList::Destroy(nsIPresContext* aPresContext)
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
@ -2173,8 +2173,8 @@ nsFrameManager::PropertyList::Destroy(nsIPresContext* aPresContext)
}
PRBool
nsFrameManager::PropertyList::RemovePropertyForFrame(nsIPresContext* aPresContext,
const nsIFrame* aFrame)
nsFrameManagerBase::PropertyList::RemovePropertyForFrame(nsIPresContext* aPresContext,
const nsIFrame* aFrame)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mFrameValueMap, aFrame, PL_DHASH_LOOKUP));

Просмотреть файл

@ -37,18 +37,7 @@
#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;
struct CantRenderReplacedElementEvent;
#include "nsFrameManagerBase.h"
// Option flags for GetFrameProperty() member function
#define NS_IFRAME_MGR_REMOVE_PROP 0x0001
@ -62,12 +51,19 @@ struct CantRenderReplacedElementEvent;
* they're queued and processed later.
*/
class nsFrameManager
class nsFrameManager : public nsFrameManagerBase
{
public:
nsFrameManager() NS_HIDDEN;
~nsFrameManager() NS_HIDDEN;
void* operator new(size_t aSize, nsIPresShell* aHost) {
NS_ASSERTION(aSize == sizeof(nsFrameManager), "Unexpected subclass");
NS_ASSERTION(aSize == sizeof(nsFrameManagerBase),
"Superclass/subclass mismatch");
return aHost->FrameManager();
}
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
// Initialization
@ -279,11 +275,8 @@ public:
NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
#endif
struct PropertyList;
private:
class UndisplayedMap;
friend struct CantRenderReplacedElementEvent;
NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
@ -291,18 +284,6 @@ private:
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,

Просмотреть файл

@ -0,0 +1,75 @@
/* -*- 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 <pp@ludusdesign.com>
* Brian Ryner <bryner@brianryner.com>
*
* 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 _nsFrameManagerBase_h_
#define _nsFrameManagerBase_h_
#include "pldhash.h"
class nsIPresShell;
class nsStyleSet;
class nsIContent;
class nsPlaceholderFrame;
class nsIFrame;
class nsStyleContext;
class nsIAtom;
class nsStyleChangeList;
class nsILayoutHistoryState;
struct CantRenderReplacedElementEvent;
class nsFrameManagerBase
{
public:
// force a vtable entry
virtual ~nsFrameManagerBase() {}
struct PropertyList;
protected:
class UndisplayedMap;
// 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;
};
#endif

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsReflowType.h"
#include "nsCompatibility.h"
#include "nsCOMArray.h"
#include "nsFrameManagerBase.h"
#include <stdio.h> // for FILE definition
class nsIAtom;
@ -164,7 +165,10 @@ public:
return mFrameConstructor;
}
nsFrameManager* FrameManager() { return mFrameManager; }
nsFrameManager* FrameManager() const {
return NS_REINTERPRET_CAST(nsFrameManager*,
&NS_CONST_CAST(nsIPresShell*, this)->mFrameManager);
}
#endif
@ -658,7 +662,7 @@ protected:
nsStyleSet* mStyleSet; // [OWNS]
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
nsFrameManager* mFrameManager; // [OWNS]
nsFrameManagerBase mFrameManager; // [OWNS]
};
/**

Просмотреть файл

@ -1445,7 +1445,7 @@ VerifyStyleTree(nsIPresContext* aPresContext, nsFrameManager* aFrameManager)
aFrameManager->DebugVerifyStyleTree(rootFrame);
}
}
#define VERIFY_STYLE_TREE VerifyStyleTree(mPresContext, mFrameManager)
#define VERIFY_STYLE_TREE VerifyStyleTree(mPresContext, FrameManager())
#else
#define VERIFY_STYLE_TREE
#endif
@ -1574,6 +1574,8 @@ PresShell::PresShell():
#endif
mSelectionFlags = nsISelectionDisplay::DISPLAY_TEXT | nsISelectionDisplay::DISPLAY_IMAGES;
mIsThemeSupportDisabled = PR_FALSE;
new (this) nsFrameManager();
}
NS_IMPL_ADDREF(PresShell)
@ -1639,7 +1641,6 @@ PresShell::~PresShell()
mLastCallbackEventRequest == nsnull,
"post-reflow queues not empty. This means we're leaking");
delete mFrameManager;
delete mStyleSet;
delete mFrameConstructor;
@ -1710,11 +1711,7 @@ PresShell::Init(nsIDocument* aDocument,
return result;
// Create and initialize the frame manager
mFrameManager = new nsFrameManager();
if (!mFrameManager) {
return NS_ERROR_OUT_OF_MEMORY;
}
result = mFrameManager->Init(this, mStyleSet);
result = FrameManager()->Init(this, mStyleSet);
NS_ENSURE_SUCCESS(result, result);
result = mSelection->Init((nsIFocusTracker *) this, nsnull);
@ -1875,9 +1872,7 @@ PresShell::Destroy()
}
// Destroy the frame manager. This will destroy the frame hierarchy
if (mFrameManager) {
mFrameManager->Destroy();
}
FrameManager()->Destroy();
// Let the style set do its cleanup.
mStyleSet->Shutdown(mPresContext);
@ -2752,7 +2747,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull;
// Get the root frame from the frame manager
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (root) {
MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n",
@ -2765,7 +2760,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
// precursors to the root content object's frame
mFrameConstructor->ConstructRootFrame(this, mPresContext,
root, rootFrame);
mFrameManager->SetRootFrame(rootFrame);
FrameManager()->SetRootFrame(rootFrame);
}
// Have the style sheet processor construct frame for the root
@ -2914,7 +2909,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
// If we don't have a root frame yet, that means we haven't had our initial
// reflow...
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
// Kick off a top-down reflow
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
@ -3073,7 +3068,7 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
CancelReflowCommandInternal(aFrame, nsnull);
// Notify the frame manager
mFrameManager->NotifyDestroyingFrame(aFrame);
FrameManager()->NotifyDestroyingFrame(aFrame);
}
return NS_OK;
@ -3429,7 +3424,7 @@ PresShell::StyleChangeReflow()
WillCauseReflow();
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
// Kick off a top-down reflow
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
@ -3498,7 +3493,7 @@ PresShell::StyleChangeReflow()
NS_IMETHODIMP
PresShell::GetRootFrame(nsIFrame** aResult) const
{
*aResult = mFrameManager->GetRootFrame();
*aResult = FrameManager()->GetRootFrame();
return NS_OK;
}
@ -3513,7 +3508,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
nsIPageSequenceFrame* pageSequence = nsnull;
// The page sequence frame is the child of the rootFrame
nsIFrame *rootFrame = mFrameManager->GetRootFrame();
nsIFrame *rootFrame = FrameManager()->GetRootFrame();
nsIFrame* child = rootFrame->GetFirstChild(nsnull);
if (nsnull != child) {
@ -3586,7 +3581,7 @@ PresShell::EndLoad(nsIDocument *aDocument)
{
// Restore frame state for the root scroll frame
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (!container)
return;
@ -3602,7 +3597,7 @@ PresShell::EndLoad(nsIDocument *aDocument)
nsIFrame* scrollFrame = nsnull;
GetRootScrollFrame(mPresContext, rootFrame, &scrollFrame);
if (scrollFrame) {
mFrameManager->RestoreFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState);
FrameManager()->RestoreFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState);
}
}
@ -3893,7 +3888,7 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
NS_IMETHODIMP
PresShell::CantRenderReplacedElement(nsIFrame* aFrame)
{
return mFrameManager->CantRenderReplacedElement(aFrame);
return FrameManager()->CantRenderReplacedElement(aFrame);
}
NS_IMETHODIMP
@ -4617,7 +4612,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa
NS_IF_ADDREF(*aState);
// Capture frame state for the entire frame hierarchy
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame) return NS_OK;
// Capture frame state for the root scroll frame
// Don't capture state when first creating doc element heirarchy
@ -4627,12 +4622,12 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa
nsIFrame* scrollFrame = nsnull;
GetRootScrollFrame(mPresContext, rootFrame, &scrollFrame);
if (scrollFrame) {
mFrameManager->CaptureFrameStateFor(scrollFrame, historyState,
FrameManager()->CaptureFrameStateFor(scrollFrame, historyState,
nsIStatefulFrame::eDocumentScrollState);
}
}
mFrameManager->CaptureFrameState(rootFrame, historyState);
FrameManager()->CaptureFrameState(rootFrame, historyState);
return NS_OK;
}
@ -4820,7 +4815,7 @@ PresShell::UnsuppressAndInvalidate()
}
mPaintingSuppressed = PR_FALSE;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
nsRect rect = rootFrame->GetRect();
if (!rect.IsEmpty()) {
@ -5296,12 +5291,12 @@ PresShell::ReconstructStyleData()
{
mStylesHaveChanged = PR_FALSE;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame)
return NS_OK;
nsStyleChangeList changeList;
mFrameManager->ComputeStyleChangeFor(rootFrame, &changeList,
FrameManager()->ComputeStyleChangeFor(rootFrame, &changeList,
NS_STYLE_HINT_NONE);
mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext);
@ -5377,7 +5372,7 @@ NS_IMETHODIMP
PresShell::GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aResult) const
{
*aResult = mFrameManager->GetPrimaryFrameFor(aContent);
*aResult = FrameManager()->GetPrimaryFrameFor(aContent);
return NS_OK;
}
@ -5404,7 +5399,7 @@ NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const
{
*aResult = mFrameManager->GetPlaceholderFrameFor(aFrame);
*aResult = FrameManager()->GetPlaceholderFrameFor(aFrame);
return NS_OK;
}
@ -5443,7 +5438,7 @@ NS_IMETHODIMP
PresShell::BidiStyleChangeReflow()
{
// Have the root frame's style context remap its style
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
mStyleSet->ClearStyleData(mPresContext);
ReconstructFrames();
@ -6278,7 +6273,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
if (0 != mReflowCommands.Count()) {
nsHTMLReflowMetrics desiredSize(nsnull);
nsIRenderingContext* rcx;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
nsSize maxSize = rootFrame->GetSize();
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
@ -7028,7 +7023,7 @@ PresShell::VerifyIncrementalReflow()
// Now that the document has been reflowed, use its frame tree to
// compare against our frame tree.
nsIFrame* root1 = mFrameManager->GetRootFrame();
nsIFrame* root1 = FrameManager()->GetRootFrame();
nsIFrame* root2;
sh->GetRootFrame(&root2);
PRBool ok = CompareTrees(mPresContext, root1, cx, root2);

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsReflowType.h"
#include "nsCompatibility.h"
#include "nsCOMArray.h"
#include "nsFrameManagerBase.h"
#include <stdio.h> // for FILE definition
class nsIAtom;
@ -164,7 +165,10 @@ public:
return mFrameConstructor;
}
nsFrameManager* FrameManager() { return mFrameManager; }
nsFrameManager* FrameManager() const {
return NS_REINTERPRET_CAST(nsFrameManager*,
&NS_CONST_CAST(nsIPresShell*, this)->mFrameManager);
}
#endif
@ -658,7 +662,7 @@ protected:
nsStyleSet* mStyleSet; // [OWNS]
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
nsFrameManager* mFrameManager; // [OWNS]
nsFrameManagerBase mFrameManager; // [OWNS]
};
/**

Просмотреть файл

@ -212,7 +212,7 @@ public:
UndisplayedNode* mNext;
};
class nsFrameManager::UndisplayedMap {
class nsFrameManagerBase::UndisplayedMap {
public:
UndisplayedMap(PRUint32 aNumBuckets = 16) NS_HIDDEN;
~UndisplayedMap(void) NS_HIDDEN;
@ -1863,7 +1863,7 @@ nsFrameManager::DestroyPropertyList(nsIPresContext* aPresContext)
}
}
nsFrameManager::PropertyList*
nsFrameManagerBase::PropertyList*
nsFrameManager::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
@ -1990,9 +1990,9 @@ nsFrameManager::RemoveFrameProperty(const nsIFrame* aFrame,
MOZ_DECL_CTOR_COUNTER(UndisplayedMap)
nsFrameManager::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
nsFrameManagerBase::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
{
MOZ_COUNT_CTOR(nsFrameManager::UndisplayedMap);
MOZ_COUNT_CTOR(nsFrameManagerBase::UndisplayedMap);
mTable = PL_NewHashTable(aNumBuckets, (PLHashFunction)HashKey,
(PLHashComparator)CompareKeys,
(PLHashComparator)nsnull,
@ -2000,15 +2000,15 @@ nsFrameManager::UndisplayedMap::UndisplayedMap(PRUint32 aNumBuckets)
mLastLookup = nsnull;
}
nsFrameManager::UndisplayedMap::~UndisplayedMap(void)
nsFrameManagerBase::UndisplayedMap::~UndisplayedMap(void)
{
MOZ_COUNT_DTOR(nsFrameManager::UndisplayedMap);
MOZ_COUNT_DTOR(nsFrameManagerBase::UndisplayedMap);
Clear();
PL_HashTableDestroy(mTable);
}
PLHashEntry**
nsFrameManager::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
{
if (mLastLookup && (aParentContent == (*mLastLookup)->key)) {
return mLastLookup;
@ -2022,7 +2022,7 @@ nsFrameManager::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
}
UndisplayedNode*
nsFrameManager::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
if (*entry) {
@ -2032,8 +2032,8 @@ nsFrameManager::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
}
void
nsFrameManager::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
if (*entry) {
@ -2059,9 +2059,9 @@ nsFrameManager::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
}
nsresult
nsFrameManager::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
nsIContent* aChild,
nsStyleContext* aStyle)
nsFrameManagerBase::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
nsIContent* aChild,
nsStyleContext* aStyle)
{
UndisplayedNode* node = new UndisplayedNode(aChild, aStyle);
if (! node) {
@ -2073,8 +2073,8 @@ nsFrameManager::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
}
void
nsFrameManager::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
UndisplayedNode* aNode)
nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
UndisplayedNode* aNode)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
NS_ASSERTION(*entry, "content not in map");
@ -2105,7 +2105,7 @@ nsFrameManager::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
}
void
nsFrameManager::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
{
PLHashEntry** entry = GetEntryFor(aParentContent);
NS_ASSERTION(entry, "content not in map");
@ -2128,7 +2128,7 @@ RemoveUndisplayedEntry(PLHashEntry* he, PRIntn i, void* arg)
}
void
nsFrameManager::UndisplayedMap::Clear(void)
nsFrameManagerBase::UndisplayedMap::Clear(void)
{
mLastLookup = nsnull;
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
@ -2136,15 +2136,15 @@ nsFrameManager::UndisplayedMap::Clear(void)
//----------------------------------------------------------------------
nsFrameManager::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
nsFrameManagerBase::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mNext(nsnull)
{
PL_DHashTableInit(&mFrameValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsFrameManager::PropertyList::~PropertyList()
nsFrameManagerBase::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mFrameValueMap);
}
@ -2153,8 +2153,8 @@ PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsFrameManager::PropertyList *propList =
NS_STATIC_CAST(nsFrameManager::PropertyList*, table->data);
nsFrameManagerBase::PropertyList *propList =
NS_STATIC_CAST(nsFrameManagerBase::PropertyList*, table->data);
nsIPresContext *presContext = NS_STATIC_CAST(nsIPresContext*, arg);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
@ -2164,7 +2164,7 @@ DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
void
nsFrameManager::PropertyList::Destroy(nsIPresContext* aPresContext)
nsFrameManagerBase::PropertyList::Destroy(nsIPresContext* aPresContext)
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
@ -2173,8 +2173,8 @@ nsFrameManager::PropertyList::Destroy(nsIPresContext* aPresContext)
}
PRBool
nsFrameManager::PropertyList::RemovePropertyForFrame(nsIPresContext* aPresContext,
const nsIFrame* aFrame)
nsFrameManagerBase::PropertyList::RemovePropertyForFrame(nsIPresContext* aPresContext,
const nsIFrame* aFrame)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mFrameValueMap, aFrame, PL_DHASH_LOOKUP));

Просмотреть файл

@ -1445,7 +1445,7 @@ VerifyStyleTree(nsIPresContext* aPresContext, nsFrameManager* aFrameManager)
aFrameManager->DebugVerifyStyleTree(rootFrame);
}
}
#define VERIFY_STYLE_TREE VerifyStyleTree(mPresContext, mFrameManager)
#define VERIFY_STYLE_TREE VerifyStyleTree(mPresContext, FrameManager())
#else
#define VERIFY_STYLE_TREE
#endif
@ -1574,6 +1574,8 @@ PresShell::PresShell():
#endif
mSelectionFlags = nsISelectionDisplay::DISPLAY_TEXT | nsISelectionDisplay::DISPLAY_IMAGES;
mIsThemeSupportDisabled = PR_FALSE;
new (this) nsFrameManager();
}
NS_IMPL_ADDREF(PresShell)
@ -1639,7 +1641,6 @@ PresShell::~PresShell()
mLastCallbackEventRequest == nsnull,
"post-reflow queues not empty. This means we're leaking");
delete mFrameManager;
delete mStyleSet;
delete mFrameConstructor;
@ -1710,11 +1711,7 @@ PresShell::Init(nsIDocument* aDocument,
return result;
// Create and initialize the frame manager
mFrameManager = new nsFrameManager();
if (!mFrameManager) {
return NS_ERROR_OUT_OF_MEMORY;
}
result = mFrameManager->Init(this, mStyleSet);
result = FrameManager()->Init(this, mStyleSet);
NS_ENSURE_SUCCESS(result, result);
result = mSelection->Init((nsIFocusTracker *) this, nsnull);
@ -1875,9 +1872,7 @@ PresShell::Destroy()
}
// Destroy the frame manager. This will destroy the frame hierarchy
if (mFrameManager) {
mFrameManager->Destroy();
}
FrameManager()->Destroy();
// Let the style set do its cleanup.
mStyleSet->Shutdown(mPresContext);
@ -2752,7 +2747,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull;
// Get the root frame from the frame manager
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (root) {
MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n",
@ -2765,7 +2760,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
// precursors to the root content object's frame
mFrameConstructor->ConstructRootFrame(this, mPresContext,
root, rootFrame);
mFrameManager->SetRootFrame(rootFrame);
FrameManager()->SetRootFrame(rootFrame);
}
// Have the style sheet processor construct frame for the root
@ -2914,7 +2909,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
// If we don't have a root frame yet, that means we haven't had our initial
// reflow...
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
// Kick off a top-down reflow
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
@ -3073,7 +3068,7 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
CancelReflowCommandInternal(aFrame, nsnull);
// Notify the frame manager
mFrameManager->NotifyDestroyingFrame(aFrame);
FrameManager()->NotifyDestroyingFrame(aFrame);
}
return NS_OK;
@ -3429,7 +3424,7 @@ PresShell::StyleChangeReflow()
WillCauseReflow();
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
// Kick off a top-down reflow
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
@ -3498,7 +3493,7 @@ PresShell::StyleChangeReflow()
NS_IMETHODIMP
PresShell::GetRootFrame(nsIFrame** aResult) const
{
*aResult = mFrameManager->GetRootFrame();
*aResult = FrameManager()->GetRootFrame();
return NS_OK;
}
@ -3513,7 +3508,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
nsIPageSequenceFrame* pageSequence = nsnull;
// The page sequence frame is the child of the rootFrame
nsIFrame *rootFrame = mFrameManager->GetRootFrame();
nsIFrame *rootFrame = FrameManager()->GetRootFrame();
nsIFrame* child = rootFrame->GetFirstChild(nsnull);
if (nsnull != child) {
@ -3586,7 +3581,7 @@ PresShell::EndLoad(nsIDocument *aDocument)
{
// Restore frame state for the root scroll frame
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (!container)
return;
@ -3602,7 +3597,7 @@ PresShell::EndLoad(nsIDocument *aDocument)
nsIFrame* scrollFrame = nsnull;
GetRootScrollFrame(mPresContext, rootFrame, &scrollFrame);
if (scrollFrame) {
mFrameManager->RestoreFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState);
FrameManager()->RestoreFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState);
}
}
@ -3893,7 +3888,7 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
NS_IMETHODIMP
PresShell::CantRenderReplacedElement(nsIFrame* aFrame)
{
return mFrameManager->CantRenderReplacedElement(aFrame);
return FrameManager()->CantRenderReplacedElement(aFrame);
}
NS_IMETHODIMP
@ -4617,7 +4612,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa
NS_IF_ADDREF(*aState);
// Capture frame state for the entire frame hierarchy
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame) return NS_OK;
// Capture frame state for the root scroll frame
// Don't capture state when first creating doc element heirarchy
@ -4627,12 +4622,12 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa
nsIFrame* scrollFrame = nsnull;
GetRootScrollFrame(mPresContext, rootFrame, &scrollFrame);
if (scrollFrame) {
mFrameManager->CaptureFrameStateFor(scrollFrame, historyState,
FrameManager()->CaptureFrameStateFor(scrollFrame, historyState,
nsIStatefulFrame::eDocumentScrollState);
}
}
mFrameManager->CaptureFrameState(rootFrame, historyState);
FrameManager()->CaptureFrameState(rootFrame, historyState);
return NS_OK;
}
@ -4820,7 +4815,7 @@ PresShell::UnsuppressAndInvalidate()
}
mPaintingSuppressed = PR_FALSE;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
nsRect rect = rootFrame->GetRect();
if (!rect.IsEmpty()) {
@ -5296,12 +5291,12 @@ PresShell::ReconstructStyleData()
{
mStylesHaveChanged = PR_FALSE;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame)
return NS_OK;
nsStyleChangeList changeList;
mFrameManager->ComputeStyleChangeFor(rootFrame, &changeList,
FrameManager()->ComputeStyleChangeFor(rootFrame, &changeList,
NS_STYLE_HINT_NONE);
mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext);
@ -5377,7 +5372,7 @@ NS_IMETHODIMP
PresShell::GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aResult) const
{
*aResult = mFrameManager->GetPrimaryFrameFor(aContent);
*aResult = FrameManager()->GetPrimaryFrameFor(aContent);
return NS_OK;
}
@ -5404,7 +5399,7 @@ NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const
{
*aResult = mFrameManager->GetPlaceholderFrameFor(aFrame);
*aResult = FrameManager()->GetPlaceholderFrameFor(aFrame);
return NS_OK;
}
@ -5443,7 +5438,7 @@ NS_IMETHODIMP
PresShell::BidiStyleChangeReflow()
{
// Have the root frame's style context remap its style
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (rootFrame) {
mStyleSet->ClearStyleData(mPresContext);
ReconstructFrames();
@ -6278,7 +6273,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
if (0 != mReflowCommands.Count()) {
nsHTMLReflowMetrics desiredSize(nsnull);
nsIRenderingContext* rcx;
nsIFrame* rootFrame = mFrameManager->GetRootFrame();
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
nsSize maxSize = rootFrame->GetSize();
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
@ -7028,7 +7023,7 @@ PresShell::VerifyIncrementalReflow()
// Now that the document has been reflowed, use its frame tree to
// compare against our frame tree.
nsIFrame* root1 = mFrameManager->GetRootFrame();
nsIFrame* root1 = FrameManager()->GetRootFrame();
nsIFrame* root2;
sh->GetRootFrame(&root2);
PRBool ok = CompareTrees(mPresContext, root1, cx, root2);