Define share_style_if_possible on LayoutElement.

This commit is contained in:
Ms2ger 2015-10-15 13:55:02 +02:00
parent e6e514c89a
commit f3faaa6b01
2 changed files with 26 additions and 23 deletions

View file

@ -165,10 +165,17 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
// Check to see whether we can share a style with someone.
let style_sharing_candidate_cache =
&mut self.layout_context.style_sharing_candidate_cache();
let sharing_result = unsafe {
node.share_style_if_possible(style_sharing_candidate_cache,
parent_opt.clone())
let sharing_result = match node.as_element() {
Some(element) => {
unsafe {
element.share_style_if_possible(style_sharing_candidate_cache,
parent_opt.clone())
}
},
None => StyleSharingResult::CannotShare(false),
};
// Otherwise, match and cascade selectors.
match sharing_result {
StyleSharingResult::CannotShare(mut shareable) => {