pub struct FrameWidget { /* private fields */ }Expand description
The engine’s entry point for a single rendering context.
§Responsibilities
- Owns the
Document(DOM tree) - Owns the
Viewport(dimensions, scale factor) - Owns the
EventHandler(input → DOM events) - Owns the scroll subsystems (
ScrollTree,ScrollOffsets) - Runs the lifecycle pipeline: style → layout → paint
§Chrome mapping
| Chrome | Kozan |
|---|---|
WebFrameWidgetImpl | Platform bridge (input, resize) |
LocalFrameView | Lifecycle orchestration |
DocumentLifecycle | LifecycleState + DirtyPhases |
LayoutView | Document root (layout via DocumentLayoutView) |
§Usage (from platform)
let mut widget = FrameWidget::new();
widget.resize(1920, 1080);
// User builds DOM
let doc = widget.document_mut();
// Event loop (called from Scheduler::tick render callback)
widget.handle_input(input_event);
widget.update_lifecycle();
// Read paint result
if let Some(dl) = widget.last_display_list() {
// send to renderer
}Implementations§
Source§impl FrameWidget
impl FrameWidget
pub fn new() -> Self
pub fn document(&self) -> &Document
pub fn document_mut(&mut self) -> &mut Document
pub fn font_system(&self) -> &FontSystem
pub fn viewport(&self) -> &Viewport
pub fn last_fragment(&self) -> Option<&Arc<Fragment>>
pub fn lifecycle(&self) -> LifecycleState
Sourcepub fn handle_input(&mut self, event: InputEvent) -> bool
pub fn handle_input(&mut self, event: InputEvent) -> bool
Handle an input event.
Performs hit testing against the last fragment tree, dispatches
DOM events, and applies scroll actions via the scroll controller.
Returns true if visual state changed (DOM mutation or scroll).
Chrome: WebFrameWidgetImpl::HandleInputEvent().
Sourcepub fn apply_compositor_scroll(&mut self, offsets: &ScrollOffsets)
pub fn apply_compositor_scroll(&mut self, offsets: &ScrollOffsets)
Apply scroll offsets received from the compositor.
Called at the start of each frame on the view thread so the next paint uses the compositor’s authoritative scroll positions.
Sourcepub fn update_lifecycle(&mut self)
pub fn update_lifecycle(&mut self)
Run the rendering lifecycle pipeline.
Chrome: LocalFrameView::UpdateLifecyclePhases().
Phases: style recalc → layout → paint.
DirtyPhases controls which phases actually run — scroll only
invalidates paint, so style+layout are skipped at 60fps during scroll.
Sourcepub fn last_display_list(&self) -> Option<Arc<DisplayList>>
pub fn last_display_list(&self) -> Option<Arc<DisplayList>>
The last paint result. The Arc is cloned cheaply — no copy of the list.
Sourcepub fn take_layer_tree(&mut self) -> Option<LayerTree>
pub fn take_layer_tree(&mut self) -> Option<LayerTree>
Take the layer tree for commit to the compositor.
Sourcepub fn scroll_state_snapshot(&self) -> (ScrollTree, ScrollOffsets)
pub fn scroll_state_snapshot(&self) -> (ScrollTree, ScrollOffsets)
Clone scroll state for the compositor. Cheap: typically 1-5 nodes × 40 bytes.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Update the viewport dimensions (physical pixels).
pub fn set_scale_factor(&mut self, factor: f64)
Sourcepub fn mark_needs_update(&mut self)
pub fn mark_needs_update(&mut self)
Force the lifecycle to re-run on the next update_lifecycle() call.
Called by the platform when the scheduler’s frame callback fires,
because set_needs_frame() means something changed that requires
a new frame.
pub fn last_timing(&self) -> FrameTiming
pub fn set_focus(&mut self, _focused: bool)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FrameWidget
impl !RefUnwindSafe for FrameWidget
impl !Send for FrameWidget
impl !Sync for FrameWidget
impl Unpin for FrameWidget
impl UnsafeUnpin for FrameWidget
impl !UnwindSafe for FrameWidget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more