Bug 796938 - Switch to GetEntryDocument in GetDocumentCharacterSetForURI. r=smaug
authorBobby Holley <bobbyholley@gmail.com>
Tue, 19 Aug 2014 12:02:06 -0700
changeset 214759 4c95deee6bcd8833e6991f02babedb871ea83ba7
parent 214758 1317e7b98dbfd23ad1ebd4f14fcd5d6fab848b25
child 214760 8b1137d02c20c6b223fa39697cc63fe4a93250ca
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs796938
milestone34.0a1
Bug 796938 - Switch to GetEntryDocument in GetDocumentCharacterSetForURI. r=smaug
dom/base/nsLocation.cpp
--- a/dom/base/nsLocation.cpp
+++ b/dom/base/nsLocation.cpp
@@ -37,25 +37,18 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static nsresult
 GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
 {
   aCharset.Truncate();
 
-  JSContext *cx = nsContentUtils::GetCurrentJSContext();
-  if (cx) {
-    nsCOMPtr<nsPIDOMWindow> window =
-      do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
-    NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
-
-    if (nsIDocument* doc = window->GetDoc()) {
-      aCharset = doc->GetDocumentCharacterSet();
-    }
+  if (nsIDocument* doc = GetEntryDocument()) {
+    aCharset = doc->GetDocumentCharacterSet();
   }
 
   return NS_OK;
 }
 
 nsLocation::nsLocation(nsPIDOMWindow* aWindow, nsIDocShell *aDocShell)
   : mInnerWindow(aWindow)
 {