mirror of
https://github.com/servo/servo.git
synced 2025-07-01 20:43:39 +01:00
style: Don't cache structs if they have been adjusted.
StyleAdjuster looks a bunch of things that we don't record as dependencies.
This commit is contained in:
parent
73ae5ffd94
commit
a7dd19cfb1
1 changed files with 42 additions and 5 deletions
|
@ -2602,6 +2602,11 @@ pub struct StyleBuilder<'a> {
|
||||||
/// The pseudo-element this style will represent.
|
/// The pseudo-element this style will represent.
|
||||||
pseudo: Option<<&'a PseudoElement>,
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
|
|
||||||
|
/// Whether we have mutated any reset structs since the the last time
|
||||||
|
/// `clear_modified_reset` was called. This is used to tell whether the
|
||||||
|
/// `StyleAdjuster` did any work.
|
||||||
|
modified_reset: bool,
|
||||||
|
|
||||||
/// The writing mode flags.
|
/// The writing mode flags.
|
||||||
///
|
///
|
||||||
/// TODO(emilio): Make private.
|
/// TODO(emilio): Make private.
|
||||||
|
@ -2665,6 +2670,7 @@ impl<'a> StyleBuilder<'a> {
|
||||||
reset_style,
|
reset_style,
|
||||||
pseudo,
|
pseudo,
|
||||||
rules,
|
rules,
|
||||||
|
modified_reset: false,
|
||||||
custom_properties,
|
custom_properties,
|
||||||
writing_mode,
|
writing_mode,
|
||||||
font_size_keyword,
|
font_size_keyword,
|
||||||
|
@ -2706,6 +2712,7 @@ impl<'a> StyleBuilder<'a> {
|
||||||
inherited_style_ignoring_first_line: inherited_style,
|
inherited_style_ignoring_first_line: inherited_style,
|
||||||
reset_style,
|
reset_style,
|
||||||
pseudo,
|
pseudo,
|
||||||
|
modified_reset: false,
|
||||||
rules: None, // FIXME(emilio): Dubious...
|
rules: None, // FIXME(emilio): Dubious...
|
||||||
custom_properties: style_to_derive_from.custom_properties(),
|
custom_properties: style_to_derive_from.custom_properties(),
|
||||||
writing_mode: style_to_derive_from.writing_mode,
|
writing_mode: style_to_derive_from.writing_mode,
|
||||||
|
@ -2745,6 +2752,7 @@ impl<'a> StyleBuilder<'a> {
|
||||||
|
|
||||||
% if not property.style_struct.inherited:
|
% if not property.style_struct.inherited:
|
||||||
self.flags.insert(::properties::computed_value_flags::INHERITS_RESET_STYLE);
|
self.flags.insert(::properties::computed_value_flags::INHERITS_RESET_STYLE);
|
||||||
|
self.modified_reset = true;
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% if property.ident == "content":
|
% if property.ident == "content":
|
||||||
|
@ -2770,6 +2778,10 @@ impl<'a> StyleBuilder<'a> {
|
||||||
let reset_struct =
|
let reset_struct =
|
||||||
self.reset_style.get_${property.style_struct.name_lower}();
|
self.reset_style.get_${property.style_struct.name_lower}();
|
||||||
|
|
||||||
|
% if not property.style_struct.inherited:
|
||||||
|
self.modified_reset = true;
|
||||||
|
% endif
|
||||||
|
|
||||||
self.${property.style_struct.ident}.mutate()
|
self.${property.style_struct.ident}.mutate()
|
||||||
.reset_${property.ident}(
|
.reset_${property.ident}(
|
||||||
reset_struct,
|
reset_struct,
|
||||||
|
@ -2786,6 +2798,10 @@ impl<'a> StyleBuilder<'a> {
|
||||||
&mut self,
|
&mut self,
|
||||||
value: longhands::${property.ident}::computed_value::T
|
value: longhands::${property.ident}::computed_value::T
|
||||||
) {
|
) {
|
||||||
|
% if not property.style_struct.inherited:
|
||||||
|
self.modified_reset = true;
|
||||||
|
% endif
|
||||||
|
|
||||||
<% props_need_device = ["content", "list_style_type", "font_variant_alternates"] %>
|
<% props_need_device = ["content", "list_style_type", "font_variant_alternates"] %>
|
||||||
self.${property.style_struct.ident}.mutate()
|
self.${property.style_struct.ident}.mutate()
|
||||||
.set_${property.ident}(
|
.set_${property.ident}(
|
||||||
|
@ -2849,11 +2865,17 @@ impl<'a> StyleBuilder<'a> {
|
||||||
|
|
||||||
/// Gets a mutable view of the current `${style_struct.name}` style.
|
/// Gets a mutable view of the current `${style_struct.name}` style.
|
||||||
pub fn mutate_${style_struct.name_lower}(&mut self) -> &mut style_structs::${style_struct.name} {
|
pub fn mutate_${style_struct.name_lower}(&mut self) -> &mut style_structs::${style_struct.name} {
|
||||||
|
% if not property.style_struct.inherited:
|
||||||
|
self.modified_reset = true;
|
||||||
|
% endif
|
||||||
self.${style_struct.ident}.mutate()
|
self.${style_struct.ident}.mutate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a mutable view of the current `${style_struct.name}` style.
|
/// Gets a mutable view of the current `${style_struct.name}` style.
|
||||||
pub fn take_${style_struct.name_lower}(&mut self) -> UniqueArc<style_structs::${style_struct.name}> {
|
pub fn take_${style_struct.name_lower}(&mut self) -> UniqueArc<style_structs::${style_struct.name}> {
|
||||||
|
% if not property.style_struct.inherited:
|
||||||
|
self.modified_reset = true;
|
||||||
|
% endif
|
||||||
self.${style_struct.ident}.take()
|
self.${style_struct.ident}.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2902,6 +2924,16 @@ impl<'a> StyleBuilder<'a> {
|
||||||
longhands::_moz_top_layer::computed_value::T::top)
|
longhands::_moz_top_layer::computed_value::T::top)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clears the "have any reset structs been modified" flag.
|
||||||
|
fn clear_modified_reset(&mut self) {
|
||||||
|
self.modified_reset = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether we have mutated any reset structs since the the last
|
||||||
|
/// time `clear_modified_reset` was called.
|
||||||
|
fn modified_reset(&self) -> bool {
|
||||||
|
self.modified_reset
|
||||||
|
}
|
||||||
|
|
||||||
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
||||||
pub fn build(self) -> Arc<ComputedValues> {
|
pub fn build(self) -> Arc<ComputedValues> {
|
||||||
|
@ -3469,11 +3501,6 @@ where
|
||||||
|
|
||||||
let mut builder = context.builder;
|
let mut builder = context.builder;
|
||||||
|
|
||||||
{
|
|
||||||
StyleAdjuster::new(&mut builder)
|
|
||||||
.adjust(layout_parent_style, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
if let Some(ref mut bg) = builder.get_background_if_mutated() {
|
if let Some(ref mut bg) = builder.get_background_if_mutated() {
|
||||||
bg.fill_arrays();
|
bg.fill_arrays();
|
||||||
|
@ -3493,6 +3520,16 @@ where
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
|
builder.clear_modified_reset();
|
||||||
|
|
||||||
|
StyleAdjuster::new(&mut builder)
|
||||||
|
.adjust(layout_parent_style, flags);
|
||||||
|
|
||||||
|
if builder.modified_reset() {
|
||||||
|
context.rule_cache_conditions.borrow_mut()
|
||||||
|
.set_uncacheable();
|
||||||
|
}
|
||||||
|
|
||||||
builder.build()
|
builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue