diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 9098a8cace8..3c01e452564 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -2664,17 +2664,18 @@ extern "C" { ServoComputedValuesBorrowed) -> ServoComputedValuesStrong; } +extern "C" { + pub fn Servo_ComputedValues_GetStyleRuleList(values: + ServoComputedValuesBorrowed, + rules: + RawGeckoServoStyleRuleListBorrowedMut); +} extern "C" { pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData); } extern "C" { pub fn Servo_Shutdown(); } -extern "C" { - pub fn Servo_Element_GetStyleRuleList(element: RawGeckoElementBorrowed, - rules: - RawGeckoServoStyleRuleListBorrowedMut); -} extern "C" { pub fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed, restyle_hint: nsRestyleHint, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 7bc71af9fcd..50da9bd43ac 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1705,6 +1705,24 @@ pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: b.specifies_animations() || b.specifies_transitions() } +#[no_mangle] +pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoComputedValuesBorrowed, + rules: RawGeckoServoStyleRuleListBorrowedMut) { + let values = ComputedValues::as_arc(&values); + if let Some(ref rule_node) = values.rules { + let mut result = vec![]; + for node in rule_node.self_and_ancestors() { + if let &StyleSource::Style(ref rule) = node.style_source() { + result.push(Locked::::arc_as_borrowed(&rule)); + } + } + unsafe { rules.set_len(result.len() as u32) }; + for (&src, dest) in result.into_iter().zip(rules.iter_mut()) { + *dest = src; + } + } +} + /// See the comment in `Device` to see why it's ok to pass an owned reference to /// the pres context (hint: the context outlives the StyleSet, that holds the /// device alive). @@ -2626,30 +2644,6 @@ unsafe fn maybe_restyle<'a>(data: &'a mut AtomicRefMut, Some(&mut data.restyle) } -#[no_mangle] -pub extern "C" fn Servo_Element_GetStyleRuleList(element: RawGeckoElementBorrowed, - rules: RawGeckoServoStyleRuleListBorrowedMut) { - let element = GeckoElement(element); - let data = match element.borrow_data() { - Some(element_data) => element_data, - None => return, - }; - let computed = match data.styles.get_primary() { - Some(values) => values, - None => return, - }; - let mut result = vec![]; - for rule_node in computed.rules().self_and_ancestors() { - if let &StyleSource::Style(ref rule) = rule_node.style_source() { - result.push(Locked::::arc_as_borrowed(&rule)); - } - } - unsafe { rules.set_len(result.len() as u32) }; - for (&src, dest) in result.into_iter().zip(rules.iter_mut()) { - *dest = src; - } -} - #[no_mangle] pub extern "C" fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed, restyle_hint: nsRestyleHint,