mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-29 08:54:28 +00:00
Issue #2678 - Stop using EnsureExpandoObject in codegen code when we just want to preserver the wrapper for a DOM proxy.
This commit is contained in:
@@ -260,6 +260,7 @@ public:
|
||||
|
||||
// nsWrapperCache
|
||||
using nsWrapperCache::GetWrapperPreserveColor;
|
||||
using nsWrapperCache::PreserveWrapper;
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
protected:
|
||||
virtual ~nsContentList();
|
||||
@@ -268,6 +269,10 @@ protected:
|
||||
{
|
||||
return nsWrapperCache::GetWrapperPreserveColor();
|
||||
}
|
||||
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
|
||||
{
|
||||
nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
|
||||
}
|
||||
public:
|
||||
|
||||
// nsIDOMHTMLCollection
|
||||
|
||||
+2
-14
@@ -3708,17 +3708,6 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
||||
self.properties = properties
|
||||
|
||||
def definition_body(self):
|
||||
if self.descriptor.proxy:
|
||||
preserveWrapper = dedent(
|
||||
"""
|
||||
// For DOM proxies, the only reliable way to preserve the wrapper
|
||||
// is to force creation of the expando object.
|
||||
JS::Rooted<JSObject*> unused(aCx,
|
||||
DOMProxyHandler::EnsureExpandoObject(aCx, aReflector));
|
||||
""")
|
||||
else:
|
||||
preserveWrapper = "PreserveWrapper(aObject);\n"
|
||||
|
||||
failureCode = dedent(
|
||||
"""
|
||||
aCache->ReleaseWrapper(aObject);
|
||||
@@ -3773,7 +3762,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
||||
// somewhat common) to have a non-null aGivenProto which is the
|
||||
// same as canonicalProto.
|
||||
if (proto != canonicalProto) {
|
||||
$*{preserveWrapper}
|
||||
PreserveWrapper(aObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3785,8 +3774,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
||||
failureCode),
|
||||
slots=InitMemberSlots(self.descriptor, failureCode),
|
||||
setImmutablePrototype=SetImmutablePrototype(self.descriptor,
|
||||
failureCode),
|
||||
preserveWrapper=preserveWrapper)
|
||||
failureCode))
|
||||
|
||||
|
||||
class CGWrapMethod(CGAbstractMethod):
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
|
||||
// nsWrapperCache
|
||||
using nsWrapperCache::GetWrapperPreserveColor;
|
||||
using nsWrapperCache::PreserveWrapper;
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
protected:
|
||||
virtual ~HTMLFormControlsCollection();
|
||||
@@ -85,6 +86,10 @@ protected:
|
||||
{
|
||||
return nsWrapperCache::GetWrapperPreserveColor();
|
||||
}
|
||||
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
|
||||
{
|
||||
nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
|
||||
}
|
||||
public:
|
||||
|
||||
static bool ShouldBeInElements(nsIFormControl* aFormControl);
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
// nsWrapperCache
|
||||
using nsWrapperCache::GetWrapperPreserveColor;
|
||||
using nsWrapperCache::GetWrapper;
|
||||
using nsWrapperCache::PreserveWrapper;
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
protected:
|
||||
virtual ~HTMLOptionsCollection() = default;
|
||||
@@ -52,6 +53,10 @@ protected:
|
||||
{
|
||||
return nsWrapperCache::GetWrapperPreserveColor();
|
||||
}
|
||||
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
|
||||
{
|
||||
nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
|
||||
}
|
||||
public:
|
||||
|
||||
// nsIDOMHTMLOptionsCollection interface
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
|
||||
// nsWrapperCache
|
||||
using nsWrapperCache::GetWrapperPreserveColor;
|
||||
using nsWrapperCache::PreserveWrapper;
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
protected:
|
||||
virtual ~TableRowsCollection();
|
||||
@@ -56,6 +57,10 @@ protected:
|
||||
{
|
||||
return nsWrapperCache::GetWrapperPreserveColor();
|
||||
}
|
||||
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
|
||||
{
|
||||
nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
|
||||
}
|
||||
|
||||
// Those rows that are not in table sections
|
||||
HTMLTableElement* mParent;
|
||||
|
||||
@@ -85,9 +85,16 @@ public:
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
void PreserveWrapper(nsISupports* aScriptObjectHolder)
|
||||
{
|
||||
PreserveWrapperInternal(aScriptObjectHolder);
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) = 0;
|
||||
protected:
|
||||
// Hook for calling nsWrapperCache::GetWrapperPreserveColor.
|
||||
virtual JSObject* GetWrapperPreserveColorInternal() = 0;
|
||||
// Hook for calling nsWrapperCache::PreserveWrapper.
|
||||
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)
|
||||
|
||||
Reference in New Issue
Block a user