Bug 1218454 - part 3 - move nsILoadContext::GetOriginAttributes out-of-line; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Mon, 26 Oct 2015 16:05:13 -0400
changeset 309466 8ff6fdf5aeead29e2903b7c7ff04116f07a9985c
parent 309465 a06c0763b93a89bddd09d91d06294636d860e439
child 309467 50a3b107d89681522d389bed2286906361dc2fe7
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1218454
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1218454 - part 3 - move nsILoadContext::GetOriginAttributes out-of-line; r=bz
docshell/base/LoadContext.cpp
docshell/base/nsILoadContext.idl
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -2,17 +2,44 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LoadContext.h"
+#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
+#include "nsContentUtils.h"
+#include "xpcpublic.h"
 
+bool
+nsILoadContext::GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
+{
+  mozilla::dom::AutoJSAPI jsapi;
+  bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
+  NS_ENSURE_TRUE(ok, false);
+  JS::Rooted<JS::Value> v(jsapi.cx());
+  nsresult rv = GetOriginAttributes(&v);
+  NS_ENSURE_SUCCESS(rv, false);
+  NS_ENSURE_TRUE(v.isObject(), false);
+  JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
+
+  // If we're JS-implemented, the object will be left in a different (System-Principaled)
+  // scope, so we may need to enter its compartment.
+  MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
+  JSAutoCompartment ac(jsapi.cx(), obj);
+
+  mozilla::DocShellOriginAttributes attrs;
+  ok = attrs.Init(jsapi.cx(), v);
+  NS_ENSURE_TRUE(ok, false);
+  aAttrs = attrs;
+  return true;
+}
+  
 namespace mozilla {
 
 NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
 
 LoadContext::LoadContext(nsIPrincipal* aPrincipal,
                          nsILoadContext* aOptionalBase)
   : mTopFrameElement(nullptr)
   , mNestedFrameId(0)
--- a/docshell/base/nsILoadContext.idl
+++ b/docshell/base/nsILoadContext.idl
@@ -7,28 +7,25 @@
 #include "nsISupports.idl"
 
 interface nsIDOMWindow;
 interface nsIDOMElement;
 
 %{C++
 #ifdef MOZILLA_INTERNAL_API
 #include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes
-#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
-#include "xpcpublic.h" // for PrivilegedJunkScope
-#include "nsContentUtils.h" // for IsSystemPrincipal
 #endif
 %}
 
 /**
  * An nsILoadContext represents the context of a load.  This interface
  * can be queried for various information about where the load is
  * happening.
  */
-[scriptable, uuid(96014778-d30b-4fee-8902-a3481788907b)]
+[scriptable, uuid(c71ef717-8fb9-425e-98ef-aef5894890f8)]
 interface nsILoadContext : nsISupports
 {
   /**
    * associatedWindow is the window with which the load is associated, if any.
    * Note that the load may be triggered by a document which is different from
    * the document in associatedWindow, and in fact the source of the load need
    * not be same-origin with the document in associatedWindow.  This attribute
    * may be null if there is no associated window.
@@ -134,35 +131,15 @@ interface nsILoadContext : nsISupports
    * nsILoadContext.
    */
   readonly attribute jsval originAttributes;
 
 %{C++
 #ifdef MOZILLA_INTERNAL_API
   /**
    * The C++ getter for origin attributes.
+   *
+   * Defined in LoadContext.cpp
    */
-  bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
-  {
-    mozilla::dom::AutoJSAPI jsapi;
-    bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
-    NS_ENSURE_TRUE(ok, false);
-    JS::Rooted<JS::Value> v(jsapi.cx());
-    nsresult rv = GetOriginAttributes(&v);
-    NS_ENSURE_SUCCESS(rv, false);
-    NS_ENSURE_TRUE(v.isObject(), false);
-    JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
-
-    // If we're JS-implemented, the object will be left in a different (System-Principaled)
-    // scope, so we may need to enter its compartment.
-    MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
-    JSAutoCompartment ac(jsapi.cx(), obj);
-
-    mozilla::DocShellOriginAttributes attrs;
-    ok = attrs.Init(jsapi.cx(), v);
-    NS_ENSURE_TRUE(ok, false);
-    aAttrs = attrs;
-    return true;
-  }
-
+  bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs);
 #endif
 %}
 };