From a5db0f5415a9bef9d27815e54cd37304f41866c2 Mon Sep 17 00:00:00 2001 From: Bogdan Tara Date: Fri, 3 Aug 2018 19:24:41 +0300 Subject: [PATCH] Backed out changeset 85fd8d212397 (bug 1479544) for windows build bustages CLOSED TREE --- chrome/nsChromeRegistry.cpp | 41 ++++++++++++++++++++++++++++++++ chrome/nsChromeRegistry.h | 1 + chrome/nsIChromeRegistry.idl | 3 +++ dom/base/nsGlobalWindowOuter.cpp | 7 ++++++ dom/base/nsGlobalWindowOuter.h | 1 + dom/base/nsPIDOMWindow.h | 1 + 6 files changed, 54 insertions(+) diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 027d48f62a1a..5850c011aafb 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -472,6 +472,47 @@ nsChromeRegistry::FlushAllCaches() NS_CHROME_FLUSH_TOPIC, nullptr); } +// xxxbsmedberg Move me to nsIWindowMediator +NS_IMETHODIMP +nsChromeRegistry::ReloadChrome() +{ + FlushAllCaches(); + // Do a reload of all top level windows. + nsresult rv = NS_OK; + + // Get the window mediator + nsCOMPtr windowMediator + (do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); + if (windowMediator) { + nsCOMPtr windowEnumerator; + + rv = windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator)); + if (NS_SUCCEEDED(rv)) { + // Get each dom window + bool more; + rv = windowEnumerator->HasMoreElements(&more); + if (NS_FAILED(rv)) return rv; + while (more) { + nsCOMPtr protoWindow; + rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow)); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr domWindow = do_QueryInterface(protoWindow); + if (domWindow) { + Location* location = domWindow->GetLocation(); + if (location) { + rv = location->Reload(false); + if (NS_FAILED(rv)) return rv; + } + } + } + rv = windowEnumerator->HasMoreElements(&more); + if (NS_FAILED(rv)) return rv; + } + } + } + return rv; +} + NS_IMETHODIMP nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, bool *aResult) { diff --git a/chrome/nsChromeRegistry.h b/chrome/nsChromeRegistry.h index b5dd03c8c68a..9d70d3678509 100644 --- a/chrome/nsChromeRegistry.h +++ b/chrome/nsChromeRegistry.h @@ -39,6 +39,7 @@ public: NS_DECL_ISUPPORTS // nsIXULChromeRegistry methods: + NS_IMETHOD ReloadChrome() override; NS_IMETHOD RefreshSkins() override; NS_IMETHOD AllowScriptsForPackage(nsIURI* url, bool* _retval) override; diff --git a/chrome/nsIChromeRegistry.idl b/chrome/nsIChromeRegistry.idl index 91814f281532..8d67c6a50066 100644 --- a/chrome/nsIChromeRegistry.idl +++ b/chrome/nsIChromeRegistry.idl @@ -48,6 +48,9 @@ interface nsIChromeRegistry : nsISupports [scriptable, uuid(93251ddf-5e85-4172-ac2a-31780562974f)] interface nsIXULChromeRegistry : nsIChromeRegistry { + /* Should be called when locales change to reload all chrome (including XUL). */ + void reloadChrome(); + // If the optional asBCP47 parameter is true, the locale code will be // converted to a BCP47 language tag; in particular, this means that // "ja-JP-mac" will be returned as "ja-JP-x-lvariant-mac", which can be diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 193ce132b602..894086f1c095 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -6430,6 +6430,13 @@ nsGlobalWindowOuter::GetPrivateRoot() return top; } +Location* +nsGlobalWindowOuter::GetLocation() +{ + // This method can be called on the outer window as well. + FORWARD_TO_INNER(GetLocation, (), nullptr); +} + void nsGlobalWindowOuter::ActivateOrDeactivate(bool aActivate) { diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index 8d73a0e54d26..7db69b85d87c 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -561,6 +561,7 @@ public: } void GetNameOuter(nsAString& aName); void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError); + mozilla::dom::Location* GetLocation() override; void GetStatusOuter(nsAString& aStatus); void SetStatusOuter(const nsAString& aStatus); void CloseOuter(bool aTrustedCaller); diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index dec694fb0aac..66a0c513b501 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -1098,6 +1098,7 @@ public: // XXX(nika): These feel like they should be inner window only, but they're // called on the outer window. virtual mozilla::dom::Navigator* GetNavigator() = 0; + virtual mozilla::dom::Location* GetLocation() = 0; virtual nsresult GetPrompter(nsIPrompt** aPrompt) = 0; virtual nsresult GetControllers(nsIControllers** aControllers) = 0;