servo: Merge #14223 - Delegate logical bitfield setters to physical to fix cascade (from Manishearth:fix-logical-cascade); r=emilio
authorManish Goregaokar <manishsmail@gmail.com>
Wed, 16 Nov 2016 19:10:25 -0600
changeset 340164 c540bc5a85a119d84a5fc22b318135d7ea283e6c
parent 340163 f4b7c1063b4a49ee918465118627f64dca7d5c18
child 340165 637897853905780bcf5563bf7b74b8fe3d45ab4a
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
servo: Merge #14223 - Delegate logical bitfield setters to physical to fix cascade (from Manishearth:fix-logical-cascade); r=emilio (fixes #14222) Five minutes early for "tomorrow", _shrug_. I'm not entirely sure of this fix. It depends on properties going through the cascade in source order all else being the same. I think that's the case. Fixes wikipedia though. r? @emilio or @SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: 8c6703637ff82e3a6063cfb032e6179e3dc4d18a
servo/components/style/properties/helpers.mako.rs
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -201,33 +201,36 @@
                                 cascade_info: &mut Option<<&mut CascadeInfo>,
                                 error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
             let declared_value = match *declaration {
                 PropertyDeclaration::${property.camel_case}(ref declared_value) => {
                     declared_value
                 }
                 _ => 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_${property.ident}() {
+                if seen.get${maybe_physical}_${property.ident}(${maybe_wm}) {
                     return
                 }
-                seen.set_${property.ident}();
+                seen.set${maybe_physical}_${property.ident}(${maybe_wm});
                 {
                     let custom_props = context.style().custom_properties();
                     ::properties::substitute_variables_${property.ident}(
                         declared_value, &custom_props,
                     |value| {
                         if let Some(ref mut cascade_info) = *cascade_info {
                             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) => {
                                 let computed = specified_value.to_computed_value(context);
                                 % if property.has_uncacheable_values:
                                 context.mutate_style().mutate_${data.current_style_struct.name_lower}()
                                                       .set_${property.ident}(computed, cacheable ${maybe_wm});
                                 % else:
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -145,16 +145,17 @@ pub mod shorthands {
 pub mod animated_properties {
     <%include file="/helpers/animated_properties.mako.rs" />
 }
 
 
 // TODO(SimonSapin): Convert this to a syntax extension rather than a Mako template.
 // Maybe submit for inclusion in libstd?
 mod property_bit_field {
+    use logical_geometry::WritingMode;
 
     pub struct PropertyBitField {
         storage: [u32; (${len(data.longhands)} - 1 + 32) / 32]
     }
 
     impl PropertyBitField {
         #[inline]
         pub fn new() -> PropertyBitField {
@@ -177,16 +178,34 @@ mod property_bit_field {
                     self.get(${i})
                 }
                 #[allow(non_snake_case)]
                 #[inline]
                 pub fn set_${property.ident}(&mut self) {
                     self.set(${i})
                 }
             % endif
+            % if property.logical:
+                #[allow(non_snake_case)]
+                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}()
+                        </%def>
+                    </%helpers:logical_setter_helper>
+                }
+                #[allow(non_snake_case)]
+                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}()
+                        </%def>
+                    </%helpers:logical_setter_helper>
+                }
+            % endif
         % endfor
     }
 }
 
 % for property in data.longhands:
     % if not property.derived_from:
         #[allow(non_snake_case)]
         fn substitute_variables_${property.ident}<F>(