Skip to content

Commit

Permalink
Give StyleBuilder separate inherited styles for inherited and non-inh…
Browse files Browse the repository at this point in the history
…erited structs.

This is needed for ::first-line, which causes its kids to inherit different properties from different places.

Part 2 of Gecko bug 1382806.  r=emilio
  • Loading branch information
bzbarsky committed Jul 26, 2017
1 parent 648c0a3 commit f991b76
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/style/properties/properties.mako.rs
Expand Up @@ -2470,6 +2470,11 @@ pub struct StyleBuilder<'a> {
/// `parent_style.unwrap_or(device.default_computed_values())`.
inherited_style: &'a ComputedValues,

/// The style we're inheriting from for properties that don't inherit from
/// ::first-line. This is the same as inherited_style, unless
/// inherited_style is a ::first-line style.
inherited_style_ignoring_first_line: &'a ComputedValues,

/// The style we're getting reset structs from.
reset_style: &'a ComputedValues,

Expand Down Expand Up @@ -2528,6 +2533,7 @@ impl<'a> StyleBuilder<'a> {
device,
parent_style,
inherited_style,
inherited_style_ignoring_first_line: inherited_style,
reset_style,
pseudo,
rules,
Expand Down Expand Up @@ -2560,6 +2566,7 @@ impl<'a> StyleBuilder<'a> {
device,
parent_style,
inherited_style,
inherited_style_ignoring_first_line: inherited_style,
reset_style,
pseudo,
rules: None, // FIXME(emilio): Dubious...
Expand All @@ -2581,8 +2588,13 @@ impl<'a> StyleBuilder<'a> {
/// Inherit `${property.ident}` from our parent style.
#[allow(non_snake_case)]
pub fn inherit_${property.ident}(&mut self) {
% if property.style_struct.inherited:
let inherited_struct =
self.inherited_style.get_${property.style_struct.name_lower}();
% else:
let inherited_struct =
self.inherited_style_ignoring_first_line.get_${property.style_struct.name_lower}();
% endif
self.${property.style_struct.ident}.mutate()
.copy_${property.ident}_from(
inherited_struct,
Expand Down Expand Up @@ -2776,7 +2788,11 @@ impl<'a> StyleBuilder<'a> {
/// next-best thing and call them `parent_${style_struct.name_lower}`
/// instead.
pub fn get_parent_${style_struct.name_lower}(&self) -> &style_structs::${style_struct.name} {
% if style_struct.inherited:
self.inherited_style.get_${style_struct.name_lower}()
% else:
self.inherited_style_ignoring_first_line.get_${style_struct.name_lower}()
% endif
}
% endfor
}
Expand Down

0 comments on commit f991b76

Please sign in to comment.