diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2016-10-28 14:01:07 -0700 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2016-10-29 14:58:07 -0700 |
commit | be89f736751d63307c01750f98d5c07a1e940add (patch) | |
tree | 6cd08307470e9cc337906794fc853205e7c784e4 /components/style | |
parent | 5442fbec3f5a4d00c6cc61adfefc0ae747194db2 (diff) | |
download | servo-be89f736751d63307c01750f98d5c07a1e940add.tar.gz servo-be89f736751d63307c01750f98d5c07a1e940add.zip |
Rename NodeData and associated data structures to Element*.
MozReview-Commit-ID: 96VsmsoZtjZ
Diffstat (limited to 'components/style')
-rwxr-xr-x | components/style/binding_tools/regen.py | 4 | ||||
-rw-r--r-- | components/style/data.rs | 56 | ||||
-rw-r--r-- | components/style/dom.rs | 12 | ||||
-rw-r--r-- | components/style/gecko/traversal.rs | 4 | ||||
-rw-r--r-- | components/style/gecko/wrapper.rs | 12 | ||||
-rw-r--r-- | components/style/gecko_bindings/structs_debug.rs | 4 | ||||
-rw-r--r-- | components/style/gecko_bindings/structs_release.rs | 4 | ||||
-rw-r--r-- | components/style/matching.rs | 6 | ||||
-rw-r--r-- | components/style/traversal.rs | 6 |
9 files changed, 54 insertions, 54 deletions
diff --git a/components/style/binding_tools/regen.py b/components/style/binding_tools/regen.py index 0aa1a62c532..e18bfbc6d78 100755 --- a/components/style/binding_tools/regen.py +++ b/components/style/binding_tools/regen.py @@ -67,7 +67,7 @@ COMPILATION_TARGETS = { }, "raw_lines": [ "use atomic_refcell::AtomicRefCell;", - "use data::NodeData;", + "use data::ElementData;", "pub use nsstring::nsStringRepr as nsString;" ], "blacklist_types": ["nsString"], @@ -226,7 +226,7 @@ COMPILATION_TARGETS = { }, { "generic": False, "gecko": "ServoNodeData", - "servo": "AtomicRefCell<NodeData>", + "servo": "AtomicRefCell<ElementData>", } ], }, diff --git a/components/style/data.rs b/components/style/data.rs index 9e6d6054fb0..f6011c81fcb 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -35,7 +35,7 @@ impl DerefMut for PseudoStyles { /// The styles associated with a node, including the styles for any /// pseudo-elements. #[derive(Clone, Debug)] -pub struct NodeStyles { +pub struct ElementStyles { /// The results of CSS styling for this node. pub primary: Arc<ComputedValues>, @@ -43,9 +43,9 @@ pub struct NodeStyles { pub pseudos: PseudoStyles, } -impl NodeStyles { +impl ElementStyles { pub fn new(primary: Arc<ComputedValues>) -> Self { - NodeStyles { + ElementStyles { primary: primary, pseudos: PseudoStyles::empty(), } @@ -53,7 +53,7 @@ impl NodeStyles { } #[derive(Debug)] -enum NodeDataStyles { +enum ElementDataStyles { /// The field has not been initialized. Uninitialized, @@ -64,19 +64,19 @@ enum NodeDataStyles { /// immutable, but for now we need to mutate it a bit before styling to /// handle animations. /// - /// Note that since NodeStyles contains an Arc, the null pointer + /// Note that since ElementStyles contains an Arc, the null pointer /// optimization prevents the Option<> here from consuming an extra word. - Previous(Option<NodeStyles>), + Previous(Option<ElementStyles>), /// The field holds the current, up-to-date style. /// /// This is the output of the styling algorithm. - Current(NodeStyles), + Current(ElementStyles), } -impl NodeDataStyles { +impl ElementDataStyles { fn is_previous(&self) -> bool { - use self::NodeDataStyles::*; + use self::ElementDataStyles::*; match *self { Previous(_) => true, _ => false, @@ -113,34 +113,34 @@ impl RestyleData { /// In both cases, it is wrapped inside an AtomicRefCell to ensure thread /// safety. #[derive(Debug)] -pub struct NodeData { - styles: NodeDataStyles, +pub struct ElementData { + styles: ElementDataStyles, pub restyle_data: Option<RestyleData>, } -impl NodeData { +impl ElementData { pub fn new() -> Self { - NodeData { - styles: NodeDataStyles::Uninitialized, + ElementData { + styles: ElementDataStyles::Uninitialized, restyle_data: None, } } pub fn has_current_styles(&self) -> bool { match self.styles { - NodeDataStyles::Current(_) => true, + ElementDataStyles::Current(_) => true, _ => false, } } - pub fn get_current_styles(&self) -> Option<&NodeStyles> { + pub fn get_current_styles(&self) -> Option<&ElementStyles> { match self.styles { - NodeDataStyles::Current(ref s) => Some(s), + ElementDataStyles::Current(ref s) => Some(s), _ => None, } } - pub fn current_styles(&self) -> &NodeStyles { + pub fn current_styles(&self) -> &ElementStyles { self.get_current_styles().expect("Calling current_styles before or during styling") } @@ -149,29 +149,29 @@ impl NodeData { #[cfg(not(feature = "gecko"))] pub fn current_pseudos_mut(&mut self) -> &mut PseudoStyles { match self.styles { - NodeDataStyles::Current(ref mut s) => &mut s.pseudos, + ElementDataStyles::Current(ref mut s) => &mut s.pseudos, _ => panic!("Calling current_pseudos_mut before or during styling"), } } - pub fn previous_styles(&self) -> Option<&NodeStyles> { + pub fn previous_styles(&self) -> Option<&ElementStyles> { match self.styles { - NodeDataStyles::Previous(ref s) => s.as_ref(), + ElementDataStyles::Previous(ref s) => s.as_ref(), _ => panic!("Calling previous_styles without having gathered it"), } } - pub fn previous_styles_mut(&mut self) -> Option<&mut NodeStyles> { + pub fn previous_styles_mut(&mut self) -> Option<&mut ElementStyles> { match self.styles { - NodeDataStyles::Previous(ref mut s) => s.as_mut(), + ElementDataStyles::Previous(ref mut s) => s.as_mut(), _ => panic!("Calling previous_styles without having gathered it"), } } pub fn gather_previous_styles<F>(&mut self, f: F) - where F: FnOnce() -> Option<NodeStyles> + where F: FnOnce() -> Option<ElementStyles> { - use self::NodeDataStyles::*; + use self::ElementDataStyles::*; self.styles = match mem::replace(&mut self.styles, Uninitialized) { Uninitialized => Previous(f()), Current(x) => Previous(Some(x)), @@ -186,13 +186,13 @@ impl NodeData { } pub fn style_text_node(&mut self, style: Arc<ComputedValues>) { - self.styles = NodeDataStyles::Current(NodeStyles::new(style)); + self.styles = ElementDataStyles::Current(ElementStyles::new(style)); self.restyle_data = None; } - pub fn finish_styling(&mut self, styles: NodeStyles) { + pub fn finish_styling(&mut self, styles: ElementStyles) { debug_assert!(self.styles.is_previous()); - self.styles = NodeDataStyles::Current(styles); + self.styles = ElementDataStyles::Current(styles); self.restyle_data = None; } } diff --git a/components/style/dom.rs b/components/style/dom.rs index 03eee395f7b..7ab817ac2c6 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -7,7 +7,7 @@ #![allow(unsafe_code)] use atomic_refcell::{AtomicRef, AtomicRefMut}; -use data::{NodeStyles, NodeData}; +use data::{ElementStyles, ElementData}; use element_state::ElementState; use parking_lot::RwLock; use properties::{ComputedValues, PropertyDeclarationBlock}; @@ -219,10 +219,10 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre /// Returns the styles from the layout frame that owns them, if any. /// - /// FIXME(bholley): Once we start dropping NodeData from nodes when + /// FIXME(bholley): Once we start dropping ElementData from nodes when /// creating frames, we'll want to teach this method to actually get /// style data from the frame. - fn get_styles_from_frame(&self) -> Option<NodeStyles> { None } + fn get_styles_from_frame(&self) -> Option<ElementStyles> { None } /// Returns the styling mode for this node. This is only valid to call before /// and during restyling, before finish_styling is invoked. @@ -262,10 +262,10 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre /// Sets up the appropriate data structures to style a node, returing a /// mutable handle to the node data upon which further style calculations /// can be performed. - fn begin_styling(&self) -> AtomicRefMut<NodeData>; + fn begin_styling(&self) -> AtomicRefMut<ElementData>; - /// Immutable borrows the NodeData. - fn borrow_data(&self) -> Option<AtomicRef<NodeData>>; + /// Immutable borrows the ElementData. + fn borrow_data(&self) -> Option<AtomicRef<ElementData>>; /// Properly marks nodes as dirty in response to restyle hints. fn note_restyle_hint<C: DomTraversalContext<Self::ConcreteNode>>(&self, hint: RestyleHint) { diff --git a/components/style/gecko/traversal.rs b/components/style/gecko/traversal.rs index e827911006e..0825d83665f 100644 --- a/components/style/gecko/traversal.rs +++ b/components/style/gecko/traversal.rs @@ -4,7 +4,7 @@ use atomic_refcell::AtomicRefCell; use context::{LocalStyleContext, SharedStyleContext, StyleContext}; -use data::NodeData; +use data::ElementData; use dom::{NodeInfo, OpaqueNode, StylingMode, TElement, TNode}; use gecko::context::StandaloneStyleContext; use gecko::wrapper::{GeckoElement, GeckoNode}; @@ -55,7 +55,7 @@ impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> { } } - fn ensure_element_data<'a>(element: &'a GeckoElement<'ln>) -> &'a AtomicRefCell<NodeData> { + fn ensure_element_data<'a>(element: &'a GeckoElement<'ln>) -> &'a AtomicRefCell<ElementData> { element.ensure_data() } diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index a4fa5d552e1..65fe599485d 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -6,7 +6,7 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; -use data::NodeData; +use data::ElementData; use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode}; use dom::{OpaqueNode, PresentationalHintsSynthetizer}; use element_state::ElementState; @@ -332,15 +332,15 @@ impl<'le> GeckoElement<'le> { .get(pseudo).map(|c| c.clone())) } - fn get_node_data(&self) -> Option<&AtomicRefCell<NodeData>> { + fn get_node_data(&self) -> Option<&AtomicRefCell<ElementData>> { unsafe { self.raw_node().mServoData.get().as_ref() } } - pub fn ensure_data(&self) -> &AtomicRefCell<NodeData> { + pub fn ensure_data(&self) -> &AtomicRefCell<ElementData> { match self.get_node_data() { Some(x) => x, None => { - let ptr = Box::into_raw(Box::new(AtomicRefCell::new(NodeData::new()))); + let ptr = Box::into_raw(Box::new(AtomicRefCell::new(ElementData::new()))); self.raw_node().mServoData.set(ptr); unsafe { &* ptr } }, @@ -444,13 +444,13 @@ impl<'le> TElement for GeckoElement<'le> { panic!("Atomic child count not implemented in Gecko"); } - fn begin_styling(&self) -> AtomicRefMut<NodeData> { + fn begin_styling(&self) -> AtomicRefMut<ElementData> { let mut data = self.ensure_data().borrow_mut(); data.gather_previous_styles(|| self.get_styles_from_frame()); data } - fn borrow_data(&self) -> Option<AtomicRef<NodeData>> { + fn borrow_data(&self) -> Option<AtomicRef<ElementData>> { self.get_node_data().map(|x| x.borrow()) } } diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index 0b5b95d840f..c86a2cf8108 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -1,11 +1,11 @@ /* automatically generated by rust-bindgen */ use atomic_refcell::AtomicRefCell; -use data::NodeData; +use data::ElementData; pub use nsstring::nsStringRepr as nsString; pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>; pub type ServoCell<T> = ::std::cell::Cell<T>; -pub type ServoNodeData = AtomicRefCell<NodeData>; +pub type ServoNodeData = AtomicRefCell<ElementData>; #[derive(Debug)] #[repr(C)] diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index 5695b8e8423..720bc7a77b7 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -1,11 +1,11 @@ /* automatically generated by rust-bindgen */ use atomic_refcell::AtomicRefCell; -use data::NodeData; +use data::ElementData; pub use nsstring::nsStringRepr as nsString; pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>; pub type ServoCell<T> = ::std::cell::Cell<T>; -pub type ServoNodeData = AtomicRefCell<NodeData>; +pub type ServoNodeData = AtomicRefCell<ElementData>; #[derive(Debug)] #[repr(C)] diff --git a/components/style/matching.rs b/components/style/matching.rs index 07add314809..a5216d14416 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -11,7 +11,7 @@ use arc_ptr_eq; use cache::{LRUCache, SimpleHashCache}; use cascade_info::CascadeInfo; use context::{SharedStyleContext, StyleContext}; -use data::{NodeStyles, PseudoStyles}; +use data::{ElementStyles, PseudoStyles}; use dom::{TElement, TNode, TRestyleDamage, UnsafeNode}; use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade}; use properties::longhands::display::computed_value as display; @@ -737,7 +737,7 @@ pub trait MatchMethods : TElement { RestyleResult::Continue }; - data.finish_styling(NodeStyles::new(shared_style)); + data.finish_styling(ElementStyles::new(shared_style)); return StyleSharingResult::StyleWasShared(i, damage, restyle_result) } @@ -882,7 +882,7 @@ pub trait MatchMethods : TElement { }; - new_styles = NodeStyles::new( + new_styles = ElementStyles::new( self.cascade_node_pseudo_element(context, parent_style.clone(), old_primary, diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 80f5cc43dc1..5d5e5e6f418 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -6,7 +6,7 @@ use atomic_refcell::AtomicRefCell; use context::{LocalStyleContext, SharedStyleContext, StyleContext}; -use data::NodeData; +use data::ElementData; use dom::{OpaqueNode, StylingMode, TElement, TNode, UnsafeNode}; use matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult}; use selectors::bloom::BloomFilter; @@ -197,10 +197,10 @@ pub trait DomTraversalContext<N: TNode> { } } - /// Ensures the existence of the NodeData, and returns it. This can't live + /// Ensures the existence of the ElementData, and returns it. This can't live /// on TNode because of the trait-based separation between Servo's script /// and layout crates. - fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<NodeData>; + fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<ElementData>; fn local_context(&self) -> &LocalStyleContext; } |