Skip to content

Commit

Permalink
fixed #25281
Browse files Browse the repository at this point in the history
  • Loading branch information
shnmorimoto committed Mar 28, 2020
1 parent 7d66871 commit 80b2a87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2968,12 +2968,19 @@ def __init__(self, descriptor, toJSONMethod):
def definition_body(self):
ret = ''
interface = self.descriptor.interface

for m in interface.members:
if m.isAttr() and not m.isStatic() and m.type.isJSONType():
name = m.identifier.name
conditions = MemberCondition(None, None, m.exposureSet)
ret_conditions = 'vec![' + ",".join(conditions) + "]"
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() }) {
return false;
}
Expand All @@ -2983,7 +2990,7 @@ def definition_body(self):
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'
return CGGeneric(ret)

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/guard.rs
Expand Up @@ -50,7 +50,7 @@ pub enum 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 {
Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false),
Condition::Func(f) => f(cx, obj),
Expand Down
3 changes: 3 additions & 0 deletions components/script/dom/bindings/interface.rs
Expand Up @@ -375,6 +375,9 @@ pub fn is_exposed_in(object: HandleObject, globals: Globals) -> bool {
unsafe {
let unwrapped = UncheckedUnwrapObject(object.get(), /* stopAtWindowProxy = */ 0);
let dom_class = get_dom_class(unwrapped).unwrap();
if (dom_class.global.is_empty()) && (!globals.is_empty()) {
return false
}
globals.contains(dom_class.global)
}
}
Expand Down

0 comments on commit 80b2a87

Please sign in to comment.