2000-01-22 06:15:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2009-01-17 05:05:14 +03:00
|
|
|
* vim: set ts=2 sw=2 et tw=79:
|
2000-01-22 06:15:41 +03:00
|
|
|
*
|
2012-05-21 15:12:37 +04: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 06:15:41 +03:00
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsContentTreeOwner.h"
|
|
|
|
#include "nsXULWindow.h"
|
|
|
|
|
2000-01-27 08:59:44 +03:00
|
|
|
// Helper Classes
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2006-02-22 06:58:48 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2000-01-27 08:59:44 +03:00
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
// Interfaces needed to be included
|
2011-07-15 14:31:34 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2006-02-07 23:46:39 +03:00
|
|
|
#include "nsIDOMChromeWindow.h"
|
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2002-01-16 03:11:29 +03:00
|
|
|
#include "nsIEmbeddingSiteWindow.h"
|
2000-02-08 19:11:10 +03:00
|
|
|
#include "nsIPrompt.h"
|
2001-04-10 22:30:25 +04:00
|
|
|
#include "nsIAuthPrompt.h"
|
2000-01-27 08:59:44 +03:00
|
|
|
#include "nsIWindowMediator.h"
|
2000-03-24 06:46:15 +03:00
|
|
|
#include "nsIXULBrowserWindow.h"
|
2005-09-30 22:51:46 +04:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIURIFixup.h"
|
|
|
|
#include "nsCDefaultURIFixup.h"
|
2006-02-07 23:46:39 +03:00
|
|
|
#include "nsIWebNavigation.h"
|
2013-09-10 08:18:46 +04:00
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsIExternalURLHandlerService.h"
|
|
|
|
#include "nsIMIMEInfo.h"
|
2013-10-22 17:27:34 +04:00
|
|
|
#include "nsIWidget.h"
|
2014-06-20 22:07:47 +04:00
|
|
|
#include "nsWindowWatcher.h"
|
2012-06-13 02:01:25 +04:00
|
|
|
#include "mozilla/BrowserElementParent.h"
|
2018-07-17 22:37:48 +03:00
|
|
|
#include "mozilla/NullPrincipal.h"
|
2018-06-30 02:29:50 +03:00
|
|
|
#include "nsDocShellLoadInfo.h"
|
2000-01-27 08:59:44 +03:00
|
|
|
|
2006-02-02 23:02:34 +03:00
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
2013-10-03 00:09:18 +04:00
|
|
|
#include "nsIDocument.h"
|
2011-01-25 21:13:43 +03:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#endif
|
2001-08-31 08:28:26 +04:00
|
|
|
|
2011-06-20 07:00:16 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-07-18 10:54:08 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-12-12 05:51:58 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2011-06-20 07:00:16 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
2002-01-05 05:22:45 +03:00
|
|
|
//*****************************************************************************
|
2012-06-10 02:15:12 +04:00
|
|
|
//*** nsSiteWindow declaration
|
2002-01-05 05:22:45 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-06-10 02:15:12 +04:00
|
|
|
class nsSiteWindow : public nsIEmbeddingSiteWindow
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
2015-07-08 04:49:00 +03:00
|
|
|
// nsSiteWindow shares a lifetime with nsContentTreeOwner, and proxies it's
|
|
|
|
// AddRef and Release calls to said object.
|
|
|
|
// When nsContentTreeOwner is destroyed, nsSiteWindow will be destroyed as well.
|
|
|
|
// nsContentTreeOwner is a friend class of nsSiteWindow such that it can call
|
|
|
|
// nsSiteWindow's destructor, which is private, as public destructors
|
|
|
|
// on reference counted classes are generally unsafe.
|
|
|
|
friend class nsContentTreeOwner;
|
|
|
|
|
2002-01-05 05:22:45 +03:00
|
|
|
public:
|
2014-09-03 02:24:24 +04:00
|
|
|
explicit nsSiteWindow(nsContentTreeOwner *aAggregator);
|
2002-01-05 05:22:45 +03:00
|
|
|
|
2015-07-08 04:49:00 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2002-01-05 05:22:45 +03:00
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
|
|
|
|
|
|
|
private:
|
2015-07-08 04:49:00 +03:00
|
|
|
virtual ~nsSiteWindow();
|
2002-01-05 05:22:45 +03:00
|
|
|
nsContentTreeOwner *mAggregator;
|
|
|
|
};
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsContentTreeOwner: Object Management
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) : mXULWindow(nullptr),
|
2011-10-17 18:59:28 +04:00
|
|
|
mPrimary(fPrimary), mContentTitleSetting(false)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2002-01-16 03:11:29 +03:00
|
|
|
// note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
|
2012-06-10 02:15:12 +04:00
|
|
|
mSiteWindow = new nsSiteWindow(this);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsContentTreeOwner::~nsContentTreeOwner()
|
|
|
|
{
|
2012-06-10 02:15:12 +04:00
|
|
|
delete mSiteWindow;
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsISupports
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2000-01-22 06:15:41 +03:00
|
|
|
|
|
|
|
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 16:40:10 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
2006-02-04 00:28:11 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
2010-10-29 02:00:31 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome3)
|
2000-02-08 16:40:10 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
2006-02-07 23:46:39 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
2006-02-22 08:09:01 +03:00
|
|
|
// NOTE: This is using aggregation because there are some properties and
|
2006-02-22 08:19:21 +03: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-10 02:15:12 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIEmbeddingSiteWindow, mSiteWindow)
|
2000-01-22 06:15:41 +03:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2000-02-08 16:40:10 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIInterfaceRequestor
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2000-02-08 16:40:10 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
|
|
|
{
|
2001-02-26 03:33:48 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
|
|
|
*aSink = 0;
|
|
|
|
|
2007-02-19 18:26:48 +03:00
|
|
|
if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 03:33:48 +03:00
|
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
2007-02-19 18:26:48 +03:00
|
|
|
}
|
|
|
|
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-04-10 22:30:25 +04:00
|
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
2007-02-19 18:26:48 +03:00
|
|
|
}
|
2001-02-26 03:33:48 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 03:33:48 +03:00
|
|
|
nsCOMPtr<nsIDocShell> shell;
|
|
|
|
mXULWindow->GetDocShell(getter_AddRefs(shell));
|
2005-02-02 12:39:30 +03:00
|
|
|
if (shell)
|
|
|
|
return shell->QueryInterface(aIID, aSink);
|
2001-02-26 03:33:48 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter))) {
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-02-26 03:33:48 +03: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 18:26:48 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-11-06 04:19:39 +03:00
|
|
|
return mXULWindow->QueryInterface(aIID, aSink);
|
2007-02-19 18:26:48 +03:00
|
|
|
}
|
2001-11-06 04:19:39 +03:00
|
|
|
|
2001-02-26 03:33:48 +03:00
|
|
|
return QueryInterface(aIID, aSink);
|
2000-02-08 16:40:10 +03:00
|
|
|
}
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIDocShellTreeOwner
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2000-01-22 06:15:41 +03:00
|
|
|
|
2007-10-06 03:37:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
2016-12-09 00:12:36 +03:00
|
|
|
bool aPrimary)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-10-06 03:37:25 +04:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2016-12-09 00:12:36 +03:00
|
|
|
return mXULWindow->ContentShellAdded(aContentShell, aPrimary);
|
2007-10-06 03:37:25 +04:00
|
|
|
}
|
2006-02-22 06:58:48 +03:00
|
|
|
|
2007-10-06 03:37:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->ContentShellRemoved(aContentShell);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2013-05-09 01:16:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
|
2000-02-02 05:28:32 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-02 05:28:32 +03:00
|
|
|
return mXULWindow->GetPrimaryContentShell(aShell);
|
|
|
|
}
|
|
|
|
|
2015-10-01 20:06:51 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::TabParentAdded(nsITabParent* aTab, bool aPrimary)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->TabParentAdded(aTab, aPrimary);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::TabParentRemoved(nsITabParent* aTab)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->TabParentRemoved(aTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetPrimaryTabParent(nsITabParent** aTab)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetPrimaryTabParent(aTab);
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:31:41 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetPrimaryContentSize(int32_t* aWidth,
|
|
|
|
int32_t* aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetPrimaryContentSize(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::SetPrimaryContentSize(int32_t aWidth,
|
|
|
|
int32_t aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->SetPrimaryContentSize(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetRootShellSize(int32_t* aWidth,
|
|
|
|
int32_t* aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetRootShellSize(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::SetRootShellSize(int32_t aWidth,
|
|
|
|
int32_t aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->SetRootShellSize(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
|
2000-02-05 06:26:12 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCX, int32_t aCY)
|
2000-02-05 06:26:12 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-05 06:26:12 +03:00
|
|
|
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
2001-03-09 05:04:06 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsContentTreeOwner::SetPersistence(bool aPersistPosition,
|
|
|
|
bool aPersistSize,
|
|
|
|
bool aPersistSizeMode)
|
2001-03-09 05:04:06 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2013-07-18 10:54:08 +04:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2012-10-02 12:24:10 +04:00
|
|
|
if (!docShellElement)
|
2001-03-09 05:04:06 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoString persistString;
|
2001-11-14 04:33:42 +03:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
2001-03-09 05:04:06 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool saveString = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index;
|
2001-03-09 05:04:06 +03:00
|
|
|
|
|
|
|
// Set X
|
|
|
|
index = persistString.Find("screenX");
|
|
|
|
if (!aPersistPosition && index >= 0) {
|
|
|
|
persistString.Cut(index, 7);
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
} else if (aPersistPosition && index < 0) {
|
2004-06-17 04:13:25 +04:00
|
|
|
persistString.AppendLiteral(" screenX");
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
}
|
|
|
|
// Set Y
|
|
|
|
index = persistString.Find("screenY");
|
|
|
|
if (!aPersistPosition && index >= 0) {
|
|
|
|
persistString.Cut(index, 7);
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
} else if (aPersistPosition && index < 0) {
|
2004-06-17 04:13:25 +04:00
|
|
|
persistString.AppendLiteral(" screenY");
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
}
|
|
|
|
// Set CX
|
|
|
|
index = persistString.Find("width");
|
|
|
|
if (!aPersistSize && index >= 0) {
|
|
|
|
persistString.Cut(index, 5);
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
} else if (aPersistSize && index < 0) {
|
2004-06-17 04:13:25 +04:00
|
|
|
persistString.AppendLiteral(" width");
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
}
|
|
|
|
// Set CY
|
|
|
|
index = persistString.Find("height");
|
|
|
|
if (!aPersistSize && index >= 0) {
|
|
|
|
persistString.Cut(index, 6);
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
} else if (aPersistSize && index < 0) {
|
2004-06-17 04:13:25 +04:00
|
|
|
persistString.AppendLiteral(" height");
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
}
|
|
|
|
// Set SizeMode
|
|
|
|
index = persistString.Find("sizemode");
|
|
|
|
if (!aPersistSizeMode && (index >= 0)) {
|
|
|
|
persistString.Cut(index, 8);
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
} else if (aPersistSizeMode && (index < 0)) {
|
2004-06-17 04:13:25 +04:00
|
|
|
persistString.AppendLiteral(" sizemode");
|
2011-10-17 18:59:28 +04:00
|
|
|
saveString = true;
|
2001-03-09 05:04:06 +03:00
|
|
|
}
|
|
|
|
|
2013-07-18 10:54:08 +04:00
|
|
|
ErrorResult rv;
|
|
|
|
if(saveString) {
|
|
|
|
docShellElement->SetAttribute(NS_LITERAL_STRING("persist"), persistString, rv);
|
|
|
|
}
|
2001-03-09 05:04:06 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsContentTreeOwner::GetPersistence(bool* aPersistPosition,
|
|
|
|
bool* aPersistSize,
|
|
|
|
bool* aPersistSizeMode)
|
2001-03-09 05:04:06 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2013-07-18 10:54:08 +04:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2012-10-02 12:24:10 +04:00
|
|
|
if (!docShellElement)
|
2001-03-09 05:04:06 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoString persistString;
|
2001-11-14 04:33:42 +03:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
2001-03-09 05:04:06 +03: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 18:59:28 +04:00
|
|
|
*aPersistPosition = persistString.Find("screenX") >= 0 || persistString.Find("screenY") >= 0 ? true : false;
|
2001-03-09 05:04:06 +03:00
|
|
|
if (aPersistSize)
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? true : false;
|
2001-03-09 05:04:06 +03:00
|
|
|
if (aPersistSizeMode)
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPersistSizeMode = persistString.Find("sizemode") >= 0 ? true : false;
|
2001-03-09 05:04:06 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-15 01:27:53 +04:00
|
|
|
NS_IMETHODIMP
|
2016-12-09 05:41:45 +03:00
|
|
|
nsContentTreeOwner::GetTabCount(uint32_t* aResult)
|
2011-04-15 01:27:53 +04:00
|
|
|
{
|
2016-12-09 05:41:45 +03:00
|
|
|
if (mXULWindow) {
|
|
|
|
return mXULWindow->GetTabCount(aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = 0;
|
2011-04-15 01:27:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:31:41 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContentTreeOwner::GetHasPrimaryContent(bool* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetHasPrimaryContent(aResult);
|
|
|
|
}
|
|
|
|
|
2000-02-08 16:40:10 +03:00
|
|
|
//*****************************************************************************
|
2010-10-29 02:00:31 +04:00
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome3
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2010-10-29 02:00:31 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &originalTarget,
|
|
|
|
nsIURI *linkURI,
|
2018-05-30 05:58:48 +03:00
|
|
|
nsINode *linkNode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isAppTab,
|
2010-10-29 02:00:31 +04: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);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-10-29 02:00:31 +04:00
|
|
|
_retval = originalTarget;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-25 22:35:45 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
|
|
|
nsIURI *aURI,
|
|
|
|
nsIURI *aReferrer,
|
2017-03-16 21:32:26 +03:00
|
|
|
bool aHasPostData,
|
2017-01-18 10:24:55 +03:00
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2014-09-25 22:35:45 +04:00
|
|
|
bool *_retval)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
|
|
|
|
|
|
|
if (xulBrowserWindow)
|
2017-03-16 21:32:26 +03:00
|
|
|
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData,
|
2017-01-18 10:24:55 +03:00
|
|
|
aTriggeringPrincipal, _retval);
|
2014-09-25 22:35:45 +04:00
|
|
|
|
|
|
|
*_retval = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-24 18:08:31 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURIInThisProcess(nsIURI* aURI,
|
|
|
|
bool* aRetVal)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Should only be called in child process.");
|
|
|
|
*aRetVal = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-10-21 23:56:51 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(nsIDocShell* aDocShell,
|
|
|
|
nsIURI* aURI,
|
|
|
|
nsIURI* aReferrer,
|
2017-01-18 10:24:55 +03:00
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2017-01-27 22:14:31 +03:00
|
|
|
uint32_t aLoadFlags,
|
2016-10-21 23:56:51 +03:00
|
|
|
bool* aRetVal)
|
|
|
|
{
|
|
|
|
NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");
|
|
|
|
*aRetVal = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-29 02:00:31 +04:00
|
|
|
//*****************************************************************************
|
2006-02-04 00:28:11 +03:00
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome2
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2000-02-08 16:40:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatusWithContext(uint32_t aStatusType,
|
2006-02-04 00:28:11 +03:00
|
|
|
const nsAString &aStatusText,
|
|
|
|
nsISupports *aStatusContext)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2005-02-17 22:46:01 +03:00
|
|
|
// We only allow the status to be set from the primary content shell
|
2006-02-26 22:00:30 +03:00
|
|
|
if (!mPrimary && aStatusType != STATUS_LINK)
|
2005-02-17 22:46:01 +03:00
|
|
|
return NS_OK;
|
2007-02-19 18:26:48 +03:00
|
|
|
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-08-21 18:47:51 +04:00
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
2000-03-24 06:46:15 +03:00
|
|
|
|
2006-02-04 00:28:11 +03:00
|
|
|
if (xulBrowserWindow)
|
|
|
|
{
|
|
|
|
switch(aStatusType)
|
|
|
|
{
|
|
|
|
case STATUS_LINK:
|
|
|
|
{
|
2018-04-27 06:37:29 +03:00
|
|
|
nsCOMPtr<dom::Element> element = do_QueryInterface(aStatusContext);
|
2006-02-04 00:28:11 +03:00
|
|
|
xulBrowserWindow->SetOverLink(aStatusText, element);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-16 08:45:26 +03:00
|
|
|
|
2001-08-31 08:28:26 +04:00
|
|
|
return NS_OK;
|
2000-02-08 16:40:10 +03:00
|
|
|
}
|
|
|
|
|
2006-02-04 00:28:11 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIWebBrowserChrome
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2006-02-04 00:28:11 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatus(uint32_t aStatusType,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aStatus)
|
2006-02-04 00:28:11 +03:00
|
|
|
{
|
|
|
|
return SetStatusWithContext(aStatusType,
|
2007-07-08 11:08:04 +04:00
|
|
|
aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
|
2006-02-04 00:50:25 +03:00
|
|
|
: EmptyString(),
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr);
|
2006-02-04 00:28:11 +03:00
|
|
|
}
|
|
|
|
|
2000-02-08 16:40:10 +03: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 04:19:39 +03:00
|
|
|
// Unimplemented, and probably will remain so; xpfe windows have docshells,
|
2002-03-19 02:33:49 +03:00
|
|
|
// not webbrowsers.
|
|
|
|
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
|
|
|
*aWebBrowser = 0;
|
2001-11-06 04:19:39 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 16:40:10 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(uint32_t aChromeFlags)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2005-02-02 12:39:30 +03:00
|
|
|
return mXULWindow->SetChromeFlags(aChromeFlags);
|
2000-02-08 16:40:10 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(uint32_t* aChromeFlags)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2005-02-02 12:39:30 +03:00
|
|
|
return mXULWindow->GetChromeFlags(aChromeFlags);
|
2000-02-08 16:40:10 +03:00
|
|
|
}
|
|
|
|
|
2001-03-13 15:21:34 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::DestroyBrowserWindow()
|
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(int32_t aCX, int32_t aCY)
|
2000-03-14 10:06:07 +03:00
|
|
|
{
|
|
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShowAsModal()
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-02-16 04:16:00 +03:00
|
|
|
return mXULWindow->ShowModal();
|
2000-03-14 10:06:07 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(bool *_retval)
|
2000-11-09 03:16:29 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2001-03-13 02:08:29 +03:00
|
|
|
*_retval = mXULWindow->mContinueModalLoop;
|
|
|
|
return NS_OK;
|
2000-11-09 03:16:29 +03:00
|
|
|
}
|
|
|
|
|
2000-07-13 03:56:14 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ExitModalEventLoop(nsresult aStatus)
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2017-07-06 15:00:35 +03:00
|
|
|
return mXULWindow->ExitModalLoop(aStatus);
|
2000-07-13 03:56:14 +04:00
|
|
|
}
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner::nsIBaseWindow
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2000-01-22 06:15:41 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
2017-07-06 15:00:35 +03:00
|
|
|
nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2000-01-27 08:59:44 +03:00
|
|
|
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
|
2016-05-12 03:07:45 +03:00
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, 0), NS_ERROR_FAILURE);
|
2000-01-27 08:59:44 +03:00
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Create()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 08:59:44 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Destroy()
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->Destroy();
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 23:41:19 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
|
|
|
|
}
|
|
|
|
|
2015-11-25 22:12:07 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale);
|
|
|
|
}
|
|
|
|
|
2016-02-18 13:46:16 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->SetPositionDesktopPix(aX, aY);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->SetPosition(aX, aY);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPosition(int32_t* aX, int32_t* aY)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->GetPosition(aX, aY);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->SetSize(aCX, aCY, aRepaint);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->GetSize(aCX, aCY);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY,
|
2016-05-12 03:07:45 +03:00
|
|
|
int32_t aCX, int32_t aCY, uint32_t aFlags)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2016-05-12 03:07:45 +03:00
|
|
|
return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aFlags);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aCX, int32_t* aCY)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2017-07-06 15:00:35 +03:00
|
|
|
return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Repaint(bool aForce)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->Repaint(aForce);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->GetParentWidget(aParentWidget);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 08:59:44 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->GetParentNativeWindow(aParentNativeWindow);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ASSERTION(false, "You can't call this");
|
2000-01-27 08:59:44 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2012-07-25 05:35:32 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(nsAString& aNativeHandle)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetNativeHandle(aNativeHandle);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->GetVisibility(aVisibility);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(bool aVisibility)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-08 16:40:10 +03:00
|
|
|
return mXULWindow->SetVisibility(aVisibility);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetEnabled(bool *aEnabled)
|
2002-03-01 02:22:55 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-03-01 02:22:55 +03:00
|
|
|
return mXULWindow->GetEnabled(aEnabled);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetEnabled(bool aEnable)
|
2002-03-01 02:22:55 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2002-03-01 02:22:55 +03:00
|
|
|
return mXULWindow->SetEnabled(aEnable);
|
|
|
|
}
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMainWidget);
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-01-22 06:15:41 +03:00
|
|
|
|
2000-02-05 06:26:12 +03:00
|
|
|
*aMainWidget = mXULWindow->mWindow;
|
|
|
|
NS_IF_ADDREF(*aMainWidget);
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetFocus()
|
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-02-05 06:26:12 +03:00
|
|
|
return mXULWindow->SetFocus();
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2017-09-25 06:10:51 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetTitle(nsAString& aTitle)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2007-02-19 18:26:48 +03:00
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2000-01-22 06:15:41 +03:00
|
|
|
|
2005-02-01 11:50:50 +03:00
|
|
|
return mXULWindow->GetTitle(aTitle);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2017-09-25 06:10:51 +03:00
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle)
|
2000-01-22 06:15:41 +03:00
|
|
|
{
|
2000-01-30 10:29:38 +03:00
|
|
|
// We only allow the title to be set from the primary content shell
|
2003-08-08 01:05:58 +04:00
|
|
|
if(!mPrimary || !mContentTitleSetting)
|
|
|
|
return NS_OK;
|
2007-02-19 18:26:48 +03:00
|
|
|
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2003-08-08 01:05:58 +04:00
|
|
|
nsAutoString title;
|
|
|
|
nsAutoString docTitle(aTitle);
|
|
|
|
|
|
|
|
if (docTitle.IsEmpty())
|
|
|
|
docTitle.Assign(mTitleDefault);
|
2013-07-18 10:54:08 +04:00
|
|
|
|
2003-08-08 03:01:24 +04: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 10:54:08 +04:00
|
|
|
|
2005-10-15 03:39:45 +04:00
|
|
|
if (!mWindowTitleModifier.IsEmpty())
|
|
|
|
title += mTitleSeparator + mWindowTitleModifier;
|
2003-08-08 03:01:24 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
title.Assign(mWindowTitleModifier); // Title will just be plain "Mozilla"
|
2000-01-22 06:15:41 +03:00
|
|
|
|
2005-09-30 22:51:46 +04: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 10:54:08 +04:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2005-09-30 22:51:46 +04: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
|
|
|
|
//
|
2017-03-22 13:39:31 +03:00
|
|
|
// use the document's ContentPrincipal to find the true owner
|
2005-09-30 22:51:46 +04:00
|
|
|
// in case of javascript: or data: documents
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> dsitem;
|
|
|
|
GetPrimaryContentShell(getter_AddRefs(dsitem));
|
2014-01-10 06:03:47 +04:00
|
|
|
nsCOMPtr<nsIScriptObjectPrincipal> doc =
|
|
|
|
do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
|
2005-09-30 22:51:46 +04: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-15 03:33:51 +04:00
|
|
|
// (don't bother if there's no host)
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString host;
|
|
|
|
nsAutoCString prepath;
|
2005-10-15 03:33:51 +04:00
|
|
|
tmpuri->GetHost(host);
|
2005-09-30 22:51:46 +04:00
|
|
|
tmpuri->GetPrePath(prepath);
|
2005-10-15 03:33:51 +04:00
|
|
|
if (!host.IsEmpty()) {
|
2005-09-30 22:51:46 +04:00
|
|
|
//
|
|
|
|
// We have a scheme/host, update the title
|
|
|
|
//
|
|
|
|
title.Insert(NS_ConvertUTF8toUTF16(prepath) +
|
|
|
|
mTitleSeparator, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-18 10:54:08 +04:00
|
|
|
nsIDocument* document = docShellElement->OwnerDoc();
|
|
|
|
ErrorResult rv;
|
|
|
|
document->SetTitle(title, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2005-09-30 22:51:46 +04:00
|
|
|
}
|
|
|
|
|
2017-09-25 06:10:51 +03:00
|
|
|
return mXULWindow->SetTitle(title);
|
2000-01-22 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
2006-02-07 23:46:39 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: nsIWindowProvider
|
2017-07-06 15:00:35 +03:00
|
|
|
//*****************************************************************************
|
2006-02-07 23:46:39 +03:00
|
|
|
NS_IMETHODIMP
|
2016-01-30 20:05:36 +03:00
|
|
|
nsContentTreeOwner::ProvideWindow(mozIDOMWindowProxy* aParent,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aChromeFlags,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified,
|
|
|
|
bool aSizeSpecified,
|
2006-02-07 23:46:39 +03:00
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
2016-10-27 19:37:44 +03:00
|
|
|
bool aForceNoOpener,
|
2018-06-30 02:29:50 +03:00
|
|
|
nsDocShellLoadInfo* aLoadInfo,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aWindowIsNew,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindowProxy** aReturn)
|
2006-02-07 23:46:39 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
2016-01-30 20:05:36 +03:00
|
|
|
|
|
|
|
auto* parent = nsPIDOMWindowOuter::From(aParent);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aReturn = nullptr;
|
2006-02-07 23:46:39 +03: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 11:08:04 +04:00
|
|
|
static_cast<nsIDocShellTreeOwner*>(this)),
|
2006-02-07 23:46:39 +03:00
|
|
|
"Parent from wrong docshell tree?");
|
|
|
|
#endif
|
|
|
|
|
2012-06-13 02:01:25 +04: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);
|
2016-10-15 04:46:26 +03:00
|
|
|
if (docshell && docshell->GetIsInMozBrowser() &&
|
2012-06-13 02:01:25 +04:00
|
|
|
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
|
2013-09-10 08:18:46 +04:00
|
|
|
|
|
|
|
BrowserElementParent::OpenWindowResult opened =
|
2016-01-30 20:05:36 +03:00
|
|
|
BrowserElementParent::OpenWindowInProcess(parent, aURI, aName,
|
2016-10-27 19:37:44 +03:00
|
|
|
aFeatures, aForceNoOpener, aReturn);
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2013-09-10 08:18:46 +04:00
|
|
|
// If OpenWindowInProcess handled the open (by opening it or blocking the
|
2012-06-13 02:01:25 +04:00
|
|
|
// popup), tell our caller not to proceed trying to create a new window
|
|
|
|
// through other means.
|
2013-09-10 08:18:46 +04: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));
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2013-09-10 08:18:46 +04:00
|
|
|
if (info && found) {
|
|
|
|
info->LaunchWithURI(aURI, nullptr);
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 02:01:25 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 22:07:47 +04:00
|
|
|
int32_t openLocation =
|
2016-01-30 20:05:36 +03:00
|
|
|
nsWindowWatcher::GetWindowOpenLocation(parent, aChromeFlags, aCalledFromJS,
|
2014-06-20 22:07:47 +04:00
|
|
|
aPositionSpecified, aSizeSpecified);
|
2013-02-18 15:27:48 +04:00
|
|
|
|
2014-06-20 22:07:47 +04:00
|
|
|
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
|
|
|
|
openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
2006-02-07 23:46:39 +03:00
|
|
|
// Just open a window normally
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWin;
|
2006-02-07 23:46:39 +03: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 22:07:47 +04:00
|
|
|
|
2006-02-07 23:46:39 +03:00
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
|
|
|
|
chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
|
|
|
|
if (!browserDOMWin) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-06-20 22:07:47 +04:00
|
|
|
*aWindowIsNew = (openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
|
2007-12-14 20:27:31 +03:00
|
|
|
|
2009-01-17 05:05:14 +03:00
|
|
|
{
|
2014-04-15 07:27:00 +04:00
|
|
|
dom::AutoNoJSAPI nojsapi;
|
2009-01-17 05:05:14 +03:00
|
|
|
|
2016-10-27 19:37:44 +03:00
|
|
|
uint32_t flags = nsIBrowserDOMWindow::OPEN_NEW;
|
|
|
|
if (aForceNoOpener) {
|
|
|
|
flags |= nsIBrowserDOMWindow::OPEN_NO_OPENER;
|
|
|
|
}
|
|
|
|
|
2017-08-03 18:21:11 +03:00
|
|
|
// Get a new rendering area from the browserDOMWin.
|
|
|
|
// Since we are not loading any URI, we follow the principle of least
|
|
|
|
// privilege and use a nullPrincipal as the triggeringPrincipal.
|
2016-10-07 21:59:59 +03:00
|
|
|
//
|
|
|
|
// This method handles setting the opener for us, so we don't need to set it
|
|
|
|
// ourselves.
|
2018-03-22 21:36:20 +03:00
|
|
|
RefPtr<NullPrincipal> nullPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
|
2017-08-03 18:21:11 +03:00
|
|
|
return browserDOMWin->CreateContentWindow(aURI, aParent, openLocation,
|
|
|
|
flags, nullPrincipal, aReturn);
|
2009-01-17 05:05:14 +03:00
|
|
|
}
|
2006-02-07 23:46:39 +03:00
|
|
|
}
|
|
|
|
|
2000-01-22 06:15:41 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsContentTreeOwner: Accessors
|
2011-01-25 21:13:43 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsContentTitleSettingEvent : public Runnable
|
2011-01-25 21:13:43 +03:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 10:54:08 +04:00
|
|
|
nsContentTitleSettingEvent(dom::Element* dse, const nsAString& wtm)
|
2017-06-12 22:34:10 +03:00
|
|
|
: Runnable("nsContentTitleSettingEvent"),
|
|
|
|
mElement(dse),
|
2011-01-25 21:13:43 +03:00
|
|
|
mTitleDefault(wtm) {}
|
|
|
|
|
2016-08-08 05:18:10 +03:00
|
|
|
NS_IMETHOD Run() override
|
2011-01-25 21:13:43 +03:00
|
|
|
{
|
2013-07-18 10:54:08 +04:00
|
|
|
ErrorResult rv;
|
|
|
|
mElement->SetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault, rv);
|
|
|
|
mElement->RemoveAttribute(NS_LITERAL_STRING("titlemodifier"), rv);
|
2011-01-25 21:13:43 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-07-18 10:54:08 +04:00
|
|
|
nsCOMPtr<dom::Element> mElement;
|
2011-01-25 21:13:43 +03:00
|
|
|
nsString mTitleDefault;
|
|
|
|
};
|
|
|
|
#endif
|
2000-01-22 06:15:41 +03:00
|
|
|
|
|
|
|
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
|
|
|
{
|
|
|
|
mXULWindow = aXULWindow;
|
2012-10-02 12:24:10 +04:00
|
|
|
if (mXULWindow && mPrimary) {
|
2000-02-15 13:20:41 +03:00
|
|
|
// Get the window title modifiers
|
2013-07-18 10:54:08 +04:00
|
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
2000-02-15 13:20:41 +03:00
|
|
|
|
|
|
|
nsAutoString contentTitleSetting;
|
|
|
|
|
2013-07-18 10:54:08 +04:00
|
|
|
if(docShellElement)
|
2000-02-15 13:20:41 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("contenttitlesetting"), contentTitleSetting);
|
2004-05-23 02:15:22 +04:00
|
|
|
if(contentTitleSetting.EqualsLiteral("true"))
|
2000-02-15 13:20:41 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mContentTitleSetting = true;
|
2003-08-12 09:51:39 +04:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault);
|
2001-11-14 04:33:42 +03:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
|
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
|
2013-07-18 10:54:08 +04:00
|
|
|
|
2008-09-15 17:07:44 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2003-08-12 09:51:39 +04: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 21:13:43 +03:00
|
|
|
NS_DispatchToCurrentThread(
|
|
|
|
new nsContentTitleSettingEvent(docShellElement,
|
|
|
|
mWindowTitleModifier));
|
2003-08-12 09:51:39 +04:00
|
|
|
mTitleDefault = mWindowTitleModifier;
|
|
|
|
mWindowTitleModifier.Truncate();
|
|
|
|
}
|
|
|
|
#endif
|
2005-10-15 03:39:45 +04:00
|
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemenuseparator"), mTitleSeparator);
|
2000-02-15 13:20:41 +03: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 06:15:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXULWindow* nsContentTreeOwner::XULWindow()
|
|
|
|
{
|
|
|
|
return mXULWindow;
|
2000-01-27 08:59:44 +03:00
|
|
|
}
|
2000-01-27 09:05:39 +03:00
|
|
|
|
2002-01-05 05:22:45 +03:00
|
|
|
//*****************************************************************************
|
2012-06-10 02:15:12 +04:00
|
|
|
//*** nsSiteWindow implementation
|
2002-01-05 05:22:45 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::nsSiteWindow(nsContentTreeOwner *aAggregator)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
mAggregator = aAggregator;
|
|
|
|
}
|
|
|
|
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::~nsSiteWindow()
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-10 02:15:12 +04:00
|
|
|
NS_IMPL_ADDREF_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
|
|
|
NS_IMPL_RELEASE_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
2002-01-05 05:22:45 +03:00
|
|
|
|
2012-06-10 02:15:12 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSiteWindow)
|
2002-01-05 05:22:45 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2002-01-16 03:11:29 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
2002-01-05 05:22:45 +03:00
|
|
|
NS_INTERFACE_MAP_END_AGGREGATED(mAggregator)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSiteWindow::SetDimensions(uint32_t aFlags,
|
|
|
|
int32_t aX, int32_t aY, int32_t aCX, int32_t aCY)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
// XXX we're ignoring aFlags
|
2016-05-12 03:07:45 +03:00
|
|
|
return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY,
|
|
|
|
nsIBaseWindow::eRepaint);
|
2002-01-05 05:22:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSiteWindow::GetDimensions(uint32_t aFlags,
|
|
|
|
int32_t *aX, int32_t *aY, int32_t *aCX, int32_t *aCY)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
// XXX we're ignoring aFlags
|
|
|
|
return mAggregator->GetPositionAndSize(aX, aY, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::SetFocus(void)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
2002-01-16 03:11:29 +03: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 05:22:45 +03:00
|
|
|
nsXULWindow *window = mAggregator->XULWindow();
|
|
|
|
if (window) {
|
|
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
|
|
window->GetDocShell(getter_AddRefs(docshell));
|
2014-01-10 06:03:47 +04:00
|
|
|
if (docShell) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> domWindow(docShell->GetWindow());
|
2014-01-10 06:03:47 +04:00
|
|
|
if (domWindow)
|
|
|
|
domWindow->Focus();
|
|
|
|
}
|
2002-01-05 05:22:45 +03:00
|
|
|
}
|
2002-01-16 03:11:29 +03:00
|
|
|
#endif
|
2002-01-05 05:22:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this implementation focuses another window. if there isn't another
|
|
|
|
window to focus, we do nothing. */
|
|
|
|
NS_IMETHODIMP
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::Blur(void)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
2013-12-04 02:03:45 +04:00
|
|
|
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
|
|
|
2002-01-05 05:22:45 +03:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWindow;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool more, foundUs;
|
2002-01-05 05:22:45 +03:00
|
|
|
nsXULWindow *ourWindow = mAggregator->XULWindow();
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
|
|
if (windowMediator)
|
2011-10-17 18:59:28 +04:00
|
|
|
windowMediator->GetZOrderXULWindowEnumerator(0, true,
|
2002-01-05 05:22:45 +03:00
|
|
|
getter_AddRefs(windowEnumerator));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!windowEnumerator)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// step through the top-level windows
|
2011-10-17 18:59:28 +04:00
|
|
|
foundUs = false;
|
2002-01-05 05:22:45 +03: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 18:59:28 +04:00
|
|
|
foundUs = true;
|
2002-01-05 05:22:45 +03: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 06:03:47 +04:00
|
|
|
if (!docshell) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> domWindow = docshell->GetWindow();
|
2002-01-05 05:22:45 +03:00
|
|
|
if (domWindow)
|
|
|
|
domWindow->Focus();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::GetVisibility(bool *aVisibility)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
return mAggregator->GetVisibility(aVisibility);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::SetVisibility(bool aVisibility)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
return mAggregator->SetVisibility(aVisibility);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-09-25 06:10:51 +03:00
|
|
|
nsSiteWindow::GetTitle(nsAString& aTitle)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
return mAggregator->GetTitle(aTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-09-25 06:10:51 +03:00
|
|
|
nsSiteWindow::SetTitle(const nsAString& aTitle)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
return mAggregator->SetTitle(aTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-10 02:15:12 +04:00
|
|
|
nsSiteWindow::GetSiteWindow(void **aSiteWindow)
|
2002-01-05 05:22:45 +03:00
|
|
|
{
|
|
|
|
return mAggregator->GetParentNativeWindow(aSiteWindow);
|
|
|
|
}
|
|
|
|
|