michael@0: /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Local Includes michael@0: #include "nsChromeTreeOwner.h" michael@0: #include "nsXULWindow.h" michael@0: michael@0: // Helper Classes michael@0: #include "nsString.h" michael@0: #include "nsIEmbeddingSiteWindow.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsIDocShellTreeItem.h" michael@0: michael@0: // Interfaces needed to include michael@0: #include "nsIPrompt.h" michael@0: #include "nsIAuthPrompt.h" michael@0: #include "nsIBrowserDOMWindow.h" michael@0: #include "nsIWebProgress.h" michael@0: #include "nsIWidget.h" michael@0: #include "nsIWindowMediator.h" michael@0: #include "nsIDOMChromeWindow.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsIDOMNodeList.h" michael@0: #include "nsIDOMXULElement.h" michael@0: #include "nsIXULBrowserWindow.h" michael@0: #include "mozilla/dom/Element.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner string literals michael@0: //***************************************************************************** michael@0: michael@0: struct nsChromeTreeOwnerLiterals michael@0: { michael@0: const nsLiteralString kPersist; michael@0: const nsLiteralString kScreenX; michael@0: const nsLiteralString kScreenY; michael@0: const nsLiteralString kWidth; michael@0: const nsLiteralString kHeight; michael@0: const nsLiteralString kSizemode; michael@0: const nsLiteralString kSpace; michael@0: michael@0: nsChromeTreeOwnerLiterals() michael@0: : NS_LITERAL_STRING_INIT(kPersist,"persist") michael@0: , NS_LITERAL_STRING_INIT(kScreenX,"screenX") michael@0: , NS_LITERAL_STRING_INIT(kScreenY,"screenY") michael@0: , NS_LITERAL_STRING_INIT(kWidth,"width") michael@0: , NS_LITERAL_STRING_INIT(kHeight,"height") michael@0: , NS_LITERAL_STRING_INIT(kSizemode,"sizemode") michael@0: , NS_LITERAL_STRING_INIT(kSpace," ") michael@0: {} michael@0: }; michael@0: michael@0: static nsChromeTreeOwnerLiterals *gLiterals; michael@0: michael@0: nsresult michael@0: nsChromeTreeOwner::InitGlobals() michael@0: { michael@0: NS_ASSERTION(gLiterals == nullptr, "already initialized"); michael@0: gLiterals = new nsChromeTreeOwnerLiterals(); michael@0: if (!gLiterals) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: return NS_OK; michael@0: } michael@0: michael@0: void michael@0: nsChromeTreeOwner::FreeGlobals() michael@0: { michael@0: delete gLiterals; michael@0: gLiterals = nullptr; michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: //*** nsChromeTreeOwner: Object Management michael@0: //***************************************************************************** michael@0: michael@0: nsChromeTreeOwner::nsChromeTreeOwner() : mXULWindow(nullptr) michael@0: { michael@0: } michael@0: michael@0: nsChromeTreeOwner::~nsChromeTreeOwner() michael@0: { michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner::nsISupports michael@0: //***************************************************************************** michael@0: michael@0: NS_IMPL_ADDREF(nsChromeTreeOwner) michael@0: NS_IMPL_RELEASE(nsChromeTreeOwner) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN(nsChromeTreeOwner) michael@0: NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner) michael@0: NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) michael@0: NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) michael@0: NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) michael@0: NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner::nsIInterfaceRequestor michael@0: //***************************************************************************** michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aSink); michael@0: michael@0: if(aIID.Equals(NS_GET_IID(nsIPrompt))) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetInterface(aIID, aSink); michael@0: } michael@0: if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetInterface(aIID, aSink); michael@0: } michael@0: if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetInterface(aIID, aSink); michael@0: } michael@0: if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow))) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetInterface(aIID, aSink); michael@0: } michael@0: if (aIID.Equals(NS_GET_IID(nsIXULWindow))) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->QueryInterface(aIID, aSink); michael@0: } michael@0: michael@0: return QueryInterface(aIID, aSink); michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner::nsIDocShellTreeOwner michael@0: //***************************************************************************** michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const char16_t* aName, michael@0: nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor, michael@0: nsIDocShellTreeItem** aFoundItem) michael@0: { michael@0: NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); michael@0: michael@0: NS_ENSURE_ARG_POINTER(aFoundItem); michael@0: michael@0: *aFoundItem = nullptr; michael@0: michael@0: bool fIs_Content = false; michael@0: michael@0: /* Special Cases */ michael@0: if(!aName || !*aName) michael@0: return NS_OK; michael@0: michael@0: nsDependentString name(aName); michael@0: michael@0: if(name.LowerCaseEqualsLiteral("_blank")) michael@0: return NS_OK; michael@0: // _main is an IE target which should be case-insensitive but isn't michael@0: // see bug 217886 for details michael@0: if(name.LowerCaseEqualsLiteral("_content") || name.EqualsLiteral("_main")) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: fIs_Content = true; michael@0: mXULWindow->GetPrimaryContentShell(aFoundItem); michael@0: if(*aFoundItem) michael@0: return NS_OK; michael@0: // Otherwise fall through and ask the other windows for a content area. michael@0: } michael@0: michael@0: nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID)); michael@0: NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE); michael@0: michael@0: nsCOMPtr windowEnumerator; michael@0: NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nullptr, michael@0: getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE); michael@0: michael@0: bool more; michael@0: michael@0: windowEnumerator->HasMoreElements(&more); michael@0: while(more) michael@0: { michael@0: nsCOMPtr nextWindow = nullptr; michael@0: windowEnumerator->GetNext(getter_AddRefs(nextWindow)); michael@0: nsCOMPtr xulWindow(do_QueryInterface(nextWindow)); michael@0: NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE); michael@0: michael@0: nsCOMPtr shellAsTreeItem; michael@0: michael@0: if(fIs_Content) michael@0: { michael@0: xulWindow->GetPrimaryContentShell(aFoundItem); michael@0: } michael@0: else michael@0: { michael@0: // Note that we don't look for targetable content shells here... michael@0: // in fact, we aren't looking for content shells at all! michael@0: nsCOMPtr shell; michael@0: xulWindow->GetDocShell(getter_AddRefs(shell)); michael@0: shellAsTreeItem = do_QueryInterface(shell); michael@0: if (shellAsTreeItem) { michael@0: // Get the root tree item of same type, since roots are the only michael@0: // things that call into the treeowner to look for named items. michael@0: nsCOMPtr root; michael@0: shellAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); michael@0: shellAsTreeItem = root; michael@0: } michael@0: if(shellAsTreeItem && aRequestor != shellAsTreeItem) michael@0: { michael@0: // Do this so we can pass in the tree owner as the requestor so the child knows not michael@0: // to call back up. michael@0: nsCOMPtr shellOwner; michael@0: shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); michael@0: nsCOMPtr shellOwnerSupports(do_QueryInterface(shellOwner)); michael@0: michael@0: shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, michael@0: aOriginalRequestor, aFoundItem); michael@0: } michael@0: } michael@0: if(*aFoundItem) michael@0: return NS_OK; michael@0: windowEnumerator->HasMoreElements(&more); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell, michael@0: bool aPrimary, bool aTargetable, michael@0: const nsAString& aID) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aTargetable, michael@0: aID); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->ContentShellRemoved(aContentShell); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetPrimaryContentShell(aShell); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::GetContentWindow(JSContext* aCx, JS::MutableHandle aVal) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: michael@0: nsCOMPtr domWin; michael@0: mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin)); michael@0: nsCOMPtr chromeWin = do_QueryInterface(domWin); michael@0: if (!chromeWin) michael@0: return NS_OK; michael@0: michael@0: nsCOMPtr browserDOMWin; michael@0: chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); michael@0: if (!browserDOMWin) michael@0: return NS_OK; michael@0: michael@0: return browserDOMWin->GetContentWindow(aVal); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, michael@0: int32_t aCX, int32_t aCY) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::SetPersistence(bool aPersistPosition, michael@0: bool aPersistSize, michael@0: bool aPersistSizeMode) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); michael@0: if (!docShellElement) michael@0: return NS_ERROR_FAILURE; michael@0: michael@0: nsAutoString persistString; michael@0: docShellElement->GetAttribute(gLiterals->kPersist, persistString); michael@0: michael@0: bool saveString = false; michael@0: int32_t index; michael@0: michael@0: #define FIND_PERSIST_STRING(aString, aCond) \ michael@0: index = persistString.Find(aString); \ michael@0: if (!aCond && index > kNotFound) { \ michael@0: persistString.Cut(index, aString.Length()); \ michael@0: saveString = true; \ michael@0: } else if (aCond && index == kNotFound) { \ michael@0: persistString.Append(gLiterals->kSpace + aString); \ michael@0: saveString = true; \ michael@0: } michael@0: FIND_PERSIST_STRING(gLiterals->kScreenX, aPersistPosition); michael@0: FIND_PERSIST_STRING(gLiterals->kScreenY, aPersistPosition); michael@0: FIND_PERSIST_STRING(gLiterals->kWidth, aPersistSize); michael@0: FIND_PERSIST_STRING(gLiterals->kHeight, aPersistSize); michael@0: FIND_PERSIST_STRING(gLiterals->kSizemode, aPersistSizeMode); michael@0: michael@0: ErrorResult rv; michael@0: if (saveString) { michael@0: docShellElement->SetAttribute(gLiterals->kPersist, persistString, rv); michael@0: } michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::GetPersistence(bool* aPersistPosition, michael@0: bool* aPersistSize, michael@0: bool* aPersistSizeMode) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); michael@0: if (!docShellElement) michael@0: return NS_ERROR_FAILURE; michael@0: michael@0: nsAutoString persistString; michael@0: docShellElement->GetAttribute(gLiterals->kPersist, persistString); michael@0: michael@0: // data structure doesn't quite match the question, but it's close enough michael@0: // for what we want (since this method is never actually called...) michael@0: if (aPersistPosition) michael@0: *aPersistPosition = persistString.Find(gLiterals->kScreenX) > kNotFound || michael@0: persistString.Find(gLiterals->kScreenY) > kNotFound; michael@0: if (aPersistSize) michael@0: *aPersistSize = persistString.Find(gLiterals->kWidth) > kNotFound || michael@0: persistString.Find(gLiterals->kHeight) > kNotFound; michael@0: if (aPersistSizeMode) michael@0: *aPersistSizeMode = persistString.Find(gLiterals->kSizemode) > kNotFound; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::GetTargetableShellCount(uint32_t* aResult) michael@0: { michael@0: *aResult = 0; michael@0: return NS_OK; michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner::nsIBaseWindow michael@0: //***************************************************************************** michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::InitWindow(nativeWindow aParentNativeWindow, michael@0: nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy) michael@0: { michael@0: // Ignore widget parents for now. Don't think those are a vaild thing to call. michael@0: NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::Create() michael@0: { michael@0: NS_ASSERTION(false, "You can't call this"); michael@0: return NS_ERROR_UNEXPECTED; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::Destroy() michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->Destroy(); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double *aScale) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetPosition(int32_t x, int32_t y) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetPosition(x, y); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetPosition(int32_t* x, int32_t* y) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetPosition(x, y); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetSize(int32_t cx, int32_t cy, bool fRepaint) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetSize(cx, cy, fRepaint); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetSize(int32_t* cx, int32_t* cy) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetSize(cx, cy); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(int32_t x, int32_t y, int32_t cx, michael@0: int32_t cy, bool fRepaint) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetPositionAndSize(x, y, cx, cy, fRepaint); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, michael@0: int32_t* cy) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetPositionAndSize(x, y, cx, cy); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::Repaint(bool aForce) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->Repaint(aForce); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetParentWidget(nsIWidget** aParentWidget) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetParentWidget(aParentWidget); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetParentWidget(nsIWidget* aParentWidget) michael@0: { michael@0: NS_ASSERTION(false, "You can't call this"); michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetParentNativeWindow(aParentNativeWindow); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow) michael@0: { michael@0: NS_ASSERTION(false, "You can't call this"); michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetNativeHandle(nsAString& aNativeHandle) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetNativeHandle(aNativeHandle); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetVisibility(bool* aVisibility) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetVisibility(aVisibility); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetVisibility(bool aVisibility) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetVisibility(aVisibility); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetEnabled(bool *aEnabled) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetEnabled(aEnabled); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetEnabled(bool aEnable) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetEnabled(aEnable); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetMainWidget(nsIWidget** aMainWidget) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aMainWidget); michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: michael@0: *aMainWidget = mXULWindow->mWindow; michael@0: NS_IF_ADDREF(*aMainWidget); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetFocus() michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetFocus(); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::GetTitle(char16_t** aTitle) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->GetTitle(aTitle); michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::SetTitle(const char16_t* aTitle) michael@0: { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: return mXULWindow->SetTitle(aTitle); michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner::nsIWebProgressListener michael@0: //***************************************************************************** michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::OnProgressChange(nsIWebProgress* aWebProgress, michael@0: nsIRequest* aRequest, michael@0: int32_t aCurSelfProgress, michael@0: int32_t aMaxSelfProgress, michael@0: int32_t aCurTotalProgress, michael@0: int32_t aMaxTotalProgress) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::OnStateChange(nsIWebProgress* aWebProgress, michael@0: nsIRequest* aRequest, michael@0: uint32_t aProgressStateFlags, michael@0: nsresult aStatus) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, michael@0: nsIRequest* aRequest, michael@0: nsIURI* aLocation, michael@0: uint32_t aFlags) michael@0: { michael@0: bool itsForYou = true; michael@0: michael@0: if (aWebProgress) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: nsCOMPtr progressWin; michael@0: aWebProgress->GetDOMWindow(getter_AddRefs(progressWin)); michael@0: michael@0: nsCOMPtr docshell; michael@0: mXULWindow->GetDocShell(getter_AddRefs(docshell)); michael@0: nsCOMPtr ourWin(do_QueryInterface(docshell)); michael@0: michael@0: if (ourWin != progressWin) michael@0: itsForYou = false; michael@0: } michael@0: michael@0: // If loading a new root .xul document, then redo chrome. michael@0: if (itsForYou) { michael@0: NS_ENSURE_STATE(mXULWindow); michael@0: mXULWindow->mChromeLoaded = false; michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, michael@0: nsIRequest* aRequest, michael@0: nsresult aStatus, michael@0: const char16_t* aMessage) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsChromeTreeOwner::OnSecurityChange(nsIWebProgress *aWebProgress, michael@0: nsIRequest *aRequest, michael@0: uint32_t state) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner: Helpers michael@0: //***************************************************************************** michael@0: michael@0: //***************************************************************************** michael@0: // nsChromeTreeOwner: Accessors michael@0: //***************************************************************************** michael@0: michael@0: void nsChromeTreeOwner::XULWindow(nsXULWindow* aXULWindow) michael@0: { michael@0: mXULWindow = aXULWindow; michael@0: } michael@0: michael@0: nsXULWindow* nsChromeTreeOwner::XULWindow() michael@0: { michael@0: return mXULWindow; michael@0: }