mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 23:06:52 +00:00
e39f9f88f7
- Bug 1152171 part 2 - Rename AnimationTimeline to DocumentTimeline; r=smaug (26c118319) - Bug 1152171 part 3 - Update web-platform-tests expectations; r=jgraham (b7b4032aa) - Bug 1153734 part 1 - Remove AnimationEffect; r=smaug (9cf67a02e) - Bug 1153734 part 2 - Rename Animation to KeyframeEffectReadonly; r=smaug (b69556ee6) - Bug 1153734 part 3 - Rename AnimationPlayer.source to AnimationPlayer.effect; r=smaug (50d3130ee) - Bug 1153734 part 4 - Rename other uses of 'source' and 'source content'; r=jwatt (b02c4ba36) - Bug 1153734 part 5 - Add AnimationEffectReadonly as a superinterface of KeyframeEffectReadonly; r=smaug (c3395d3f5) - Bug 1149990 - Support replaying of finished CSS transitions by supporting setting of currentTime/startTime. r=birtles (3fb2cb401) - Bug 1154615 part 1 - Rename AnimationPlayer to Animation in WebIDL; r=smaug (6c2125b49) - Bug 1154615 part 2 - Rename PendingPlayerTracker to PendingAnimationTracker; r=jwatt (8d6804def) - Bug 1154615 part 3 - Rename internal members of PendingAnimationTracker; r=jwatt (f348f6355) - Bug 1154615 part 4 - Rename references to players in dom/animation; r=jwatt (0250572e8) - Bug 1117603 part 1 - Don't assume style rules have been refreshed in GetAnimationRule; r=dbaron (a5d340d0f) - remove kungFuDeathGrip (49df758e6) - Bug 1117603 part 2 - Don't unregister from the refresh driver unless we are also queueing events; r=dbaron (715c9caa1) - Bug 1154615 part 5 - Rename AnimationPlayerCollection to AnimationCollection; r=jwatt (4c596f089) - Bug 1154615 part 6 - Rename references to players within layout/; r=jwatt (42405f3fc) - Bug 1154615 part 7 - Rename CSSAnimationPlayer and CSSTransitionPlayer; r=jwatt (49ab272ed) - Bug 1154615 part 8 - Rename references to players in animation observers; r=jwatt (c3fa26d7a) - Bug 1154615 part 9 - Rename test files; r=jwatt (9d9f03e7b) - Bug 1145439 (Part 1) - Throttle requestAnimationFrame for non-visible iframes. r=mstange,mchang (be7d183d6) - Bug 1145439 (Part 2) - Make test_scroll_event_ordering.html wait for rAF to unthrottle. r=roc (9ac8317c9) - Bug 1144324 - Try to register for, and handle, touch events when APZ is enabled. r=dvander,jimm (fb75d1665) - Bug 1144324 - Remove the codepaths that conditionally enable touch events based on touch the presence of touch listeners. r=smaug,jimm (710617e6b) - Bug 1003991 - Disable https:// only load for ServiceWorkers when Developer Tools are open. r=nsm, r=miker (9d6669814) - Bug 1153267 - part 1 - use smart-pointer .forget() instead of NS_ADDREF+assign; r=ehsan (e4555c90c) - Bug 1153267 - part 2 - use smart pointers instead of manual NS_ADDREF'ing outparams; r=ehsan (ae8b60d5a) - Bug 1153267 - fix typo that broke OS X builds on a CLOSED TREE; r=bustage (08fdb3c4f) - Bug 1146843 - Revert part of cset 33c30e283fa8 because the code is used in Fennec. r=snorp (407248257) - Bug 1151940 part 1. Make some readonly properties defined on Window by CSSOM-view replaceable. r=smaug (5cb9b91f0) - Bug 1151940 part 2. Add a convenience function in nsGlobalWindow for replacing a property on the window with a new value. r=smaug (2ba39331c) - Bug 1151940 part 3. Make some writable cssom-view attributes that we only allow setting from chrome act the way readonly replaceables would when called from content. r=smaug (b485e1b44) - Goanna -> Gecko (2c539d7be) - Goanna -> Gecko (25d34e213) - Bug 1148962 - Use TakeOwnershipOfErrorReporting in CPOW code (r=bholley) (96c997639) - pointer style (a07fbffaa) - Bug 1152577: Add 'aReason' argument to AutoEntryScript constructor, and provide plausible names for its instantiations. r=bholley (512fa27e2) - bug 1155691 - Expose WindowRoot to chrome from window in webidl. r=smaug (235281924) - Bug 404828 - No need to assert that the top window isn't reachable. r=smaug (d73154fa0) - Bug 404828 - Followup: remove assertion expectations on a CLOSED TREE. a=tomcat (a5dabe1b7) - Bug 1156102 - Mark nsGlobalWindowObserver::mWindow as MOZ_NON_OWNING_REF; r=baku (c0d4208b7) - Bug 1107801 - Improve gamepad support on MacOS. r=ted (c591bd5ac) - Goanna -> Gecko (d9b81bc9e) - Bug 852944 - Gamepad API IPC; r=ted, r=baku (521892538) - Bug 1143529 part 1. Stop manually calling WrapObject in DataStoreService::GetDataStoresResolve. r=baku (056ad6bfe) - Bug 1143529 part 2. Tighten up the assert in binding Wrap methods. r=peterv (765a13325) - Bug 1152169 - DataStoreService should check if the first revision exists, r=bent (ee371cc5d) - Bug 1152169 followup: Mark FirstRevisionIdCallback methods Run() and HandleEvent() as 'override'. rs=ehsan (8186c4168) - Bug 1143651 - don't use CallQueryInterface when the compiler can do the cast for us; r=ehsan (a50f0a54b) - Bug 1144322 - Handle tabindex in overridden IsInteractiveHTMLContent methods. r=smaug (fd4b9beed) - Bug 1086684 - Stash the full path for file inputs to avoid doing IPC at inopportune times. r=ehsan/bent/gps (b843b1efc) - Bug 1143934 - Disallow mozSetFileNameArray in content processes. r=ehsan (42e5c8c6d) - Bug 1143934 - Fix assorted forms mochitests for e10s-compatibility. r=smaug (7a3babfed) - Bug 1143934 - Work around SessionStore dependency on current brokenness. r=ttaubert (5b0fcb5ce) - Bug 956530 - Clear the delayed caret data when clicking on a selected part of a text control if the focus event handler selects the control; r=roc (2859f07b4) - Bug 956530 follow-up: Fix the test failure on Windows 8 caused by the text box having a glowing outline as a result of being clicked on (d34e8da1a) - Bug 1157898 part 1. Make code of the form "return rv.ErrorCode();" where rv is an ErrorResult use StealNSResult instead. r=peterv (800da50e2) - Bug 1157898 part 2. Make code of the form "NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());" use Failed and StealNSResult instead. r=peterv (472432a83) - Bug 1157898 part 3. Fix the remaining consumers of rv.ErrorCode() in NS_ENSURE_* expressions to not do that. r=peterv (d452807e7) - Bug 1122238 part 1. Switch to using the new stackframe APIs in JSStackFrame. r=bholley (9d87b261a) - Bug 1122238 part 2. Stop caching things in JSStackFrame when we're called over Xrays. r=bholley (83eda7275) - Bug 1122238 part 3. Drop all the DOMException-cloning and sanitization gunk we added in bug 1107592 and bug 1107953 and bug 1117242 . r=bholley (f237aa948) - add support for NetBSD/SPARC64 (065783b70) - Bug 1153484 - Fetch should ignore invalid headers, but still process later headers. r=nsm (8925ddd77) - Bug 1157754 part 2. Convert consumers of ErrorResult::ClearMessage() to the new better APIs we have for suppressing exceptions on ErrorResult. r=bkelly (6519fbd5e) - Bug 1157754 part 3. Make ClearMessage private on ErrorResult. r=peterv (3fb218692) - Bug 1157898 part 4. Add ErrorResult::ErrorCodeIs() and use it in various places to get rid of ErrorCode(). r=peterv (bed7bfb4c) - Bug 1130686 - Refactor PromiseHolder in the service worker clients code. r=nsm (b3dbdcbfe) - Bug 1130686 - Implement client.focus. r=baku (5dee6d850) - Bug 1149163 part 1 - Clean up nsHTMLEditRules::GetInnerContent; r=froydnj (cc8f65b54) - Bug 1149163 part 2 - Make nsDOMIterator infallible; r=froydnj (d975f6c62) - Bug 1149163 part 3 - Clean up nsHTMLEditRules::BustUpInlinesAtBRs; r=froydnj (58155adad) - Bug 1149163 part 4 - Allow use of temporary nsBoolDomIterFunctor; r=froydnj (dbafec00f) - Bug 1149163 part 5 - Clean up nsHTMLEditRules::GetNodesForOperation; r=froydnj (41179d810) - Bug 1149163 part 6 - Clean up nsHTMLEditRules::LookInsideDivBQandList; r=froydnj (0b757bf14) - Bug 1149163 part 7 - Clean up nsHTMLEditRules::PromoteRange; r=froydnj (c49c714b1) - Bug 1149163 part 8 - Clean up nsHTMLEditRules::GetPromotedRanges; r=froydnj (5163a0026) - Bug 1148228 - Stop checking ul twice (43a22088c) - Bug 1141017 - resurrect serif and monospace. r=ehsan (95a1b6fcf) - Bug 1147412 part 1 - Make methods take nsINode*, not just nsIContent*; r=ehsan (7f762cdbe) - Bug 1147412 part 2 - Clean up nsHTMLEditor::SetInlinePropertyOnTextNode; r=ehsan (faf805587) - Bug 1147412 part 3 - Fix completely broken nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet implementation; r=ehsan (73fea67c1) - Bug 1147412 part 4 - Clean up nsHTMLEditor::GetInlinePropertyBase; r=ehsan (3265bfbce) - Bug 1147412 part 5 - Clean up nsHTMLEditor::RemoveInlinePropertyImpl; r=ehsan (0f402bd7e) - Bug 1147412 part 6 - Remove nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode*,...); r=ehsan (100e4038a) - Bug 1147412 part 7 - Remove nsHTMLCSSUtils::GetComputedStyle(nsIDOMElement*); r=ehsan (6c51103bc) - Bug 1147412 part 8 - Clean up nsHTMLCSSUtils::IsCSSInvertible; r=ehsan (01e60c446) - Bug 1147412 part 9 - Convert some nsHTMLEditor members to Element; r=ehsan (e7efb1ac4) - Bug 1147412 part 10 - Clean up nsHTMLCSSUtils::Get*Property, GetCSSInlinePropertyBase; r=ehsan (54154143d) - Bug 1149163 part 9 - Clean up nsHTMLEditRules::GetNodesFromSelection; r=froydnj (5186308b9) - Bug 1154701 part 1 - Clean up nsHTMLEditor::CreateListOfNodesToPaste; r=ehsan (ea95238d5) - Bug 1153629 part 1 - Clean up nsHTMLEditRules::GetListActionNodes; r=ehsan (51f3b3e95) - Bug 1153629 part 2 - Clean up nsHTMLEditRules::GetParagraphFormatNodes; r=ehsan (a27bd7751) - Bug 1153629 part 3 - Clean up nsHTMLEditRules::GetNodesFromPoint; r=ehsan (edc7e4561) - Bug 1153629 part 4 - Clean up nsHTMLEditRules::ListIsEmptyLine; r=ehsan (ce3289bc7) - Bug 1153629 part 5 - Clean up nsHTMLEditRules::GetChildNodesForOperation; r=ehsan (b3a509dbf) - Bug 1153629 part 6 - Clean up nsHTMLEditRules::MakeBlockquote; r=ehsan (cb3808182) - Bug 1153629 part 7 - Clean up nsHTMLEditRules::RemoveBlockStyle, RemovePartOfBlock; r=ehsan (660b9f76e) - Bug 1153629 part 8 - Clean up nsHTMLEditRules::ApplyBlockStyle; r=ehsan (f54f9538c) - Bug 1153629 part 9 - Clean up nsHTMLEditRules::MakeTransitionList; r=ehsan (fb63cf6d8) - Bug 1153629 part 10 - Clean up nsHTMLEditRules::AlignInnerBlocks; r=ehsan (752d2df7a) - Bug 1153629 part 11 - Clean up nsHTMLEditRules::AdjustSpecialBreaks; r=ehsan (16ef0416b) - Bug 1153629 part 12 - Clean up nsHTMLEditRules::RemoveEmptyNodes; r=ehsan (d528e70e6) - Bug 1154701 part 2 - Use more OwningNonNull in editor; r=ehsan (85b1929e6) - Bug 1154701 part 3 - Clean up nsHTMLEditor::GetListAndTableParents, DiscoverPartialListsAndTables, ScanForListAndTableStructure, ReplaceOrphanedStructure; r=ehsan (7fe31f058) - Bug 1154701 part 4 - Switch nsHTMLEditor::mContentFilters to nsTArray; r=ehsan (64e6dd160) - Bug 1154701 part 5 - Switch nsHTMLEditor::objectResizeEventListeners to nsTArray; r=ehsan (036bc65fe) - Bug 1154701 part 6 - Clean up nsHTMLEditor::SetInlinePropertyOnNodeImpl; r=ehsan (2d619ca16) - Bug 1154701 part 7 - Clean up nsHTMLEditor::SetInlineProperty; r=ehsan (7a367d31b) - Bug 1154701 part 8 - Clean up nsHTMLEditor::SetInlinePropertyOnNode; r=ehsan (707c07d93) - Bug 1154701 part 9 - Clean up nsHTMLEditor::RelativeFontChange; r=ehsan (273ae9c64) - Bug 1154701 part 10 - Switch nsEditor::mActionListeners to nsTArray; r=ehsan (d2b5732fe) - Bug 1154701 part 11 - Switch nsEditor::mEditorObservers to nsTArray; r=ehsan (25a5af12e) - Bug 1154701 part 12 - Switch nsEditor::mDocStateListeners to nsTArray; r=ehsan (665af0792) - Bug 1154701 part 13 - Clean up nsHTMLEditor::SetCSSBackgroundColor; r=ehsan (ba424ade8) - Bug 1154701 part 14 - Remove unused nsCOMArray cruft; r=ehsan (3a8679a67) - Bug 1101651 - Part 1: xpcomrt version of dom media library need for standalone webrtcs. r=jesup (ae37b5464) - Bug 1137447 - New app update telemetry for patch type (complete or partial), extended error codes, and general cleanup. r=bbondy (c736ae502)
1155 lines
36 KiB
C++
1155 lines
36 KiB
C++
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: set ts=2 sw=2 et tw=79:
|
|
*
|
|
* 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/. */
|
|
|
|
// Local Includes
|
|
#include "nsContentTreeOwner.h"
|
|
#include "nsXULWindow.h"
|
|
|
|
// Helper Classes
|
|
#include "nsIServiceManager.h"
|
|
#include "nsAutoPtr.h"
|
|
|
|
// Interfaces needed to be included
|
|
#include "nsIDOMNode.h"
|
|
#include "nsIDOMElement.h"
|
|
#include "nsIDOMNodeList.h"
|
|
#include "nsIDOMWindow.h"
|
|
#include "nsIDOMChromeWindow.h"
|
|
#include "nsIBrowserDOMWindow.h"
|
|
#include "nsIDOMXULElement.h"
|
|
#include "nsIEmbeddingSiteWindow.h"
|
|
#include "nsIPrompt.h"
|
|
#include "nsIAuthPrompt.h"
|
|
#include "nsIWindowMediator.h"
|
|
#include "nsIXULBrowserWindow.h"
|
|
#include "nsIPrincipal.h"
|
|
#include "nsIURIFixup.h"
|
|
#include "nsCDefaultURIFixup.h"
|
|
#include "nsIWebNavigation.h"
|
|
#include "nsDocShellCID.h"
|
|
#include "nsIExternalURLHandlerService.h"
|
|
#include "nsIMIMEInfo.h"
|
|
#include "nsIWidget.h"
|
|
#include "nsWindowWatcher.h"
|
|
#include "mozilla/BrowserElementParent.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
#include "nsIURI.h"
|
|
#include "nsIDocument.h"
|
|
#if defined(XP_MACOSX)
|
|
#include "nsThreadUtils.h"
|
|
#endif
|
|
|
|
#include "mozilla/Preferences.h"
|
|
#include "mozilla/dom/Element.h"
|
|
#include "mozilla/dom/ScriptSettings.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
//*****************************************************************************
|
|
//*** nsSiteWindow declaration
|
|
//*****************************************************************************
|
|
|
|
class nsSiteWindow : public nsIEmbeddingSiteWindow
|
|
{
|
|
public:
|
|
explicit nsSiteWindow(nsContentTreeOwner *aAggregator);
|
|
virtual ~nsSiteWindow();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
|
|
|
private:
|
|
nsContentTreeOwner *mAggregator;
|
|
};
|
|
|
|
namespace mozilla {
|
|
template<>
|
|
struct HasDangerousPublicDestructor<nsSiteWindow>
|
|
{
|
|
static const bool value = true;
|
|
};
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//*** nsContentTreeOwner: Object Management
|
|
//*****************************************************************************
|
|
|
|
nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) : mXULWindow(nullptr),
|
|
mPrimary(fPrimary), mContentTitleSetting(false)
|
|
{
|
|
// note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
|
|
mSiteWindow = new nsSiteWindow(this);
|
|
}
|
|
|
|
nsContentTreeOwner::~nsContentTreeOwner()
|
|
{
|
|
delete mSiteWindow;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsISupports
|
|
//*****************************************************************************
|
|
|
|
NS_IMPL_ADDREF(nsContentTreeOwner)
|
|
NS_IMPL_RELEASE(nsContentTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsContentTreeOwner)
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner)
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner)
|
|
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome3)
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
|
// NOTE: This is using aggregation because there are some properties and
|
|
// 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....
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIEmbeddingSiteWindow, mSiteWindow)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIInterfaceRequestor
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
|
*aSink = 0;
|
|
|
|
if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
|
}
|
|
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetInterface(aIID, aSink);
|
|
}
|
|
if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
nsCOMPtr<nsIDocShell> shell;
|
|
mXULWindow->GetDocShell(getter_AddRefs(shell));
|
|
if (shell)
|
|
return shell->QueryInterface(aIID, aSink);
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
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;
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->QueryInterface(aIID, aSink);
|
|
}
|
|
|
|
return QueryInterface(aIID, aSink);
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIDocShellTreeOwner
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const char16_t* aName,
|
|
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
|
|
nsIDocShellTreeItem** aFoundItem)
|
|
{
|
|
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
|
|
NS_ENSURE_ARG_POINTER(aFoundItem);
|
|
|
|
*aFoundItem = nullptr;
|
|
|
|
bool fIs_Content = false;
|
|
|
|
/* Special Cases */
|
|
if (!aName || !*aName)
|
|
return NS_OK;
|
|
|
|
nsDependentString name(aName);
|
|
|
|
if (name.LowerCaseEqualsLiteral("_blank"))
|
|
return NS_OK;
|
|
// _main is an IE target which should be case-insensitive but isn't
|
|
// see bug 217886 for details
|
|
if (name.LowerCaseEqualsLiteral("_content") ||
|
|
name.EqualsLiteral("_main")) {
|
|
// 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.
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
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
|
|
|
|
int32_t count = mXULWindow->mTargetableShells.Count();
|
|
for (int32_t i = 0; i < count; ++i) {
|
|
nsCOMPtr<nsIDocShellTreeItem> item =
|
|
do_QueryReferent(mXULWindow->mTargetableShells[i]);
|
|
if (SameCOMIdentity(item, aRequestor)) {
|
|
NS_ADDREF(*aFoundItem = aRequestor);
|
|
return NS_OK;
|
|
}
|
|
}
|
|
}
|
|
mXULWindow->GetPrimaryContentShell(aFoundItem);
|
|
if(*aFoundItem)
|
|
return NS_OK;
|
|
// Fall through and keep looking...
|
|
fIs_Content = true;
|
|
}
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nullptr,
|
|
getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
|
|
|
|
bool more;
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
while(more) {
|
|
nsCOMPtr<nsISupports> nextWindow = nullptr;
|
|
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) {
|
|
int32_t count = win->mTargetableShells.Count();
|
|
int32_t i;
|
|
for (i = 0; i < count && !*aFoundItem; ++i) {
|
|
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) {
|
|
// Do this so we can pass in the tree owner as the
|
|
// requestor so the child knows not to call back up.
|
|
nsCOMPtr<nsIDocShellTreeOwner> shellOwner;
|
|
shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner));
|
|
nsCOMPtr<nsISupports> shellOwnerSupports =
|
|
do_QueryInterface(shellOwner);
|
|
|
|
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports,
|
|
aOriginalRequestor,
|
|
aFoundItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (*aFoundItem)
|
|
return NS_OK;
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
|
bool aPrimary, bool aTargetable,
|
|
const nsAString& aID)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aTargetable,
|
|
aID);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->ContentShellRemoved(aContentShell);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetPrimaryContentShell(aShell);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
|
int32_t aCX, int32_t aCY)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::SetPersistence(bool aPersistPosition,
|
|
bool aPersistSize,
|
|
bool aPersistSizeMode)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
|
if (!docShellElement)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
nsAutoString persistString;
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
|
|
|
bool saveString = false;
|
|
int32_t index;
|
|
|
|
// Set X
|
|
index = persistString.Find("screenX");
|
|
if (!aPersistPosition && index >= 0) {
|
|
persistString.Cut(index, 7);
|
|
saveString = true;
|
|
} else if (aPersistPosition && index < 0) {
|
|
persistString.AppendLiteral(" screenX");
|
|
saveString = true;
|
|
}
|
|
// Set Y
|
|
index = persistString.Find("screenY");
|
|
if (!aPersistPosition && index >= 0) {
|
|
persistString.Cut(index, 7);
|
|
saveString = true;
|
|
} else if (aPersistPosition && index < 0) {
|
|
persistString.AppendLiteral(" screenY");
|
|
saveString = true;
|
|
}
|
|
// Set CX
|
|
index = persistString.Find("width");
|
|
if (!aPersistSize && index >= 0) {
|
|
persistString.Cut(index, 5);
|
|
saveString = true;
|
|
} else if (aPersistSize && index < 0) {
|
|
persistString.AppendLiteral(" width");
|
|
saveString = true;
|
|
}
|
|
// Set CY
|
|
index = persistString.Find("height");
|
|
if (!aPersistSize && index >= 0) {
|
|
persistString.Cut(index, 6);
|
|
saveString = true;
|
|
} else if (aPersistSize && index < 0) {
|
|
persistString.AppendLiteral(" height");
|
|
saveString = true;
|
|
}
|
|
// Set SizeMode
|
|
index = persistString.Find("sizemode");
|
|
if (!aPersistSizeMode && (index >= 0)) {
|
|
persistString.Cut(index, 8);
|
|
saveString = true;
|
|
} else if (aPersistSizeMode && (index < 0)) {
|
|
persistString.AppendLiteral(" sizemode");
|
|
saveString = true;
|
|
}
|
|
|
|
ErrorResult rv;
|
|
if(saveString) {
|
|
docShellElement->SetAttribute(NS_LITERAL_STRING("persist"), persistString, rv);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::GetPersistence(bool* aPersistPosition,
|
|
bool* aPersistSize,
|
|
bool* aPersistSizeMode)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
|
if (!docShellElement)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
nsAutoString persistString;
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
|
|
|
|
// 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)
|
|
*aPersistPosition = persistString.Find("screenX") >= 0 || persistString.Find("screenY") >= 0 ? true : false;
|
|
if (aPersistSize)
|
|
*aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? true : false;
|
|
if (aPersistSizeMode)
|
|
*aPersistSizeMode = persistString.Find("sizemode") >= 0 ? true : false;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::GetTargetableShellCount(uint32_t* aResult)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
*aResult = mXULWindow->mTargetableShells.Count();
|
|
return NS_OK;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIWebBrowserChrome3
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &originalTarget,
|
|
nsIURI *linkURI,
|
|
nsIDOMNode *linkNode,
|
|
bool isAppTab,
|
|
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;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
|
nsIURI *aURI,
|
|
nsIURI *aReferrer,
|
|
bool *_retval)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
|
|
|
if (xulBrowserWindow)
|
|
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer, _retval);
|
|
|
|
*_retval = true;
|
|
return NS_OK;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIWebBrowserChrome2
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatusWithContext(uint32_t aStatusType,
|
|
const nsAString &aStatusText,
|
|
nsISupports *aStatusContext)
|
|
{
|
|
// We only allow the status to be set from the primary content shell
|
|
if (!mPrimary && aStatusType != STATUS_LINK)
|
|
return NS_OK;
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIWebBrowserChrome
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetStatus(uint32_t aStatusType,
|
|
const char16_t* aStatus)
|
|
{
|
|
return SetStatusWithContext(aStatusType,
|
|
aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
|
|
: EmptyString(),
|
|
nullptr);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetWebBrowser(nsIWebBrowser* aWebBrowser)
|
|
{
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|
{
|
|
// Unimplemented, and probably will remain so; xpfe windows have docshells,
|
|
// not webbrowsers.
|
|
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
|
*aWebBrowser = 0;
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(uint32_t aChromeFlags)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetChromeFlags(aChromeFlags);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(uint32_t* aChromeFlags)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetChromeFlags(aChromeFlags);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::DestroyBrowserWindow()
|
|
{
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(int32_t aCX, int32_t aCY)
|
|
{
|
|
NS_ERROR("Haven't Implemented this yet");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ShowAsModal()
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->ShowModal();
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(bool *_retval)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
*_retval = mXULWindow->mContinueModalLoop;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::ExitModalEventLoop(nsresult aStatus)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->ExitModalLoop(aStatus);
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner::nsIBaseWindow
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
|
nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
|
|
{
|
|
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Create()
|
|
{
|
|
NS_ASSERTION(false, "You can't call this");
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Destroy()
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->Destroy();
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetPosition(aX, aY);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPosition(int32_t* aX, int32_t* aY)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetPosition(aX, aY);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetSize(aCX, aCY, aRepaint);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetSize(aCX, aCY);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY,
|
|
int32_t aCX, int32_t aCY, bool aRepaint)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY,
|
|
int32_t* aCX, int32_t* aCY)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::Repaint(bool aForce)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->Repaint(aForce);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetParentWidget(aParentWidget);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
|
{
|
|
NS_ASSERTION(false, "You can't call this");
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetParentNativeWindow(aParentNativeWindow);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
|
{
|
|
NS_ASSERTION(false, "You can't call this");
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(nsAString& aNativeHandle)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetNativeHandle(aNativeHandle);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetVisibility(aVisibility);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(bool aVisibility)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetVisibility(aVisibility);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetEnabled(bool *aEnabled)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->GetEnabled(aEnabled);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetEnabled(bool aEnable)
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetEnabled(aEnable);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aMainWidget);
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
*aMainWidget = mXULWindow->mWindow;
|
|
NS_IF_ADDREF(*aMainWidget);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetFocus()
|
|
{
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
return mXULWindow->SetFocus();
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::GetTitle(char16_t** aTitle)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aTitle);
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
return mXULWindow->GetTitle(aTitle);
|
|
}
|
|
|
|
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const char16_t* aTitle)
|
|
{
|
|
// We only allow the title to be set from the primary content shell
|
|
if(!mPrimary || !mContentTitleSetting)
|
|
return NS_OK;
|
|
|
|
NS_ENSURE_STATE(mXULWindow);
|
|
|
|
nsAutoString title;
|
|
nsAutoString docTitle(aTitle);
|
|
|
|
if (docTitle.IsEmpty())
|
|
docTitle.Assign(mTitleDefault);
|
|
|
|
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;
|
|
}
|
|
|
|
if (!mWindowTitleModifier.IsEmpty())
|
|
title += mTitleSeparator + mWindowTitleModifier;
|
|
}
|
|
else
|
|
title.Assign(mWindowTitleModifier); // Title will just be plain "Mozilla"
|
|
|
|
//
|
|
// 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.
|
|
//
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
|
|
|
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));
|
|
nsCOMPtr<nsIScriptObjectPrincipal> doc =
|
|
do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
|
|
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) {
|
|
// (don't bother if there's no host)
|
|
nsAutoCString host;
|
|
nsAutoCString prepath;
|
|
tmpuri->GetHost(host);
|
|
tmpuri->GetPrePath(prepath);
|
|
if (!host.IsEmpty()) {
|
|
//
|
|
// We have a scheme/host, update the title
|
|
//
|
|
title.Insert(NS_ConvertUTF8toUTF16(prepath) +
|
|
mTitleSeparator, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
nsIDocument* document = docShellElement->OwnerDoc();
|
|
ErrorResult rv;
|
|
document->SetTitle(title, rv);
|
|
return rv.StealNSResult();
|
|
}
|
|
|
|
return mXULWindow->SetTitle(title.get());
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner: nsIWindowProvider
|
|
//*****************************************************************************
|
|
NS_IMETHODIMP
|
|
nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
|
uint32_t aChromeFlags,
|
|
bool aCalledFromJS,
|
|
bool aPositionSpecified,
|
|
bool aSizeSpecified,
|
|
nsIURI* aURI,
|
|
const nsAString& aName,
|
|
const nsACString& aFeatures,
|
|
bool* aWindowIsNew,
|
|
nsIDOMWindow** aReturn)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
*aReturn = nullptr;
|
|
|
|
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,
|
|
static_cast<nsIDocShellTreeOwner*>(this)),
|
|
"Parent from wrong docshell tree?");
|
|
#endif
|
|
|
|
// 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);
|
|
if (docshell && docshell->GetIsInBrowserOrApp() &&
|
|
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
|
|
|
|
BrowserElementParent::OpenWindowResult opened =
|
|
BrowserElementParent::OpenWindowInProcess(aParent, aURI, aName,
|
|
aFeatures, aReturn);
|
|
|
|
// If OpenWindowInProcess handled the open (by opening it or blocking the
|
|
// popup), tell our caller not to proceed trying to create a new window
|
|
// through other means.
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
int32_t openLocation =
|
|
nsWindowWatcher::GetWindowOpenLocation(aParent, aChromeFlags, aCalledFromJS,
|
|
aPositionSpecified, aSizeSpecified);
|
|
|
|
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
|
|
openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
|
// Just open a window normally
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWin;
|
|
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;
|
|
}
|
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
|
|
chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
|
|
if (!browserDOMWin) {
|
|
return NS_OK;
|
|
}
|
|
|
|
*aWindowIsNew = (openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
|
|
|
|
{
|
|
dom::AutoNoJSAPI nojsapi;
|
|
|
|
// 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.
|
|
return browserDOMWin->OpenURI(nullptr, aParent, openLocation,
|
|
nsIBrowserDOMWindow::OPEN_NEW, aReturn);
|
|
}
|
|
}
|
|
|
|
//*****************************************************************************
|
|
// nsContentTreeOwner: Accessors
|
|
//*****************************************************************************
|
|
|
|
#if defined(XP_MACOSX)
|
|
class nsContentTitleSettingEvent : public nsRunnable
|
|
{
|
|
public:
|
|
nsContentTitleSettingEvent(dom::Element* dse, const nsAString& wtm)
|
|
: mElement(dse),
|
|
mTitleDefault(wtm) {}
|
|
|
|
NS_IMETHOD Run()
|
|
{
|
|
ErrorResult rv;
|
|
mElement->SetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault, rv);
|
|
mElement->RemoveAttribute(NS_LITERAL_STRING("titlemodifier"), rv);
|
|
return NS_OK;
|
|
}
|
|
|
|
private:
|
|
nsCOMPtr<dom::Element> mElement;
|
|
nsString mTitleDefault;
|
|
};
|
|
#endif
|
|
|
|
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
|
|
{
|
|
mXULWindow = aXULWindow;
|
|
if (mXULWindow && mPrimary) {
|
|
// Get the window title modifiers
|
|
nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
|
|
|
|
nsAutoString contentTitleSetting;
|
|
|
|
if(docShellElement)
|
|
{
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("contenttitlesetting"), contentTitleSetting);
|
|
if(contentTitleSetting.EqualsLiteral("true"))
|
|
{
|
|
mContentTitleSetting = true;
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault);
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
|
|
|
|
#if defined(XP_MACOSX)
|
|
// On OS X, treat the titlemodifier like it's the titledefault, and don't ever append
|
|
// the separator + appname.
|
|
if (mTitleDefault.IsEmpty()) {
|
|
NS_DispatchToCurrentThread(
|
|
new nsContentTitleSettingEvent(docShellElement,
|
|
mWindowTitleModifier));
|
|
mTitleDefault = mWindowTitleModifier;
|
|
mWindowTitleModifier.Truncate();
|
|
}
|
|
#endif
|
|
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemenuseparator"), mTitleSeparator);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
NS_ERROR("This condition should never happen. If it does, "
|
|
"we just won't get a modifier, but it still shouldn't happen.");
|
|
}
|
|
}
|
|
}
|
|
|
|
nsXULWindow* nsContentTreeOwner::XULWindow()
|
|
{
|
|
return mXULWindow;
|
|
}
|
|
|
|
//*****************************************************************************
|
|
//*** nsSiteWindow implementation
|
|
//*****************************************************************************
|
|
|
|
nsSiteWindow::nsSiteWindow(nsContentTreeOwner *aAggregator)
|
|
{
|
|
mAggregator = aAggregator;
|
|
}
|
|
|
|
nsSiteWindow::~nsSiteWindow()
|
|
{
|
|
}
|
|
|
|
NS_IMPL_ADDREF_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
|
NS_IMPL_RELEASE_USING_AGGREGATOR(nsSiteWindow, mAggregator)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSiteWindow)
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
|
NS_INTERFACE_MAP_END_AGGREGATED(mAggregator)
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::SetDimensions(uint32_t aFlags,
|
|
int32_t aX, int32_t aY, int32_t aCX, int32_t aCY)
|
|
{
|
|
// XXX we're ignoring aFlags
|
|
return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY, true);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::GetDimensions(uint32_t aFlags,
|
|
int32_t *aX, int32_t *aY, int32_t *aCX, int32_t *aCY)
|
|
{
|
|
// XXX we're ignoring aFlags
|
|
return mAggregator->GetPositionAndSize(aX, aY, aCX, aCY);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::SetFocus(void)
|
|
{
|
|
#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.
|
|
*/
|
|
nsXULWindow *window = mAggregator->XULWindow();
|
|
if (window) {
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
window->GetDocShell(getter_AddRefs(docshell));
|
|
if (docShell) {
|
|
nsCOMPtr<nsIDOMWindow> domWindow(docShell->GetWindow());
|
|
if (domWindow)
|
|
domWindow->Focus();
|
|
}
|
|
}
|
|
#endif
|
|
return NS_OK;
|
|
}
|
|
|
|
/* this implementation focuses another window. if there isn't another
|
|
window to focus, we do nothing. */
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::Blur(void)
|
|
{
|
|
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
nsCOMPtr<nsIXULWindow> xulWindow;
|
|
bool more, foundUs;
|
|
nsXULWindow *ourWindow = mAggregator->XULWindow();
|
|
|
|
{
|
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
|
if (windowMediator)
|
|
windowMediator->GetZOrderXULWindowEnumerator(0, true,
|
|
getter_AddRefs(windowEnumerator));
|
|
}
|
|
|
|
if (!windowEnumerator)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
// step through the top-level windows
|
|
foundUs = false;
|
|
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)
|
|
foundUs = true;
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
}
|
|
|
|
// change focus to the window we just found
|
|
if (xulWindow) {
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
xulWindow->GetDocShell(getter_AddRefs(docshell));
|
|
if (!docshell) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow(docshell->GetWindow());
|
|
if (domWindow)
|
|
domWindow->Focus();
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::GetVisibility(bool *aVisibility)
|
|
{
|
|
return mAggregator->GetVisibility(aVisibility);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::SetVisibility(bool aVisibility)
|
|
{
|
|
return mAggregator->SetVisibility(aVisibility);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::GetTitle(char16_t * *aTitle)
|
|
{
|
|
return mAggregator->GetTitle(aTitle);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::SetTitle(const char16_t * aTitle)
|
|
{
|
|
return mAggregator->SetTitle(aTitle);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSiteWindow::GetSiteWindow(void **aSiteWindow)
|
|
{
|
|
return mAggregator->GetParentNativeWindow(aSiteWindow);
|
|
}
|
|
|