mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
First check in for nsXULWindow, nsContentTreeOwner and nsChromeTreeOwner. These collectively serve as the eventual replacement for nsWebShellWindow. (This is not hooked to the build).
This commit is contained in:
parent
93a2638f9a
commit
55e2d93c13
260
xpfe/appshell/src/nsChromeTreeOwner.cpp
Normal file
260
xpfe/appshell/src/nsChromeTreeOwner.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#include "nsChromeTreeOwner.h"
|
||||
#include "nsXULWindow.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsChromeTreeOwner: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsChromeTreeOwner::nsChromeTreeOwner() : mXULWindow(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsChromeTreeOwner::~nsChromeTreeOwner()
|
||||
{
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsChromeTreeOwner::nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsChromeTreeOwner)
|
||||
NS_IMPL_RELEASE(nsChromeTreeOwner)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsChromeTreeOwner)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsChromeTreeOwner::nsIDocShellTreeOwner
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
|
||||
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
|
||||
{
|
||||
|
||||
/*
|
||||
Return the child DocShellTreeItem with the specified name.
|
||||
name - This is the name of the item that is trying to be found.
|
||||
aRequestor - This is the docshellTreeItem that is requesting the find. This
|
||||
parameter is used to identify when the child is asking it's parent to find
|
||||
a child with the specific name. The parent uses this parameter to ensure
|
||||
a resursive state does not occur by not again asking the requestor for find
|
||||
a shell by the specified name. Inversely the child uses it to ensure it
|
||||
does not ask it's parent to do the search if it's parent is the one that
|
||||
asked it to search.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
||||
PRBool aPrimary, const PRUnichar* aID)
|
||||
{
|
||||
/*
|
||||
Called when a content shell is added to the the docShell Tree.
|
||||
aContentShell - the docShell that has been added.
|
||||
aPrimary - true if this is the primary content shell
|
||||
aID - the ID of the docShell that has been added.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetNewBrowserChrome(PRInt32 aChromeFlags,
|
||||
nsIWebBrowserChrome** aWebBrowserChrome)
|
||||
{
|
||||
/*
|
||||
Tells the implementer of this interface to create a new webBrowserChrome
|
||||
object for it. Typically this means the implemetor will create a new
|
||||
top level window that is represented by nsIWebBrowserChrome. This
|
||||
most often will be called when for instance there is a need for a new
|
||||
JS window, etc. Soon after this new object is returned, the webBrowser
|
||||
attribute will checked, if one does not exist, one will be created and
|
||||
setWebBrowser will be called with the new widget to instantiate in this
|
||||
new window.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsChromeTreeOwner::nsIBaseWindow
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
||||
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::Create()
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::Destroy()
|
||||
{
|
||||
// We don't support the dynamic destroy and recreate on the object. Just
|
||||
// create a new object!
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetPosition(PRInt32 x, PRInt32 y)
|
||||
{
|
||||
return mXULWindow->SetPosition(x, y);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetPosition(PRInt32* x, PRInt32* y)
|
||||
{
|
||||
return mXULWindow->GetPosition(x, y);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
return mXULWindow->SetSize(cx, cy, fRepaint);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetSize(PRInt32* cx, PRInt32* cy)
|
||||
{
|
||||
return mXULWindow->GetSize(cx, cy);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
||||
PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
return mXULWindow->SetPositionAndSize(x, y, cx, cy, fRepaint);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
|
||||
PRInt32* cy)
|
||||
{
|
||||
return mXULWindow->GetPositionAndSize(x, y, cx, cy);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::Repaint(PRBool aForce)
|
||||
{
|
||||
return mXULWindow->Repaint(aForce);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentWidget);
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "You can't call this");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetVisibility(PRBool* aVisibility)
|
||||
{
|
||||
return mXULWindow->GetVisibility(aVisibility);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetVisibility(PRBool aVisibility)
|
||||
{
|
||||
return mXULWindow->SetVisibility(aVisibility);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMainWidget);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetFocus()
|
||||
{
|
||||
return mXULWindow->SetFocus();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::FocusAvailable(nsIBaseWindow* aCurrentFocus,
|
||||
PRBool* aTookFocus)
|
||||
{
|
||||
return mXULWindow->FocusAvailable(aCurrentFocus, aTookFocus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::GetTitle(PRUnichar** aTitle)
|
||||
{
|
||||
return mXULWindow->GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetTitle(const PRUnichar* aTitle)
|
||||
{
|
||||
return mXULWindow->SetTitle(aTitle);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsChromeTreeOwner: Helpers
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
// nsChromeTreeOwner: Accessors
|
||||
//*****************************************************************************
|
||||
|
||||
void nsChromeTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
||||
{
|
||||
mXULWindow = aXULWindow;
|
||||
}
|
||||
|
||||
nsXULWindow* nsChromeTreeOwner::XULWindow()
|
||||
{
|
||||
return mXULWindow;
|
||||
}
|
54
xpfe/appshell/src/nsChromeTreeOwner.h
Normal file
54
xpfe/appshell/src/nsChromeTreeOwner.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; 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>
|
||||
*/
|
||||
|
||||
#ifndef nsChromeTreeOwner_h__
|
||||
#define nsChromeTreeOwner_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
|
||||
class nsXULWindow;
|
||||
|
||||
class nsChromeTreeOwner : public nsIDocShellTreeOwner,
|
||||
public nsIBaseWindow
|
||||
{
|
||||
friend class nsXULWindow;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIDOCSHELLTREEOWNER
|
||||
|
||||
protected:
|
||||
nsChromeTreeOwner();
|
||||
~nsChromeTreeOwner();
|
||||
|
||||
void XULWindow(nsXULWindow* aXULWindow);
|
||||
nsXULWindow* XULWindow();
|
||||
|
||||
protected:
|
||||
nsXULWindow* mXULWindow;
|
||||
};
|
||||
|
||||
#endif /* nsChromeTreeOwner_h__ */
|
345
xpfe/appshell/src/nsContentTreeOwner.cpp
Normal file
345
xpfe/appshell/src/nsContentTreeOwner.cpp
Normal file
@ -0,0 +1,345 @@
|
||||
/* -*- 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"
|
||||
|
||||
// Interfaces needed to be included
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsContentTreeOwner: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsContentTreeOwner::nsContentTreeOwner() : mXULWindow(nsnull)
|
||||
{
|
||||
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)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner::nsIDocShellTreeOwner
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
|
||||
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
|
||||
{
|
||||
|
||||
/*
|
||||
Return the child DocShellTreeItem with the specified name.
|
||||
name - This is the name of the item that is trying to be found.
|
||||
aRequestor - This is the docshellTreeItem that is requesting the find. This
|
||||
parameter is used to identify when the child is asking it's parent to find
|
||||
a child with the specific name. The parent uses this parameter to ensure
|
||||
a resursive state does not occur by not again asking the requestor for find
|
||||
a shell by the specified name. Inversely the child uses it to ensure it
|
||||
does not ask it's parent to do the search if it's parent is the one that
|
||||
asked it to search.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
||||
PRBool aPrimary, const PRUnichar* aID)
|
||||
{
|
||||
/*
|
||||
Called when a content shell is added to the the docShell Tree.
|
||||
aContentShell - the docShell that has been added.
|
||||
aPrimary - true if this is the primary content shell
|
||||
aID - the ID of the docShell that has been added.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetNewBrowserChrome(PRInt32 aChromeFlags,
|
||||
nsIWebBrowserChrome** aWebBrowserChrome)
|
||||
{
|
||||
/*
|
||||
Tells the implementer of this interface to create a new webBrowserChrome
|
||||
object for it. Typically this means the implemetor will create a new
|
||||
top level window that is represented by nsIWebBrowserChrome. This
|
||||
most often will be called when for instance there is a need for a new
|
||||
JS window, etc. Soon after this new object is returned, the webBrowser
|
||||
attribute will checked, if one does not exist, one will be created and
|
||||
setWebBrowser will be called with the new widget to instantiate in this
|
||||
new window.
|
||||
*/
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner::nsIBaseWindow
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
||||
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::Create()
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::Destroy()
|
||||
{
|
||||
// We don't support the dynamic destroy and recreate on the object. Just
|
||||
// create a new object!
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetPosition(PRInt32 x, PRInt32 y)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetPosition(PRInt32* x, PRInt32* y)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(x && y);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetSize(PRInt32* cx, PRInt32* cy)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(cx && cy);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
||||
PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
|
||||
PRInt32* cy)
|
||||
{
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::Repaint(PRBool aForce)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentWidget);
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(PRBool* aVisibility)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aVisibility);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(PRBool aVisibility)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMainWidget);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::SetFocus()
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsContentTreeOwner::FocusAvailable(nsIBaseWindow* aCurrentFocus,
|
||||
PRBool* aTookFocus)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// Get the window title modifiers
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
mXULWindow->GetDOMElementFromDocShell(mXULWindow->mDocShell,
|
||||
getter_AddRefs(docShellElement));
|
||||
|
||||
nsAutoString windowTitleModifier;
|
||||
nsAutoString titleSeparator;
|
||||
nsAutoString titlePreface;
|
||||
|
||||
if(docShellElement)
|
||||
{
|
||||
docShellElement->GetAttribute("titlemodifier", windowTitleModifier);
|
||||
docShellElement->GetAttribute("titlemenuseparator", titleSeparator);
|
||||
docShellElement->GetAttribute("titlepreface", titlePreface);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("This condition should never happen. If it does, "
|
||||
"we just won't get a modifier, but it still shouldn't happen.");
|
||||
}
|
||||
|
||||
nsAutoString title;
|
||||
nsAutoString docTitle(aTitle);
|
||||
|
||||
if(docTitle.Length() > 0)
|
||||
{
|
||||
if(titlePreface.Length() > 0)
|
||||
{
|
||||
// Title will be: "Preface: Doc Title - Mozilla"
|
||||
title = titlePreface + docTitle;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Title will be: "Doc Title - Mozilla"
|
||||
title = docTitle;
|
||||
}
|
||||
title += titleSeparator + windowTitleModifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Title will just be plain: Mozilla
|
||||
title = windowTitleModifier;
|
||||
}
|
||||
|
||||
// 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
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner: Accessors
|
||||
//*****************************************************************************
|
||||
|
||||
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
||||
{
|
||||
mXULWindow = aXULWindow;
|
||||
}
|
||||
|
||||
nsXULWindow* nsContentTreeOwner::XULWindow()
|
||||
{
|
||||
return mXULWindow;
|
||||
}
|
54
xpfe/appshell/src/nsContentTreeOwner.h
Normal file
54
xpfe/appshell/src/nsContentTreeOwner.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; 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>
|
||||
*/
|
||||
|
||||
#ifndef nsContentTreeOwner_h__
|
||||
#define nsContentTreeOwner_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
|
||||
class nsXULWindow;
|
||||
|
||||
class nsContentTreeOwner : public nsIDocShellTreeOwner,
|
||||
public nsIBaseWindow
|
||||
{
|
||||
friend class nsXULWindow;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIDOCSHELLTREEOWNER
|
||||
|
||||
protected:
|
||||
nsContentTreeOwner();
|
||||
~nsContentTreeOwner();
|
||||
|
||||
void XULWindow(nsXULWindow* aXULWindow);
|
||||
nsXULWindow* XULWindow();
|
||||
|
||||
protected:
|
||||
nsXULWindow* mXULWindow;
|
||||
};
|
||||
|
||||
#endif /* nsContentTreeOwner_h__ */
|
529
xpfe/appshell/src/nsXULWindow.cpp
Normal file
529
xpfe/appshell/src/nsXULWindow.cpp
Normal file
@ -0,0 +1,529 @@
|
||||
/* -*- 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 "nsXULWindow.h"
|
||||
|
||||
// Helper classes
|
||||
#include "nsString.h"
|
||||
#include "prprf.h"
|
||||
|
||||
//Interfaces needed to be included
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
|
||||
// XXX Get rid of this
|
||||
#pragma message("WARNING: XXX bad include, remove it.")
|
||||
#include "nsIWebShellWindow.h"
|
||||
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsXULWindow: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsXULWindow::nsXULWindow() : mContentTreeOwner(nsnull),
|
||||
mChromeTreeOwner(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsXULWindow::~nsXULWindow()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsXULWindow::nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsXULWindow)
|
||||
NS_IMPL_RELEASE(nsXULWindow)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsXULWindow::nsIXULWindow
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocShell);
|
||||
|
||||
*aDocShell = mDocShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetPrimaryContentShell(nsIDocShellTreeItem**
|
||||
aDocShellTreeItem)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocShellTreeItem);
|
||||
|
||||
//XXX First Check
|
||||
NS_ERROR("Not Yet Implemented");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetContentShellById(const PRUnichar* aID,
|
||||
nsIDocShellTreeItem** aDocShellTreeItem)
|
||||
{
|
||||
//XXX First Check
|
||||
NS_ERROR("Not Yet Implemented");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
||||
PRBool aPersistCX, PRBool aPersistCY)
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
||||
if(!docShellElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString persistString;
|
||||
docShellElement->GetAttribute("persist", persistString);
|
||||
|
||||
PRBool saveString = PR_FALSE;
|
||||
PRInt32 index;
|
||||
|
||||
// Set X
|
||||
index = persistString.Find("screenX");
|
||||
if(!aPersistX && (index >= 0))
|
||||
{
|
||||
persistString.Cut(index, 7);
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
else if(aPersistX && (index < 0 ))
|
||||
{
|
||||
persistString.Append(" screenX");
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
// Set Y
|
||||
index = persistString.Find("screenY");
|
||||
if(!aPersistY && (index >= 0))
|
||||
{
|
||||
persistString.Cut(index, 7);
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
else if(aPersistY && (index < 0 ))
|
||||
{
|
||||
persistString.Append(" screenY");
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
// Set CX
|
||||
index = persistString.Find("width");
|
||||
if(!aPersistCX && (index >= 0))
|
||||
{
|
||||
persistString.Cut(index, 5);
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
else if(aPersistCX && (index < 0 ))
|
||||
{
|
||||
persistString.Append(" width");
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
// Set CY
|
||||
index = persistString.Find("height");
|
||||
if(!aPersistCY && (index >= 0))
|
||||
{
|
||||
persistString.Cut(index, 6);
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
else if(aPersistCY && (index < 0 ))
|
||||
{
|
||||
persistString.Append(" height");
|
||||
saveString = PR_TRUE;
|
||||
}
|
||||
|
||||
if(saveString)
|
||||
docShellElement->SetAttribute("persist", persistString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
|
||||
PRBool* aPersistCX, PRBool* aPersistCY)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
||||
if(!docShellElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString persistString;
|
||||
docShellElement->GetAttribute("persist", persistString);
|
||||
|
||||
if(aPersistX)
|
||||
*aPersistX = persistString.Find("screenX") >= 0 ? PR_TRUE : PR_FALSE;
|
||||
if(aPersistY)
|
||||
*aPersistY = persistString.Find("screenY") >= 0 ? PR_TRUE : PR_FALSE;
|
||||
if(aPersistCX)
|
||||
*aPersistCX = persistString.Find("width") >= 0 ? PR_TRUE : PR_FALSE;
|
||||
if(aPersistCY)
|
||||
*aPersistCY = persistString.Find("height") >= 0 ? PR_TRUE : PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsXULWindow::nsIBaseWindow
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::InitWindow(nativeWindow aParentNativeWindow,
|
||||
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::Create()
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::Destroy()
|
||||
{
|
||||
if(mDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(mDocShell));
|
||||
shellAsWin->Destroy();
|
||||
mDocShell = nsnull;
|
||||
}
|
||||
if(mContentTreeOwner)
|
||||
{
|
||||
mContentTreeOwner->XULWindow(nsnull);
|
||||
NS_RELEASE(mContentTreeOwner);
|
||||
}
|
||||
if(mChromeTreeOwner)
|
||||
{
|
||||
mChromeTreeOwner->XULWindow(nsnull);
|
||||
NS_RELEASE(mChromeTreeOwner);
|
||||
}
|
||||
mWindow = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetPosition(PRInt32 aX, PRInt32 aY)
|
||||
{
|
||||
mWindow->Move(aX, aY);
|
||||
PersistPositionAndSize(PR_TRUE, PR_FALSE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetPosition(PRInt32* x, PRInt32* y)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(x && y);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetSize(PRInt32* cx, PRInt32* cy)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(cx && cy);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
||||
PRInt32 cy, PRBool fRepaint)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
|
||||
PRInt32* cy)
|
||||
{
|
||||
nsRect rect;
|
||||
|
||||
mWindow->GetScreenBounds(rect);
|
||||
|
||||
if(x)
|
||||
*x = rect.x;
|
||||
if(y)
|
||||
*y = rect.y;
|
||||
if(cx)
|
||||
*cx = rect.width;
|
||||
if(cy)
|
||||
*cy = rect.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::Repaint(PRBool aForce)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetParentWidget(nsIWidget** aParentWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentWidget);
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetParentWidget(nsIWidget* aParentWidget)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetVisibility(PRBool* aVisibility)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aVisibility);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetVisibility(PRBool aVisibility)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetMainWidget(nsIWidget** aMainWidget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMainWidget);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetFocus()
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::FocusAvailable(nsIBaseWindow* aCurrentFocus,
|
||||
PRBool* aTookFocus)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetTitle(PRUnichar** aTitle)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTitle);
|
||||
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::SetTitle(const PRUnichar* aTitle)
|
||||
{
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
|
||||
nsAutoString title(aTitle);
|
||||
|
||||
NS_ENSURE_SUCCESS(mWindow->SetTitle(title), NS_ERROR_FAILURE);
|
||||
|
||||
// Tell the window mediator that a title has changed
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
||||
if(!windowMediator)
|
||||
return NS_OK;
|
||||
|
||||
// XXX Update windowMediator to take nsIXULWindow
|
||||
nsCOMPtr<nsIWebShellWindow>
|
||||
webShellWindow(do_QueryInterface(NS_STATIC_CAST(nsIXULWindow*, this)));
|
||||
NS_ENSURE_TRUE(webShellWindow, NS_ERROR_FAILURE);
|
||||
windowMediator->UpdateWindowTitle(webShellWindow, aTitle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsXULWindow: Helpers
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::EnsureChromeTreeOwner()
|
||||
{
|
||||
if(mChromeTreeOwner)
|
||||
return NS_OK;
|
||||
|
||||
mChromeTreeOwner = new nsChromeTreeOwner();
|
||||
NS_ENSURE_TRUE(mChromeTreeOwner, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(mChromeTreeOwner);
|
||||
mChromeTreeOwner->XULWindow(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::EnsureContentTreeOwner()
|
||||
{
|
||||
if(mContentTreeOwner)
|
||||
return NS_OK;
|
||||
|
||||
mContentTreeOwner = new nsContentTreeOwner();
|
||||
NS_ENSURE_TRUE(mContentTreeOwner, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ADDREF(mContentTreeOwner);
|
||||
mContentTreeOwner->XULWindow(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::GetDOMElementFromDocShell(nsIDocShell* aDocShell,
|
||||
nsIDOMElement** aDOMElement)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocShell);
|
||||
NS_ENSURE_ARG_POINTER(aDOMElement);
|
||||
|
||||
*aDOMElement = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
|
||||
aDocShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if(!cv)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if(!docv)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(*getter_AddRefs(doc));
|
||||
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc));
|
||||
if(!domdoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
domdoc->GetDocumentElement(aDOMElement);
|
||||
if(!*aDOMElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
||||
if(!docShellElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 x, y, cx, cy;
|
||||
NS_ENSURE_SUCCESS(GetPositionAndSize(&x, &y, &cx, &cy), NS_ERROR_FAILURE);
|
||||
|
||||
// (But only for size elements which are persisted.)
|
||||
/* Note we use the same cheesy way to determine that as in
|
||||
nsXULDocument.cpp. Some day that'll be fixed and there will
|
||||
be an obscure bug here. */
|
||||
/* Note that storing sizes which are not persisted makes it
|
||||
difficult to distinguish between windows intrinsically sized
|
||||
and not. */
|
||||
nsAutoString persistString;
|
||||
docShellElement->GetAttribute("persist", persistString);
|
||||
|
||||
char sizeBuf[10];
|
||||
nsAutoString sizeString;
|
||||
if(aPosition)
|
||||
{
|
||||
if(persistString.Find("screenX") >= 0)
|
||||
{
|
||||
PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)x);
|
||||
sizeString = sizeBuf;
|
||||
docShellElement->SetAttribute("screenX", sizeString);
|
||||
}
|
||||
if(persistString.Find("screenY") >= 0)
|
||||
{
|
||||
PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)y);
|
||||
sizeString = sizeBuf;
|
||||
docShellElement->SetAttribute("screenY", sizeString);
|
||||
}
|
||||
}
|
||||
|
||||
if(aSize)
|
||||
{
|
||||
if(persistString.Find("width") >= 0)
|
||||
{
|
||||
PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)cx);
|
||||
sizeString = sizeBuf;
|
||||
docShellElement->SetAttribute("width", sizeString);
|
||||
}
|
||||
if(persistString.Find("height") >= 0)
|
||||
{
|
||||
PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)cy);
|
||||
sizeString = sizeBuf;
|
||||
docShellElement->SetAttribute("height", sizeString);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsXULWindow: Accessors
|
||||
//*****************************************************************************
|
||||
|
63
xpfe/appshell/src/nsXULWindow.h
Normal file
63
xpfe/appshell/src/nsXULWindow.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; 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>
|
||||
*/
|
||||
|
||||
#ifndef nsXULWindow_h__
|
||||
#define nsXULWindow_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsChromeTreeOwner.h"
|
||||
#include "nsContentTreeOwner.h"
|
||||
|
||||
class nsXULWindow : public nsIXULWindow, public nsIBaseWindow
|
||||
{
|
||||
friend class nsChromeTreeOwner;
|
||||
friend class nsContentTreeOwner;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIXULWINDOW
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
|
||||
protected:
|
||||
nsXULWindow();
|
||||
~nsXULWindow();
|
||||
|
||||
NS_IMETHOD EnsureChromeTreeOwner();
|
||||
NS_IMETHOD EnsureContentTreeOwner();
|
||||
|
||||
NS_IMETHOD GetDOMElementFromDocShell(nsIDocShell* aDocShell,
|
||||
nsIDOMElement** aDOMElement);
|
||||
NS_IMETHOD PersistPositionAndSize(PRBool aPosition, PRBool aSize);
|
||||
|
||||
protected:
|
||||
nsChromeTreeOwner* mChromeTreeOwner;
|
||||
nsContentTreeOwner* mContentTreeOwner;
|
||||
nsCOMPtr<nsIWidget> mWindow;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
};
|
||||
|
||||
#endif /* nsXULWindow_h__ */
|
Loading…
Reference in New Issue
Block a user