diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2016-10-25 19:50:31 -0700 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2016-10-27 10:22:32 -0700 |
commit | 1090abae877bb6624e49b34540682a389e7daaac (patch) | |
tree | ee6a10eb6fbb90cd198d234e4993ae059c5f89b0 /components/script/layout_wrapper.rs | |
parent | 1cfd5e81725c0bf6f9ec59f3d80646303bad2555 (diff) | |
download | servo-1090abae877bb6624e49b34540682a389e7daaac.tar.gz servo-1090abae877bb6624e49b34540682a389e7daaac.zip |
Don't traverse text nodes during styling.
MozReview-Commit-ID: 6CtQMxbcLnF
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r-- | components/script/layout_wrapper.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 0cc2e7f3c78..b5e1c5a4f60 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -763,6 +763,9 @@ impl<'ln> NodeInfo for ServoThreadSafeLayoutNode<'ln> { } fn is_text_node(&self) -> bool { + // It's unlikely that text nodes will ever be used to implement a + // pseudo-element, but the type system doesn't really enforce that, + // so we check to be safe. self.pseudo == PseudoElementType::Normal && self.node.is_text_node() } @@ -802,11 +805,18 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } fn style_for_text_node(&self) -> Arc<ComputedValues> { + // 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.) debug_assert!(self.is_text_node()); let parent = self.node.parent_node().unwrap(); let parent_data = parent.get_style_data().unwrap().borrow(); - let parent_style = &parent_data.current_styles().primary; - ComputedValues::style_for_child_text_node(parent_style) + parent_data.current_styles().primary.clone() } fn debug_id(self) -> usize { |