From c313c8d17ee1fa74d12e4a36ac9be708424e3c56 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 4 Jan 2017 13:44:08 -0500 Subject: [PATCH] Bug 1298588 part 6, servo piece. Stop using initial_values when doing inheritance in Gecko glue code. r=bholley --- components/style/gecko_bindings/bindings.rs | 3 ++- components/style/properties/gecko.mako.rs | 11 ++--------- ports/geckolib/glue.rs | 9 ++++++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 83350c3d389..a78aec48ff9 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1361,7 +1361,8 @@ extern "C" { -> ServoComputedValuesStrong; } extern "C" { - pub fn Servo_ComputedValues_Inherit(parent_style: + pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed, + parent_style: ServoComputedValuesBorrowedOrNull) -> ServoComputedValuesStrong; } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 0dffdd16344..6fd2d868b26 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -78,7 +78,7 @@ pub struct ComputedValues { } impl ComputedValues { - pub fn inherit_from(parent: &Arc) -> Arc { + pub fn inherit_from(parent: &Arc, default: &Arc) -> Arc { Arc::new(ComputedValues { custom_properties: parent.custom_properties.clone(), shareable: parent.shareable, @@ -88,7 +88,7 @@ impl ComputedValues { % if style_struct.inherited: ${style_struct.ident}: parent.${style_struct.ident}.clone(), % else: - ${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(), + ${style_struct.ident}: default.${style_struct.ident}.clone(), % endif % endfor }) @@ -113,13 +113,6 @@ impl ComputedValues { } } - pub fn style_for_child_text_node(parent: &Arc) -> Arc { - // Gecko expects text nodes to be styled as if they were elements that - // matched no rules (that is, inherited style structs are inherited and - // non-inherited style structs are set to their initial values). - ComputedValues::inherit_from(parent) - } - pub fn initial_values() -> &'static Self { unsafe { debug_assert!(!raw_initial_values().is_null()); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 5e5b1316a9b..314d33a5bf4 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -581,13 +581,16 @@ fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom, } #[no_mangle] -pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValuesBorrowedOrNull) +pub extern "C" fn Servo_ComputedValues_Inherit( + raw_data: RawServoStyleSetBorrowed, + parent_style: ServoComputedValuesBorrowedOrNull) -> ServoComputedValuesStrong { + let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style); let style = if let Some(reference) = maybe_arc.as_ref() { - ComputedValues::inherit_from(reference) + ComputedValues::inherit_from(reference, &data.default_computed_values) } else { - Arc::new(ComputedValues::initial_values().clone()) + data.default_computed_values.clone() }; style.into_strong() }