2000-01-22 03:15:41 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
*
|
|
|
|
* 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 the Mozilla browser.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications, Inc. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Travis Bogard <travis@netscape.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsContentTreeOwner.h"
|
|
|
|
#include "nsXULWindow.h"
|
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
// Helper Classes
|
|
|
|
#include "nsIGenericFactory.h"
|
|
|
|
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
// Interfaces needed to be included
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsIDOMXULElement.h"
|
2000-02-08 16:11:10 +00:00
|
|
|
#include "nsIPrompt.h"
|
2000-01-27 05:59:44 +00:00
|
|
|
#include "nsIWindowMediator.h"
|
|
|
|
|
|
|
|
// CIDs
|
|
|
|
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
2000-01-22 03:15:41 +00:00
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsContentTreeOwner: Object Management
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2000-01-30 07:29:38 +00:00
|
|
|
nsContentTreeOwner::nsContentTreeOwner(PRBool fPrimary) : mXULWindow(nsnull),
|
2000-02-15 10:20:41 +00:00
|
|
|
mPrimary(fPrimary), mContentTitleSetting(PR_FALSE),
|
|
|
|
mChromeMask(nsIWebBrowserChrome::allChrome)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContentTreeOwner::~nsContentTreeOwner()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsISupports
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsContentTreeOwner)
|
|
|
|
NS_IMPL_RELEASE(nsContentTreeOwner)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsContentTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
2000-01-22 03:15:41 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIInterfaceRequestor
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
|
|
|
|
|
|
|
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)))
|
|
|
|
*aSink = NS_STATIC_CAST(nsIWebBrowserChrome*, this);
|
2000-02-08 16:11:10 +00:00
|
|
|
else if(aIID.Equals(NS_GET_IID(nsIPrompt)))
|
|
|
|
return mXULWindow->QueryInterface(aIID, aSink);
|
2000-02-08 13:40:10 +00:00
|
|
|
else
|
|
|
|
return QueryInterface(aIID, aSink);
|
|
|
|
|
|
|
|
NS_IF_ADDREF(((nsISupports*)*aSink));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIDocShellTreeOwner
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|
|
|
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aFoundItem);
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
*aFoundItem = nsnull;
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
nsAutoString name(aName);
|
|
|
|
|
2000-02-10 07:41:11 +00:00
|
|
|
PRBool fIs_Content = PR_FALSE;
|
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
/* Special Cases */
|
|
|
|
if(name.Length() == 0)
|
|
|
|
return NS_OK;
|
|
|
|
if(name.EqualsIgnoreCase("_blank"))
|
|
|
|
return NS_OK;
|
|
|
|
if(name.EqualsIgnoreCase("_content"))
|
2000-02-10 07:41:11 +00:00
|
|
|
{
|
|
|
|
fIs_Content = PR_TRUE;
|
|
|
|
mXULWindow->GetPrimaryContentShell(aFoundItem);
|
|
|
|
if(*aFoundItem)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-27 05:59:44 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
|
|
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
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;
|
|
|
|
xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem));
|
|
|
|
|
2000-02-10 07:41:11 +00:00
|
|
|
if(shellAsTreeItem)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2000-01-27 05:59:44 +00:00
|
|
|
if(*aFoundItem)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
|
|
|
PRBool aPrimary, const PRUnichar* aID)
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
mXULWindow->ContentShellAdded(aContentShell, aPrimary, aID);
|
2000-01-22 03:15:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-02 02:28:32 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
|
|
|
|
{
|
|
|
|
return mXULWindow->GetPrimaryContentShell(aShell);
|
|
|
|
}
|
|
|
|
|
2000-02-05 03:26:12 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
|
|
|
PRInt32 aCX, PRInt32 aCY)
|
|
|
|
{
|
|
|
|
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShowModal()
|
|
|
|
{
|
|
|
|
return mXULWindow->ShowModal();
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetNewWindow(PRInt32 aChromeFlags,
|
|
|
|
nsIDocShellTreeItem** aDocShellTreeItem)
|
|
|
|
{
|
|
|
|
return mXULWindow->GetNewWindow(aChromeFlags, aDocShellTreeItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetJSStatus(const PRUnichar* aStatus)
|
|
|
|
{
|
2000-03-16 05:45:26 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> window;
|
|
|
|
mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window));
|
|
|
|
if(window)
|
|
|
|
window->SetAttribute("status", aStatus);
|
2000-02-14 06:15:35 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetJSDefaultStatus(const PRUnichar* aStatus)
|
|
|
|
{
|
2000-03-16 05:45:26 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> window;
|
|
|
|
mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window));
|
|
|
|
if(window)
|
|
|
|
window->SetAttribute("defaultStatus", aStatus);
|
2000-02-14 06:15:35 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetOverLink(const PRUnichar* aLink)
|
|
|
|
{
|
2000-03-16 05:45:26 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> window;
|
|
|
|
mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window));
|
|
|
|
if(window)
|
|
|
|
window->SetAttribute("overLink", aLink);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetWebBrowser(nsIWebBrowser* aWebBrowser)
|
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetChromeMask(PRUint32 aChromeMask)
|
|
|
|
{
|
|
|
|
mChromeMask = aChromeMask;
|
|
|
|
NS_ENSURE_SUCCESS(ApplyChromeMask(), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetChromeMask(PRUint32* aChromeMask)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aChromeMask);
|
|
|
|
|
|
|
|
*aChromeMask = mChromeMask;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-14 07:06:07 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetNewBrowser(PRUint32 aChromeFlags,
|
|
|
|
nsIWebBrowser** aWebBrowser)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-03-15 04:34:29 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::FindNamedBrowser(const PRUnichar* aName,
|
|
|
|
nsIWebBrowser** aWebBrowser)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-03-14 07:06:07 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShowAsModal()
|
|
|
|
{
|
|
|
|
return ShowModal();
|
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIBaseWindow
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
|
|
|
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
|
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, PR_FALSE), NS_ERROR_FAILURE);
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Create()
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Destroy()
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->Destroy();
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetPosition(aX, aY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetPosition(aX, aY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetSize(aCX, aCY, aRepaint);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetSize(aCX, aCY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
|
|
|
|
PRInt32* aCX, PRInt32* aCY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Repaint(PRBool aForce)
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->Repaint(aForce);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetParentWidget(aParentWidget);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetParentNativeWindow(aParentNativeWindow);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(PRBool* aVisibility)
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetVisibility(aVisibility);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetVisibility(aVisibility);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMainWidget);
|
|
|
|
|
2000-02-05 03:26:12 +00:00
|
|
|
*aMainWidget = mXULWindow->mWindow;
|
|
|
|
NS_IF_ADDREF(*aMainWidget);
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetFocus()
|
|
|
|
{
|
2000-02-05 03:26:12 +00:00
|
|
|
return mXULWindow->SetFocus();
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::FocusAvailable(nsIBaseWindow* aCurrentFocus,
|
|
|
|
PRBool* aTookFocus)
|
|
|
|
{
|
2000-02-05 03:26:12 +00:00
|
|
|
return mXULWindow->FocusAvailable(aCurrentFocus, aTookFocus);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetTitle(PRUnichar** aTitle)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTitle);
|
|
|
|
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle)
|
|
|
|
{
|
2000-01-30 07:29:38 +00:00
|
|
|
// We only allow the title to be set from the primary content shell
|
2000-02-15 10:20:41 +00:00
|
|
|
if(!mPrimary || !mContentTitleSetting)
|
2000-01-30 07:29:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
nsAutoString title;
|
|
|
|
nsAutoString docTitle(aTitle);
|
|
|
|
|
|
|
|
if(docTitle.Length() > 0)
|
|
|
|
{
|
2000-02-15 10:20:41 +00:00
|
|
|
if(mTitlePreface.Length() > 0)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
|
|
|
// Title will be: "Preface: Doc Title - Mozilla"
|
2000-02-15 10:20:41 +00:00
|
|
|
title = mTitlePreface + docTitle;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Title will be: "Doc Title - Mozilla"
|
|
|
|
title = docTitle;
|
|
|
|
}
|
2000-02-15 10:20:41 +00:00
|
|
|
title += mTitleSeparator + mWindowTitleModifier;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Title will just be plain: Mozilla
|
2000-02-15 10:20:41 +00:00
|
|
|
title = mWindowTitleModifier;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Don't need to fully qualify this once I remove nsWebShellWindow::SetTitle
|
|
|
|
// return mXULWindow->SetTitle(title.GetUnicode());
|
|
|
|
return mXULWindow->nsXULWindow::SetTitle(title.GetUnicode());
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: Helpers
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ApplyChromeMask()
|
|
|
|
{
|
|
|
|
if(!mXULWindow->mChromeLoaded)
|
|
|
|
return NS_OK; // We'll do this later when chrome is loaded
|
|
|
|
|
2000-02-19 00:56:13 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> window;
|
2000-03-16 05:45:26 +00:00
|
|
|
mXULWindow->GetWindowDOMElement(getter_AddRefs(window));
|
2000-02-19 00:56:13 +00:00
|
|
|
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
mXULWindow->mWindow->ShowMenuBar(mChromeMask &
|
|
|
|
nsIWebBrowserChrome::menuBarOn ?
|
|
|
|
PR_TRUE : PR_FALSE);
|
|
|
|
|
2000-02-19 00:56:13 +00:00
|
|
|
// Construct the new value for the 'chromehidden' attribute that
|
|
|
|
// we'll whack onto the window. We've got style rules in
|
|
|
|
// navigator.css that trigger visibility based on the
|
|
|
|
// 'chromehidden' attribute of the <window> tag.
|
|
|
|
nsAutoString newvalue;
|
|
|
|
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::menuBarOn)) {
|
|
|
|
newvalue += "menubar ";
|
|
|
|
}
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::toolBarOn)) {
|
|
|
|
newvalue += "toolbar ";
|
|
|
|
}
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::locationBarOn)) {
|
|
|
|
newvalue += "location ";
|
|
|
|
}
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::personalToolBarOn)) {
|
|
|
|
newvalue += "directories ";
|
|
|
|
}
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::statusBarOn)) {
|
|
|
|
newvalue += "status ";
|
|
|
|
}
|
|
|
|
if (! (mChromeMask & nsIWebBrowserChrome::extraChromeOn)) {
|
|
|
|
newvalue += "extrachrome";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the old value, to avoid useless style reflows if we're just
|
|
|
|
// setting stuff to the exact same thing.
|
|
|
|
nsAutoString oldvalue;
|
|
|
|
window->GetAttribute("chromehidden", oldvalue);
|
|
|
|
|
|
|
|
if (oldvalue != newvalue) {
|
|
|
|
window->SetAttribute("chromehidden", newvalue);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: Accessors
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
|
|
|
{
|
|
|
|
mXULWindow = aXULWindow;
|
2000-02-15 10:20:41 +00:00
|
|
|
if(mXULWindow && mPrimary)
|
|
|
|
{
|
|
|
|
// Get the window title modifiers
|
|
|
|
nsCOMPtr<nsIDOMElement> docShellElement;
|
2000-03-16 05:45:26 +00:00
|
|
|
mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
|
2000-02-15 10:20:41 +00:00
|
|
|
|
|
|
|
nsAutoString contentTitleSetting;
|
|
|
|
|
|
|
|
if(docShellElement)
|
|
|
|
{
|
|
|
|
docShellElement->GetAttribute("contenttitlesettting", contentTitleSetting);
|
|
|
|
if(contentTitleSetting.Equals("true"))
|
|
|
|
{
|
|
|
|
mContentTitleSetting = PR_TRUE;
|
|
|
|
docShellElement->GetAttribute("titlemodifier", mWindowTitleModifier);
|
|
|
|
docShellElement->GetAttribute("titlemenuseparator", mTitleSeparator);
|
|
|
|
docShellElement->GetAttribute("titlepreface", mTitlePreface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NS_ERROR("This condition should never happen. If it does, "
|
|
|
|
"we just won't get a modifier, but it still shouldn't happen.");
|
|
|
|
}
|
|
|
|
}
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXULWindow* nsContentTreeOwner::XULWindow()
|
|
|
|
{
|
|
|
|
return mXULWindow;
|
2000-01-27 05:59:44 +00:00
|
|
|
}
|
2000-01-27 06:05:39 +00:00
|
|
|
|