Bug 727884 - Make nsWrapperCache::WrapObject take a JSObject scope instead of XPCWrappedNativeScope. r=peterv

This commit is contained in:
Blake Kaplan 2012-03-14 16:25:40 +01:00
parent d40766dda2
commit 7a4eeff601
35 changed files with 46 additions and 53 deletions

View File

@ -345,7 +345,7 @@ public:
NS_DECL_NSIDOMFILELIST
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -192,7 +192,7 @@ NS_IMPL_ADDREF_INHERITED(nsSimpleContentList, nsBaseContentList)
NS_IMPL_RELEASE_INHERITED(nsSimpleContentList, nsBaseContentList)
JSObject*
nsSimpleContentList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
nsSimpleContentList::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::NodeList::create(cx, scope, this, triedToWrap);
@ -509,8 +509,7 @@ nsContentList::~nsContentList()
}
JSObject*
nsContentList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
nsContentList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::HTMLCollection::create(cx, scope, this,
triedToWrap);

View File

@ -138,7 +138,7 @@ public:
virtual PRInt32 IndexOf(nsIContent *aContent, bool aDoFlush);
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap) = 0;
protected:
@ -162,7 +162,7 @@ public:
{
return mRoot;
}
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
private:
@ -293,7 +293,7 @@ public:
virtual ~nsContentList();
// nsWrapperCache
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
// nsIDOMHTMLCollection

View File

@ -630,7 +630,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMFileList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMFileList)
JSObject*
nsDOMFileList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
nsDOMFileList::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::FileList::create(cx, scope, this, triedToWrap);

View File

@ -80,7 +80,7 @@ nsDOMSettableTokenList::SetValue(const nsAString& aValue)
}
JSObject*
nsDOMSettableTokenList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
nsDOMSettableTokenList::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::DOMSettableTokenList::create(cx, scope, this,

View File

@ -59,7 +59,7 @@ public:
nsDOMSettableTokenList(nsGenericElement* aElement, nsIAtom* aAttrAtom);
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
protected:

View File

@ -309,8 +309,7 @@ nsDOMTokenList::ToString(nsAString& aResult)
}
JSObject*
nsDOMTokenList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
nsDOMTokenList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::DOMTokenList::create(cx, scope, this,
triedToWrap);

View File

@ -58,7 +58,7 @@ public:
void DropReference();
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsINode *GetParentObject()

View File

@ -1758,7 +1758,7 @@ NS_INTERFACE_TABLE_HEAD(nsChildContentList)
NS_INTERFACE_MAP_END
JSObject*
nsChildContentList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
nsChildContentList::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::NodeList::create(cx, scope, this, triedToWrap);

View File

@ -107,7 +107,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsChildContentList)
// nsWrapperCache
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
// nsIDOMNodeList interface

View File

@ -149,7 +149,7 @@ public:
SetIsProxy();
}
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::TouchList::create(cx, scope, this,

View File

@ -75,7 +75,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPaintRequestList)
NS_DECL_NSIDOMPAINTREQUESTLIST
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::PaintRequestList::create(cx, scope, this,

View File

@ -148,8 +148,7 @@ nsClientRectList::GetItemAt(PRUint32 aIndex)
}
JSObject*
nsClientRectList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
nsClientRectList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::ClientRectList::create(cx, scope, this,
triedToWrap);

View File

@ -80,7 +80,7 @@ public:
NS_DECL_NSIDOMCLIENTRECTLIST
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -150,7 +150,7 @@ public:
nsresult GetSortedControls(nsTArray<nsGenericHTMLFormElement*>& aControls) const;
// nsWrapperCache
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::HTMLCollection::create(cx, scope, this,

View File

@ -2061,7 +2061,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHTMLOptionCollection)
JSObject*
nsHTMLOptionCollection::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
nsHTMLOptionCollection::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::HTMLOptionsCollection::create(cx, scope, this,

View File

@ -76,7 +76,7 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
// nsIDOMHTMLOptionsCollection interface

View File

@ -86,7 +86,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TableRowsCollection)
// nsWrapperCache
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::HTMLCollection::create(cx, scope, this,

View File

@ -100,8 +100,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGLengthList)
NS_INTERFACE_MAP_END
JSObject*
DOMSVGLengthList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
DOMSVGLengthList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::SVGLengthList::create(cx, scope, this,
triedToWrap);

View File

@ -102,7 +102,7 @@ public:
}
};
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -101,8 +101,7 @@ NS_INTERFACE_MAP_END
JSObject*
DOMSVGNumberList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
DOMSVGNumberList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::SVGNumberList::create(cx, scope, this,
triedToWrap);

View File

@ -101,7 +101,7 @@ public:
}
}
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -113,8 +113,7 @@ DOMSVGPathSegList::~DOMSVGPathSegList()
}
JSObject*
DOMSVGPathSegList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
DOMSVGPathSegList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::SVGPathSegList::create(cx, scope, this,
triedToWrap);

View File

