Specialize text node style resolution so geckolib can avoid inheriting non-inherited structs.

This commit is contained in:
Cameron McCormack 2016-04-27 17:11:38 +10:00
parent fbc575407d
commit dafc683aef
3 changed files with 34 additions and 5 deletions

View file

@ -1496,6 +1496,8 @@ pub trait ComputedValues : Clone + Send + Sync + 'static {
% endfor
) -> Self;
fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self>;
fn initial_values() -> &'static Self;
fn do_cascade_property<F: FnOnce(&Vec<Option<CascadePropertyFn<Self>>>)>(f: F);
@ -1554,6 +1556,18 @@ impl ComputedValues for ServoComputedValues {
}
}
fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self> {
// Text nodes get a copy of the parent style. Inheriting all non-
// inherited properties into the text node is odd from a CSS
// perspective, but makes fragment construction easier (by making
// properties like vertical-align on fragments have values that
// match the parent element). This is an implementation detail of
// Servo layout that is not central to how fragment construction
// works, but would be difficult to change. (Text node style is
// also not visible to script.)
parent.clone()
}
fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
fn do_cascade_property<F: FnOnce(&Vec<Option<CascadePropertyFn<Self>>>)>(f: F) {