Struct LayoutThread

Source
pub struct LayoutThread {
Show 22 fields id: PipelineId, webview_id: WebViewId, url: ServoUrl, stylist: Stylist, is_iframe: bool, script_chan: GenericSender<ScriptThreadMessage>, time_profiler_chan: ProfilerChan, image_cache: Arc<dyn ImageCache>, font_context: Arc<FontContext>, have_added_user_agent_stylesheets: bool, have_ever_generated_display_list: Cell<bool>, need_new_display_list: Cell<bool>, need_new_stacking_context_tree: Cell<bool>, box_tree: RefCell<Option<Arc<BoxTree>>>, fragment_tree: RefCell<Option<Rc<FragmentTree>>>, stacking_context_tree: RefCell<Option<StackingContextTree>>, epoch: Cell<Epoch>, resolved_images_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder), Result<Image, ResolveImageError>>>>, registered_painters: RegisteredPaintersImpl, compositor_api: CrossProcessCompositorApi, debug: DebugOptions, previously_highlighted_dom_node: Cell<Option<OpaqueNode>>,
}
Expand description

Information needed by layout.

Fields§

§id: PipelineId

The ID of the pipeline that we belong to.

§webview_id: WebViewId

The webview that contains the pipeline we belong to.

§url: ServoUrl

The URL of the pipeline that we belong to.

§stylist: Stylist

Performs CSS selector matching and style resolution.

§is_iframe: bool

Is the current reflow of an iframe, as opposed to a root window?

§script_chan: GenericSender<ScriptThreadMessage>

The channel on which messages can be sent to the script thread.

§time_profiler_chan: ProfilerChan

The channel on which messages can be sent to the time profiler.

§image_cache: Arc<dyn ImageCache>

Reference to the script thread image cache.

§font_context: Arc<FontContext>

A FontContext to be used during layout.

§have_added_user_agent_stylesheets: bool

Whether or not user agent stylesheets have been added to the Stylist or not.

§have_ever_generated_display_list: Cell<bool>

Is this the first reflow in this LayoutThread?

§need_new_display_list: Cell<bool>

Whether a new display list is necessary due to changes to layout or stacking contexts. This is set to true every time layout changes, even when a display list isn’t requested for this layout, such as for layout queries. The next time a layout requests a display list, it is produced unconditionally, even when the layout trees remain the same.

§need_new_stacking_context_tree: Cell<bool>

Whether or not the existing stacking context tree is dirty and needs to be rebuilt. This happens after a relayout or overflow update. The reason that we don’t simply clear the stacking context tree when it becomes dirty is that we need to preserve scroll offsets from the old tree to the new one.

§box_tree: RefCell<Option<Arc<BoxTree>>>

The box tree.

§fragment_tree: RefCell<Option<Rc<FragmentTree>>>

The fragment tree.

§stacking_context_tree: RefCell<Option<StackingContextTree>>

The StackingContextTree cached from previous layouts.

§epoch: Cell<Epoch>

A counter for epoch messages

§resolved_images_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder), Result<Image, ResolveImageError>>>>§registered_painters: RegisteredPaintersImpl

The executors for paint worklets.

§compositor_api: CrossProcessCompositorApi

Cross-process access to the Compositor API.

§debug: DebugOptions

Debug options, copied from configuration to this LayoutThread in order to avoid having to constantly access the thread-safe global options.

§previously_highlighted_dom_node: Cell<Option<OpaqueNode>>

Tracks the node that was highlighted by the devtools during the last reflow.

If this changed, then we need to create a new display list.

Implementations§

Source§

impl LayoutThread

Source

fn new(config: LayoutConfig) -> LayoutThread

Source

fn build_shared_style_context<'a>( &'a self, guards: StylesheetGuards<'a>, snapshot_map: &'a SnapshotMap, animation_timeline_value: f64, animations: &DocumentAnimationSet, traversal_flags: TraversalFlags, ) -> SharedStyleContext<'a>

Source