@ -88,7 +88,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGPathSegList)
NS_DECL_NSIDOMSVGPATHSEGLIST
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -132,8 +132,7 @@ DOMSVGPointList::~DOMSVGPointList()
}
JSObject*
DOMSVGPointList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
DOMSVGPointList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
return mozilla::dom::binding::SVGPointList::create(cx, scope, this,
triedToWrap);

View File

@ -88,7 +88,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGPointList)
NS_DECL_NSIDOMSVGPOINTLIST
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -103,7 +103,7 @@ NS_INTERFACE_MAP_END
// DOMSVGTransformList methods:
JSObject*
DOMSVGTransformList::WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
DOMSVGTransformList::WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::SVGTransformList::create(cx, scope, this,

View File

@ -97,7 +97,7 @@ public:
}
}
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsISupports* GetParentObject()

View File

@ -113,7 +113,7 @@ public:
nsXBLInsertionPoint* GetInsertionPointAt(PRInt32 i) { return static_cast<nsXBLInsertionPoint*>(mElements->ElementAt(i)); }
void RemoveInsertionPointAt(PRInt32 i) { mElements->RemoveElementAt(i); }
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::NodeList::create(cx, scope, this,

View File

@ -301,8 +301,7 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// nsWrapperCache
JSObject *WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
JSObject *WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
{
NS_ASSERTION(IsOuterWindow(),
"Inner window supports nsWrapperCache, fix WrapObject!");

View File

@ -183,7 +183,7 @@ public:
* object doesn't actually support creating a wrapper through its WrapObject
* hook.
*/
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap)
{
*triedToWrap = false;

View File

@ -919,7 +919,8 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
if (!flat) {
bool triedToWrap;
flat = cache->WrapObject(lccx.GetJSContext(), xpcscope,
flat = cache->WrapObject(lccx.GetJSContext(),
xpcscope->GetGlobalJSObject(),
&triedToWrap);
if (!flat && triedToWrap)
return false;

View File

@ -534,24 +534,24 @@ ListBase<LC>::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope)
template<class LC>
JSObject *
ListBase<LC>::create(JSContext *cx, XPCWrappedNativeScope *scope, ListType *aList,
ListBase<LC>::create(JSContext *cx, JSObject *scope, ListType *aList,
nsWrapperCache* aWrapperCache, bool *triedToWrap)
{
*triedToWrap = true;
JSObject *parent = WrapNativeParent(cx, scope->GetGlobalJSObject(), aList->GetParentObject());
JSObject *parent = WrapNativeParent(cx, scope, aList->GetParentObject());
if (!parent)
return NULL;
JSAutoEnterCompartment ac;
if (js::GetGlobalForObjectCrossCompartment(parent) != scope->GetGlobalJSObject()) {
if (js::GetGlobalForObjectCrossCompartment(parent) != scope) {
if (!ac.enter(cx, parent))
return NULL;
scope = XPCWrappedNativeScope::FindInJSObjectScope(cx, parent);
}
JSObject *proto = getPrototype(cx, scope, triedToWrap);
XPCWrappedNativeScope *xpcscope =
XPCWrappedNativeScope::FindInJSObjectScope(cx, parent);
JSObject *proto = getPrototype(cx, xpcscope, triedToWrap);
if (!proto && !*triedToWrap)
aWrapperCache->ClearIsProxy();
if (!proto)

View File

@ -210,7 +210,7 @@ private:
static bool hasPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id);
public:
static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope, ListType *list,
static JSObject *create(JSContext *cx, JSObject *scope, ListType *list,
nsWrapperCache* cache, bool *triedToWrap);
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled)

View File

@ -353,7 +353,7 @@ listDefinitionTemplate = (
"class ${name} {\n"
"public:\n"
" template<typename I>\n"
" static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope, I *list, bool *triedToWrap)\n"
" static JSObject *create(JSContext *cx, JSObject *scope, I *list, bool *triedToWrap)\n"
" {\n"
" return create(cx, scope, list, GetWrapperCache(list), triedToWrap);\n"
" }\n"
@ -362,7 +362,7 @@ listDefinitionTemplate = (
" static ${nativeClass} *getNative(JSObject *obj);\n"
"\n"
"private:\n"
" static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope, ${nativeClass} *list, nsWrapperCache *cache, bool *triedToWrap);\n"
" static JSObject *create(JSContext *cx, JSObject *scope, ${nativeClass} *list, nsWrapperCache *cache, bool *triedToWrap);\n"
"};"
"\n"
"\n")
@ -573,7 +573,7 @@ listTemplateFooter = (
"template class ListBase<${name}Class>;\n"
"\n"
"JSObject*\n"
"${name}::create(JSContext *cx, XPCWrappedNativeScope *scope, ${nativeClass} *list, nsWrapperCache *cache, bool *triedToWrap)\n"
"${name}::create(JSContext *cx, JSObject *scope, ${nativeClass} *list, nsWrapperCache *cache, bool *triedToWrap)\n"
"{\n"
" return ${name}Wrapper::create(cx, scope, list, cache, triedToWrap);\n"
"}\n"