aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/css/matching.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2015-12-15 20:37:53 -0800
committerBobby Holley <bobbyholley@gmail.com>2015-12-23 12:05:25 -0700
commite55a56d757e8760e73f48558b080fea90acd9ca7 (patch)
treeea89e1147092380a364e09be06e869e7c01f3e27 /components/layout/css/matching.rs
parent6637626e02f30d2c476eba96d117f77575eaacb6 (diff)
downloadservo-e55a56d757e8760e73f48558b080fea90acd9ca7.tar.gz
servo-e55a56d757e8760e73f48558b080fea90acd9ca7.zip
Add an is_text_node to LayoutNode, so that we don't need to implement type_id for the style system.
Diffstat (limited to 'components/layout/css/matching.rs')
-rw-r--r--components/layout/css/matching.rs74
1 files changed, 35 insertions, 39 deletions
diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs
index 7036038369c..ae136aea5ff 100644
--- a/components/layout/css/matching.rs
+++ b/components/layout/css/matching.rs
@@ -11,7 +11,6 @@ use context::SharedLayoutContext;
use data::LayoutDataWrapper;
use incremental::{self, RestyleDamage};
use msg::ParseErrorReporter;
-use script::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
use script::layout_interface::Animation;
use selectors::bloom::BloomFilter;
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
@@ -724,49 +723,46 @@ impl<'ln, ConcreteLayoutNode> MatchMethods<'ln, ConcreteLayoutNode>
match *layout_data_ref {
None => panic!("no layout data"),
Some(ref mut layout_data) => {
- match self.type_id() {
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
- // 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 cloned_parent_style = parent_style.unwrap().clone();
- layout_data.shared_data.style = Some(cloned_parent_style);
+ 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 cloned_parent_style = parent_style.unwrap().clone();
+ layout_data.shared_data.style = Some(cloned_parent_style);
+ } else {
+ let mut damage = self.cascade_node_pseudo_element(
+ layout_context,
+ parent_style,
+ &applicable_declarations.normal,
+ &mut layout_data.shared_data.style,
+ applicable_declarations_cache,
+ new_animations_sender,
+ applicable_declarations.normal_shareable,
+ true);
+ if !applicable_declarations.before.is_empty() {
+ damage = damage | self.cascade_node_pseudo_element(
+ layout_context,
+ Some(layout_data.shared_data.style.as_ref().unwrap()),
+ &*applicable_declarations.before,
+ &mut layout_data.data.before_style,
+ applicable_declarations_cache,
+ new_animations_sender,
+ false,
+ false);
}
- _ => {
- let mut damage = self.cascade_node_pseudo_element(
+ if !applicable_declarations.after.is_empty() {
+ damage = damage | self.cascade_node_pseudo_element(
layout_context,
- parent_style,
- &applicable_declarations.normal,
- &mut layout_data.shared_data.style,
+ Some(layout_data.shared_data.style.as_ref().unwrap()),
+ &*applicable_declarations.after,
+ &mut layout_data.data.after_style,
applicable_declarations_cache,
new_animations_sender,
- applicable_declarations.normal_shareable,
- true);
- if applicable_declarations.before.len() > 0 {
- damage = damage | self.cascade_node_pseudo_element(
- layout_context,
- Some(layout_data.shared_data.style.as_ref().unwrap()),
- &*applicable_declarations.before,
- &mut layout_data.data.before_style,
- applicable_declarations_cache,
- new_animations_sender,
- false,
- false);
- }
- if applicable_declarations.after.len() > 0 {
- damage = damage | self.cascade_node_pseudo_element(
- layout_context,
- Some(layout_data.shared_data.style.as_ref().unwrap()),
- &*applicable_declarations.after,
- &mut layout_data.data.after_style,
- applicable_declarations_cache,
- new_animations_sender,
- false,
- false);
- }
- layout_data.data.restyle_damage = damage;
+ false,
+ false);
}
+ layout_data.data.restyle_damage = damage;
}
}
}