This commit is contained in:
Shinichi Morimoto 2020-03-28 20:17:16 +09:00
parent 7d66871a9f
commit 80b2a87be7
3 changed files with 13 additions and 3 deletions

View file

@ -2968,12 +2968,19 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
def definition_body(self): def definition_body(self):
ret = '' ret = ''
interface = self.descriptor.interface interface = self.descriptor.interface
for m in interface.members: for m in interface.members:
if m.isAttr() and not m.isStatic() and m.type.isJSONType(): if m.isAttr() and not m.isStatic() and m.type.isJSONType():
name = m.identifier.name name = m.identifier.name
conditions = MemberCondition(None, None, m.exposureSet)
ret_conditions = 'vec![' + ",".join(conditions) + "]"
ret += fill( ret += fill(
""" """
rooted!(in(cx) let mut temp = UndefinedValue()); let conditions = ${conditions};
if !conditions.iter().any(|c| c.is_satisfied(SafeJSContext::from_ptr(cx), HandleObject::from_raw(obj), HandleObject::from_raw(obj))) {
return false;
}
rooted!(in(cx) let mut temp = UndefinedValue());
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false; return false;
} }
@ -2983,7 +2990,7 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
return false; return false;
} }
""", """,
name=name, nameAsArray=str_to_const_array(name)) name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions)
ret += 'return true;\n' ret += 'return true;\n'
return CGGeneric(ret) return CGGeneric(ret)

View file

@ -50,7 +50,7 @@ pub enum Condition {
} }
impl Condition { impl Condition {
fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool { pub fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool {
match *self { match *self {
Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false), Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false),
Condition::Func(f) => f(cx, obj), Condition::Func(f) => f(cx, obj),

View file

@ -375,6 +375,9 @@ pub fn is_exposed_in(object: HandleObject, globals: Globals) -> bool {
unsafe { unsafe {
let unwrapped = UncheckedUnwrapObject(object.get(), /* stopAtWindowProxy = */ 0); let unwrapped = UncheckedUnwrapObject(object.get(), /* stopAtWindowProxy = */ 0);
let dom_class = get_dom_class(unwrapped).unwrap(); let dom_class = get_dom_class(unwrapped).unwrap();
if (dom_class.global.is_empty()) && (!globals.is_empty()) {
return false
}
globals.contains(dom_class.global) globals.contains(dom_class.global)
} }
} }