mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Parameterize the rest of the style system on TNode.
This commit is contained in:
parent
5c749127cc
commit
c2daea2c9c
37 changed files with 149 additions and 113 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use data::PrivateStyleData;
|
||||
use element_state::ElementState;
|
||||
use properties::{ComputedValues, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, TComputedValues};
|
||||
use restyle_hints::{ElementSnapshot, RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint};
|
||||
use selector_impl::ElementExt;
|
||||
use selectors::Element;
|
||||
|
@ -43,14 +43,16 @@ impl OpaqueNode {
|
|||
}
|
||||
|
||||
pub trait TRestyleDamage : BitOr<Output=Self> + Copy {
|
||||
fn compute(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> Self;
|
||||
type ConcreteComputedValues: TComputedValues;
|
||||
fn compute(old: Option<&Arc<Self::ConcreteComputedValues>>, new: &Self::ConcreteComputedValues) -> Self;
|
||||
fn rebuild_and_reflow() -> Self;
|
||||
}
|
||||
|
||||
pub trait TNode : Sized + Copy + Clone {
|
||||
type ConcreteElement: TElement<ConcreteNode = Self, ConcreteDocument = Self::ConcreteDocument>;
|
||||
type ConcreteDocument: TDocument<ConcreteNode = Self, ConcreteElement = Self::ConcreteElement>;
|
||||
type ConcreteRestyleDamage: TRestyleDamage;
|
||||
type ConcreteRestyleDamage: TRestyleDamage<ConcreteComputedValues = Self::ConcreteComputedValues>;
|
||||
type ConcreteComputedValues: TComputedValues;
|
||||
|
||||
fn to_unsafe(&self) -> UnsafeNode;
|
||||
unsafe fn from_unsafe(n: &UnsafeNode) -> Self;
|
||||
|
@ -135,17 +137,20 @@ pub trait TNode : Sized + Copy + Clone {
|
|||
/// Borrows the PrivateStyleData without checks.
|
||||
#[inline(always)]
|
||||
unsafe fn borrow_data_unchecked(&self)
|
||||
-> Option<*const PrivateStyleData<<Self::ConcreteElement as Element>::Impl>>;
|
||||
-> Option<*const PrivateStyleData<<Self::ConcreteElement as Element>::Impl,
|
||||
Self::ConcreteComputedValues>>;
|
||||
|
||||
/// Borrows the PrivateStyleData immutably. Fails on a conflicting borrow.
|
||||
#[inline(always)]
|
||||
fn borrow_data(&self)
|
||||
-> Option<Ref<PrivateStyleData<<Self::ConcreteElement as Element>::Impl>>>;
|
||||
-> Option<Ref<PrivateStyleData<<Self::ConcreteElement as Element>::Impl,
|
||||
Self::ConcreteComputedValues>>>;
|
||||
|
||||
/// Borrows the PrivateStyleData mutably. Fails on a conflicting borrow.
|
||||
#[inline(always)]
|
||||
fn mutate_data(&self)
|
||||
-> Option<RefMut<PrivateStyleData<<Self::ConcreteElement as Element>::Impl>>>;
|
||||
-> Option<RefMut<PrivateStyleData<<Self::ConcreteElement as Element>::Impl,
|
||||
Self::ConcreteComputedValues>>>;
|
||||
|
||||
/// Get the description of how to account for recent style changes.
|
||||
fn restyle_damage(self) -> Self::ConcreteRestyleDamage;
|
||||
|
@ -166,7 +171,7 @@ pub trait TNode : Sized + Copy + Clone {
|
|||
|
||||
/// Returns the style results for the given node. If CSS selector matching
|
||||
/// has not yet been performed, fails.
|
||||
fn style(&self) -> Ref<Arc<ComputedValues>> {
|
||||
fn style(&self) -> Ref<Arc<Self::ConcreteComputedValues>> {
|
||||
Ref::map(self.borrow_data().unwrap(), |data| data.style.as_ref().unwrap())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue