Bug 1115375 - [JSAPI] Add nsAutoJSString::Init that doesn't require a JSContext. r=bholley, a=bajaj
authorDave Huseby <dhuseby@mozilla.com>
Thu, 19 Feb 2015 14:16:00 -0500
changeset 237146 ad7ef54f1d8693768b63ac3066904fa0966be281
parent 237145 1e1aee3bd362f3a6f0fbe3cad70861e1da97fe9f
child 237147 b5a532c7f6060a76b51dc0e37a25869912410221
push id213
push userryanvm@gmail.com
push dateTue, 24 Feb 2015 00:59:48 +0000
treeherdermozilla-b2g37_v2_2@b5a532c7f606 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, bajaj
bugs1115375
milestone37.0
Bug 1115375 - [JSAPI] Add nsAutoJSString::Init that doesn't require a JSContext. r=bholley, a=bajaj
dom/base/nsJSUtils.cpp
dom/base/nsJSUtils.h
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -366,8 +366,14 @@ nsJSUtils::GetScopeChainForElement(JSCon
 JSObject* GetDefaultScopeFromJSContext(JSContext *cx)
 {
   // DOM JSContexts don't store their default compartment object on
   // the cx, so in those cases we need to fetch it via the scx
   // instead.
   nsIScriptContext *scx = GetScriptContextFromJSContext(cx);
   return  scx ? scx->GetWindowProxy() : nullptr;
 }
+
+bool nsAutoJSString::init(const JS::Value &v)
+{
+  return init(nsContentUtils::RootingCxForThread(), v);
+}
+
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -211,12 +211,14 @@ public:
   }
 
   bool init(JSContext* aContext, jsid id)
   {
     JS::Rooted<JS::Value> v(aContext);
     return JS_IdToValue(aContext, id, &v) && init(aContext, v);
   }
 
+  bool init(const JS::Value &v);
+
   ~nsAutoJSString() {}
 };
 
 #endif /* nsJSUtils_h__ */