mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Refactor the cascade
Converting the specified value of some properties into a computed value depends on the value of other properties. For example, the `em` unit of any length depends on the `font-size` property. Previously, we would do a first pass over applicable declarations to build up a `values::computed::Context` struct with a number of fields for each such piece of data from other properties. This simplies the struct by instead having it contain the set of computed values (for a given element) that is being populated and classify properties into "early" and "other", such that the only dependencies can be from "other" to "early". We iterate applicable_declarations twice, first cascading "early" properties then "other". Unfortunately, it’s not easy to check that this classification is correct.
This commit is contained in:
parent
bab28e5070
commit
529164e4a5
3 changed files with 213 additions and 339 deletions
|
@ -8,7 +8,7 @@ use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser,
|
|||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
use properties::longhands;
|
||||
use properties::INITIAL_VALUES;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::collections::hash_map::{Entry, HashMap};
|
||||
use std::fmt;
|
||||
|
@ -594,21 +594,8 @@ impl MaybeNew for ViewportConstraints {
|
|||
let context = Context {
|
||||
is_root_element: false,
|
||||
viewport_size: initial_viewport,
|
||||
inherited_font_weight: longhands::font_weight::get_initial_value(),
|
||||
inherited_font_size: longhands::font_size::get_initial_value(),
|
||||
inherited_text_decorations_in_effect: longhands::_servo_text_decorations_in_effect::get_initial_value(),
|
||||
font_size: longhands::font_size::get_initial_value(),
|
||||
root_font_size: longhands::font_size::get_initial_value(),
|
||||
display: longhands::display::get_initial_value(),
|
||||
color: longhands::color::get_initial_value(),
|
||||
text_decoration: longhands::text_decoration::get_initial_value(),
|
||||
positioned: false,
|
||||
floated: false,
|
||||
border_top_present: false,
|
||||
border_right_present: false,
|
||||
border_bottom_present: false,
|
||||
border_left_present: false,
|
||||
outline_style_present: false,
|
||||
inherited_style: &*INITIAL_VALUES,
|
||||
style: INITIAL_VALUES.clone(),
|
||||
};
|
||||
|
||||
// DEVICE-ADAPT § 9.3 Resolving 'extend-to-zoom'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue