зеркало из https://github.com/mozilla/pjs.git
Implemented FindItemWithName and ContentShellAdded. Changed FindNamedBrowserChrome to deal with nsIWebBrowser instead of nsIWebBrowserChrome and changed the name to FindNamedBrowser. Changed FindNamedBrowser and GetNamedBrowser to return the type instead of having it as an out parameter. This is cleaner for JS.
This commit is contained in:
Родитель
185eefdef5
Коммит
7d83f1db2c
|
@ -30,6 +30,8 @@
|
||||||
#include "nsHTMLReflowState.h"
|
#include "nsHTMLReflowState.h"
|
||||||
|
|
||||||
// Interfaces needed to be included
|
// Interfaces needed to be included
|
||||||
|
#include "nsIDOMDocument.h"
|
||||||
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
|
|
||||||
// CIDs
|
// CIDs
|
||||||
|
@ -88,69 +90,42 @@ NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
|
||||||
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
|
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aFoundItem);
|
NS_ENSURE_ARG_POINTER(aFoundItem);
|
||||||
|
*aFoundItem = nsnull;
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
nsAutoString name(aName);
|
||||||
|
|
||||||
//XXXTAB
|
/* Special Cases */
|
||||||
/* *aFoundItem = nsnull;
|
|
||||||
|
|
||||||
nsAutoString name(aName);
|
|
||||||
|
|
||||||
PRBool fIs_Content = PR_FALSE;
|
|
||||||
|
|
||||||
/* Special Cases */ /*
|
|
||||||
if(name.Length() == 0)
|
if(name.Length() == 0)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_blank"))
|
if(name.EqualsIgnoreCase("_blank"))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_content"))
|
if(name.EqualsIgnoreCase("_content"))
|
||||||
{
|
{
|
||||||
fIs_Content = PR_TRUE;
|
*aFoundItem = mWebBrowser->mDocShellAsItem;
|
||||||
mXULWindow->GetPrimaryContentShell(aFoundItem);
|
NS_IF_ADDREF(*aFoundItem);
|
||||||
if(*aFoundItem)
|
return NS_OK;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
if(mTreeOwner)
|
||||||
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
return mTreeOwner->FindItemWithName(aName, aRequestor, aFoundItem);
|
||||||
|
|
||||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
NS_ENSURE_TRUE(mWebBrowserChrome, NS_ERROR_FAILURE);
|
||||||
NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nsnull,
|
|
||||||
getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
PRBool more;
|
|
||||||
|
|
||||||
windowEnumerator->HasMoreElements(&more);
|
|
||||||
while(more)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsISupports> nextWindow = nsnull;
|
|
||||||
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
|
|
||||||
nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
|
|
||||||
NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
|
nsCOMPtr<nsIWebBrowser> foundWebBrowser;
|
||||||
xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem));
|
NS_ENSURE_SUCCESS(mWebBrowserChrome->FindNamedBrowser(aName,
|
||||||
|
getter_AddRefs(foundWebBrowser)), NS_ERROR_FAILURE);
|
||||||
|
|
||||||
if(shellAsTreeItem)
|
if(!foundWebBrowser)
|
||||||
{
|
return NS_OK;
|
||||||
if(fIs_Content)
|
|
||||||
*aFoundItem = shellAsTreeItem;
|
|
||||||
else if(aRequestor != shellAsTreeItem.get())
|
|
||||||
{
|
|
||||||
// Do this so we can pass in the tree owner as the requestor so the child knows not
|
|
||||||
// to call back up.
|
|
||||||
nsCOMPtr<nsIDocShellTreeOwner> shellOwner;
|
|
||||||
shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner));
|
|
||||||
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
|
|
||||||
|
|
||||||
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
|
nsCOMPtr<nsIDocShell> foundDocShell;
|
||||||
}
|
foundWebBrowser->GetDocShell(getter_AddRefs(foundDocShell));
|
||||||
if(*aFoundItem)
|
|
||||||
return NS_OK;
|
nsCOMPtr<nsIDocShellTreeItem> foundDocShellAsItem;
|
||||||
}
|
*aFoundItem = foundDocShellAsItem;
|
||||||
windowEnumerator->HasMoreElements(&more);
|
NS_IF_ADDREF(*aFoundItem);
|
||||||
}
|
|
||||||
return NS_OK;*/
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
||||||
|
@ -183,6 +158,18 @@ NS_IMETHODIMP nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
||||||
if(aShellItem == mWebBrowser->mDocShellAsItem.get())
|
if(aShellItem == mWebBrowser->mDocShellAsItem.get())
|
||||||
return mWebBrowserChrome->SizeBrowserTo(aCX, aCY);
|
return mWebBrowserChrome->SizeBrowserTo(aCX, aCY);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(aShellItem));
|
||||||
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||||
|
webNav->GetDocument(getter_AddRefs(domDocument));
|
||||||
|
NS_ENSURE_TRUE(domDocument, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMElement> domElement;
|
||||||
|
domDocument->GetDocumentElement(getter_AddRefs(domElement));
|
||||||
|
NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
// Set the preferred Size
|
||||||
//XXX
|
//XXX
|
||||||
NS_ERROR("Implement this");
|
NS_ERROR("Implement this");
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -95,9 +95,9 @@ interface nsIWebBrowserChrome : nsISupports
|
||||||
setWebBrowser will be called with the new widget to instantiate in this
|
setWebBrowser will be called with the new widget to instantiate in this
|
||||||
new window.
|
new window.
|
||||||
*/
|
*/
|
||||||
void getNewBrowser(in unsigned long chromeMask, out nsIWebBrowser webBrowser);
|
nsIWebBrowser getNewBrowser(in unsigned long chromeMask);
|
||||||
|
|
||||||
void findNamedBrowserChrome(in wstring aName, out nsIWebBrowserChrome webBrowserChrome);
|
nsIWebBrowser findNamedBrowser(in wstring aName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Tells the chrome to size itself such that the browser will be the
|
Tells the chrome to size itself such that the browser will be the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче