From 498b17c6b61029c166b1dd52312ea83193e0b7fd Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Thu, 10 Feb 2000 07:04:09 +0000 Subject: [PATCH] Made sure we set the tree item before adding it to the parent. Then we also must notify the tree owner of the addition of the content shell after it has been added. This the bugs having to do with treeOwner showing up (27087, 2719, 25951). r=hyatt git-svn-id: svn://10.0.0.236/trunk@60298 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrameFrame.cpp | 37 +++++++++++-------- .../layout/html/document/src/nsFrameFrame.cpp | 37 +++++++++++-------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 5d04d100e39..bc7931bdabc 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -17,7 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): + * Travis Bogard */ #include "nsCOMPtr.h" #include "nsLeafFrame.h" @@ -27,6 +28,7 @@ #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" +#include "nsIDocShellTreeOwner.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" @@ -713,20 +715,10 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, if (nsnull != container) { nsCOMPtr parentAsNode(do_QueryInterface(container)); if (parentAsNode) { - parentAsNode->AddChild(docShellAsItem); - - // connect the container... - nsIWebShellContainer* outerContainer = nsnull; - container->QueryInterface(kIWebShellContainerIID, (void**) &outerContainer); - if (nsnull != outerContainer) { - mWebShell->SetContainer(outerContainer); - NS_RELEASE(outerContainer); - } - -#ifdef INCLUDE_XUL nsCOMPtr parentAsItem(do_QueryInterface(parentAsNode)); PRInt32 parentType; parentAsItem->GetItemType(&parentType); + nsIAtom* typeAtom = NS_NewAtom("type"); nsAutoString value, valuePiece; PRBool isContent; @@ -746,20 +738,34 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, if (isContent) { // The web shell's type is content. docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); - nsCOMPtr shellAsContainer(do_QueryInterface(mWebShell)); - shellAsContainer->ContentShellAdded(mWebShell, content); } else { // Inherit our type from our parent webshell. If it is // chrome, we'll be chrome. If it is content, we'll be // content. docShellAsItem->SetItemType(parentType); } + + parentAsNode->AddChild(docShellAsItem); + + if (isContent) { + nsCOMPtr parentTreeOwner; + parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner)); + if(parentTreeOwner) + parentTreeOwner->ContentShellAdded(docShellAsItem, + value.EqualsIgnoreCase("content-primary") ? PR_TRUE : PR_FALSE, + value.GetUnicode()); + } + // connect the container... + nsCOMPtr outerContainer(do_QueryInterface(container)); + if (outerContainer) + mWebShell->SetContainer(outerContainer); + // Make sure all shells have links back to the content element in the // nearest enclosing chrome shell. nsCOMPtr parentShell(do_QueryInterface(parentAsNode)); nsCOMPtr chromeEventHandler; - if (parentType == nsWebShellChrome) { + if (parentType == nsIDocShellTreeItem::typeChrome) { // Our parent shell is a chrome shell. It is therefore our nearest // enclosing chrome shell. chromeEventHandler = do_QueryInterface(mContent); @@ -773,7 +779,6 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, mWebShell->SetChromeEventHandler(chromeEventHandler); -#endif // INCLUDE_XUL nsCOMPtr parentPrefs; // connect the prefs parentShell->GetPrefs(getter_AddRefs(parentPrefs)); diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 5d04d100e39..bc7931bdabc 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -17,7 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): + * Travis Bogard */ #include "nsCOMPtr.h" #include "nsLeafFrame.h" @@ -27,6 +28,7 @@ #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" +#include "nsIDocShellTreeOwner.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" @@ -713,20 +715,10 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, if (nsnull != container) { nsCOMPtr parentAsNode(do_QueryInterface(container)); if (parentAsNode) { - parentAsNode->AddChild(docShellAsItem); - - // connect the container... - nsIWebShellContainer* outerContainer = nsnull; - container->QueryInterface(kIWebShellContainerIID, (void**) &outerContainer); - if (nsnull != outerContainer) { - mWebShell->SetContainer(outerContainer); - NS_RELEASE(outerContainer); - } - -#ifdef INCLUDE_XUL nsCOMPtr parentAsItem(do_QueryInterface(parentAsNode)); PRInt32 parentType; parentAsItem->GetItemType(&parentType); + nsIAtom* typeAtom = NS_NewAtom("type"); nsAutoString value, valuePiece; PRBool isContent; @@ -746,20 +738,34 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, if (isContent) { // The web shell's type is content. docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); - nsCOMPtr shellAsContainer(do_QueryInterface(mWebShell)); - shellAsContainer->ContentShellAdded(mWebShell, content); } else { // Inherit our type from our parent webshell. If it is // chrome, we'll be chrome. If it is content, we'll be // content. docShellAsItem->SetItemType(parentType); } + + parentAsNode->AddChild(docShellAsItem); + + if (isContent) { + nsCOMPtr parentTreeOwner; + parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner)); + if(parentTreeOwner) + parentTreeOwner->ContentShellAdded(docShellAsItem, + value.EqualsIgnoreCase("content-primary") ? PR_TRUE : PR_FALSE, + value.GetUnicode()); + } + // connect the container... + nsCOMPtr outerContainer(do_QueryInterface(container)); + if (outerContainer) + mWebShell->SetContainer(outerContainer); + // Make sure all shells have links back to the content element in the // nearest enclosing chrome shell. nsCOMPtr parentShell(do_QueryInterface(parentAsNode)); nsCOMPtr chromeEventHandler; - if (parentType == nsWebShellChrome) { + if (parentType == nsIDocShellTreeItem::typeChrome) { // Our parent shell is a chrome shell. It is therefore our nearest // enclosing chrome shell. chromeEventHandler = do_QueryInterface(mContent); @@ -773,7 +779,6 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, mWebShell->SetChromeEventHandler(chromeEventHandler); -#endif // INCLUDE_XUL nsCOMPtr parentPrefs; // connect the prefs parentShell->GetPrefs(getter_AddRefs(parentPrefs));