mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove borrow_data and mutate_data from TNode.
The new restyle architecture doesn't store these things in consistent places, so we need a more abstract API.
This commit is contained in:
parent
ddbc016f51
commit
bfbbef6ecd
9 changed files with 115 additions and 84 deletions
|
@ -6,8 +6,7 @@
|
|||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||
use data::PersistentStyleData;
|
||||
use data::PseudoStyles;
|
||||
use element_state::ElementState;
|
||||
use parking_lot::RwLock;
|
||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
|
@ -147,13 +146,25 @@ pub trait TNode : Sized + Copy + Clone + NodeInfo {
|
|||
/// traversal. Returns the number of children left to process.
|
||||
fn did_process_child(&self) -> isize;
|
||||
|
||||
/// Borrows the style data immutably. Fails on a conflicting borrow.
|
||||
#[inline(always)]
|
||||
fn borrow_data(&self) -> Option<AtomicRef<PersistentStyleData>>;
|
||||
/// Returns the computed style values corresponding to the existing style
|
||||
/// for this node, if any.
|
||||
///
|
||||
/// This returns an cloned Arc (rather than a borrow) to abstract over the
|
||||
/// multitude of ways these values may be stored under the hood. By
|
||||
/// returning an enum with various OwningRef/OwningHandle entries, we could
|
||||
/// avoid the refcounting traffic here, but it's probably not worth the
|
||||
/// complexity.
|
||||
fn get_existing_style(&self) -> Option<Arc<ComputedValues>>;
|
||||
|
||||
/// Borrows the style data mutably. Fails on a conflicting borrow.
|
||||
#[inline(always)]
|
||||
fn mutate_data(&self) -> Option<AtomicRefMut<PersistentStyleData>>;
|
||||
/// Sets the computed style for this node.
|
||||
fn set_style(&self, style: Option<Arc<ComputedValues>>);
|
||||
|
||||
/// Transfers ownership of the existing pseudo styles, if any, to the
|
||||
/// caller. The stored pseudo styles are replaced with an empty map.
|
||||
fn take_pseudo_styles(&self) -> PseudoStyles;
|
||||
|
||||
/// Sets the pseudo styles on the element, replacing any existing styles.
|
||||
fn set_pseudo_styles(&self, styles: PseudoStyles);
|
||||
|
||||
/// Get the description of how to account for recent style changes.
|
||||
fn restyle_damage(self) -> Self::ConcreteRestyleDamage;
|
||||
|
@ -171,11 +182,6 @@ pub trait TNode : Sized + Copy + Clone + NodeInfo {
|
|||
|
||||
fn next_sibling(&self) -> Option<Self>;
|
||||
|
||||
/// Removes the style from this node.
|
||||
fn unstyle(self) {
|
||||
self.mutate_data().unwrap().style = None;
|
||||
}
|
||||
|
||||
/// XXX: It's a bit unfortunate we need to pass the current computed values
|
||||
/// as an argument here, but otherwise Servo would crash due to double
|
||||
/// borrows to return it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue