diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-24 16:38:11 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-24 16:42:19 +0200 |
| commit | 89927d7de069169eeecfa091d6b77408b69fe188 (patch) | |
| tree | bd9172a9935f2e15214d82c36d2e411c3623b7f5 /src/model/layout.rs | |
| parent | 8fbb11fc05b3313bf102c1f23693290661d00863 (diff) | |
`StyleSlot`, `KeyId` and `NodeId`
Diffstat (limited to 'src/model/layout.rs')
| -rw-r--r-- | src/model/layout.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/model/layout.rs b/src/model/layout.rs index da6290ae..9a4d5df3 100644 --- a/src/model/layout.rs +++ b/src/model/layout.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Debug, Formatter}; use std::hash::Hash; use std::sync::Arc; -use super::{Barrier, Resolve, StyleChain}; +use super::{Barrier, NodeId, Resolve, StyleChain, StyleSlot}; use crate::diag::TypResult; use crate::eval::{RawAlign, RawLength}; use crate::frame::{Element, Frame, Geometry}; @@ -148,9 +148,9 @@ impl LayoutNode { (**self.0).as_any().is::<T>() } - /// A barrier for the node. - pub fn barrier(&self) -> Barrier { - (**self.0).barrier() + /// The id of this node. + pub fn id(&self) -> NodeId { + (**self.0).node_id() } /// Try to downcast to a specific layout node. @@ -220,7 +220,8 @@ impl Layout for LayoutNode { styles: StyleChain, ) -> TypResult<Vec<Arc<Frame>>> { ctx.query((self, regions, styles), |ctx, (node, regions, styles)| { - node.0.layout(ctx, regions, node.barrier().chain(&styles)) + let slot = StyleSlot::from(Barrier::new(node.id())); + node.0.layout(ctx, regions, slot.chain(&styles)) }) .clone() } @@ -250,7 +251,7 @@ impl PartialEq for LayoutNode { trait Bounds: Layout + Debug + Sync + Send + 'static { fn as_any(&self) -> &dyn Any; - fn barrier(&self) -> Barrier; + fn node_id(&self) -> NodeId; } impl<T> Bounds for T @@ -261,8 +262,8 @@ where self } - fn barrier(&self) -> Barrier { - Barrier::new::<T>() + fn node_id(&self) -> NodeId { + NodeId::of::<Self>() } } |
