mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
fixed #25281
This commit is contained in:
parent
7d66871a9f
commit
80b2a87be7
3 changed files with 13 additions and 3 deletions
|
@ -2968,11 +2968,18 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
|
|||
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(
|
||||
"""
|
||||
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;
|
||||
|
@ -2983,7 +2990,7 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
|
|||
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)
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue