pub trait Layout {
Show 37 methods
// Required methods
fn device(&self) -> &Device;
fn set_theme(&mut self, theme: Theme) -> bool;
fn set_viewport_details(
&mut self,
viewport_details: ViewportDetails,
) -> bool;
fn load_web_fonts_from_stylesheet(
&self,
stylesheet: &ServoArc<Stylesheet>,
font_context: &WebFontDocumentContext,
);
fn add_stylesheet(
&mut self,
stylesheet: ServoArc<Stylesheet>,
before_stylsheet: Option<ServoArc<Stylesheet>>,
font_context: &WebFontDocumentContext,
);
fn exit_now(&mut self);
fn collect_reports(
&self,
reports: &mut Vec<Report>,
ops: &mut MallocSizeOfOps,
);
fn set_quirks_mode(&mut self, quirks_mode: QuirksMode);
fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>);
fn remove_cached_image(&mut self, image_url: &ServoUrl);
fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult>;
fn ensure_stacking_context_tree(&self, viewport_details: ViewportDetails);
fn register_paint_worklet_modules(
&mut self,
name: Atom,
properties: Vec<Atom>,
painter: Box<dyn Painter>,
);
fn set_scroll_offsets_from_renderer(
&mut self,
scroll_states: &FxHashMap<ExternalScrollId, LayoutVector2D>,
);
fn scroll_offset(&self, id: ExternalScrollId) -> Option<LayoutVector2D>;
fn needs_new_display_list(&self) -> bool;
fn set_needs_new_display_list(&self);
fn node_rendering_type(
&self,
node: TrustedNodeAddress,
pseudo: Option<PseudoElement>,
) -> NodeRenderingType;
fn query_containing_block(
&self,
node: TrustedNodeAddress,
) -> Option<UntrustedNodeAddress>;
fn query_padding(&self, node: TrustedNodeAddress) -> Option<PhysicalSides>;
fn query_box_area(
&self,
node: TrustedNodeAddress,
area: BoxAreaType,
exclude_transform_and_inline: bool,
) -> Option<Rect<Au, CSSPixel>>;
fn query_box_areas(
&self,
node: TrustedNodeAddress,
area: BoxAreaType,
) -> CSSPixelRectIterator;
fn query_client_rect(&self, node: TrustedNodeAddress) -> Rect<i32, CSSPixel>;
fn query_current_css_zoom(&self, node: TrustedNodeAddress) -> f32;
fn query_element_inner_outer_text(&self, node: TrustedNodeAddress) -> String;
fn query_offset_parent(
&self,
node: TrustedNodeAddress,
) -> OffsetParentResponse;
fn query_scroll_container(
&self,
node: Option<TrustedNodeAddress>,
flags: ScrollContainerQueryFlags,
) -> Option<ScrollContainerResponse>;
fn query_resolved_style(
&self,
node: TrustedNodeAddress,
pseudo: Option<PseudoElement>,
property_id: PropertyId,
animations: DocumentAnimationSet,
animation_timeline_value: f64,
) -> String;
fn query_resolved_font_style(
&self,
node: TrustedNodeAddress,
value: &str,
animations: DocumentAnimationSet,
animation_timeline_value: f64,
) -> Option<ServoArc<Font>>;
fn query_scrolling_area(
&self,
node: Option<TrustedNodeAddress>,
) -> Rect<i32, CSSPixel>;
fn query_text_index(
&self,
node: TrustedNodeAddress,
point: Point2D<Au, CSSPixel>,
) -> Option<usize>;
fn query_elements_from_point(
&self,
point: LayoutPoint,
flags: ElementsFromPointFlags,
) -> Vec<ElementsFromPointResult>;
fn query_effective_overflow(
&self,
node: TrustedNodeAddress,
) -> Option<AxesOverflow>;
fn stylist_mut(&mut self) -> &mut Stylist;
fn set_accessibility_active(&self, enabled: bool, epoch: Epoch);
fn needs_accessibility_update(&self) -> bool;
fn set_needs_accessibility_update(&self);
}Required Methods§
Sourcefn device(&self) -> &Device
fn device(&self) -> &Device
Get a reference to this Layout’s Stylo Device used to handle media queries and
resolve font metrics.
Sourcefn set_viewport_details(&mut self, viewport_details: ViewportDetails) -> bool
fn set_viewport_details(&mut self, viewport_details: ViewportDetails) -> bool
Set the ViewportDetails on this Layout’s Device. The caller should also
trigger a new layout when this happens, though it can happen later. Returns true
if the ViewportDetails actually changed or false otherwise.
Sourcefn load_web_fonts_from_stylesheet(
&self,
stylesheet: &ServoArc<Stylesheet>,
font_context: &WebFontDocumentContext,
)
fn load_web_fonts_from_stylesheet( &self, stylesheet: &ServoArc<Stylesheet>, font_context: &WebFontDocumentContext, )
Load all fonts from the given stylesheet, returning the number of fonts that need to be loaded.
Sourcefn add_stylesheet(
&mut self,
stylesheet: ServoArc<Stylesheet>,
before_stylsheet: Option<ServoArc<Stylesheet>>,
font_context: &WebFontDocumentContext,
)
fn add_stylesheet( &mut self, stylesheet: ServoArc<Stylesheet>, before_stylsheet: Option<ServoArc<Stylesheet>>, font_context: &WebFontDocumentContext, )
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).
Sourcefn collect_reports(&self, reports: &mut Vec<Report>, ops: &mut MallocSizeOfOps)
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.
Sourcefn set_quirks_mode(&mut self, quirks_mode: QuirksMode)
fn set_quirks_mode(&mut self, quirks_mode: QuirksMode)
Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
Sourcefn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>)
fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>)
Removes a stylesheet from the Layout.
Sourcefn remove_cached_image(&mut self, image_url: &ServoUrl)
fn remove_cached_image(&mut self, image_url: &ServoUrl)
Removes an image from the Layout image resolver cache.
Sourcefn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult>
fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult>
Requests a reflow.
Sourcefn ensure_stacking_context_tree(&self, viewport_details: ViewportDetails)
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.
Sourcefn register_paint_worklet_modules(
&mut self,
name: Atom,
properties: Vec<Atom>,
painter: Box<dyn Painter>,
)
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.
Sourcefn set_scroll_offsets_from_renderer(
&mut self,
scroll_states: &FxHashMap<ExternalScrollId, LayoutVector2D>,
)
fn set_scroll_offsets_from_renderer( &mut self, scroll_states: &FxHashMap<ExternalScrollId, LayoutVector2D>, )
Set the scroll states of this layout after a Paint scroll.
Sourcefn scroll_offset(&self, id: ExternalScrollId) -> Option<LayoutVector2D>
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.
Sourcefn needs_new_display_list(&self) -> bool
fn needs_new_display_list(&self) -> bool
Returns true if this layout needs to produce a new display list for rendering updates.
Sourcefn set_needs_new_display_list(&self)
fn set_needs_new_display_list(&self)
Marks that this layout needs to produce a new display list for rendering updates.
Sourcefn node_rendering_type(
&self,
node: TrustedNodeAddress,
pseudo: Option<PseudoElement>,
) -> NodeRenderingType
fn node_rendering_type( &self, node: TrustedNodeAddress, pseudo: Option<PseudoElement>, ) -> NodeRenderingType
Returns the NodeRenderingType for this node and pseudo. This is used to determine
if a node is being rendered, delegating its rendering, or not being rendered at all.
fn query_containing_block( &self, node: TrustedNodeAddress, ) -> Option<UntrustedNodeAddress>
fn query_padding(&self, node: TrustedNodeAddress) -> Option<PhysicalSides>
fn query_box_area( &self, node: TrustedNodeAddress, area: BoxAreaType, exclude_transform_and_inline: bool, ) -> Option<Rect<Au, CSSPixel>>
fn query_box_areas( &self, node: TrustedNodeAddress, area: BoxAreaType, ) -> CSSPixelRectIterator
fn query_client_rect(&self, node: TrustedNodeAddress) -> Rect<i32, CSSPixel>
fn query_current_css_zoom(&self, node: TrustedNodeAddress) -> f32
fn query_element_inner_outer_text(&self, node: TrustedNodeAddress) -> String
fn query_offset_parent(&self, node: TrustedNodeAddress) -> OffsetParentResponse
Sourcefn query_scroll_container(
&self,
node: Option<TrustedNodeAddress>,
flags: ScrollContainerQueryFlags,
) -> Option<ScrollContainerResponse>
fn query_scroll_container( &self, node: Option<TrustedNodeAddress>, flags: ScrollContainerQueryFlags, ) -> Option<ScrollContainerResponse>
Query the scroll container for the given node. If node is None, the scroll container for
the viewport is returned.
fn query_resolved_style( &self, node: TrustedNodeAddress, pseudo: Option<PseudoElement>, property_id: PropertyId, animations: DocumentAnimationSet, animation_timeline_value: f64, ) -> String
fn query_resolved_font_style( &self, node: TrustedNodeAddress, value: &str, animations: DocumentAnimationSet, animation_timeline_value: f64, ) -> Option<ServoArc<Font>>
fn query_scrolling_area( &self, node: Option<TrustedNodeAddress>, ) -> Rect<i32, CSSPixel>
Sourcefn query_text_index(
&self,
node: TrustedNodeAddress,
point: Point2D<Au, CSSPixel>,
) -> Option<usize>
fn query_text_index( &self, node: TrustedNodeAddress, point: Point2D<Au, CSSPixel>, ) -> Option<usize>
Find the character offset of the point in the given node, if it has text content.
fn query_elements_from_point( &self, point: LayoutPoint, flags: ElementsFromPointFlags, ) -> Vec<ElementsFromPointResult>
fn query_effective_overflow( &self, node: TrustedNodeAddress, ) -> Option<AxesOverflow>
fn stylist_mut(&mut self) -> &mut Stylist
Sourcefn set_accessibility_active(&self, enabled: bool, epoch: Epoch)
fn set_accessibility_active(&self, enabled: bool, epoch: Epoch)
Set whether the accessibility tree should be constructed for this Layout. This should be called by the embedder when accessibility is requested by the user.
Sourcefn needs_accessibility_update(&self) -> bool
fn needs_accessibility_update(&self) -> bool
Whether the accessibility tree needs updating. This is set to true when
- accessibility is activated; or
- a page is loaded after accesibility is activated.
In future, this should be set to true if DOM or style have changed in a way that impacts the accessibility tree.
Checked in can_skip_reflow_request_entirely(), as a dirty accessibility tree should force a reflow, and handle_reflow() to determine whether to update the accessibility tree during reflow.