pub trait FragmentQuery {
type FragmentId: Copy + Eq + Hash;
// Required methods
fn generation_id(&self) -> u64;
fn hit_test(&self, point: Point) -> Option<FragmentHit<Self::FragmentId>>;
fn box_model(&self, source_id: SourceNodeId) -> Option<BoxModel>;
fn fragments_for_anchor<'a>(
&'a self,
anchor: &str,
) -> Box<dyn Iterator<Item = Self::FragmentId> + 'a>;
fn text_range_for_fragment(
&self,
fragment: Self::FragmentId,
) -> Option<SourceRange>;
fn rects_for_selection(&self, range: SourceRange) -> Vec<Rect>;
}Expand description
Common-minimum laid-out-geometry queries. Each lane that has a
layout phase implements this. Internal FragmentId type is per-
lane (opaque to consumers — only used as a map key).
Required Associated Types§
Sourcetype FragmentId: Copy + Eq + Hash
type FragmentId: Copy + Eq + Hash
Per-lane opaque fragment identity. Consumers compare for equality and use as map keys.
Required Methods§
Sourcefn generation_id(&self) -> u64
fn generation_id(&self) -> u64
Epoch — invalidated on any relayout. Consumers cache against this; the value rolls when the plane regenerates.
Sourcefn hit_test(&self, point: Point) -> Option<FragmentHit<Self::FragmentId>>
fn hit_test(&self, point: Point) -> Option<FragmentHit<Self::FragmentId>>
Hit-test at a viewport point. Returns the topmost fragment
hit (paint-order semantics), or None if the point falls
outside any fragment.
Sourcefn box_model(&self, source_id: SourceNodeId) -> Option<BoxModel>
fn box_model(&self, source_id: SourceNodeId) -> Option<BoxModel>
CSS box-model for a source node. None if the node has no
fragment (e.g., display: none, or before layout completes).
Sourcefn fragments_for_anchor<'a>(
&'a self,
anchor: &str,
) -> Box<dyn Iterator<Item = Self::FragmentId> + 'a>
fn fragments_for_anchor<'a>( &'a self, anchor: &str, ) -> Box<dyn Iterator<Item = Self::FragmentId> + 'a>
Fragments under a named anchor (e.g., #section-2).
Sourcefn text_range_for_fragment(
&self,
fragment: Self::FragmentId,
) -> Option<SourceRange>
fn text_range_for_fragment( &self, fragment: Self::FragmentId, ) -> Option<SourceRange>
Reverse mapping: fragment → source span. Used by selection, “what node was here,” and Apparatus.
Sourcefn rects_for_selection(&self, range: SourceRange) -> Vec<Rect>
fn rects_for_selection(&self, range: SourceRange) -> Vec<Rect>
Selection → screen rects. Multi-rect because a selection can span lines or wrap; consumers (selection-highlight painter) draw one rect per returned entry.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".