pub trait InstanceNode {
Show 31 methods
// Required methods
fn base(&self) -> &BaseInstance;
fn instantiate(args: InstantiationArgs) -> Rc<Self>
where Self: Sized;
fn resolve_debug(
&self,
f: &mut Formatter<'_>,
expanded_node: Option<&ExpandedNode>,
) -> Result;
// Provided methods
fn requires_non_reactive_update(
&self,
_expanded_node: &ExpandedNode,
) -> bool { ... }
fn resolve_scene_light(
&self,
_expanded_node: &ExpandedNode,
_context: &RuntimeContext,
) -> Option<SceneLight> { ... }
fn resolve_scene_ambient_light(
&self,
_expanded_node: &ExpandedNode,
_context: &RuntimeContext,
) -> Option<SceneAmbientLight> { ... }
fn establishes_light_frame(&self) -> bool { ... }
fn update(
self: Rc<Self>,
_expanded_node: &Rc<ExpandedNode>,
_context: &Rc<RuntimeContext>,
) { ... }
fn handle_pre_render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
) { ... }
fn render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
) { ... }
fn handle_post_render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
) { ... }
fn handle_mount(
self: Rc<Self>,
expanded_node: &Rc<ExpandedNode>,
context: &Rc<RuntimeContext>,
) { ... }
fn handle_unmount(
&self,
expanded_node: &Rc<ExpandedNode>,
context: &Rc<RuntimeContext>,
) { ... }
fn handle_scroll(&self, args_scroll: Scroll) { ... }
fn get_template(&self) -> Option<&InstanceNodePtrList> { ... }
fn clips_content(&self, _expanded_node: &ExpandedNode) -> bool { ... }
fn ray_cast_test(
&self,
expanded_node: &ExpandedNode,
ray: Point2<Window>,
) -> bool { ... }
fn scrolls_content(&self, _expanded_node: &ExpandedNode) -> bool { ... }
fn property_requires_occlusion_recompute(
&self,
_property_name: &str,
) -> bool { ... }
fn materializes_native_surface(&self, _expanded_node: &ExpandedNode) -> bool { ... }
fn materializes_native_surface_before_children(
&self,
_expanded_node: &ExpandedNode,
) -> bool { ... }
fn resolve_scroll_offset(
&self,
_expanded_node: &ExpandedNode,
) -> Option<(f64, f64)> { ... }
fn received_children_source(&self) -> ReceivedChildrenSource { ... }
fn handle_native_interrupt(
&self,
_expanded_node: &Rc<ExpandedNode>,
_interrupt: &NativeInterrupt,
) { ... }
fn handle_control_flow_node_expansion(
self: Rc<Self>,
_expanded_node: &Rc<ExpandedNode>,
_context: &Rc<RuntimeContext>,
) { ... }
fn handle_setup_projected_children(
self: Rc<Self>,
_expanded_node: &Rc<ExpandedNode>,
_context: &Rc<RuntimeContext>,
) { ... }
fn resolve_coverage_path(
&self,
_expanded_node: &ExpandedNode,
) -> Option<BezPath> { ... }
fn resolve_alpha_mask_paints(
&self,
_expanded_node: &ExpandedNode,
) -> Vec<AlphaMaskPaint> { ... }
fn resolve_occlusion_path(
&self,
expanded_node: &ExpandedNode,
) -> Option<BezPath> { ... }
fn resolve_coverage_opacity(&self, expanded_node: &ExpandedNode) -> f64 { ... }
fn resolve_effect_clip_path(
&self,
_expanded_node: &ExpandedNode,
) -> Option<BezPath> { ... }
}Expand description
Central runtime representation of a properties-computable and renderable node.
InstanceNodes are conceptually stateless, and rely on ExpandedNodes for stateful representations.
An InstanceNode sits in between a pax_compiler::TemplateNodeDefinition, the
compile-time definition analogue to this instance, and ExpandedNode.
There is a 1:1 relationship between pax_compiler::TemplateNodeDefinitions and InstanceNodes.
There is a one-to-many relationship between one InstanceNode and possibly many variant ExpandedNodes,
due to duplication via for.
InstanceNodes are architecturally “type-aware” — they can perform type-specific operations e.g. on the state stored in ExpandedNode, while
ExpandedNodes are “type-blind”. The latter store polymorphic data but cannot operate on it without the type-aware assistance of their linked InstanceNode.
(See RepeatInstance::expand_node where we visit a singular InstanceNode several times, producing multiple ExpandedNodes.)
Required Methods§
Sourcefn base(&self) -> &BaseInstance
fn base(&self) -> &BaseInstance
Retrieves the base instance, containing common functionality that all instances share
fn instantiate(args: InstantiationArgs) -> Rc<Self>where
Self: Sized,
fn resolve_debug( &self, f: &mut Formatter<'_>, expanded_node: Option<&ExpandedNode>, ) -> Result
Provided Methods§
Sourcefn requires_non_reactive_update(&self, _expanded_node: &ExpandedNode) -> bool
fn requires_non_reactive_update(&self, _expanded_node: &ExpandedNode) -> bool
Whether this instance has per-frame update work that cannot be driven entirely through reactive property effects.
Sourcefn resolve_scene_light(
&self,
_expanded_node: &ExpandedNode,
_context: &RuntimeContext,
) -> Option<SceneLight>
fn resolve_scene_light( &self, _expanded_node: &ExpandedNode, _context: &RuntimeContext, ) -> Option<SceneLight>
Returns a resolved light contribution for non-rendering lighting primitives.
Sourcefn resolve_scene_ambient_light(
&self,
_expanded_node: &ExpandedNode,
_context: &RuntimeContext,
) -> Option<SceneAmbientLight>
fn resolve_scene_ambient_light( &self, _expanded_node: &ExpandedNode, _context: &RuntimeContext, ) -> Option<SceneAmbientLight>
Returns a resolved ambient contribution for non-rendering lighting primitives.
Sourcefn establishes_light_frame(&self) -> bool
fn establishes_light_frame(&self) -> bool
Whether this node establishes a lexical boundary for descendant lights.
Sourcefn update(
self: Rc<Self>,
_expanded_node: &Rc<ExpandedNode>,
_context: &Rc<RuntimeContext>,
)
fn update( self: Rc<Self>, _expanded_node: &Rc<ExpandedNode>, _context: &Rc<RuntimeContext>, )
Updates the expanded node, recomputing its properties and possibly updating its children.
Sourcefn handle_pre_render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
)
fn handle_pre_render( &self, expanded_node: &ExpandedNode, context: &Rc<RuntimeContext>, rcs: &mut dyn RenderContext, )
Second lifecycle method during each render loop, occurs after
properties have been computed, but before rendering
Example use-case: perform side-effects to the drawing contexts.
This is how Frame performs clipping, for example.
Occurs in a pre-order traversal of the render tree.
Sourcefn render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
)
fn render( &self, expanded_node: &ExpandedNode, context: &Rc<RuntimeContext>, rcs: &mut dyn RenderContext, )
Third lifecycle method during each render loop, occurs after all descendents have been rendered. Occurs in a post-order traversal of the render tree. Most primitives are expected to draw their contents to the rendering context during this event.
Sourcefn handle_post_render(
&self,
expanded_node: &ExpandedNode,
context: &Rc<RuntimeContext>,
rcs: &mut dyn RenderContext,
)
fn handle_post_render( &self, expanded_node: &ExpandedNode, context: &Rc<RuntimeContext>, rcs: &mut dyn RenderContext, )
Fourth and final lifecycle method during each render loop, occurs
after all descendents have been rendered AND the current node has been rendered.
Useful for clean-up, e.g. this is where Frame cleans up the drawing contexts
to stop clipping.
Occurs in a post-order traversal of the render tree.
Sourcefn handle_mount(
self: Rc<Self>,
expanded_node: &Rc<ExpandedNode>,
context: &Rc<RuntimeContext>,
)
fn handle_mount( self: Rc<Self>, expanded_node: &Rc<ExpandedNode>, context: &Rc<RuntimeContext>, )
Fires during the tick when a node is first attached to the render tree. For example,
this event fires by all nodes on the global first tick, and by all nodes in a subtree
when a Conditional subsequently turns on a subtree (i.e. when the Conditionals criterion becomes true after being false through the end of at least 1 frame.)
A use-case: send a message to native renderers that a Text element should be rendered and tracked
Sourcefn handle_unmount(
&self,
expanded_node: &Rc<ExpandedNode>,
context: &Rc<RuntimeContext>,
)
fn handle_unmount( &self, expanded_node: &Rc<ExpandedNode>, context: &Rc<RuntimeContext>, )
Fires during element unmount, when an element is about to be removed from the render tree (e.g. by a Conditional)
A use-case: send a message to native renderers that a Text element should be removed
Sourcefn handle_scroll(&self, args_scroll: Scroll)
fn handle_scroll(&self, args_scroll: Scroll)
Invoked by event interrupts to pass scroll information to render node
fn get_template(&self) -> Option<&InstanceNodePtrList>
Sourcefn clips_content(&self, _expanded_node: &ExpandedNode) -> bool
fn clips_content(&self, _expanded_node: &ExpandedNode) -> bool
Used by frame to control content clipping
Sourcefn ray_cast_test(
&self,
expanded_node: &ExpandedNode,
ray: Point2<Window>,
) -> bool
fn ray_cast_test( &self, expanded_node: &ExpandedNode, ray: Point2<Window>, ) -> bool
Override when a primitive needs a more precise hit region than its layout bounds.
Sourcefn scrolls_content(&self, _expanded_node: &ExpandedNode) -> bool
fn scrolls_content(&self, _expanded_node: &ExpandedNode) -> bool
Used by scroller-like primitives to allocate a browser-owned presentation layer.
Sourcefn property_requires_occlusion_recompute(&self, _property_name: &str) -> bool
fn property_requires_occlusion_recompute(&self, _property_name: &str) -> bool
Returns whether changes to a named typed property require recomputing the full occlusion/native-mask/layer-partition pass.
Common geometry, transform, opacity, and child-list dependencies are tracked separately for every node. Override this for typed properties that only affect local content or native patches and cannot change occlusion coverage, clipping, z-order, or layer ownership.
Sourcefn materializes_native_surface(&self, _expanded_node: &ExpandedNode) -> bool
fn materializes_native_surface(&self, _expanded_node: &ExpandedNode) -> bool
True when an otherwise layout-only primitive currently materializes a native surface.
Sourcefn materializes_native_surface_before_children(
&self,
_expanded_node: &ExpandedNode,
) -> bool
fn materializes_native_surface_before_children( &self, _expanded_node: &ExpandedNode, ) -> bool
True when a materialized native surface should be projected before descendants.
Most renderables are post-order so their own pixels sit above descendants in logical tree order. Native backing surfaces, such as liquid-glass Groups, need the opposite: the chassis should create/project the native surface before descendant content while still including the surface in native occlusion and vector-mask computation.
Sourcefn resolve_scroll_offset(
&self,
_expanded_node: &ExpandedNode,
) -> Option<(f64, f64)>
fn resolve_scroll_offset( &self, _expanded_node: &ExpandedNode, ) -> Option<(f64, f64)>
Returns the current browser-owned scroll offset in local scroller coordinates.
Sourcefn received_children_source(&self) -> ReceivedChildrenSource
fn received_children_source(&self) -> ReceivedChildrenSource
Selects which engine child family should be normalized into
received_children for semantic container-style consumers.
This hook is about provenance, not semantics:
Ownedmeans the node’s active child tree is already its received payloadProjectedmeans the node receives payload from its caller and the runtime delivers that payload through projection soslot(...)can consume it
The default remains heuristic for now: components normalize projected children, while other nodes normalize owned children.
fn handle_native_interrupt( &self, _expanded_node: &Rc<ExpandedNode>, _interrupt: &NativeInterrupt, )
fn handle_control_flow_node_expansion( self: Rc<Self>, _expanded_node: &Rc<ExpandedNode>, _context: &Rc<RuntimeContext>, )
fn handle_setup_projected_children( self: Rc<Self>, _expanded_node: &Rc<ExpandedNode>, _context: &Rc<RuntimeContext>, )
fn resolve_coverage_path( &self, _expanded_node: &ExpandedNode, ) -> Option<BezPath>
Sourcefn resolve_alpha_mask_paints(
&self,
_expanded_node: &ExpandedNode,
) -> Vec<AlphaMaskPaint>
fn resolve_alpha_mask_paints( &self, _expanded_node: &ExpandedNode, ) -> Vec<AlphaMaskPaint>
Resolves vector paint for an alpha-mask source without rendering or mutating the source’s retained canvas state.
Sourcefn resolve_occlusion_path(
&self,
expanded_node: &ExpandedNode,
) -> Option<BezPath>
fn resolve_occlusion_path( &self, expanded_node: &ExpandedNode, ) -> Option<BezPath>
Returns coverage used by the occlusion/native-mask/layer-partition pass.
The default uses the same coverage path as masks and hit-style geometry, but primitives with render-side animation may return a conservative stable path here so animation-only properties do not force the occlusion pass to rebuild expensive geometry every frame.
fn resolve_coverage_opacity(&self, expanded_node: &ExpandedNode) -> f64
fn resolve_effect_clip_path( &self, _expanded_node: &ExpandedNode, ) -> Option<BezPath>
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".