diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-07-27 16:40:23 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-07-27 19:57:33 +0200 |
commit | 3984e3901130a629293361c5eb8366e00b824a2f (patch) | |
tree | 9d488ca46e5331287a1ceb93e170a36d57931c8f /components/layout/css/node_style.rs | |
parent | 5cf662fb9759924e75d3bfe77f1b7607e9961bcb (diff) | |
download | servo-3984e3901130a629293361c5eb8366e00b824a2f.tar.gz servo-3984e3901130a629293361c5eb8366e00b824a2f.zip |
Replace the StyledNode trait with inherent methods.
Diffstat (limited to 'components/layout/css/node_style.rs')
-rw-r--r-- | components/layout/css/node_style.rs | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/components/layout/css/node_style.rs b/components/layout/css/node_style.rs deleted file mode 100644 index 72afd0c6193..00000000000 --- a/components/layout/css/node_style.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Style retrieval from DOM elements. - -use data::LayoutDataWrapper; -use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; - -use style::properties::ComputedValues; - -use std::cell::Ref; -use std::sync::Arc; - -/// Node mixin providing `style` method that returns a `NodeStyle` -pub trait StyledNode { - fn get_style<'a>(&self, layout_data_ref: &'a LayoutDataWrapper) -> &'a Arc<ComputedValues>; - /// Returns the style results for the given node. If CSS selector matching has not yet been - /// performed, fails. - fn style<'a>(&'a self) -> Ref<'a, Arc<ComputedValues>>; - /// Removes the style from this node. - fn unstyle(self); -} - -impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> { - #[inline] - fn get_style<'a>(&self, layout_data_ref: &'a LayoutDataWrapper) -> &'a Arc<ComputedValues> { - match self.get_pseudo_element_type() { - PseudoElementType::Before(_) => layout_data_ref.data.before_style.as_ref().unwrap(), - PseudoElementType::After(_) => layout_data_ref.data.after_style.as_ref().unwrap(), - PseudoElementType::Normal => layout_data_ref.shared_data.style.as_ref().unwrap(), - } - } - - #[inline] - fn style<'a>(&'a self) -> Ref<'a, Arc<ComputedValues>> { - Ref::map(self.borrow_layout_data(), |layout_data_ref| { - let layout_data = layout_data_ref.as_ref().expect("no layout data"); - self.get_style(layout_data) - }) - } - - fn unstyle(self) { - let mut layout_data_ref = self.mutate_layout_data(); - let layout_data = layout_data_ref.as_mut().expect("no layout data"); - - let style = - match self.get_pseudo_element_type() { - PseudoElementType::Before(_) => &mut layout_data.data.before_style, - PseudoElementType::After (_) => &mut layout_data.data.after_style, - PseudoElementType::Normal => &mut layout_data.shared_data.style, - }; - - *style = None; - } -} |