mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 778044. Add a way to pref off Paris binding constructor objects. r=peterv
This commit is contained in:
parent
60ef34b89f
commit
437a27a6d1
@ -4639,7 +4639,8 @@ nsDOMClassInfo::Init()
|
|||||||
mozilla::dom::oldproxybindings::Register(nameSpaceManager);
|
mozilla::dom::oldproxybindings::Register(nameSpaceManager);
|
||||||
|
|
||||||
if (!AzureCanvasEnabled()) {
|
if (!AzureCanvasEnabled()) {
|
||||||
nameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING("CanvasRenderingContext2D"), NULL);
|
nameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING("CanvasRenderingContext2D"),
|
||||||
|
nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sIsInitialized = true;
|
sIsInitialized = true;
|
||||||
@ -6790,6 +6791,10 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name_struct->mPrefEnabled && !(*name_struct->mPrefEnabled)()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (mozilla::dom::DefineConstructor(cx, obj, define, &rv)) {
|
if (mozilla::dom::DefineConstructor(cx, obj, define, &rv)) {
|
||||||
*did_resolve = NS_SUCCEEDED(rv);
|
*did_resolve = NS_SUCCEEDED(rv);
|
||||||
|
|
||||||
|
@ -781,7 +781,8 @@ nsScriptNameSpaceManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|||||||
|
|
||||||
void
|
void
|
||||||
nsScriptNameSpaceManager::RegisterDefineDOMInterface(const nsAFlatString& aName,
|
nsScriptNameSpaceManager::RegisterDefineDOMInterface(const nsAFlatString& aName,
|
||||||
mozilla::dom::DefineInterface aDefineDOMInterface)
|
mozilla::dom::DefineInterface aDefineDOMInterface,
|
||||||
|
mozilla::dom::PrefEnabled aPrefEnabled)
|
||||||
{
|
{
|
||||||
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, &aName);
|
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, &aName);
|
||||||
if (s) {
|
if (s) {
|
||||||
@ -789,5 +790,6 @@ nsScriptNameSpaceManager::RegisterDefineDOMInterface(const nsAFlatString& aName,
|
|||||||
s->mType = nsGlobalNameStruct::eTypeNewDOMBinding;
|
s->mType = nsGlobalNameStruct::eTypeNewDOMBinding;
|
||||||
}
|
}
|
||||||
s->mDefineDOMInterface = aDefineDOMInterface;
|
s->mDefineDOMInterface = aDefineDOMInterface;
|
||||||
|
s->mPrefEnabled = aPrefEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ struct nsGlobalNameStruct
|
|||||||
|
|
||||||
// For new style DOM bindings.
|
// For new style DOM bindings.
|
||||||
mozilla::dom::DefineInterface mDefineDOMInterface;
|
mozilla::dom::DefineInterface mDefineDOMInterface;
|
||||||
|
mozilla::dom::PrefEnabled mPrefEnabled; // May be null if not pref controlled
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -139,7 +140,8 @@ public:
|
|||||||
nsGlobalNameStruct* GetConstructorProto(const nsGlobalNameStruct* aStruct);
|
nsGlobalNameStruct* GetConstructorProto(const nsGlobalNameStruct* aStruct);
|
||||||
|
|
||||||
void RegisterDefineDOMInterface(const nsAFlatString& aName,
|
void RegisterDefineDOMInterface(const nsAFlatString& aName,
|
||||||
mozilla::dom::DefineInterface aDefineDOMInterface);
|
mozilla::dom::DefineInterface aDefineDOMInterface,
|
||||||
|
mozilla::dom::PrefEnabled aPrefEnabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
||||||
|
@ -1338,6 +1338,24 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
|||||||
*aEnabled = true;
|
*aEnabled = true;
|
||||||
return !!%s(aCx, global, aReceiver);""" % (getter))
|
return !!%s(aCx, global, aReceiver);""" % (getter))
|
||||||
|
|
||||||
|
class CGPrefEnabled(CGAbstractMethod):
|
||||||
|
"""
|
||||||
|
A method for testing whether the preference controlling this
|
||||||
|
interface is enabled. When it's not, the interface should not be
|
||||||
|
visible on the global.
|
||||||
|
"""
|
||||||
|
def __init__(self, descriptor):
|
||||||
|
CGAbstractMethod.__init__(self, descriptor, 'PrefEnabled', 'bool', [])
|
||||||
|
|
||||||
|
def declare(self):
|
||||||
|
return CGAbstractMethod.declare(self)
|
||||||
|
|
||||||
|
def define(self):
|
||||||
|
return CGAbstractMethod.define(self)
|
||||||
|
|
||||||
|
def definition_body(self):
|
||||||
|
return " return %s::PrefEnabled();" % self.descriptor.nativeType
|
||||||
|
|
||||||
class CGIsMethod(CGAbstractMethod):
|
class CGIsMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('JSObject*', 'obj')]
|
args = [Argument('JSObject*', 'obj')]
|
||||||
@ -4999,6 +5017,11 @@ class CGDescriptor(CGThing):
|
|||||||
|
|
||||||
if descriptor.interface.hasInterfaceObject():
|
if descriptor.interface.hasInterfaceObject():
|
||||||
cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
|
cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
|
||||||
|
if (not descriptor.interface.isExternal() and
|
||||||
|
# Workers stuff is never pref-controlled
|
||||||
|
not descriptor.workers and
|
||||||
|
descriptor.interface.getExtendedAttribute("PrefControlled") is not None):
|
||||||
|
cgThings.append(CGPrefEnabled(descriptor))
|
||||||
|
|
||||||
if descriptor.interface.hasInterfacePrototypeObject():
|
if descriptor.interface.hasInterfacePrototypeObject():
|
||||||
cgThings.append(CGNativePropertyHooks(descriptor))
|
cgThings.append(CGNativePropertyHooks(descriptor))
|
||||||
@ -5310,12 +5333,16 @@ class CGRegisterProtos(CGAbstractMethod):
|
|||||||
|
|
||||||
def _defineMacro(self):
|
def _defineMacro(self):
|
||||||
return """
|
return """
|
||||||
#define REGISTER_PROTO(_dom_class) \\
|
#define REGISTER_PROTO(_dom_class, _pref_check) \\
|
||||||
aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Binding::DefineDOMInterface);\n\n"""
|
aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Binding::DefineDOMInterface, _pref_check);\n\n"""
|
||||||
def _undefineMacro(self):
|
def _undefineMacro(self):
|
||||||
return "\n#undef REGISTER_PROTO"
|
return "\n#undef REGISTER_PROTO"
|
||||||
def _registerProtos(self):
|
def _registerProtos(self):
|
||||||
lines = ["REGISTER_PROTO(%s);" % desc.name
|
def getPrefCheck(desc):
|
||||||
|
if desc.interface.getExtendedAttribute("PrefControlled") is None:
|
||||||
|
return "nullptr"
|
||||||
|
return "%sBinding::PrefEnabled" % desc.name
|
||||||
|
lines = ["REGISTER_PROTO(%s, %s);" % (desc.name, getPrefCheck(desc))
|
||||||
for desc in self.config.getDescriptors(hasInterfaceObject=True,
|
for desc in self.config.getDescriptors(hasInterfaceObject=True,
|
||||||
isExternal=False,
|
isExternal=False,
|
||||||
workers=False,
|
workers=False,
|
||||||
|
@ -738,6 +738,9 @@ class IDLInterface(IDLObjectWithScope):
|
|||||||
return loopPoint
|
return loopPoint
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def getExtendedAttribute(self, name):
|
||||||
|
return self._extendedAttrDict.get(name, None)
|
||||||
|
|
||||||
class IDLDictionary(IDLObjectWithScope):
|
class IDLDictionary(IDLObjectWithScope):
|
||||||
def __init__(self, location, parentScope, name, parent, members):
|
def __init__(self, location, parentScope, name, parent, members):
|
||||||
assert isinstance(parentScope, IDLScope)
|
assert isinstance(parentScope, IDLScope)
|
||||||
|
@ -736,7 +736,7 @@ def writeStubFile(filename, config, interfaces):
|
|||||||
"Register(nsScriptNameSpaceManager* aNameSpaceManager)\n"
|
"Register(nsScriptNameSpaceManager* aNameSpaceManager)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"#define REGISTER_PROTO(_dom_class) \\\n"
|
"#define REGISTER_PROTO(_dom_class) \\\n"
|
||||||
" aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Wrapper::DefineDOMInterface);\n\n"""
|
" aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Wrapper::DefineDOMInterface, nullptr);\n\n"""
|
||||||
"\n")
|
"\n")
|
||||||
for clazz in config.list_classes.itervalues():
|
for clazz in config.list_classes.itervalues():
|
||||||
f.write(" REGISTER_PROTO(%s);\n" % clazz.name)
|
f.write(" REGISTER_PROTO(%s);\n" % clazz.name)
|
||||||
|
@ -345,6 +345,9 @@ inline bool IsDOMProxy(JSObject *obj)
|
|||||||
typedef bool
|
typedef bool
|
||||||
(*DefineInterface)(JSContext *cx, JSObject *global, bool *enabled);
|
(*DefineInterface)(JSContext *cx, JSObject *global, bool *enabled);
|
||||||
|
|
||||||
|
typedef bool
|
||||||
|
(*PrefEnabled)();
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
DefineStaticJSVals(JSContext *cx);
|
DefineStaticJSVals(JSContext *cx);
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user