Auto merge of #14223 - Manishearth:fix-logical-cascade, r=emilio

Delegate logical bitfield setters to physical to fix cascade

(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

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14223)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-16 19:10:25 -06:00 committed by GitHub
commit 8c6703637f
2 changed files with 27 additions and 5 deletions

View file

@ -206,11 +206,17 @@
} }
_ => panic!("entered the wrong cascade_property() implementation"), _ => 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 not property.derived_from:
if seen.get_${property.ident}() { if seen.get${maybe_physical}_${property.ident}(${maybe_wm}) {
return return
} }
seen.set_${property.ident}(); seen.set${maybe_physical}_${property.ident}(${maybe_wm});
{ {
let custom_props = context.style().custom_properties(); let custom_props = context.style().custom_properties();
::properties::substitute_variables_${property.ident}( ::properties::substitute_variables_${property.ident}(
@ -220,9 +226,6 @@
cascade_info.on_cascade_property(&declaration, cascade_info.on_cascade_property(&declaration,
&value); &value);
} }
% if property.logical:
let wm = context.style.writing_mode;
% endif
<% maybe_wm = ", wm" if property.logical else "" %> <% maybe_wm = ", wm" if property.logical else "" %>
match *value { match *value {
DeclaredValue::Value(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {

View file

@ -150,6 +150,7 @@ pub mod animated_properties {
// TODO(SimonSapin): Convert this to a syntax extension rather than a Mako template. // TODO(SimonSapin): Convert this to a syntax extension rather than a Mako template.
// Maybe submit for inclusion in libstd? // Maybe submit for inclusion in libstd?
mod property_bit_field { mod property_bit_field {
use logical_geometry::WritingMode;
pub struct PropertyBitField { pub struct PropertyBitField {
storage: [u32; (${len(data.longhands)} - 1 + 32) / 32] storage: [u32; (${len(data.longhands)} - 1 + 32) / 32]
@ -182,6 +183,24 @@ mod property_bit_field {
self.set(${i}) self.set(${i})
} }
% endif % 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 % endfor
} }
} }