fn load_all_web_fonts_from_stylesheet_with_guard( &self, stylesheet: &DocumentStyleSheet, guard: &SharedRwLockReadGuard<'_>, )

Source

fn can_skip_reflow_request_entirely( &self, reflow_request: &ReflowRequest, ) -> bool

In some cases, if a restyle isn’t necessary we can skip doing any work for layout entirely. This check allows us to return early from layout without doing any work at all.

Source

fn maybe_print_reflow_event(&self, reflow_request: &ReflowRequest)

Source

fn handle_update_scroll_node_request( &self, reflow_request: &ReflowRequest, ) -> bool

Checks whether we need to update the scroll node, and report whether the node is scrolled. We need to update the scroll node whenever it is requested.

Source

fn handle_reflow( &mut self, reflow_request: ReflowRequest, ) -> Option<ReflowResult>

The high-level routine that performs layout.

Source

fn update_device_if_necessary( &mut self, reflow_request: &ReflowRequest, viewport_changed: bool, guards: &StylesheetGuards<'_>, ) -> bool

Source

fn prepare_stylist_for_reflow<'dom>( &mut self, reflow_request: &ReflowRequest, document: ServoLayoutDocument<'dom>, root_element: ServoLayoutElement<'dom>, guards: &StylesheetGuards<'_>, ua_stylesheets: &UserAgentStylesheets, snapshot_map: &SnapshotMap, )

Source

fn restyle_and_build_trees( &mut self, reflow_request: &mut ReflowRequest, document: ServoLayoutDocument<'_>, root_element: ServoLayoutElement<'_>, image_resolver: &Arc<ImageResolver>, ) -> (ReflowPhasesRun, RestyleDamage, IFrameSizes)

Source

fn calculate_overflow(&self, damage: RestyleDamage) -> bool

Source

fn build_stacking_context_tree_for_reflow( &self, reflow_request: &ReflowRequest, damage: RestyleDamage, ) -> bool

Source

fn build_stacking_context_tree(&self, viewport_details: ViewportDetails) -> bool

Source

fn build_display_list( &self, reflow_request: &ReflowRequest, damage: RestyleDamage, image_resolver: &Arc<ImageResolver>, ) -> bool

Build the display list for the current layout and send it to the renderer. If no display list is built, returns false.

Source

fn set_scroll_offset_from_script( &self, external_scroll_id: ExternalScrollId, offset: LayoutVector2D, ) -> bool

Source

fn profiler_metadata(&self) -> Option<TimerMetadata>

Returns profiling information which is passed to the time profiler.

Source

fn viewport_did_change(&mut self, viewport_details: ViewportDetails) -> bool

Source

fn theme_did_change(&self, theme: Theme) -> bool

Source

fn update_device( &mut self, viewport_details: ViewportDetails, theme: Theme, guards: &StylesheetGuards<'_>, )

Update layout given a new viewport. Returns true if the viewport changed or false if it didn’t.

Trait Implementations§

Source§

impl Drop for LayoutThread

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Layout for LayoutThread

Source§

fn query_box_area( &self, node: TrustedNodeAddress, area: BoxAreaType, ) -> Option<UntypedRect<Au>>

Return the union of this node’s areas in the coordinate space of the Document. This is used to implement getBoundingClientRect() and support many other API where the such query is required.

Part of https://drafts.csswg.org/cssom-view-1/#element-get-the-bounding-box.

Source§

fn query_box_areas( &self, node: TrustedNodeAddress, area: BoxAreaType, ) -> Vec<UntypedRect<Au>>

Get a Vec of bounding boxes of this node’s Fragments specific area in the coordinate space of the Document. This is used to implement getClientRects().

See https://drafts.csswg.org/cssom-view/#dom-element-getclientrects.

Source§

fn register_custom_property( &mut self, property_registration: PropertyRegistration, ) -> Result<(), RegisterPropertyError>

Source§

fn device(&self) -> &Device

Get a reference to this Layout’s Stylo Device used to handle media queries and resolve font metrics.
Source§

fn current_epoch(&self) -> Epoch

The currently laid out Epoch that this Layout has finished.
Source§

fn load_web_fonts_from_stylesheet(&self, stylesheet: ServoArc<Stylesheet>)

Load all fonts from the given stylesheet, returning the number of fonts that need to be loaded.
Source§

fn add_stylesheet( &mut self, stylesheet: ServoArc<Stylesheet>, before_stylesheet: Option<ServoArc<Stylesheet>>, )

Add a stylesheet to this Layout. This will add it to the Layout’s Stylist as well as loading all web fonts defined in the stylesheet. The second stylesheet is the insertion point (if it exists, the sheet needs to be inserted before it).
Source§

fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>)

Removes a stylesheet from the Layout.
Source§

fn query_client_rect(&self, node: TrustedNodeAddress) -> UntypedRect<i32>

Source§

fn query_element_inner_outer_text(&self, node: TrustedNodeAddress) -> String

Source§

fn query_offset_parent(&self, node: TrustedNodeAddress) -> OffsetParentResponse

Source§

fn query_scroll_parent( &self, node: TrustedNodeAddress, ) -> Option<ScrollParentResponse>

Source§

fn query_resolved_style( &self, node: TrustedNodeAddress, pseudo: Option<PseudoElement>, property_id: PropertyId, animations: DocumentAnimationSet, animation_timeline_value: f64, ) -> String

Source§

fn query_resolved_font_style( &self, node: TrustedNodeAddress, value: &str, animations: DocumentAnimationSet, animation_timeline_value: f64, ) -> Option<ServoArc<Font>>

Source§

fn query_scrolling_area( &self, node: Option<TrustedNodeAddress>, ) -> UntypedRect<i32>

Source§

fn query_text_indext( &self, node: OpaqueNode, point_in_node: UntypedPoint2D<f32>, ) -> Option<usize>

Source§

fn query_elements_from_point( &self, point: LayoutPoint, flags: ElementsFromPointFlags, ) -> Vec<ElementsFromPointResult>

Source§

fn exit_now(&mut self)

Inform the layout that its ScriptThread is about to exit.
Source§

fn collect_reports(&self, reports: &mut Vec<Report>, ops: &mut MallocSizeOfOps)

Requests that layout measure its memory usage. The resulting reports are sent back via the supplied channel.
Source§

fn set_quirks_mode(&mut self, quirks_mode: QuirksMode)

Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
Source§

fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult>

Requests a reflow.
Source§

fn ensure_stacking_context_tree(&self, viewport_details: ViewportDetails)

Do not request a reflow, but ensure that any previous reflow completes building a stacking context tree so that it is ready to query the final size of any elements in script.
Source§

fn register_paint_worklet_modules( &mut self, _name: Atom, _properties: Vec<Atom>, _painter: Box<dyn Painter>, )

Tells layout that script has added some paint worklet modules.
Source§

fn set_scroll_offsets_from_renderer( &mut self, scroll_states: &FnvHashMap<ExternalScrollId, LayoutVector2D>, )

Set the scroll states of this layout after a compositor scroll.
Source§

fn scroll_offset(&self, id: ExternalScrollId) -> Option<LayoutVector2D>

Get the scroll offset of the given scroll node with id of ExternalScrollId or None if it does not exist in the tree.
Source§

fn needs_new_display_list(&self) -> bool

Returns true if this layout needs to produce a new display list for rendering updates.

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> AsVoidPtr for T

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> MaybeSendSync for T