mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 958667 part 5. Hook up AvailableIn for interface members. r=peterv
This commit is contained in:
parent
b25f7e2745
commit
448f681d4d
@ -1315,20 +1315,25 @@ def getAvailableInTestFunc(obj):
|
||||
class MemberCondition:
|
||||
"""
|
||||
An object representing the condition for a member to actually be
|
||||
exposed. Either pref or func or both can be None. If not None,
|
||||
they should be strings that have the pref name or function name.
|
||||
exposed. Any of pref, func, and available can be None. If not
|
||||
None, they should be strings that have the pref name (for "pref")
|
||||
or function name (for "func" and "available").
|
||||
"""
|
||||
def __init__(self, pref, func):
|
||||
def __init__(self, pref, func, available=None):
|
||||
assert pref is None or isinstance(pref, str)
|
||||
assert func is None or isinstance(func, str)
|
||||
assert available is None or isinstance(available, str)
|
||||
self.pref = pref
|
||||
if func is None:
|
||||
self.func = "nullptr"
|
||||
else:
|
||||
self.func = "&" + func
|
||||
def toFuncPtr(val):
|
||||
if val is None:
|
||||
return "nullptr"
|
||||
return "&" + val
|
||||
self.func = toFuncPtr(func)
|
||||
self.available = toFuncPtr(available)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.pref == other.pref and self.func == other.func
|
||||
return (self.pref == other.pref and self.func == other.func and
|
||||
self.available == other.available)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
@ -1390,7 +1395,8 @@ class PropertyDefiner:
|
||||
return MemberCondition(PropertyDefiner.getStringAttr(interfaceMember,
|
||||
"Pref"),
|
||||
PropertyDefiner.getStringAttr(interfaceMember,
|
||||
"Func"))
|
||||
"Func"),
|
||||
getAvailableInTestFunc(interfaceMember))
|
||||
|
||||
def generatePrefableArray(self, array, name, specTemplate, specTerminator,
|
||||
specType, getCondition, getDataTuple, doIdArrays):
|
||||
@ -1427,7 +1433,7 @@ class PropertyDefiner:
|
||||
specs = []
|
||||
prefableSpecs = []
|
||||
|
||||
prefableTemplate = ' { true, %s, &%s[%d] }'
|
||||
prefableTemplate = ' { true, %s, %s, &%s[%d] }'
|
||||
prefCacheTemplate = '&%s[%d].enabled'
|
||||
def switchToCondition(props, condition):
|
||||
# Remember the info about where our pref-controlled
|
||||
@ -1439,7 +1445,9 @@ class PropertyDefiner:
|
||||
)
|
||||
# Set up pointers to the new sets of specs inside prefableSpecs
|
||||
prefableSpecs.append(prefableTemplate %
|
||||
(condition.func, name + "_specs", len(specs)))
|
||||
(condition.func,
|
||||
condition.available,
|
||||
name + "_specs", len(specs)))
|
||||
|
||||
switchToCondition(self, lastCondition)
|
||||
|
||||
|
@ -49,17 +49,36 @@ typedef bool (*PropertyEnabled)(JSContext* cx, JSObject* global);
|
||||
template<typename T>
|
||||
struct Prefable {
|
||||
inline bool isEnabled(JSContext* cx, JSObject* obj) const {
|
||||
return enabled &&
|
||||
(!enabledFunc ||
|
||||
enabledFunc(cx, js::GetGlobalForObjectCrossCompartment(obj)));
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
if (!enabledFunc && !availableFunc) {
|
||||
return true;
|
||||
}
|
||||
// Just go ahead and root obj, in case enabledFunc GCs
|
||||
JS::Rooted<JSObject*> rootedObj(cx, obj);
|
||||
if (enabledFunc &&
|
||||
!enabledFunc(cx, js::GetGlobalForObjectCrossCompartment(rootedObj))) {
|
||||
return false;
|
||||
}
|
||||
if (availableFunc &&
|
||||
!availableFunc(cx, js::GetGlobalForObjectCrossCompartment(rootedObj))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// A boolean indicating whether this set of specs is enabled
|
||||
bool enabled;
|
||||
// A function pointer to a function that can say the property is disabled
|
||||
// even if "enabled" is set to true. If the pointer is null the value of
|
||||
// "enabled" is used as-is.
|
||||
// "enabled" is used as-is unless availableFunc overrides.
|
||||
PropertyEnabled enabledFunc;
|
||||
// A function pointer to a function that can be used to disable a
|
||||
// property even if "enabled" is true and enabledFunc allowed. This
|
||||
// is basically a hack to avoid having to codegen PropertyEnabled
|
||||
// implementations in case when we need to do two separate checks.
|
||||
PropertyEnabled availableFunc;
|
||||
// Array of specs, terminated in whatever way is customary for T.
|
||||
// Null to indicate a end-of-array for Prefable, when such an
|
||||
// indicator is needed.
|
||||
|
@ -697,6 +697,11 @@ public:
|
||||
void Prefable17();
|
||||
void Prefable18();
|
||||
void Prefable19();
|
||||
void Prefable20();
|
||||
void Prefable21();
|
||||
void Prefable22();
|
||||
void Prefable23();
|
||||
void Prefable24();
|
||||
|
||||
// Miscellania
|
||||
int32_t AttrWithLenientThis();
|
||||
|
@ -678,6 +678,16 @@ interface TestInterface {
|
||||
void prefable18();
|
||||
[Func="TestFuncControlledMember"]
|
||||
void prefable19();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", ChromeOnly]
|
||||
void prefable20();
|
||||
[Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable21();
|
||||
[Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable22();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable23();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", AvailableIn=PrivilegedApps]
|
||||
void prefable24();
|
||||
|
||||
// Miscellania
|
||||
[LenientThis] attribute long attrWithLenientThis;
|
||||
|
@ -557,6 +557,56 @@ interface TestJSImplInterface {
|
||||
// Variadic handling
|
||||
void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3);
|
||||
|
||||
// Conditionally exposed methods/attributes
|
||||
[Pref="abc.def"]
|
||||
readonly attribute boolean prefable1;
|
||||
[Pref="abc.def"]
|
||||
readonly attribute boolean prefable2;
|
||||
[Pref="ghi.jkl"]
|
||||
readonly attribute boolean prefable3;
|
||||
[Pref="ghi.jkl"]
|
||||
readonly attribute boolean prefable4;
|
||||
[Pref="abc.def"]
|
||||
readonly attribute boolean prefable5;
|
||||
[Pref="abc.def", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
readonly attribute boolean prefable6;
|
||||
[Pref="abc.def", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
readonly attribute boolean prefable7;
|
||||
[Pref="ghi.jkl", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
readonly attribute boolean prefable8;
|
||||
[Pref="abc.def", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
readonly attribute boolean prefable9;
|
||||
[Pref="abc.def"]
|
||||
void prefable10();
|
||||
[Pref="abc.def", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
void prefable11();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember"]
|
||||
readonly attribute boolean prefable12;
|
||||
[Pref="abc.def", Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||
void prefable13();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember"]
|
||||
readonly attribute boolean prefable14;
|
||||
[Func="TestFuncControlledMember"]
|
||||
readonly attribute boolean prefable15;
|
||||
[Func="TestFuncControlledMember"]
|
||||
readonly attribute boolean prefable16;
|
||||
[Pref="abc.def", Func="TestFuncControlledMember"]
|
||||
void prefable17();
|
||||
[Func="TestFuncControlledMember"]
|
||||
void prefable18();
|
||||
[Func="TestFuncControlledMember"]
|
||||
void prefable19();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", ChromeOnly]
|
||||
void prefable20();
|
||||
[Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable21();
|
||||
[Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable22();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", AvailableIn=CertifiedApps]
|
||||
void prefable23();
|
||||
[Pref="abc.def", Func="TestFuncControlledMember", AvailableIn=PrivilegedApps]
|
||||
void prefable24();
|
||||
|
||||
// Miscellania
|
||||
[LenientThis] attribute long attrWithLenientThis;
|
||||
// FIXME: Bug 863954 Unforgeable things get all confused when
|
||||
|
Loading…
Reference in New Issue
Block a user