diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index a55e7e2b153..a6c21c430f4 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -245,7 +245,6 @@ inherited_style: &ComputedValues, default_style: &Arc, context: &mut computed::Context, - seen: &mut PropertyBitField, cacheable: &mut bool, cascade_info: &mut Option<<&mut CascadeInfo>, error_reporter: &mut StdBox) { @@ -256,16 +255,7 @@ _ => panic!("entered the wrong cascade_property() implementation"), }; - % if property.logical: - let wm = context.style.writing_mode; - % endif - <% maybe_wm = "wm" if property.logical else "" %> - <% maybe_physical = "_physical" if property.logical else "" %> % if not property.derived_from: - if seen.get${maybe_physical}_${property.ident}(${maybe_wm}) { - return - } - seen.set${maybe_physical}_${property.ident}(${maybe_wm}); { let custom_props = context.style().custom_properties(); ::properties::substitute_variables_${property.ident}( @@ -275,6 +265,9 @@ cascade_info.on_cascade_property(&declaration, &value); } + % if property.logical: + let wm = context.style.writing_mode; + % endif <% maybe_wm = ", wm" if property.logical else "" %> match *value { DeclaredValue::Value(ref specified_value) => { @@ -321,7 +314,6 @@ cascade_property_custom(declaration, inherited_style, context, - seen, cacheable, error_reporter); % endif diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 25b2bf5616a..696d9038353 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -84,7 +84,6 @@ fn cascade_property_custom(_declaration: &PropertyDeclaration, _inherited_style: &ComputedValues, context: &mut computed::Context, - _seen: &mut PropertyBitField, _cacheable: &mut bool, _error_reporter: &mut StdBox) { longhands::_servo_display_for_hypothetical_box::derive_from_display(context); diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 30342595b4b..9b2a851bc6f 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -204,7 +204,6 @@ ${helpers.single_keyword("unicode-bidi", fn cascade_property_custom(_declaration: &PropertyDeclaration, _inherited_style: &ComputedValues, context: &mut computed::Context, - _seen: &mut PropertyBitField, _cacheable: &mut bool, _error_reporter: &mut StdBox) { longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context); diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 21839b9ec74..50a8881a1fb 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -180,7 +180,6 @@ pub mod animated_properties { #[allow(missing_docs)] pub mod property_bit_field { - use logical_geometry::WritingMode; use properties::animated_properties::TransitionProperty; use properties::LonghandId; @@ -223,24 +222,6 @@ pub mod property_bit_field { self.insert(LonghandId::${property.camel_case}) } % endif - % if property.logical: - #[allow(non_snake_case, missing_docs)] - pub fn get_physical_${property.ident}(&self, wm: WritingMode) -> bool { - <%helpers:logical_setter_helper name="${property.name}"> - <%def name="inner(physical_ident)"> - self.get_${physical_ident}() - - - } - #[allow(non_snake_case, missing_docs)] - pub fn set_physical_${property.ident}(&mut self, wm: WritingMode) { - <%helpers:logical_setter_helper name="${property.name}"> - <%def name="inner(physical_ident)"> - self.set_${physical_ident}() - - - } - % endif % endfor /// Set the corresponding bit of TransitionProperty. @@ -450,6 +431,25 @@ impl LonghandId { % endfor } } + + /// If this is a logical property, return the corresponding physical one in the given writing mode. + /// Otherwise, return unchanged. + pub fn to_physical(&self, wm: WritingMode) -> Self { + match *self { + % for property in data.longhands: + % if property.logical: + LonghandId::${property.camel_case} => { + <%helpers:logical_setter_helper name="${property.name}"> + <%def name="inner(physical_ident)"> + LonghandId::${to_camel_case(physical_ident)} + + + } + % endif + % endfor + _ => *self + } + } } /// An identifier for a given shorthand property. @@ -1697,7 +1697,6 @@ pub type CascadePropertyFn = inherited_style: &ComputedValues, default_style: &Arc, context: &mut computed::Context, - seen: &mut PropertyBitField, cacheable: &mut bool, cascade_info: &mut Option<<&mut CascadeInfo>, error_reporter: &mut StdBox); @@ -1907,19 +1906,25 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D, continue } + <% maybe_to_physical = ".to_physical(writing_mode)" if category_to_cascade_now != "early" else "" %> + let physical_longhand_id = longhand_id ${maybe_to_physical}; + if seen.contains(physical_longhand_id) { + continue + } + seen.insert(physical_longhand_id); + let discriminant = longhand_id as usize; (CASCADE_PROPERTY[discriminant])(declaration, inherited_style, default_style, &mut context, - &mut seen, &mut cacheable, &mut cascade_info, &mut error_reporter); } % if category_to_cascade_now == "early": - let mode = get_writing_mode(context.style.get_inheritedbox()); - context.style.set_writing_mode(mode); + let writing_mode = get_writing_mode(context.style.get_inheritedbox()); + context.style.set_writing_mode(writing_mode); % endif % endfor