Bug 841289 - Remove prefable option from WebIDL codegen. r=bz

This commit is contained in:
Masatoshi Kimura 2013-03-06 07:09:38 +09:00
parent aef8062fcb
commit 0b2426e59c
8 changed files with 6 additions and 89 deletions

View File

@ -125,12 +125,6 @@ public:
"This flag should be set before creating any wrappers.");
mWrapperPtrBits = WRAPPER_IS_DOM_BINDING;
}
void ClearIsDOMBinding()
{
MOZ_ASSERT(!mWrapperPtrBits || mWrapperPtrBits == WRAPPER_IS_DOM_BINDING,
"This flag should be cleared before creating any wrappers.");
mWrapperPtrBits = 0;
}
bool IsDOMBinding() const
{

View File

@ -23,14 +23,6 @@
# * concrete - Indicates whether there exist objects with this interface as
# their primary interface. Always False for callback interfaces.
# defaults to True otherwise.
# * prefable - Indicates whether this bindings should be disabled if the
# global pref for Web IDL bindings is set to false. This is a
# risk mitigation strategy and it will cause all of the Web IDL
# bindings marked as prefable to fall back to the xpconnect
# bindings in case something goes wrong. This defaults to False.
# Setting this on objects which only have Web IDL bindings does
# not make any sense.
# Cannot be set on external interfaces.
# * workers - Indicates whether the descriptor is intended to be used for
# worker threads (defaults to false).
# * customTrace - The native class will use a custom trace hook (defaults to

View File

@ -1700,34 +1700,6 @@ class CGGetConstructorObjectMethod(CGGetPerInterfaceObject):
/* Get the interface object for this class. This will create the object as
needed. */""" + CGGetPerInterfaceObject.definition_body(self)
def CheckPref(descriptor, globalName, varName, retval, wrapperCache = None):
"""
Check whether bindings should be enabled for this descriptor. If not, set
varName to false and return retval.
"""
if not descriptor.prefable:
return ""
if wrapperCache:
wrapperCache = " %s->ClearIsDOMBinding();\n" % (wrapperCache)
else:
wrapperCache = ""
failureCode = (" %s = false;\n" +
" return %s;") % (varName, retval)
return """
{
XPCWrappedNativeScope* scope = xpc::GetObjectScope(%s);
if (!scope) {
%s
}
if (!scope->ExperimentalBindingsEnabled()) {
%s%s
}
}
""" % (globalName, failureCode, wrapperCache, failureCode)
class CGDefineDOMInterfaceMethod(CGAbstractMethod):
"""
A method for resolve hooks to try to lazily define the interface object for
@ -1760,8 +1732,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
return interfaceObject;"""
else:
getConstructor = " return GetConstructorObject(aCx, aGlobal);"
return (CheckPref(self.descriptor, "aGlobal", "*aEnabled", "nullptr") +
""" *aEnabled = true;
return (""" *aEnabled = true;
""" + getConstructor)
@ -1912,7 +1883,6 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
JSAutoCompartment ac(aCx, parent);
JSObject* global = JS_GetGlobalForObject(aCx, parent);
%s
JSObject* proto = GetProtoObject(aCx, global);
if (!proto) {
return NULL;
@ -1923,7 +1893,6 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
aCache->SetWrapper(obj);
return obj;""" % (AssertInheritanceChain(self.descriptor),
CheckPref(self.descriptor, "global", "*aTriedToWrap", "NULL", "aCache"),
CreateBindingJSObject(self.descriptor, "parent"),
InitUnforgeableProperties(self.descriptor, self.properties))
@ -2686,11 +2655,6 @@ for (uint32_t i = 0; i < length; ++i) {
exceptionCode,
codeOnFailure=failureCode))
elif not descriptor.skipGen and not descriptor.interface.isConsequential() and not descriptor.interface.isExternal():
if descriptor.prefable and not descriptor.hasXPConnectImpls:
raise TypeError("We don't support prefable castable object "
"arguments (like %s), because we don't know "
"how to handle them being preffed off" %
descriptor.interface.identifier.name)
if failureCode is not None:
templateBody += str(CastableObjectUnwrapper(
descriptor,
@ -3486,20 +3450,17 @@ if (!returnArray) {
raise MethodNotCreatorError(descriptor.interface.identifier.name)
wrapMethod = "WrapNewBindingNonWrapperCachedObject"
wrap = "%s(cx, ${obj}, %s, ${jsvalPtr})" % (wrapMethod, result)
# We don't support prefable stuff in workers.
assert(not descriptor.prefable or not descriptor.workers)
if not descriptor.prefable and not descriptor.hasXPConnectImpls:
# Non-prefable bindings can only fail to wrap as a new-binding object
# if they already threw an exception. Same thing for
# non-prefable bindings.
if not descriptor.hasXPConnectImpls:
# Can only fail to wrap as a new-binding object
# if they already threw an exception.
failed = ("MOZ_ASSERT(JS_IsExceptionPending(cx));\n" +
"%s" % exceptionCode)
else:
if descriptor.notflattened:
raise TypeError("%s is prefable but not flattened; "
raise TypeError("%s has XPConnect impls but not flattened; "
"fallback won't work correctly" %
descriptor.interface.identifier.name)
# Try old-style wrapping for bindings which might be preffed off.
# Try old-style wrapping for bindings which might be XPConnect impls.
failed = wrapAndSetPtr("HandleNewBindingWrappingFailure(cx, ${obj}, %s, ${jsvalPtr})" % result)
else:
if descriptor.notflattened:

View File

@ -328,11 +328,6 @@ class Descriptor(DescriptorProvider):
iface = iface.parent
self.operations = operations
if self.interface.isExternal() and 'prefable' in desc:
raise TypeError("%s is external but has a prefable setting" %
self.interface.identifier.name)
self.prefable = desc.get('prefable', False)
if self.workers:
if desc.get('nativeOwnership', 'worker') != 'worker':
raise TypeError("Worker descriptor for %s should have 'worker' "
@ -352,10 +347,6 @@ class Descriptor(DescriptorProvider):
(self.nativeOwnership != 'owned' and
desc.get('wrapperCache', True))))
if not self.wrapperCache and self.prefable:
raise TypeError("Descriptor for %s is prefable but not wrappercached" %
self.interface.identifier.name)
def make_name(name):
return name + "_workers" if self.workers else name
self.name = make_name(interface.identifier.name)

View File

@ -2341,7 +2341,6 @@ CompartmentNameCallback(JSRuntime *rt, JSCompartment *comp,
memcpy(buf, name.get(), name.Length() + 1);
}
bool XPCJSRuntime::gExperimentalBindingsEnabled;
bool XPCJSRuntime::gXBLScopesEnabled;
static bool
@ -2518,9 +2517,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
#endif
DOM_InitInterfaces();
Preferences::AddBoolVarCache(&gExperimentalBindingsEnabled,
"dom.experimental_bindings",
false);
Preferences::AddBoolVarCache(&gXBLScopesEnabled,
"dom.xbl_scopes",
false);

View File

@ -102,7 +102,6 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext *cx,
mNext(nullptr),
mGlobalJSObject(aGlobal),
mPrototypeNoHelper(nullptr),
mExperimentalBindingsEnabled(XPCJSRuntime::Get()->ExperimentalBindingsEnabled()),
mIsXBLScope(false)
{
// add ourselves to the scopes list

View File

@ -898,11 +898,6 @@ public:
static void ActivityCallback(void *arg, JSBool active);
bool ExperimentalBindingsEnabled()
{
return gExperimentalBindingsEnabled;
}
bool XBLScopesEnabled() {
return gXBLScopesEnabled;
}
@ -922,7 +917,6 @@ private:
void ReleaseIncrementally(nsTArray<nsISupports *> &array);
static bool gExperimentalBindingsEnabled;
static bool gXBLScopesEnabled;
static const char* mStrings[IDX_TOTAL_COUNT];
@ -1683,11 +1677,6 @@ public:
XPCContext *GetContext() { return mContext; }
void ClearContext() { mContext = nullptr; }
JSBool ExperimentalBindingsEnabled()
{
return mExperimentalBindingsEnabled;
}
typedef nsTHashtable<nsPtrHashKey<JSObject> > DOMExpandoMap;
bool RegisterDOMExpandoObject(JSObject *expando) {
@ -1748,7 +1737,6 @@ private:
nsAutoPtr<DOMExpandoMap> mDOMExpandoMap;
JSBool mExperimentalBindingsEnabled;
bool mIsXBLScope;
bool mUseXBLScope;
};

View File

@ -709,10 +709,6 @@ pref("dom.min_timeout_value", 4);
// And for background windows
pref("dom.min_background_timeout_value", 1000);
// Use the new DOM bindings (only affects any scopes created after the pref is
// changed)
pref("dom.experimental_bindings", true);
// Run content XBL in a separate scope.
pref("dom.xbl_scopes", true);