Skip to main content

FrameWidget

Struct FrameWidget 

Source
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

ChromeKozan
WebFrameWidgetImplPlatform bridge (input, resize)
LocalFrameViewLifecycle orchestration
DocumentLifecycleLifecycleState + DirtyPhases
LayoutViewDocument 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

Source

pub fn new() -> Self

Source

pub fn document(&self) -> &Document

Source

pub fn document_mut(&mut self) -> &mut Document

Source

pub fn font_system(&self) -> &FontSystem

Source

pub fn viewport(&self) -> &Viewport

Source

pub fn last_fragment(&self) -> Option<&Arc<Fragment>>

Source

pub fn lifecycle(&self) -> LifecycleState

Source

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().

Source

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.

Source

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.

Source

pub fn last_display_list(&self) -> Option<Arc<DisplayList>>

The last paint result. The Arc is cloned cheaply — no copy of the list.

Source

pub fn take_layer_tree(&mut self) -> Option<LayerTree>

Take the layer tree for commit to the compositor.

Source

pub fn scroll_state_snapshot(&self) -> (ScrollTree, ScrollOffsets)

Clone scroll state for the compositor. Cheap: typically 1-5 nodes × 40 bytes.

Source

pub fn resize(&mut self, width: u32, height: u32)

Update the viewport dimensions (physical pixels).

Source

pub fn set_scale_factor(&mut self, factor: f64)

Source

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.

Source

pub fn last_timing(&self) -> FrameTiming

Source

pub fn set_focus(&mut self, _focused: bool)

Trait Implementations§

Source§

impl Default for FrameWidget

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,