2000-01-22 03:15:41 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2009-01-17 02:05:14 +00:00
|
|
|
* vim: set ts=2 sw=2 et tw=79:
|
2000-01-22 03:15:41 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-01-22 03:15:41 +00:00
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsContentTreeOwner.h"
|
|
|
|
#include "nsXULWindow.h"
|
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
// Helper Classes
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2006-02-22 03:58:48 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2000-01-27 05:59:44 +00:00
|
|
|
|
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"
|
2011-07-15 10:31:34 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2006-02-07 20:46:39 +00:00
|
|
|
#include "nsIDOMChromeWindow.h"
|
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDOMXULElement.h"
|
2002-01-16 00:11:29 +00:00
|
|
|
#include "nsIEmbeddingSiteWindow.h"
|
2000-02-08 16:11:10 +00:00
|
|
|
#include "nsIPrompt.h"
|
2001-04-10 18:30:25 +00:00
|
|
|
#include "nsIAuthPrompt.h"
|
2000-01-27 05:59:44 +00:00
|
|
|
#include "nsIWindowMediator.h"
|
2000-03-24 03:46:15 +00:00
|
|
|
#include "nsIXULBrowserWindow.h"
|
2005-09-30 18:51:46 +00:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIURIFixup.h"
|
|
|
|
#include "nsCDefaultURIFixup.h"
|
2006-02-07 20:46:39 +00:00
|
|
|
#include "nsIWebNavigation.h"
|
2013-09-10 04:18:46 +00:00
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsIExternalURLHandlerService.h"
|
|
|
|
#include "nsIMIMEInfo.h"
|
2013-10-22 13:27:34 +00:00
|
|
|
#include "nsIWidget.h"
|
2014-06-20 18:07:47 +00:00
|
|
|
#include "nsWindowWatcher.h"
|
2012-06-12 22:01:25 +00:00
|
|
|
#include "mozilla/BrowserElementParent.h"
|
2000-01-27 05:59:44 +00:00
|
|
|
|
2001-08-31 04:28:26 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2006-02-02 20:02:34 +00:00
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
2013-10-02 20:09:18 +00:00
|
|
|
#include "nsIDocument.h"
|
2011-01-25 18:13:43 +00:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#endif
|
2001-08-31 04:28:26 +00:00
|
|
|
|
2011-06-20 03:00:16 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-07-18 06:54:08 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-12-12 01:51:58 +00:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2011-06-20 03:00:16 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
2002-01-05 02:22:45 +00:00
|
|
|
//*****************************************************************************
|
2012-06-09 22:15:12 +00:00
|
|
|
//*** nsSiteWindow declaration
|
2002-01-05 02:22:45 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-06-09 22:15:12 +00:00
|
|
|
class nsSiteWindow : public nsIEmbeddingSiteWindow
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow(nsContentTreeOwner *aAggregator);
|
|
|
|
virtual ~nsSiteWindow();
|
2002-01-05 02:22:45 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsContentTreeOwner *mAggregator;
|
|
|
|
};
|
|
|
|
|
2014-06-24 16:36:45 +00:00
|
|
|
namespace mozilla {
|
|
|
|
template<>
|
|
|
|
struct HasDangerousPublicDestructor<nsSiteWindow>
|
|
|
|
{
|
|
|
|
static const bool value = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsContentTreeOwner: Object Management
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) : mXULWindow(nullptr),
|
2011-10-17 14:59:28 +00:00
|
|
|
mPrimary(fPrimary), mContentTitleSetting(false)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2002-01-16 00:11:29 +00:00
|
|
|
// note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
|
2012-06-09 22:15:12 +00:00
|
|
|
mSiteWindow = new nsSiteWindow(this);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsContentTreeOwner::~nsContentTreeOwner()
|
|
|
|
{
|
2012-06-09 22:15:12 +00:00
|
|
|
delete mSiteWindow;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// 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)
|
2006-02-03 21:28:11 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
2010-10-28 22:00:31 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome3)
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
2006-02-07 20:46:39 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
2006-02-22 05:09:01 +00:00
|
|
|
// NOTE: This is using aggregation because there are some properties and
|
2006-02-22 05:19:21 +00:00
|
|
|
// method on nsIBaseWindow (which we implement) and on
|
|
|
|
// nsIEmbeddingSiteWindow (which we also implement) that have the same name.
|
|
|
|
// And it just so happens that we want different behavior for these methods
|
|
|
|
// and properties depending on the interface through which they're called
|
|
|
|
// (SetFocus() is a good example here). If it were not for that, we could
|
|
|
|
// ditch the aggregation and just deal with not being able to use NS_DECL_*
|
|
|
|
// macros for this stuff....
|
2012-06-09 22:15:12 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIEmbeddingSiteWindow, mSiteWindow)
|
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)
|
|
|
|
{
|
2001-02-26 00:33:48 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
|
|
|
*aSink = 0;
|
|
|
|
|
2007-02-19 15:26:48 +00:00
|
|
|
if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 00:33:48 +00:00
|
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
2007-02-19 15:26:48 +00:00
|
|
|
}
|
|
|
|
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-04-10 18:30:25 +00:00
|
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
2007-02-19 15:26:48 +00:00
|
|
|
}
|
2001-02-26 00:33:48 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 00:33:48 +00:00
|
|
|
nsCOMPtr<nsIDocShell> shell;
|
|
|
|
mXULWindow->GetDocShell(getter_AddRefs(shell));
|
2005-02-02 09:39:30 +00:00
|
|
|
if (shell)
|
|
|
|
return shell->QueryInterface(aIID, aSink);
|
2001-02-26 00:33:48 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 00:33:48 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> shell;
|
|
|
|
mXULWindow->GetPrimaryContentShell(getter_AddRefs(shell));
|
|
|
|
if (shell) {
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(shell));
|
|
|
|
if (thing)
|
|
|
|
return thing->GetInterface(aIID, aSink);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2007-02-19 15:26:48 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-11-06 01:19:39 +00:00
|
|
|
return mXULWindow->QueryInterface(aIID, aSink);
|
2007-02-19 15:26:48 +00:00
|
|
|
}
|
2001-11-06 01:19:39 +00:00
|
|
|
|
2001-02-26 00:33:48 +00:00
|
|
|
return QueryInterface(aIID, aSink);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIDocShellTreeOwner
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const char16_t* aName,
|
2005-01-11 19:36:40 +00:00
|
|
|
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
|
|
|
|
nsIDocShellTreeItem** aFoundItem)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2013-12-03 22:03:45 +00:00
|
|
|
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aFoundItem);
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aFoundItem = nullptr;
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool fIs_Content = false;
|
2000-02-10 07:41:11 +00:00
|
|
|
|
2000-01-27 05:59:44 +00:00
|
|
|
/* Special Cases */
|
2006-02-22 03:58:48 +00:00
|
|
|
if (!aName || !*aName)
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_OK;
|
2005-01-11 19:36:40 +00:00
|
|
|
|
|
|
|
nsDependentString name(aName);
|
|
|
|
|
2006-02-22 03:58:48 +00:00
|
|
|
if (name.LowerCaseEqualsLiteral("_blank"))
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_OK;
|
2003-09-04 02:23:20 +00:00
|
|
|
// _main is an IE target which should be case-insensitive but isn't
|
|
|
|
// see bug 217886 for details
|
2006-02-22 03:58:48 +00:00
|
|
|
if (name.LowerCaseEqualsLiteral("_content") ||
|
|
|
|
name.EqualsLiteral("_main")) {
|
2006-03-24 19:38:17 +00:00
|
|
|
// If we're being called with an aRequestor and it's targetable, just
|
|
|
|
// return it -- _main and _content from inside targetable content shells
|
|
|
|
// should just be that content shell. Note that we don't have to worry
|
|
|
|
// about the case when it's not targetable because it's primary -- that
|
|
|
|
// will Just Work when we call GetPrimaryContentShell.
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2006-03-24 19:38:17 +00:00
|
|
|
if (aRequestor) {
|
|
|
|
// This better be the root item!
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> debugRoot;
|
|
|
|
aRequestor->GetSameTypeRootTreeItem(getter_AddRefs(debugRoot));
|
|
|
|
NS_ASSERTION(SameCOMIdentity(debugRoot, aRequestor),
|
|
|
|
"Bogus aRequestor");
|
|
|
|
#endif
|
2007-02-19 15:26:48 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t count = mXULWindow->mTargetableShells.Count();
|
|
|
|
for (int32_t i = 0; i < count; ++i) {
|
2006-03-24 19:38:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> item =
|
|
|
|
do_QueryReferent(mXULWindow->mTargetableShells[i]);
|
|
|
|
if (SameCOMIdentity(item, aRequestor)) {
|
|
|
|
NS_ADDREF(*aFoundItem = aRequestor);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-22 03:58:48 +00:00
|
|
|
mXULWindow->GetPrimaryContentShell(aFoundItem);
|
|
|
|
if(*aFoundItem)
|
|
|
|
return NS_OK;
|
|
|
|
// Fall through and keep looking...
|
2011-10-17 14:59:28 +00:00
|
|
|
fIs_Content = true;
|
2006-02-22 03:58:48 +00:00
|
|
|
}
|
2000-01-27 05:59:44 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
|
|
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nullptr,
|
2000-01-27 05:59:44 +00:00
|
|
|
getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool more;
|
2000-01-27 05:59:44 +00:00
|
|
|
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
2006-02-22 03:58:48 +00:00
|
|
|
while(more) {
|
2012-07-30 14:20:58 +00:00
|
|
|
nsCOMPtr<nsISupports> nextWindow = nullptr;
|
2006-02-22 03:58:48 +00:00
|
|
|
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
|
|
|
|
NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
if (fIs_Content) {
|
|
|
|
xulWindow->GetPrimaryContentShell(aFoundItem);
|
|
|
|
} else {
|
|
|
|
// Get all the targetable windows from xulWindow and search them
|
|
|
|
nsRefPtr<nsXULWindow> win;
|
|
|
|
xulWindow->QueryInterface(NS_GET_IID(nsXULWindow), getter_AddRefs(win));
|
|
|
|
if (win) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t count = win->mTargetableShells.Count();
|
|
|
|
int32_t i;
|
2006-11-14 22:30:33 +00:00
|
|
|
for (i = 0; i < count && !*aFoundItem; ++i) {
|
2006-02-22 03:58:48 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem =
|
|
|
|
do_QueryReferent(win->mTargetableShells[i]);
|
|
|
|
if (shellAsTreeItem) {
|
|
|
|
// Get the root tree item of same type, since roots are the only
|
|
|
|
// things that call into the treeowner to look for named items.
|
|
|
|
// XXXbz ideally we could guarantee that mTargetableShells only
|
|
|
|
// contains roots, but the current treeowner apis don't allow
|
|
|
|
// that... yet.
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
|
|
|
shellAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
|
|
|
NS_ASSERTION(root, "Must have root tree item of same type");
|
|
|
|
shellAsTreeItem.swap(root);
|
|
|
|
if (aRequestor != shellAsTreeItem) {
|
2005-01-31 20:46:24 +00:00
|
|
|
// 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));
|
2006-02-22 03:58:48 +00:00
|
|
|
nsCOMPtr<nsISupports> shellOwnerSupports =
|
|
|
|
do_QueryInterface(shellOwner);
|
2005-01-31 20:46:24 +00:00
|
|
|
|
|
|
|
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports,
|
|
|
|
aOriginalRequestor,
|
|
|
|
aFoundItem);
|
2006-02-22 03:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-27 05:59:44 +00:00
|
|
|
}
|
2006-02-22 03:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*aFoundItem)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
}
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_OK;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2007-10-05 23:37:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aPrimary, bool aTargetable,
|
2007-10-05 23:37:25 +00:00
|
|
|
const nsAString& aID)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-10-05 23:37:25 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aTargetable,
|
|
|
|
aID);
|
|
|
|
}
|
2006-02-22 03:58:48 +00:00
|
|
|
|
2007-10-05 23:37:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->ContentShellRemoved(aContentShell);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:16:46 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
|
2000-02-02 02:28:32 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-02 02:28:32 +00:00
|
|
|
return mXULWindow->GetPrimaryContentShell(aShell);
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:16:46 +00:00
|
|
|
NS_IMETHODIMP
|
2014-01-09 17:39:36 +00:00
|
|
|
nsContentTreeOwner::GetContentWindow(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aVal)
|
2013-05-08 21:16:46 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-02-05 03:26:12 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aCX, int32_t aCY)
|
2000-02-05 03:26:12 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-05 03:26:12 +00:00
|
|
|
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
2001-03-09 02:04:06 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsContentTreeOwner::SetPersistence(bool aPersistPosition,
|
|
|
|
bool aPersistSize,
|
|
|
|
bool aPersistSizeMode)
|
2001-03-09 02:04:06 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2013-07-18 06:54:08 +00:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2012-10-02 08:24:10 +00:00
|
|
|
if (!docShellElement)
|
2001-03-09 02:04:06 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoString persistString;
|
2001-11-14 01:33:42 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
2001-03-09 02:04:06 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool saveString = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index;
|
2001-03-09 02:04:06 +00:00
|
|
|
|
|
|
|
// Set X
|
|
|
|
index = persistString.Find("screenX");
|
|
|
|
if (!aPersistPosition && index >= 0) {
|
|
|
|
persistString.Cut(index, 7);
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
} else if (aPersistPosition && index < 0) {
|
2004-06-17 00:13:25 +00:00
|
|
|
persistString.AppendLiteral(" screenX");
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
}
|
|
|
|
// Set Y
|
|
|
|
index = persistString.Find("screenY");
|
|
|
|
if (!aPersistPosition && index >= 0) {
|
|
|
|
persistString.Cut(index, 7);
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
} else if (aPersistPosition && index < 0) {
|
2004-06-17 00:13:25 +00:00
|
|
|
persistString.AppendLiteral(" screenY");
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
}
|
|
|
|
// Set CX
|
|
|
|
index = persistString.Find("width");
|
|
|
|
if (!aPersistSize && index >= 0) {
|
|
|
|
persistString.Cut(index, 5);
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
} else if (aPersistSize && index < 0) {
|
2004-06-17 00:13:25 +00:00
|
|
|
persistString.AppendLiteral(" width");
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
}
|
|
|
|
// Set CY
|
|
|
|
index = persistString.Find("height");
|
|
|
|
if (!aPersistSize && index >= 0) {
|
|
|
|
persistString.Cut(index, 6);
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
} else if (aPersistSize && index < 0) {
|
2004-06-17 00:13:25 +00:00
|
|
|
persistString.AppendLiteral(" height");
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
}
|
|
|
|
// Set SizeMode
|
|
|
|
index = persistString.Find("sizemode");
|
|
|
|
if (!aPersistSizeMode && (index >= 0)) {
|
|
|
|
persistString.Cut(index, 8);
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
} else if (aPersistSizeMode && (index < 0)) {
|
2004-06-17 00:13:25 +00:00
|
|
|
persistString.AppendLiteral(" sizemode");
|
2011-10-17 14:59:28 +00:00
|
|
|
saveString = true;
|
2001-03-09 02:04:06 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 06:54:08 +00:00
|
|
|
ErrorResult rv;
|
|
|
|
if(saveString) {
|
|
|
|
docShellElement->SetAttribute(NS_LITERAL_STRING("persist"), persistString, rv);
|
|
|
|
}
|
2001-03-09 02:04:06 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsContentTreeOwner::GetPersistence(bool* aPersistPosition,
|
|
|
|
bool* aPersistSize,
|
|
|
|
bool* aPersistSizeMode)
|
2001-03-09 02:04:06 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2013-07-18 06:54:08 +00:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2012-10-02 08:24:10 +00:00
|
|
|
if (!docShellElement)
|
2001-03-09 02:04:06 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoString persistString;
|
2001-11-14 01:33:42 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
2001-03-09 02:04:06 +00:00
|
|
|
|
|
|
|
// data structure doesn't quite match the question, but it's close enough
|
|
|
|
// for what we want (since this method is never actually called...)
|
|
|
|
if (aPersistPosition)
|
2011-10-17 14:59:28 +00:00
|
|
|
*aPersistPosition = persistString.Find("screenX") >= 0 || persistString.Find("screenY") >= 0 ? true : false;
|
2001-03-09 02:04:06 +00:00
|
|
|
if (aPersistSize)
|
2011-10-17 14:59:28 +00:00
|
|
|
*aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? true : false;
|
2001-03-09 02:04:06 +00:00
|
|
|
if (aPersistSizeMode)
|
2011-10-17 14:59:28 +00:00
|
|
|
*aPersistSizeMode = persistString.Find("sizemode") >= 0 ? true : false;
|
2001-03-09 02:04:06 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-14 21:27:53 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsContentTreeOwner::GetTargetableShellCount(uint32_t* aResult)
|
2011-04-14 21:27:53 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
*aResult = mXULWindow->mTargetableShells.Count();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
2010-10-28 22:00:31 +00:00
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome3
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &originalTarget,
|
|
|
|
nsIURI *linkURI,
|
|
|
|
nsIDOMNode *linkNode,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isAppTab,
|
2010-10-28 22:00:31 +00:00
|
|
|
nsAString &_retval)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
|
|
|
|
|
|
|
if (xulBrowserWindow)
|
|
|
|
return xulBrowserWindow->OnBeforeLinkTraversal(originalTarget, linkURI,
|
|
|
|
linkNode, isAppTab, _retval);
|
|
|
|
|
|
|
|
_retval = originalTarget;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
2006-02-03 21:28:11 +00:00
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome2
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatusWithContext(uint32_t aStatusType,
|
2006-02-03 21:28:11 +00:00
|
|
|
const nsAString &aStatusText,
|
|
|
|
nsISupports *aStatusContext)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2005-02-17 19:46:01 +00:00
|
|
|
// We only allow the status to be set from the primary content shell
|
2006-02-26 19:00:30 +00:00
|
|
|
if (!mPrimary && aStatusType != STATUS_LINK)
|
2005-02-17 19:46:01 +00:00
|
|
|
return NS_OK;
|
2007-02-19 15:26:48 +00:00
|
|
|
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2005-02-17 19:46:01 +00:00
|
|
|
|
2004-08-21 14:47:51 +00:00
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
2000-03-24 03:46:15 +00:00
|
|
|
|
2006-02-03 21:28:11 +00:00
|
|
|
if (xulBrowserWindow)
|
|
|
|
{
|
|
|
|
switch(aStatusType)
|
|
|
|
{
|
|
|
|
case STATUS_SCRIPT:
|
|
|
|
xulBrowserWindow->SetJSStatus(aStatusText);
|
|
|
|
break;
|
|
|
|
case STATUS_LINK:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aStatusContext);
|
|
|
|
xulBrowserWindow->SetOverLink(aStatusText, element);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-16 05:45:26 +00:00
|
|
|
|
2001-08-31 04:28:26 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2006-02-03 21:28:11 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatus(uint32_t aStatusType,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t* aStatus)
|
2006-02-03 21:28:11 +00:00
|
|
|
{
|
|
|
|
return SetStatusWithContext(aStatusType,
|
2007-07-08 07:08:04 +00:00
|
|
|
aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
|
2006-02-03 21:50:25 +00:00
|
|
|
: EmptyString(),
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr);
|
2006-02-03 21:28:11 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2001-11-06 01:19:39 +00:00
|
|
|
// Unimplemented, and probably will remain so; xpfe windows have docshells,
|
2002-03-18 23:33:49 +00:00
|
|
|
// not webbrowsers.
|
|
|
|
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
|
|
|
*aWebBrowser = 0;
|
2001-11-06 01:19:39 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(uint32_t aChromeFlags)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2005-02-02 09:39:30 +00:00
|
|
|
return mXULWindow->SetChromeFlags(aChromeFlags);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(uint32_t* aChromeFlags)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2005-02-02 09:39:30 +00:00
|
|
|
return mXULWindow->GetChromeFlags(aChromeFlags);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 12:21:34 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::DestroyBrowserWindow()
|
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(int32_t aCX, int32_t aCY)
|
2000-03-14 07:06:07 +00:00
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShowAsModal()
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-02-16 01:16:00 +00:00
|
|
|
return mXULWindow->ShowModal();
|
2000-03-14 07:06:07 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(bool *_retval)
|
2000-11-09 00:16:29 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-03-12 23:08:29 +00:00
|
|
|
*_retval = mXULWindow->mContinueModalLoop;
|
|
|
|
return NS_OK;
|
2000-11-09 00:16:29 +00:00
|
|
|
}
|
|
|
|
|
2000-07-12 23:56:14 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ExitModalEventLoop(nsresult aStatus)
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-03-12 23:08:29 +00:00
|
|
|
return mXULWindow->ExitModalLoop(aStatus);
|
2000-07-12 23:56:14 +00:00
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIBaseWindow
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-01-27 05:59:44 +00:00
|
|
|
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE);
|
2000-01-27 05:59:44 +00:00
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Create()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Destroy()
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->Destroy();
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-10-16 19:41:19 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetPosition(aX, aY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPosition(int32_t* aX, int32_t* aY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetPosition(aX, aY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetSize(aCX, aCY, aRepaint);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetSize(aCX, aCY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY,
|
|
|
|
int32_t aCX, int32_t aCY, bool aRepaint)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aCX, int32_t* aCY)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Repaint(bool aForce)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
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)
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
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)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
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)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 05:59:44 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2012-07-25 01:35:32 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(nsAString& aNativeHandle)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetNativeHandle(aNativeHandle);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->GetVisibility(aVisibility);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(bool aVisibility)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 13:40:10 +00:00
|
|
|
return mXULWindow->SetVisibility(aVisibility);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetEnabled(bool *aEnabled)
|
2002-02-28 23:22:55 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-02-28 23:22:55 +00:00
|
|
|
return mXULWindow->GetEnabled(aEnabled);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetEnabled(bool aEnable)
|
2002-02-28 23:22:55 +00:00
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-02-28 23:22:55 +00:00
|
|
|
return mXULWindow->SetEnabled(aEnable);
|
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMainWidget);
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-01-22 03:15:41 +00:00
|
|
|
|
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()
|
|
|
|
{
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-05 03:26:12 +00:00
|
|
|
return mXULWindow->SetFocus();
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetTitle(char16_t** aTitle)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTitle);
|
2007-02-19 15:26:48 +00:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2005-02-01 08:50:50 +00:00
|
|
|
return mXULWindow->GetTitle(aTitle);
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const char16_t* aTitle)
|
2000-01-22 03:15:41 +00:00
|
|
|
{
|
2000-01-30 07:29:38 +00:00
|
|
|
// We only allow the title to be set from the primary content shell
|
2003-08-07 21:05:58 +00:00
|
|
|
if(!mPrimary || !mContentTitleSetting)
|
|
|
|
return NS_OK;
|
2007-02-19 15:26:48 +00:00
|
|
|
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2003-08-07 21:05:58 +00:00
|
|
|
|
|
|
|
nsAutoString title;
|
|
|
|
nsAutoString docTitle(aTitle);
|
|
|
|
|
|
|
|
if (docTitle.IsEmpty())
|
|
|
|
docTitle.Assign(mTitleDefault);
|
2013-07-18 06:54:08 +00:00
|
|
|
|
2003-08-07 23:01:24 +00:00
|
|
|
if (!docTitle.IsEmpty()) {
|
|
|
|
if (!mTitlePreface.IsEmpty()) {
|
|
|
|
// Title will be: "Preface: Doc Title - Mozilla"
|
|
|
|
title.Assign(mTitlePreface);
|
|
|
|
title.Append(docTitle);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Title will be: "Doc Title - Mozilla"
|
|
|
|
title = docTitle;
|
|
|
|
}
|
2013-07-18 06:54:08 +00:00
|
|
|
|
2005-10-14 23:39:45 +00:00
|
|
|
if (!mWindowTitleModifier.IsEmpty())
|
|
|
|
title += mTitleSeparator + mWindowTitleModifier;
|
2003-08-07 23:01:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
title.Assign(mWindowTitleModifier); // Title will just be plain "Mozilla"
|
2000-01-22 03:15:41 +00:00
|
|
|
|
2005-09-30 18:51:46 +00:00
|
|
|
//
|
|
|
|
// if there is no location bar we modify the title to display at least
|
|
|
|
// the scheme and host (if any) as an anti-spoofing measure.
|
|
|
|
//
|
2013-07-18 06:54:08 +00:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2005-09-30 18:51:46 +00:00
|
|
|
|
|
|
|
if (docShellElement) {
|
|
|
|
nsAutoString chromeString;
|
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("chromehidden"), chromeString);
|
|
|
|
if (chromeString.Find(NS_LITERAL_STRING("location")) != kNotFound) {
|
|
|
|
//
|
|
|
|
// location bar is turned off, find the browser location
|
|
|
|
//
|
|
|
|
// use the document's nsPrincipal to find the true owner
|
|
|
|
// in case of javascript: or data: documents
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> dsitem;
|
|
|
|
GetPrimaryContentShell(getter_AddRefs(dsitem));
|
2014-01-10 02:03:47 +00:00
|
|
|
nsCOMPtr<nsIScriptObjectPrincipal> doc =
|
|
|
|
do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
|
2005-09-30 18:51:46 +00:00
|
|
|
if (doc) {
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsIPrincipal* principal = doc->GetPrincipal();
|
|
|
|
if (principal) {
|
|
|
|
principal->GetURI(getter_AddRefs(uri));
|
|
|
|
if (uri) {
|
|
|
|
//
|
|
|
|
// remove any user:pass information
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIURIFixup> fixup(do_GetService(NS_URIFIXUP_CONTRACTID));
|
|
|
|
if (fixup) {
|
|
|
|
nsCOMPtr<nsIURI> tmpuri;
|
|
|
|
nsresult rv = fixup->CreateExposableURI(uri,getter_AddRefs(tmpuri));
|
|
|
|
if (NS_SUCCEEDED(rv) && tmpuri) {
|
2005-10-14 23:33:51 +00:00
|
|
|
// (don't bother if there's no host)
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString host;
|
|
|
|
nsAutoCString prepath;
|
2005-10-14 23:33:51 +00:00
|
|
|
tmpuri->GetHost(host);
|
2005-09-30 18:51:46 +00:00
|
|
|
tmpuri->GetPrePath(prepath);
|
2005-10-14 23:33:51 +00:00
|
|
|
if (!host.IsEmpty()) {
|
2005-09-30 18:51:46 +00:00
|
|
|
//
|
|
|
|
// We have a scheme/host, update the title
|
|
|
|
//
|
|
|
|
title.Insert(NS_ConvertUTF8toUTF16(prepath) +
|
|
|
|
mTitleSeparator, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-18 06:54:08 +00:00
|
|
|
nsIDocument* document = docShellElement->OwnerDoc();
|
|
|
|
ErrorResult rv;
|
|
|
|
document->SetTitle(title, rv);
|
|
|
|
return rv.ErrorCode();
|
2005-09-30 18:51:46 +00:00
|
|
|
}
|
|
|
|
|
2005-02-01 08:50:50 +00:00
|
|
|
return mXULWindow->SetTitle(title.get());
|
2000-01-22 03:15:41 +00:00
|
|
|
}
|
|
|
|
|
2006-02-07 20:46:39 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: nsIWindowProvider
|
|
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aChromeFlags,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified,
|
|
|
|
bool aSizeSpecified,
|
2006-02-07 20:46:39 +00:00
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aWindowIsNew,
|
2006-02-07 20:46:39 +00:00
|
|
|
nsIDOMWindow** aReturn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aReturn = nullptr;
|
2006-02-07 20:46:39 +00:00
|
|
|
|
|
|
|
if (!mXULWindow) {
|
|
|
|
// Nothing to do here
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCOMPtr<nsIWebNavigation> parentNav = do_GetInterface(aParent);
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> parentOwner = do_GetInterface(parentNav);
|
|
|
|
NS_ASSERTION(SameCOMIdentity(parentOwner,
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsIDocShellTreeOwner*>(this)),
|
2006-02-07 20:46:39 +00:00
|
|
|
"Parent from wrong docshell tree?");
|
|
|
|
#endif
|
|
|
|
|
2012-06-12 22:01:25 +00:00
|
|
|
// If aParent is inside an <iframe mozbrowser> and this isn't a request to
|
|
|
|
// open a modal-type window, we're going to create a new <iframe mozbrowser>
|
|
|
|
// and return its window here.
|
|
|
|
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 18:32:37 +00:00
|
|
|
if (docshell && docshell->GetIsInBrowserOrApp() &&
|
2012-06-12 22:01:25 +00:00
|
|
|
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
|
2013-09-10 04:18:46 +00:00
|
|
|
|
|
|
|
BrowserElementParent::OpenWindowResult opened =
|
2012-06-12 22:01:25 +00:00
|
|
|
BrowserElementParent::OpenWindowInProcess(aParent, aURI, aName,
|
|
|
|
aFeatures, aReturn);
|
|
|
|
|
2013-09-10 04:18:46 +00:00
|
|
|
// If OpenWindowInProcess handled the open (by opening it or blocking the
|
2012-06-12 22:01:25 +00:00
|
|
|
// popup), tell our caller not to proceed trying to create a new window
|
|
|
|
// through other means.
|
2013-09-10 04:18:46 +00:00
|
|
|
if (opened != BrowserElementParent::OPEN_WINDOW_IGNORED) {
|
|
|
|
*aWindowIsNew = opened == BrowserElementParent::OPEN_WINDOW_ADDED;
|
|
|
|
return *aWindowIsNew ? NS_OK : NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're in an app and the target is _blank, send the url to the OS
|
|
|
|
if (aName.LowerCaseEqualsLiteral("_blank")) {
|
|
|
|
nsCOMPtr<nsIExternalURLHandlerService> exUrlServ(
|
|
|
|
do_GetService(NS_EXTERNALURLHANDLERSERVICE_CONTRACTID));
|
|
|
|
if (exUrlServ) {
|
|
|
|
|
|
|
|
nsCOMPtr<nsIHandlerInfo> info;
|
|
|
|
bool found;
|
|
|
|
exUrlServ->GetURLHandlerInfoFromOS(aURI, &found, getter_AddRefs(info));
|
|
|
|
|
|
|
|
if (info && found) {
|
|
|
|
info->LaunchWithURI(aURI, nullptr);
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-06-12 22:01:25 +00:00
|
|
|
}
|
|
|
|
|
2014-06-20 18:07:47 +00:00
|
|
|
int32_t openLocation =
|
|
|
|
nsWindowWatcher::GetWindowOpenLocation(aParent, aChromeFlags, aCalledFromJS,
|
|
|
|
aPositionSpecified, aSizeSpecified);
|
2013-02-18 11:27:48 +00:00
|
|
|
|
2014-06-20 18:07:47 +00:00
|
|
|
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
|
|
|
|
openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
2006-02-07 20:46:39 +00:00
|
|
|
// Just open a window normally
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-15 10:31:34 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> domWin;
|
2006-02-07 20:46:39 +00:00
|
|
|
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin));
|
|
|
|
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(domWin);
|
|
|
|
if (!chromeWin) {
|
|
|
|
// Really odd... but whatever
|
|
|
|
NS_WARNING("nsXULWindow's DOMWindow is not a chrome window");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-06-20 18:07:47 +00:00
|
|
|
|
2006-02-07 20:46:39 +00:00
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
|
|
|
|
chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
|
|
|
|
if (!browserDOMWin) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-06-20 18:07:47 +00:00
|
|
|
*aWindowIsNew = (openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
|
2007-12-14 17:27:31 +00:00
|
|
|
|
2009-01-17 02:05:14 +00:00
|
|
|
{
|
2014-04-15 03:27:00 +00:00
|
|
|
dom::AutoNoJSAPI nojsapi;
|
2009-01-17 02:05:14 +00:00
|
|
|
|
|
|
|
// Get a new rendering area from the browserDOMWin. We don't want
|
|
|
|
// to be starting any loads here, so get it with a null URI.
|
2014-06-20 18:07:47 +00:00
|
|
|
return browserDOMWin->OpenURI(nullptr, aParent, openLocation,
|
2009-01-17 02:05:14 +00:00
|
|
|
nsIBrowserDOMWindow::OPEN_NEW, aReturn);
|
|
|
|
}
|
2006-02-07 20:46:39 +00:00
|
|
|
}
|
|
|
|
|
2000-01-22 03:15:41 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: Accessors
|
2011-01-25 18:13:43 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
class nsContentTitleSettingEvent : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
2013-07-18 06:54:08 +00:00
|
|
|
nsContentTitleSettingEvent(dom::Element* dse, const nsAString& wtm)
|
2011-01-25 18:13:43 +00:00
|
|
|
: mElement(dse),
|
|
|
|
mTitleDefault(wtm) {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
2013-07-18 06:54:08 +00:00
|
|
|
ErrorResult rv;
|
|
|
|
mElement->SetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault, rv);
|
|
|
|
mElement->RemoveAttribute(NS_LITERAL_STRING("titlemodifier"), rv);
|
2011-01-25 18:13:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-07-18 06:54:08 +00:00
|
|
|
nsCOMPtr<dom::Element> mElement;
|
2011-01-25 18:13:43 +00:00
|
|
|
nsString mTitleDefault;
|
|
|
|
};
|
|
|
|
#endif
|
2000-01-22 03:15:41 +00:00
|
|
|
|
|
|
|
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
|
|
|
{
|
|
|
|
mXULWindow = aXULWindow;
|
2012-10-02 08:24:10 +00:00
|
|
|
if (mXULWindow && mPrimary) {
|
2000-02-15 10:20:41 +00:00
|
|
|
// Get the window title modifiers
|
2013-07-18 06:54:08 +00:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2000-02-15 10:20:41 +00:00
|
|
|
|
|
|
|
nsAutoString contentTitleSetting;
|
|
|
|
|
2013-07-18 06:54:08 +00:00
|
|
|
if(docShellElement)
|
2000-02-15 10:20:41 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("contenttitlesetting"), contentTitleSetting);
|
2004-05-22 22:15:22 +00:00
|
|
|
if(contentTitleSetting.EqualsLiteral("true"))
|
2000-02-15 10:20:41 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
mContentTitleSetting = true;
|
2003-08-12 05:51:39 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault);
|
2001-11-14 01:33:42 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
|
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
|
2013-07-18 06:54:08 +00:00
|
|
|
|
2008-09-15 13:07:44 +00:00
|
|
|
#if defined(XP_MACOSX)
|
2003-08-12 05:51:39 +00:00
|
|
|
// On OS X, treat the titlemodifier like it's the titledefault, and don't ever append
|
|
|
|
// the separator + appname.
|
|
|
|
if (mTitleDefault.IsEmpty()) {
|
2011-01-25 18:13:43 +00:00
|
|
|
NS_DispatchToCurrentThread(
|
|
|
|
new nsContentTitleSettingEvent(docShellElement,
|
|
|
|
mWindowTitleModifier));
|
2003-08-12 05:51:39 +00:00
|
|
|
mTitleDefault = mWindowTitleModifier;
|
|
|
|
mWindowTitleModifier.Truncate();
|
|
|
|
}
|
|
|
|
#endif
|
2005-10-14 23:39:45 +00:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemenuseparator"), mTitleSeparator);
|
2000-02-15 10:20:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2002-01-05 02:22:45 +00:00
|
|
|
//*****************************************************************************
|
2012-06-09 22:15:12 +00:00
|
|
|
//*** nsSiteWindow implementation
|
2002-01-05 02:22:45 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::nsSiteWindow(nsContentTreeOwner *aAggregator)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
mAggregator = aAggregator;
|
|
|
|
}
|
|
|
|
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::~nsSiteWindow()
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-09 22:15:12 +00:00
|
|
|
NS_IMPL_ADDREF_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
|
|
|
NS_IMPL_RELEASE_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
2002-01-05 02:22:45 +00:00
|
|
|
|
2012-06-09 22:15:12 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSiteWindow)
|
2002-01-05 02:22:45 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2002-01-16 00:11:29 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
2002-01-05 02:22:45 +00:00
|
|
|
NS_INTERFACE_MAP_END_AGGREGATED(mAggregator)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSiteWindow::SetDimensions(uint32_t aFlags,
|
|
|
|
int32_t aX, int32_t aY, int32_t aCX, int32_t aCY)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
// XXX we're ignoring aFlags
|
2011-10-17 14:59:28 +00:00
|
|
|
return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY, true);
|
2002-01-05 02:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSiteWindow::GetDimensions(uint32_t aFlags,
|
|
|
|
int32_t *aX, int32_t *aY, int32_t *aCX, int32_t *aCY)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
// XXX we're ignoring aFlags
|
|
|
|
return mAggregator->GetPositionAndSize(aX, aY, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::SetFocus(void)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
2002-01-16 00:11:29 +00:00
|
|
|
#if 0
|
|
|
|
/* This implementation focuses the main document and could make sense.
|
|
|
|
However this method is actually being used from within
|
|
|
|
nsGlobalWindow::Focus (providing a hook for MDI embedding apps)
|
|
|
|
and it's better for our purposes to not pick a document and
|
|
|
|
focus it, but allow nsGlobalWindow to carry on unhindered.
|
|
|
|
*/
|
2002-01-05 02:22:45 +00:00
|
|
|
nsXULWindow *window = mAggregator->XULWindow();
|
|
|
|
if (window) {
|
|
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
|
|
window->GetDocShell(getter_AddRefs(docshell));
|
2014-01-10 02:03:47 +00:00
|
|
|
if (docShell) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow(docShell->GetWindow());
|
|
|
|
if (domWindow)
|
|
|
|
domWindow->Focus();
|
|
|
|
}
|
2002-01-05 02:22:45 +00:00
|
|
|
}
|
2002-01-16 00:11:29 +00:00
|
|
|
#endif
|
2002-01-05 02:22:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this implementation focuses another window. if there isn't another
|
|
|
|
window to focus, we do nothing. */
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::Blur(void)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
2013-12-03 22:03:45 +00:00
|
|
|
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
|
|
|
2002-01-05 02:22:45 +00:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWindow;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool more, foundUs;
|
2002-01-05 02:22:45 +00:00
|
|
|
nsXULWindow *ourWindow = mAggregator->XULWindow();
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
|
|
if (windowMediator)
|
2011-10-17 14:59:28 +00:00
|
|
|
windowMediator->GetZOrderXULWindowEnumerator(0, true,
|
2002-01-05 02:22:45 +00:00
|
|
|
getter_AddRefs(windowEnumerator));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!windowEnumerator)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// step through the top-level windows
|
2011-10-17 14:59:28 +00:00
|
|
|
foundUs = false;
|
2002-01-05 02:22:45 +00:00
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
while (more) {
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> nextWindow;
|
|
|
|
nsCOMPtr<nsIXULWindow> nextXULWindow;
|
|
|
|
|
|
|
|
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
|
|
|
|
nextXULWindow = do_QueryInterface(nextWindow);
|
|
|
|
|
|
|
|
// got it!(?)
|
|
|
|
if (foundUs) {
|
|
|
|
xulWindow = nextXULWindow;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remember the very first one, in case we have to wrap
|
|
|
|
if (!xulWindow)
|
|
|
|
xulWindow = nextXULWindow;
|
|
|
|
|
|
|
|
// look for us
|
|
|
|
if (nextXULWindow == ourWindow)
|
2011-10-17 14:59:28 +00:00
|
|
|
foundUs = true;
|
2002-01-05 02:22:45 +00:00
|
|
|
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
}
|
|
|
|
|
|
|
|
// change focus to the window we just found
|
|
|
|
if (xulWindow) {
|
|
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
|
|
xulWindow->GetDocShell(getter_AddRefs(docshell));
|
2014-01-10 02:03:47 +00:00
|
|
|
if (!docshell) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow(docshell->GetWindow());
|
2002-01-05 02:22:45 +00:00
|
|
|
if (domWindow)
|
|
|
|
domWindow->Focus();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::GetVisibility(bool *aVisibility)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
return mAggregator->GetVisibility(aVisibility);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::SetVisibility(bool aVisibility)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
return mAggregator->SetVisibility(aVisibility);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 15:02:17 +00:00
|
|
|
nsSiteWindow::GetTitle(char16_t * *aTitle)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
return mAggregator->GetTitle(aTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 15:02:17 +00:00
|
|
|
nsSiteWindow::SetTitle(const char16_t * aTitle)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
return mAggregator->SetTitle(aTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 22:15:12 +00:00
|
|
|
nsSiteWindow::GetSiteWindow(void **aSiteWindow)
|
2002-01-05 02:22:45 +00:00
|
|
|
{
|
|
|
|
return mAggregator->GetParentNativeWindow(aSiteWindow);
|
|
|
|
}
|
|
|
|
|