aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-28 18:00:48 -0700
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-28 18:00:48 -0700
commit1177ef5869e02b5129ebde6fa9780c93d362e16c (patch)
treef8adb81e6fc5e20616a7b46aa32b45fafe0e0569 /components
parentf932db34c85dcd65a46ddde3ce0d8f6c92c28b7b (diff)
parentdafc683aefa2b03cffa426071cfa253c435cf52e (diff)
downloadservo-1177ef5869e02b5129ebde6fa9780c93d362e16c.tar.gz
servo-1177ef5869e02b5129ebde6fa9780c93d362e16c.zip
Auto merge of #10891 - heycam:text-style, r=bholley
Specialize text node style resolution so geckolib can avoid inheriting non-inherited structs. r? @bholley <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10891) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/style/matching.rs6
-rw-r--r--components/style/properties/properties.mako.rs14
2 files changed, 15 insertions, 5 deletions
diff --git a/components/style/matching.rs b/components/style/matching.rs
index 15407d10eca..84189fde404 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -662,13 +662,9 @@ pub trait MatchMethods : TNode {
let damage;
if self.is_text_node() {
- // Text nodes get a copy of the parent style. This ensures
- // that during fragment construction any non-inherited
- // CSS properties (such as vertical-align) are correctly
- // set on the fragment(s).
let mut data_ref = self.mutate_data().unwrap();
let mut data = &mut *data_ref;
- let cloned_parent_style = parent_style.unwrap().clone();
+ let cloned_parent_style = Self::ConcreteComputedValues::style_for_child_text_node(parent_style.unwrap());
damage = Self::ConcreteRestyleDamage::compute(data.style.as_ref(),
&*cloned_parent_style);
data.style = Some(cloned_parent_style);
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index c49e210567b..1717f9ae1b7 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -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) {