Renamed FindFrameWithContent() to GetPrimaryFrameFor()

This commit is contained in:
troy%netscape.com 1998-12-29 04:45:18 +00:00
parent 9b9408cc44
commit 583682a5c1
24 changed files with 162 additions and 79 deletions

View File

@ -1098,7 +1098,7 @@ nsGenericElement::RenderFrame()
nsIPresShell* shell; nsIPresShell* shell;
shell = mDocument->GetShellAt(i); shell = mDocument->GetShellAt(i);
nsIFrame* frame; nsIFrame* frame;
frame = shell->FindFrameWithContent(mContent); shell->GetPrimaryFrameFor(mContent, frame);
while (nsnull != frame) { while (nsnull != frame) {
nsIViewManager* vm; nsIViewManager* vm;
nsIView* view; nsIView* view;

View File

@ -276,7 +276,8 @@ nsHTMLFormElement::Submit()
if ((NS_OK == result) && doc) { if ((NS_OK == result) && doc) {
nsIPresShell *shell = doc->GetShellAt(0); nsIPresShell *shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(this); nsIFrame* frame;
shell->GetPrimaryFrameFor(this, frame);
if (frame) { if (frame) {
nsIFormManager* formMan = nsnull; nsIFormManager* formMan = nsnull;
nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan); nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan);
@ -309,7 +310,8 @@ nsHTMLFormElement::Reset()
if ((NS_OK == result) && doc) { if ((NS_OK == result) && doc) {
nsIPresShell *shell = doc->GetShellAt(0); nsIPresShell *shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(this); nsIFrame* frame;
shell->GetPrimaryFrameFor(this, frame);
if (frame) { if (frame) {
nsIFormManager* formMan = nsnull; nsIFormManager* formMan = nsnull;
nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan); nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan);

View File

@ -117,7 +117,8 @@ void TempList(nsIDOMHTMLTableElement* aTable) {
} }
nsIPresShell* shell = doc->GetShellAt(0); nsIPresShell* shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* rootFrame = shell->GetRootFrame(); nsIFrame* rootFrame;
shell->GetRootFrame(rootFrame);
if (nsnull != rootFrame) { if (nsnull != rootFrame) {
rootFrame->List(stdout, 0, nsnull); rootFrame->List(stdout, 0, nsnull);
} }

View File

@ -1941,7 +1941,8 @@ HTMLContentSink::ScrollToRef()
for (i = 0; i < ns; i++) { for (i = 0; i < ns; i++) {
nsIPresShell* shell = mDocument->GetShellAt(i); nsIPresShell* shell = mDocument->GetShellAt(i);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(mRefContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(mRefContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
nsIViewManager* vm = shell->GetViewManager(); nsIViewManager* vm = shell->GetViewManager();
if (nsnull != vm) { if (nsnull != vm) {

View File

@ -2207,7 +2207,9 @@ nsIFrame*
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent) nsIContent* aContent)
{ {
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent); // Get the primary frame associated with the content
nsIFrame* frame;
aPresShell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
// If the primary frame is a scroll frame, then get the scrolled frame. // If the primary frame is a scroll frame, then get the scrolled frame.
@ -2375,7 +2377,7 @@ FindPreviousSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) { for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) {
nsIContent* precedingContent; nsIContent* precedingContent;
aContainer->ChildAt(index, precedingContent); aContainer->ChildAt(index, precedingContent);
prevSibling = aPresShell->FindFrameWithContent(precedingContent); aPresShell->GetPrimaryFrameFor(precedingContent, prevSibling);
NS_RELEASE(precedingContent); NS_RELEASE(precedingContent);
if (nsnull != prevSibling) { if (nsnull != prevSibling) {
@ -2409,7 +2411,7 @@ FindNextSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer + 1; index < count; index++) { for (PRInt32 index = aIndexInContainer + 1; index < count; index++) {
nsIContent* nextContent; nsIContent* nextContent;
aContainer->ChildAt(index, nextContent); aContainer->ChildAt(index, nextContent);
nextSibling = aPresShell->FindFrameWithContent(nextContent); aPresShell->GetPrimaryFrameFor(nextContent, nextSibling);
NS_RELEASE(nextContent); NS_RELEASE(nextContent);
if (nsnull != nextSibling) { if (nsnull != nextSibling) {
@ -2454,7 +2456,7 @@ HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext,
// XXX This won't always be true if there's auto-generated before/after // XXX This won't always be true if there's auto-generated before/after
// content // content
isAppend = PR_TRUE; isAppend = PR_TRUE;
parentFrame = shell->FindFrameWithContent(aContainer); shell->GetPrimaryFrameFor(aContainer, parentFrame);
} else { } else {
// Use the prev sibling if we have it; otherwise use the next sibling. // Use the prev sibling if we have it; otherwise use the next sibling.
@ -2544,7 +2546,8 @@ HTMLStyleSheetImpl::ContentRemoved(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* childFrame = shell->FindFrameWithContent(aChild); nsIFrame* childFrame;
shell->GetPrimaryFrameFor(aChild, childFrame);
if (nsnull != childFrame) { if (nsnull != childFrame) {
// Get the parent frame. // Get the parent frame.
@ -2645,7 +2648,8 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
// Notify the first frame that maps the content. It will generate a reflow // Notify the first frame that maps the content. It will generate a reflow
// command // command
@ -2675,7 +2679,9 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
PRBool restyle = PR_FALSE; PRBool restyle = PR_FALSE;
@ -2755,7 +2761,8 @@ HTMLStyleSheetImpl::StyleRuleChanged(nsIPresContext* aPresContext,
PRInt32 aHint) PRInt32 aHint)
{ {
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->GetRootFrame(); nsIFrame* frame;
shell->GetRootFrame(frame);
PRBool reframe = PR_FALSE; PRBool reframe = PR_FALSE;
PRBool reflow = PR_FALSE; PRBool reflow = PR_FALSE;

View File

@ -99,15 +99,29 @@ public:
*/ */
NS_IMETHOD StyleChangeReflow() = 0; NS_IMETHOD StyleChangeReflow() = 0;
virtual nsIFrame* GetRootFrame() = 0; NS_IMETHOD GetRootFrame(nsIFrame*& aFrame) const = 0;
/** /**
* Returns the page sequence frame associated with the frame hierarchy. * Returns the page sequence frame associated with the frame hierarchy.
* Returns NULL if not a paginated view. * Returns NULL if not a paginated view.
*/ */
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) = 0; NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const = 0;
virtual nsIFrame* FindFrameWithContent(nsIContent* aContent) = 0; /**
* Returns the primary frame associated with the content object.
*
* The primary frame is the frame that is most closely associated with the
* content. A frame is more closely associated with the content that another
* frame if the one frame contains directly or indirectly the other frame (e.g.,
* when a frame is scrolled there is a scroll frame that contains the frame
* being scrolled). The primary frame is always the first-in-flow.
*
* In the case of absolutely positioned elements and floated elements,
* the primary frame is the frame that is out of the flow and not the
* placeholder frame.
*/
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame*& aPrimaryFrame) const = 0;
/** /**
* Get/Set the placeholder frame associated with the specified frame. * Get/Set the placeholder frame associated with the specified frame.

View File

@ -190,7 +190,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
nsIFrame* rootFrame; nsIFrame* rootFrame;
nsIStyleContext* rootStyleContext; nsIStyleContext* rootStyleContext;
rootFrame = mShell->GetRootFrame(); mShell->GetRootFrame(rootFrame);
if (nsnull != rootFrame) { if (nsnull != rootFrame) {
rootFrame->GetStyleContext(rootStyleContext); rootFrame->GetStyleContext(rootStyleContext);
rootStyleContext->RemapStyle(this); rootStyleContext->RemapStyle(this);

View File

@ -238,9 +238,9 @@ public:
NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight); NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight); NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD StyleChangeReflow(); NS_IMETHOD StyleChangeReflow();
virtual nsIFrame* GetRootFrame(); NS_IMETHOD GetRootFrame(nsIFrame*& aFrame) const;
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame); NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const;
virtual nsIFrame* FindFrameWithContent(nsIContent* aContent); NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame*& aPrimaryFrame) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame*& aPlaceholderFrame) const; nsIFrame*& aPlaceholderFrame) const;
NS_IMETHOD SetPlaceholderFrameFor(nsIFrame* aFrame, NS_IMETHOD SetPlaceholderFrameFor(nsIFrame* aFrame,
@ -751,14 +751,15 @@ PresShell::StyleChangeReflow()
return NS_OK; //XXX this needs to be real. MMP return NS_OK; //XXX this needs to be real. MMP
} }
nsIFrame* NS_IMETHODIMP
PresShell::GetRootFrame() PresShell::GetRootFrame(nsIFrame*& aFrame) const
{ {
return mRootFrame; aFrame = mRootFrame;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
PresShell::GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) PresShell::GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const
{ {
nsIFrame* child; nsIFrame* child;
nsIPageSequenceFrame* pageSequence; nsIPageSequenceFrame* pageSequence;
@ -1184,12 +1185,13 @@ FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent)
return nsnull; return nsnull;
} }
nsIFrame* NS_IMETHODIMP
PresShell::FindFrameWithContent(nsIContent* aContent) PresShell::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame*& aPrimaryFrame) const
{ {
// For the time being do a brute force depth-first search of // For the time being do a brute force depth-first search of
// the frame tree // the frame tree
return ::FindFrameWithContent(mRootFrame, aContent); aPrimaryFrame = ::FindFrameWithContent(mRootFrame, aContent);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1628,7 +1630,11 @@ PresShell::VerifyIncrementalReflow()
// Now that the document has been reflowed, use its frame tree to // Now that the document has been reflowed, use its frame tree to
// compare against our frame tree. // compare against our frame tree.
CompareTrees(GetRootFrame(), sh->GetRootFrame()); nsIFrame* root1;
nsIFrame* root2;
GetRootFrame(root1);
sh->GetRootFrame(root2);
CompareTrees(root1, root2);
NS_RELEASE(vm); NS_RELEASE(vm);
NS_RELEASE(cx); NS_RELEASE(cx);

View File

@ -99,15 +99,29 @@ public:
*/ */
NS_IMETHOD StyleChangeReflow() = 0; NS_IMETHOD StyleChangeReflow() = 0;
virtual nsIFrame* GetRootFrame() = 0; NS_IMETHOD GetRootFrame(nsIFrame*& aFrame) const = 0;
/** /**
* Returns the page sequence frame associated with the frame hierarchy. * Returns the page sequence frame associated with the frame hierarchy.
* Returns NULL if not a paginated view. * Returns NULL if not a paginated view.
*/ */
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) = 0; NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const = 0;
virtual nsIFrame* FindFrameWithContent(nsIContent* aContent) = 0; /**
* Returns the primary frame associated with the content object.
*
* The primary frame is the frame that is most closely associated with the
* content. A frame is more closely associated with the content that another
* frame if the one frame contains directly or indirectly the other frame (e.g.,
* when a frame is scrolled there is a scroll frame that contains the frame
* being scrolled). The primary frame is always the first-in-flow.
*
* In the case of absolutely positioned elements and floated elements,
* the primary frame is the frame that is out of the flow and not the
* placeholder frame.
*/
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame*& aPrimaryFrame) const = 0;
/** /**
* Get/Set the placeholder frame associated with the specified frame. * Get/Set the placeholder frame associated with the specified frame.

View File

@ -1098,7 +1098,7 @@ nsGenericElement::RenderFrame()
nsIPresShell* shell; nsIPresShell* shell;
shell = mDocument->GetShellAt(i); shell = mDocument->GetShellAt(i);
nsIFrame* frame; nsIFrame* frame;
frame = shell->FindFrameWithContent(mContent); shell->GetPrimaryFrameFor(mContent, frame);
while (nsnull != frame) { while (nsnull != frame) {
nsIViewManager* vm; nsIViewManager* vm;
nsIView* view; nsIView* view;

View File

@ -190,7 +190,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
nsIFrame* rootFrame; nsIFrame* rootFrame;
nsIStyleContext* rootStyleContext; nsIStyleContext* rootStyleContext;
rootFrame = mShell->GetRootFrame(); mShell->GetRootFrame(rootFrame);
if (nsnull != rootFrame) { if (nsnull != rootFrame) {
rootFrame->GetStyleContext(rootStyleContext); rootFrame->GetStyleContext(rootStyleContext);
rootStyleContext->RemapStyle(this); rootStyleContext->RemapStyle(this);

View File

@ -1888,8 +1888,10 @@ static void RefreshContentFrames(nsIPresContext& aPresContext,
//------------------------------------- //-------------------------------------
// Undraw all the current selected frames // Undraw all the current selected frames
// XXX Kludge for now // XXX Kludge for now
nsIPresShell * shell = aPresContext.GetShell(); nsIPresShell *shell = aPresContext.GetShell();
nsIFrame * rootFrame = shell->GetRootFrame(); nsIFrame *rootFrame;
shell->GetRootFrame(rootFrame);
PRBool foundStart = PR_FALSE; PRBool foundStart = PR_FALSE;
for (PRInt32 i=0;i<fMax;i++) { for (PRInt32 i=0;i<fMax;i++) {
@ -2102,8 +2104,9 @@ static void resetContentTrackers() {
static void RefreshFromContentTrackers(nsIPresContext& aPresContext) { static void RefreshFromContentTrackers(nsIPresContext& aPresContext) {
PRInt32 i; PRInt32 i;
nsIPresShell * shell = aPresContext.GetShell(); nsIPresShell *shell = aPresContext.GetShell();
nsIFrame * rootFrame = shell->GetRootFrame(); nsIFrame *rootFrame;
shell->GetRootFrame(rootFrame);
for (i=0;i<fTrackerRemoveListMax;i++) { for (i=0;i<fTrackerRemoveListMax;i++) {
RefreshAllContentFrames(rootFrame, fTrackerContentArrayRemoveList[i]); RefreshAllContentFrames(rootFrame, fTrackerContentArrayRemoveList[i]);
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(fTrackerContentArrayRemoveList[i])); //ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(fTrackerContentArrayRemoveList[i]));

View File

@ -144,7 +144,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext,
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsIPresShell* shell = aPresContext.GetShell(); nsIPresShell* shell = aPresContext.GetShell();
if (nsnull != shell) { if (nsnull != shell) {
NS_ASSERTION(shell->GetRootFrame() == root, "bad root frame"); nsIFrame* rootFrame;
shell->GetRootFrame(rootFrame);
NS_ASSERTION(rootFrame == root, "bad root frame");
NS_RELEASE(shell); NS_RELEASE(shell);
} }
#endif #endif

View File

@ -1888,8 +1888,10 @@ static void RefreshContentFrames(nsIPresContext& aPresContext,
//------------------------------------- //-------------------------------------
// Undraw all the current selected frames // Undraw all the current selected frames
// XXX Kludge for now // XXX Kludge for now
nsIPresShell * shell = aPresContext.GetShell(); nsIPresShell *shell = aPresContext.GetShell();
nsIFrame * rootFrame = shell->GetRootFrame(); nsIFrame *rootFrame;
shell->GetRootFrame(rootFrame);
PRBool foundStart = PR_FALSE; PRBool foundStart = PR_FALSE;
for (PRInt32 i=0;i<fMax;i++) { for (PRInt32 i=0;i<fMax;i++) {
@ -2102,8 +2104,9 @@ static void resetContentTrackers() {
static void RefreshFromContentTrackers(nsIPresContext& aPresContext) { static void RefreshFromContentTrackers(nsIPresContext& aPresContext) {
PRInt32 i; PRInt32 i;
nsIPresShell * shell = aPresContext.GetShell(); nsIPresShell *shell = aPresContext.GetShell();
nsIFrame * rootFrame = shell->GetRootFrame(); nsIFrame *rootFrame;
shell->GetRootFrame(rootFrame);
for (i=0;i<fTrackerRemoveListMax;i++) { for (i=0;i<fTrackerRemoveListMax;i++) {
RefreshAllContentFrames(rootFrame, fTrackerContentArrayRemoveList[i]); RefreshAllContentFrames(rootFrame, fTrackerContentArrayRemoveList[i]);
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(fTrackerContentArrayRemoveList[i])); //ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(fTrackerContentArrayRemoveList[i]));

View File

@ -144,7 +144,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext,
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsIPresShell* shell = aPresContext.GetShell(); nsIPresShell* shell = aPresContext.GetShell();
if (nsnull != shell) { if (nsnull != shell) {
NS_ASSERTION(shell->GetRootFrame() == root, "bad root frame"); nsIFrame* rootFrame;
shell->GetRootFrame(rootFrame);
NS_ASSERTION(rootFrame == root, "bad root frame");
NS_RELEASE(shell); NS_RELEASE(shell);
} }
#endif #endif

View File

@ -238,9 +238,9 @@ public:
NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight); NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight); NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD StyleChangeReflow(); NS_IMETHOD StyleChangeReflow();
virtual nsIFrame* GetRootFrame(); NS_IMETHOD GetRootFrame(nsIFrame*& aFrame) const;
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame); NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const;
virtual nsIFrame* FindFrameWithContent(nsIContent* aContent); NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame*& aPrimaryFrame) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame*& aPlaceholderFrame) const; nsIFrame*& aPlaceholderFrame) const;
NS_IMETHOD SetPlaceholderFrameFor(nsIFrame* aFrame, NS_IMETHOD SetPlaceholderFrameFor(nsIFrame* aFrame,
@ -751,14 +751,15 @@ PresShell::StyleChangeReflow()
return NS_OK; //XXX this needs to be real. MMP return NS_OK; //XXX this needs to be real. MMP
} }
nsIFrame* NS_IMETHODIMP
PresShell::GetRootFrame() PresShell::GetRootFrame(nsIFrame*& aFrame) const
{ {
return mRootFrame; aFrame = mRootFrame;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
PresShell::GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) PresShell::GetPageSequenceFrame(nsIPageSequenceFrame*& aPageSequenceFrame) const
{ {
nsIFrame* child; nsIFrame* child;
nsIPageSequenceFrame* pageSequence; nsIPageSequenceFrame* pageSequence;
@ -1184,12 +1185,13 @@ FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent)
return nsnull; return nsnull;
} }
nsIFrame* NS_IMETHODIMP
PresShell::FindFrameWithContent(nsIContent* aContent) PresShell::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame*& aPrimaryFrame) const
{ {
// For the time being do a brute force depth-first search of // For the time being do a brute force depth-first search of
// the frame tree // the frame tree
return ::FindFrameWithContent(mRootFrame, aContent); aPrimaryFrame = ::FindFrameWithContent(mRootFrame, aContent);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1628,7 +1630,11 @@ PresShell::VerifyIncrementalReflow()
// Now that the document has been reflowed, use its frame tree to // Now that the document has been reflowed, use its frame tree to
// compare against our frame tree. // compare against our frame tree.
CompareTrees(GetRootFrame(), sh->GetRootFrame()); nsIFrame* root1;
nsIFrame* root2;
GetRootFrame(root1);
sh->GetRootFrame(root2);
CompareTrees(root1, root2);
NS_RELEASE(vm); NS_RELEASE(vm);
NS_RELEASE(cx); NS_RELEASE(cx);

View File

@ -276,7 +276,8 @@ nsHTMLFormElement::Submit()
if ((NS_OK == result) && doc) { if ((NS_OK == result) && doc) {
nsIPresShell *shell = doc->GetShellAt(0); nsIPresShell *shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(this); nsIFrame* frame;
shell->GetPrimaryFrameFor(this, frame);
if (frame) { if (frame) {
nsIFormManager* formMan = nsnull; nsIFormManager* formMan = nsnull;
nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan); nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan);
@ -309,7 +310,8 @@ nsHTMLFormElement::Reset()
if ((NS_OK == result) && doc) { if ((NS_OK == result) && doc) {
nsIPresShell *shell = doc->GetShellAt(0); nsIPresShell *shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(this); nsIFrame* frame;
shell->GetPrimaryFrameFor(this, frame);
if (frame) { if (frame) {
nsIFormManager* formMan = nsnull; nsIFormManager* formMan = nsnull;
nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan); nsresult result = frame->QueryInterface(kIFormManagerIID, (void**)&formMan);

View File

@ -117,7 +117,8 @@ void TempList(nsIDOMHTMLTableElement* aTable) {
} }
nsIPresShell* shell = doc->GetShellAt(0); nsIPresShell* shell = doc->GetShellAt(0);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* rootFrame = shell->GetRootFrame(); nsIFrame* rootFrame;
shell->GetRootFrame(rootFrame);
if (nsnull != rootFrame) { if (nsnull != rootFrame) {
rootFrame->List(stdout, 0, nsnull); rootFrame->List(stdout, 0, nsnull);
} }

View File

@ -1941,7 +1941,8 @@ HTMLContentSink::ScrollToRef()
for (i = 0; i < ns; i++) { for (i = 0; i < ns; i++) {
nsIPresShell* shell = mDocument->GetShellAt(i); nsIPresShell* shell = mDocument->GetShellAt(i);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* frame = shell->FindFrameWithContent(mRefContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(mRefContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
nsIViewManager* vm = shell->GetViewManager(); nsIViewManager* vm = shell->GetViewManager();
if (nsnull != vm) { if (nsnull != vm) {

View File

@ -291,7 +291,8 @@ nsLabelFrame::FindForControl(nsIFormControlFrame*& aResultFrame)
value.GetStringValue(id); value.GetStringValue(id);
id.Trim(whitespace, PR_TRUE, PR_TRUE); id.Trim(whitespace, PR_TRUE, PR_TRUE);
if (id.Equals(forId)) { if (id.Equals(forId)) {
nsIFrame* frame = shell->FindFrameWithContent(htmlContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(htmlContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
nsIFormControlFrame* fcFrame = nsnull; nsIFormControlFrame* fcFrame = nsnull;
result = frame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); result = frame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);

View File

@ -2207,7 +2207,9 @@ nsIFrame*
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent) nsIContent* aContent)
{ {
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent); // Get the primary frame associated with the content
nsIFrame* frame;
aPresShell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
// If the primary frame is a scroll frame, then get the scrolled frame. // If the primary frame is a scroll frame, then get the scrolled frame.
@ -2375,7 +2377,7 @@ FindPreviousSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) { for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) {
nsIContent* precedingContent; nsIContent* precedingContent;
aContainer->ChildAt(index, precedingContent); aContainer->ChildAt(index, precedingContent);
prevSibling = aPresShell->FindFrameWithContent(precedingContent); aPresShell->GetPrimaryFrameFor(precedingContent, prevSibling);
NS_RELEASE(precedingContent); NS_RELEASE(precedingContent);
if (nsnull != prevSibling) { if (nsnull != prevSibling) {
@ -2409,7 +2411,7 @@ FindNextSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer + 1; index < count; index++) { for (PRInt32 index = aIndexInContainer + 1; index < count; index++) {
nsIContent* nextContent; nsIContent* nextContent;
aContainer->ChildAt(index, nextContent); aContainer->ChildAt(index, nextContent);
nextSibling = aPresShell->FindFrameWithContent(nextContent); aPresShell->GetPrimaryFrameFor(nextContent, nextSibling);
NS_RELEASE(nextContent); NS_RELEASE(nextContent);
if (nsnull != nextSibling) { if (nsnull != nextSibling) {
@ -2454,7 +2456,7 @@ HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext,
// XXX This won't always be true if there's auto-generated before/after // XXX This won't always be true if there's auto-generated before/after
// content // content
isAppend = PR_TRUE; isAppend = PR_TRUE;
parentFrame = shell->FindFrameWithContent(aContainer); shell->GetPrimaryFrameFor(aContainer, parentFrame);
} else { } else {
// Use the prev sibling if we have it; otherwise use the next sibling. // Use the prev sibling if we have it; otherwise use the next sibling.
@ -2544,7 +2546,8 @@ HTMLStyleSheetImpl::ContentRemoved(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* childFrame = shell->FindFrameWithContent(aChild); nsIFrame* childFrame;
shell->GetPrimaryFrameFor(aChild, childFrame);
if (nsnull != childFrame) { if (nsnull != childFrame) {
// Get the parent frame. // Get the parent frame.
@ -2645,7 +2648,8 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
// Notify the first frame that maps the content. It will generate a reflow // Notify the first frame that maps the content. It will generate a reflow
// command // command
@ -2675,7 +2679,9 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
PRBool restyle = PR_FALSE; PRBool restyle = PR_FALSE;
@ -2755,7 +2761,8 @@ HTMLStyleSheetImpl::StyleRuleChanged(nsIPresContext* aPresContext,
PRInt32 aHint) PRInt32 aHint)
{ {
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->GetRootFrame(); nsIFrame* frame;
shell->GetRootFrame(frame);
PRBool reframe = PR_FALSE; PRBool reframe = PR_FALSE;
PRBool reflow = PR_FALSE; PRBool reflow = PR_FALSE;

View File

@ -2207,7 +2207,9 @@ nsIFrame*
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext, HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent) nsIContent* aContent)
{ {
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent); // Get the primary frame associated with the content
nsIFrame* frame;
aPresShell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
// If the primary frame is a scroll frame, then get the scrolled frame. // If the primary frame is a scroll frame, then get the scrolled frame.
@ -2375,7 +2377,7 @@ FindPreviousSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) { for (PRInt32 index = aIndexInContainer - 1; index >= 0; index--) {
nsIContent* precedingContent; nsIContent* precedingContent;
aContainer->ChildAt(index, precedingContent); aContainer->ChildAt(index, precedingContent);
prevSibling = aPresShell->FindFrameWithContent(precedingContent); aPresShell->GetPrimaryFrameFor(precedingContent, prevSibling);
NS_RELEASE(precedingContent); NS_RELEASE(precedingContent);
if (nsnull != prevSibling) { if (nsnull != prevSibling) {
@ -2409,7 +2411,7 @@ FindNextSibling(nsIPresShell* aPresShell,
for (PRInt32 index = aIndexInContainer + 1; index < count; index++) { for (PRInt32 index = aIndexInContainer + 1; index < count; index++) {
nsIContent* nextContent; nsIContent* nextContent;
aContainer->ChildAt(index, nextContent); aContainer->ChildAt(index, nextContent);
nextSibling = aPresShell->FindFrameWithContent(nextContent); aPresShell->GetPrimaryFrameFor(nextContent, nextSibling);
NS_RELEASE(nextContent); NS_RELEASE(nextContent);
if (nsnull != nextSibling) { if (nsnull != nextSibling) {
@ -2454,7 +2456,7 @@ HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext,
// XXX This won't always be true if there's auto-generated before/after // XXX This won't always be true if there's auto-generated before/after
// content // content
isAppend = PR_TRUE; isAppend = PR_TRUE;
parentFrame = shell->FindFrameWithContent(aContainer); shell->GetPrimaryFrameFor(aContainer, parentFrame);
} else { } else {
// Use the prev sibling if we have it; otherwise use the next sibling. // Use the prev sibling if we have it; otherwise use the next sibling.
@ -2544,7 +2546,8 @@ HTMLStyleSheetImpl::ContentRemoved(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* childFrame = shell->FindFrameWithContent(aChild); nsIFrame* childFrame;
shell->GetPrimaryFrameFor(aChild, childFrame);
if (nsnull != childFrame) { if (nsnull != childFrame) {
// Get the parent frame. // Get the parent frame.
@ -2645,7 +2648,8 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Find the child frame // Find the child frame
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
// Notify the first frame that maps the content. It will generate a reflow // Notify the first frame that maps the content. It will generate a reflow
// command // command
@ -2675,7 +2679,9 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->FindFrameWithContent(aContent); nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, frame);
if (nsnull != frame) { if (nsnull != frame) {
PRBool restyle = PR_FALSE; PRBool restyle = PR_FALSE;
@ -2755,7 +2761,8 @@ HTMLStyleSheetImpl::StyleRuleChanged(nsIPresContext* aPresContext,
PRInt32 aHint) PRInt32 aHint)
{ {
nsIPresShell* shell = aPresContext->GetShell(); nsIPresShell* shell = aPresContext->GetShell();
nsIFrame* frame = shell->GetRootFrame(); nsIFrame* frame;
shell->GetRootFrame(frame);
PRBool reframe = PR_FALSE; PRBool reframe = PR_FALSE;
PRBool reflow = PR_FALSE; PRBool reflow = PR_FALSE;

View File

@ -2299,7 +2299,8 @@ DumpFramesRecurse(nsIWebShell* aWebShell, FILE* out, nsString *aFilterName)
fprintf(out, "webshell=%p \n", aWebShell); fprintf(out, "webshell=%p \n", aWebShell);
nsIPresShell* shell = GetPresShellFor(aWebShell); nsIPresShell* shell = GetPresShellFor(aWebShell);
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* root = shell->GetRootFrame(); nsIFrame* root;
shell->GetRootFrame(root);
if (nsnull != root) { if (nsnull != root) {
nsIListFilter *filter = nsIFrame::GetFilter(aFilterName); nsIListFilter *filter = nsIFrame::GetFilter(aFilterName);
root->List(out, 0, filter); root->List(out, 0, filter);
@ -2398,7 +2399,8 @@ nsBrowserWindow::DumpStyleContexts(FILE* out)
if (nsnull == styleSet) { if (nsnull == styleSet) {
fputs("null style set\n", out); fputs("null style set\n", out);
} else { } else {
nsIFrame* root = shell->GetRootFrame(); nsIFrame* root;
shell->GetRootFrame(root);
if (nsnull == root) { if (nsnull == root) {
fputs("null root frame\n", out); fputs("null root frame\n", out);
} else { } else {
@ -2471,7 +2473,7 @@ nsBrowserWindow::ShowFrameSize()
return; return;
} }
nsIFrame* root; nsIFrame* root;
root = shell->GetRootFrame(); shell->GetRootFrame(root);
if (nsnull != root) { if (nsnull != root) {
root->SizeOf(szh); root->SizeOf(szh);
PRUint32 totalSize; PRUint32 totalSize;

View File

@ -279,7 +279,8 @@ nsWebCrawler:: EndLoadURL(nsIWebShell* aShell,
if ((nsnull != mFilter) || (mOutputDir.Length() > 0)) { if ((nsnull != mFilter) || (mOutputDir.Length() > 0)) {
nsIPresShell* shell = GetPresShell(); nsIPresShell* shell = GetPresShell();
if (nsnull != shell) { if (nsnull != shell) {
nsIFrame* root = shell->GetRootFrame(); nsIFrame* root;
shell->GetRootFrame(root);
if (nsnull != root) { if (nsnull != root) {
nsIListFilter *filter = nsIFrame::GetFilter(mFilter); nsIListFilter *filter = nsIFrame::GetFilter(mFilter);
if (mOutputDir.Length() > 0) if (mOutputDir.Length() > 0)