mirror of
https://github.com/servo/servo.git
synced 2025-06-18 05:14:28 +00:00
Rename NodeData and associated data structures to Element*.
MozReview-Commit-ID: 96VsmsoZtjZ
This commit is contained in:
parent
5442fbec3f
commit
be89f73675
15 changed files with 75 additions and 77 deletions
|
@ -15,7 +15,7 @@ use script_layout_interface::wrapper_traits::{LayoutElement, LayoutNode, ThreadS
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use style::atomic_refcell::AtomicRefCell;
|
use style::atomic_refcell::AtomicRefCell;
|
||||||
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
||||||
use style::data::NodeData;
|
use style::data::ElementData;
|
||||||
use style::dom::{StylingMode, TElement, TNode};
|
use style::dom::{StylingMode, TElement, TNode};
|
||||||
use style::traversal::{DomTraversalContext, put_thread_local_bloom_filter};
|
use style::traversal::{DomTraversalContext, put_thread_local_bloom_filter};
|
||||||
use style::traversal::{recalc_style_at, remove_from_bloom_filter};
|
use style::traversal::{recalc_style_at, remove_from_bloom_filter};
|
||||||
|
@ -131,7 +131,7 @@ impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<NodeData> {
|
fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<ElementData> {
|
||||||
element.as_node().initialize_data();
|
element.as_node().initialize_data();
|
||||||
element.get_style_data().unwrap()
|
element.get_style_data().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub type NonOpaqueStyleAndLayoutData = AtomicRefCell<PersistentLayoutData>;
|
||||||
|
|
||||||
pub trait LayoutNodeLayoutData {
|
pub trait LayoutNodeLayoutData {
|
||||||
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
|
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
|
||||||
/// than only the style::data::NodeData.
|
/// than only the style::data::ElementData.
|
||||||
fn borrow_layout_data(&self) -> Option<AtomicRef<PersistentLayoutData>>;
|
fn borrow_layout_data(&self) -> Option<AtomicRef<PersistentLayoutData>>;
|
||||||
fn mutate_layout_data(&self) -> Option<AtomicRefMut<PersistentLayoutData>>;
|
fn mutate_layout_data(&self) -> Option<AtomicRefMut<PersistentLayoutData>>;
|
||||||
fn flow_debug_id(self) -> usize;
|
fn flow_debug_id(self) -> usize;
|
||||||
|
|
|
@ -60,7 +60,7 @@ use style::atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||||
use style::attr::AttrValue;
|
use style::attr::AttrValue;
|
||||||
use style::computed_values::display;
|
use style::computed_values::display;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::data::NodeData;
|
use style::data::ElementData;
|
||||||
use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode};
|
use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode};
|
||||||
use style::dom::{TRestyleDamage, UnsafeNode};
|
use style::dom::{TRestyleDamage, UnsafeNode};
|
||||||
use style::element_state::*;
|
use style::element_state::*;
|
||||||
|
@ -506,24 +506,24 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
||||||
old_value - 1
|
old_value - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn begin_styling(&self) -> AtomicRefMut<NodeData> {
|
fn begin_styling(&self) -> AtomicRefMut<ElementData> {
|
||||||
let mut data = self.mutate_data().unwrap();
|
let mut data = self.mutate_data().unwrap();
|
||||||
data.gather_previous_styles(|| None);
|
data.gather_previous_styles(|| None);
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow_data(&self) -> Option<AtomicRef<NodeData>> {
|
fn borrow_data(&self) -> Option<AtomicRef<ElementData>> {
|
||||||
self.get_style_data().map(|d| d.borrow())
|
self.get_style_data().map(|d| d.borrow())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> LayoutElement for ServoLayoutElement<'le> {
|
impl<'le> LayoutElement for ServoLayoutElement<'le> {
|
||||||
fn get_style_data(&self) -> Option<&AtomicRefCell<NodeData>> {
|
fn get_style_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.get_style_and_layout_data().map(|d| {
|
self.get_style_and_layout_data().map(|d| {
|
||||||
let ppld: &AtomicRefCell<PartialPersistentLayoutData> = &**d.ptr;
|
let ppld: &AtomicRefCell<PartialPersistentLayoutData> = &**d.ptr;
|
||||||
let psd: &AtomicRefCell<NodeData> = transmute(ppld);
|
let psd: &AtomicRefCell<ElementData> = transmute(ppld);
|
||||||
psd
|
psd
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -551,15 +551,13 @@ impl<'le> ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate_data(&self) -> Option<AtomicRefMut<NodeData>> {
|
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> {
|
||||||
self.get_style_data().map(|d| d.borrow_mut())
|
self.get_style_data().map(|d| d.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_partial_layout_data(&self) -> Option<&AtomicRefCell<PartialPersistentLayoutData>> {
|
fn get_partial_layout_data(&self) -> Option<&AtomicRefCell<PartialPersistentLayoutData>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.get_style_and_layout_data().map(|d| {
|
self.get_style_and_layout_data().map(|d| &**d.ptr)
|
||||||
&**d.ptr
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1090,7 +1088,7 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
|
||||||
self.element.get_attr(namespace, name)
|
self.element.get_attr(namespace, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_style_data(&self) -> Option<&AtomicRefCell<NodeData>> {
|
fn get_style_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||||
self.element.get_style_data()
|
self.element.get_style_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,14 @@ use libc::c_void;
|
||||||
use restyle_damage::RestyleDamage;
|
use restyle_damage::RestyleDamage;
|
||||||
use std::sync::atomic::AtomicIsize;
|
use std::sync::atomic::AtomicIsize;
|
||||||
use style::atomic_refcell::AtomicRefCell;
|
use style::atomic_refcell::AtomicRefCell;
|
||||||
use style::data::NodeData;
|
use style::data::ElementData;
|
||||||
|
|
||||||
pub struct PartialPersistentLayoutData {
|
pub struct PartialPersistentLayoutData {
|
||||||
/// Data that the style system associates with a node. When the
|
/// Data that the style system associates with a node. When the
|
||||||
/// style system is being used standalone, this is all that hangs
|
/// style system is being used standalone, this is all that hangs
|
||||||
/// off the node. This must be first to permit the various
|
/// off the node. This must be first to permit the various
|
||||||
/// transmutations between NodeData and PersistentLayoutData.
|
/// transmutations between ElementData and PersistentLayoutData.
|
||||||
pub style_data: NodeData,
|
pub style_data: ElementData,
|
||||||
|
|
||||||
/// Description of how to account for recent style changes.
|
/// Description of how to account for recent style changes.
|
||||||
pub restyle_damage: RestyleDamage,
|
pub restyle_damage: RestyleDamage,
|
||||||
|
@ -72,7 +72,7 @@ pub struct PartialPersistentLayoutData {
|
||||||
impl PartialPersistentLayoutData {
|
impl PartialPersistentLayoutData {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
PartialPersistentLayoutData {
|
PartialPersistentLayoutData {
|
||||||
style_data: NodeData::new(),
|
style_data: ElementData::new(),
|
||||||
restyle_damage: RestyleDamage::empty(),
|
restyle_damage: RestyleDamage::empty(),
|
||||||
parallel: DomParallelInfo::new(),
|
parallel: DomParallelInfo::new(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ use string_cache::{Atom, Namespace};
|
||||||
use style::atomic_refcell::AtomicRefCell;
|
use style::atomic_refcell::AtomicRefCell;
|
||||||
use style::computed_values::display;
|
use style::computed_values::display;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::data::NodeData;
|
use style::data::ElementData;
|
||||||
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode};
|
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode};
|
||||||
use style::dom::OpaqueNode;
|
use style::dom::OpaqueNode;
|
||||||
use style::properties::ServoComputedValues;
|
use style::properties::ServoComputedValues;
|
||||||
|
@ -274,7 +274,7 @@ pub trait DangerousThreadSafeLayoutNode: ThreadSafeLayoutNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LayoutElement: Clone + Copy + Sized + Debug + GetLayoutData + TElement {
|
pub trait LayoutElement: Clone + Copy + Sized + Debug + GetLayoutData + TElement {
|
||||||
fn get_style_data(&self) -> Option<&AtomicRefCell<NodeData>>;
|
fn get_style_data(&self) -> Option<&AtomicRefCell<ElementData>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
|
@ -296,7 +296,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str>;
|
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str>;
|
||||||
|
|
||||||
fn get_style_data(&self) -> Option<&AtomicRefCell<NodeData>>;
|
fn get_style_data(&self) -> Option<&AtomicRefCell<ElementData>>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>>;
|
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>>;
|
||||||
|
|
|
@ -67,7 +67,7 @@ COMPILATION_TARGETS = {
|
||||||
},
|
},
|
||||||
"raw_lines": [
|
"raw_lines": [
|
||||||
"use atomic_refcell::AtomicRefCell;",
|
"use atomic_refcell::AtomicRefCell;",
|
||||||
"use data::NodeData;",
|
"use data::ElementData;",
|
||||||
"pub use nsstring::nsStringRepr as nsString;"
|
"pub use nsstring::nsStringRepr as nsString;"
|
||||||
],
|
],
|
||||||
"blacklist_types": ["nsString"],
|
"blacklist_types": ["nsString"],
|
||||||
|
@ -226,7 +226,7 @@ COMPILATION_TARGETS = {
|
||||||
}, {
|
}, {
|
||||||
"generic": False,
|
"generic": False,
|
||||||
"gecko": "ServoNodeData",
|
"gecko": "ServoNodeData",
|
||||||
"servo": "AtomicRefCell<NodeData>",
|
"servo": "AtomicRefCell<ElementData>",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl DerefMut for PseudoStyles {
|
||||||
/// The styles associated with a node, including the styles for any
|
/// The styles associated with a node, including the styles for any
|
||||||
/// pseudo-elements.
|
/// pseudo-elements.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct NodeStyles {
|
pub struct ElementStyles {
|
||||||
/// The results of CSS styling for this node.
|
/// The results of CSS styling for this node.
|
||||||
pub primary: Arc<ComputedValues>,
|
pub primary: Arc<ComputedValues>,
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ pub struct NodeStyles {
|
||||||
pub pseudos: PseudoStyles,
|
pub pseudos: PseudoStyles,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeStyles {
|
impl ElementStyles {
|
||||||
pub fn new(primary: Arc<ComputedValues>) -> Self {
|
pub fn new(primary: Arc<ComputedValues>) -> Self {
|
||||||
NodeStyles {
|
ElementStyles {
|
||||||
primary: primary,
|
primary: primary,
|
||||||
pseudos: PseudoStyles::empty(),
|
pseudos: PseudoStyles::empty(),
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl NodeStyles {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum NodeDataStyles {
|
enum ElementDataStyles {
|
||||||
/// The field has not been initialized.
|
/// The field has not been initialized.
|
||||||
Uninitialized,
|
Uninitialized,
|
||||||
|
|
||||||
|
@ -64,19 +64,19 @@ enum NodeDataStyles {
|
||||||
/// immutable, but for now we need to mutate it a bit before styling to
|
/// immutable, but for now we need to mutate it a bit before styling to
|
||||||
/// handle animations.
|
/// 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.
|
/// 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.
|
/// The field holds the current, up-to-date style.
|
||||||
///
|
///
|
||||||
/// This is the output of the styling algorithm.
|
/// This is the output of the styling algorithm.
|
||||||
Current(NodeStyles),
|
Current(ElementStyles),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeDataStyles {
|
impl ElementDataStyles {
|
||||||
fn is_previous(&self) -> bool {
|
fn is_previous(&self) -> bool {
|
||||||
use self::NodeDataStyles::*;
|
use self::ElementDataStyles::*;
|
||||||
match *self {
|
match *self {
|
||||||
Previous(_) => true,
|
Previous(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -113,34 +113,34 @@ impl RestyleData {
|
||||||
/// In both cases, it is wrapped inside an AtomicRefCell to ensure thread
|
/// In both cases, it is wrapped inside an AtomicRefCell to ensure thread
|
||||||
/// safety.
|
/// safety.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NodeData {
|
pub struct ElementData {
|
||||||
styles: NodeDataStyles,
|
styles: ElementDataStyles,
|
||||||
pub restyle_data: Option<RestyleData>,
|
pub restyle_data: Option<RestyleData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeData {
|
impl ElementData {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
NodeData {
|
ElementData {
|
||||||
styles: NodeDataStyles::Uninitialized,
|
styles: ElementDataStyles::Uninitialized,
|
||||||
restyle_data: None,
|
restyle_data: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_current_styles(&self) -> bool {
|
pub fn has_current_styles(&self) -> bool {
|
||||||
match self.styles {
|
match self.styles {
|
||||||
NodeDataStyles::Current(_) => true,
|
ElementDataStyles::Current(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_styles(&self) -> Option<&NodeStyles> {
|
pub fn get_current_styles(&self) -> Option<&ElementStyles> {
|
||||||
match self.styles {
|
match self.styles {
|
||||||
NodeDataStyles::Current(ref s) => Some(s),
|
ElementDataStyles::Current(ref s) => Some(s),
|
||||||
_ => None,
|
_ => 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")
|
self.get_current_styles().expect("Calling current_styles before or during styling")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,29 +149,29 @@ impl NodeData {
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
pub fn current_pseudos_mut(&mut self) -> &mut PseudoStyles {
|
pub fn current_pseudos_mut(&mut self) -> &mut PseudoStyles {
|
||||||
match self.styles {
|
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"),
|
_ => 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 {
|
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"),
|
_ => 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 {
|
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"),
|
_ => panic!("Calling previous_styles without having gathered it"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gather_previous_styles<F>(&mut self, f: F)
|
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) {
|
self.styles = match mem::replace(&mut self.styles, Uninitialized) {
|
||||||
Uninitialized => Previous(f()),
|
Uninitialized => Previous(f()),
|
||||||
Current(x) => Previous(Some(x)),
|
Current(x) => Previous(Some(x)),
|
||||||
|
@ -186,13 +186,13 @@ impl NodeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn style_text_node(&mut self, style: Arc<ComputedValues>) {
|
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;
|
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());
|
debug_assert!(self.styles.is_previous());
|
||||||
self.styles = NodeDataStyles::Current(styles);
|
self.styles = ElementDataStyles::Current(styles);
|
||||||
self.restyle_data = None;
|
self.restyle_data = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||||
use data::{NodeStyles, NodeData};
|
use data::{ElementStyles, ElementData};
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
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.
|
/// 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
|
/// creating frames, we'll want to teach this method to actually get
|
||||||
/// style data from the frame.
|
/// 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
|
/// Returns the styling mode for this node. This is only valid to call before
|
||||||
/// and during restyling, before finish_styling is invoked.
|
/// 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
|
/// Sets up the appropriate data structures to style a node, returing a
|
||||||
/// mutable handle to the node data upon which further style calculations
|
/// mutable handle to the node data upon which further style calculations
|
||||||
/// can be performed.
|
/// can be performed.
|
||||||
fn begin_styling(&self) -> AtomicRefMut<NodeData>;
|
fn begin_styling(&self) -> AtomicRefMut<ElementData>;
|
||||||
|
|
||||||
/// Immutable borrows the NodeData.
|
/// Immutable borrows the ElementData.
|
||||||
fn borrow_data(&self) -> Option<AtomicRef<NodeData>>;
|
fn borrow_data(&self) -> Option<AtomicRef<ElementData>>;
|
||||||
|
|
||||||
/// Properly marks nodes as dirty in response to restyle hints.
|
/// Properly marks nodes as dirty in response to restyle hints.
|
||||||
fn note_restyle_hint<C: DomTraversalContext<Self::ConcreteNode>>(&self, hint: RestyleHint) {
|
fn note_restyle_hint<C: DomTraversalContext<Self::ConcreteNode>>(&self, hint: RestyleHint) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use atomic_refcell::AtomicRefCell;
|
use atomic_refcell::AtomicRefCell;
|
||||||
use context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
use context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
||||||
use data::NodeData;
|
use data::ElementData;
|
||||||
use dom::{NodeInfo, OpaqueNode, StylingMode, TElement, TNode};
|
use dom::{NodeInfo, OpaqueNode, StylingMode, TElement, TNode};
|
||||||
use gecko::context::StandaloneStyleContext;
|
use gecko::context::StandaloneStyleContext;
|
||||||
use gecko::wrapper::{GeckoElement, GeckoNode};
|
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()
|
element.ensure_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||||
use data::NodeData;
|
use data::ElementData;
|
||||||
use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
||||||
use dom::{OpaqueNode, PresentationalHintsSynthetizer};
|
use dom::{OpaqueNode, PresentationalHintsSynthetizer};
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
|
@ -332,15 +332,15 @@ impl<'le> GeckoElement<'le> {
|
||||||
.get(pseudo).map(|c| c.clone()))
|
.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() }
|
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() {
|
match self.get_node_data() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => {
|
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);
|
self.raw_node().mServoData.set(ptr);
|
||||||
unsafe { &* ptr }
|
unsafe { &* ptr }
|
||||||
},
|
},
|
||||||
|
@ -444,13 +444,13 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
panic!("Atomic child count not implemented in Gecko");
|
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();
|
let mut data = self.ensure_data().borrow_mut();
|
||||||
data.gather_previous_styles(|| self.get_styles_from_frame());
|
data.gather_previous_styles(|| self.get_styles_from_frame());
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow_data(&self) -> Option<AtomicRef<NodeData>> {
|
fn borrow_data(&self) -> Option<AtomicRef<ElementData>> {
|
||||||
self.get_node_data().map(|x| x.borrow())
|
self.get_node_data().map(|x| x.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* automatically generated by rust-bindgen */
|
/* automatically generated by rust-bindgen */
|
||||||
|
|
||||||
use atomic_refcell::AtomicRefCell;
|
use atomic_refcell::AtomicRefCell;
|
||||||
use data::NodeData;
|
use data::ElementData;
|
||||||
pub use nsstring::nsStringRepr as nsString;
|
pub use nsstring::nsStringRepr as nsString;
|
||||||
pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
||||||
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
||||||
pub type ServoNodeData = AtomicRefCell<NodeData>;
|
pub type ServoNodeData = AtomicRefCell<ElementData>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* automatically generated by rust-bindgen */
|
/* automatically generated by rust-bindgen */
|
||||||
|
|
||||||
use atomic_refcell::AtomicRefCell;
|
use atomic_refcell::AtomicRefCell;
|
||||||
use data::NodeData;
|
use data::ElementData;
|
||||||
pub use nsstring::nsStringRepr as nsString;
|
pub use nsstring::nsStringRepr as nsString;
|
||||||
pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
||||||
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
||||||
pub type ServoNodeData = AtomicRefCell<NodeData>;
|
pub type ServoNodeData = AtomicRefCell<ElementData>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use arc_ptr_eq;
|
||||||
use cache::{LRUCache, SimpleHashCache};
|
use cache::{LRUCache, SimpleHashCache};
|
||||||
use cascade_info::CascadeInfo;
|
use cascade_info::CascadeInfo;
|
||||||
use context::{SharedStyleContext, StyleContext};
|
use context::{SharedStyleContext, StyleContext};
|
||||||
use data::{NodeStyles, PseudoStyles};
|
use data::{ElementStyles, PseudoStyles};
|
||||||
use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
|
use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
|
||||||
use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
|
use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
|
||||||
use properties::longhands::display::computed_value as display;
|
use properties::longhands::display::computed_value as display;
|
||||||
|
@ -737,7 +737,7 @@ pub trait MatchMethods : TElement {
|
||||||
RestyleResult::Continue
|
RestyleResult::Continue
|
||||||
};
|
};
|
||||||
|
|
||||||
data.finish_styling(NodeStyles::new(shared_style));
|
data.finish_styling(ElementStyles::new(shared_style));
|
||||||
|
|
||||||
return StyleSharingResult::StyleWasShared(i, damage, restyle_result)
|
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,
|
self.cascade_node_pseudo_element(context,
|
||||||
parent_style.clone(),
|
parent_style.clone(),
|
||||||
old_primary,
|
old_primary,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use atomic_refcell::AtomicRefCell;
|
use atomic_refcell::AtomicRefCell;
|
||||||
use context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
use context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
||||||
use data::NodeData;
|
use data::ElementData;
|
||||||
use dom::{OpaqueNode, StylingMode, TElement, TNode, UnsafeNode};
|
use dom::{OpaqueNode, StylingMode, TElement, TNode, UnsafeNode};
|
||||||
use matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
use matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
||||||
use selectors::bloom::BloomFilter;
|
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
|
/// on TNode because of the trait-based separation between Servo's script
|
||||||
/// and layout crates.
|
/// 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;
|
fn local_context(&self) -> &LocalStyleContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ pub extern "C" fn Servo_ComputedValues_Get(node: RawGeckoNodeBorrowed)
|
||||||
if node.is_text_node() {
|
if node.is_text_node() {
|
||||||
error!("Don't call Servo_ComputedValue_Get() for text nodes");
|
error!("Don't call Servo_ComputedValue_Get() for text nodes");
|
||||||
let parent = node.parent_node().unwrap().as_element().unwrap();
|
let parent = node.parent_node().unwrap().as_element().unwrap();
|
||||||
let parent_cv = parent.borrow_data().map_or(Arc::new(ComputedValues::initial_values().clone()),
|
let parent_cv = parent.borrow_data().map_or_else(|| Arc::new(ComputedValues::initial_values().clone()),
|
||||||
|x| x.get_current_styles().unwrap()
|
|x| x.get_current_styles().unwrap()
|
||||||
.primary.clone());
|
.primary.clone());
|
||||||
return ComputedValues::inherit_from(&parent_cv).into_strong();
|
return ComputedValues::inherit_from(&parent_cv).into_strong();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue