pub(crate) struct PaintTimingHandler {Show 14 fields
viewport_rect: LayoutRect,
is_document_paintable: bool,
is_document_contentful: bool,
previously_reported_paints: PaintTimingReport,
lcp_next_uuid: u64,
lcp_candidate: Option<LCPCandidate>,
reported_image_nodes: HashSet<OpaqueNode>,
images_pending_rendering: Vec<PendingImageRecord>,
elements_with_rendered_text: HashSet<OpaqueNode>,
elements_with_pending_rendered_text: HashMap<OpaqueNode, TextRecord>,
container_timing_next_uuid: u64,
container_timing_records: FxHashMap<OpaqueNode, ContainerRecord>,
container_timing_pending: FxHashMap<OpaqueNode, PendingContainer>,
dirty_containers: FxHashSet<OpaqueNode>,
}Fields§
§viewport_rect: LayoutRectThe rect of viewport.
is_document_paintable: boolWhether the current display list contains paintable items.
is_document_contentful: boolWhether the current display list contains contentful items.
previously_reported_paints: PaintTimingReport§lcp_next_uuid: u64Counter for generating unique LCP candidate UUIDs.
lcp_candidate: Option<LCPCandidate>The LCP candidate, it may be a image or text.
reported_image_nodes: HashSet<OpaqueNode>The set of image nodes that have been reported as LCP candidates.
images_pending_rendering: Vec<PendingImageRecord>§elements_with_rendered_text: HashSet<OpaqueNode>https://www.w3.org/TR/paint-timing/#set-of-elements-with-rendered-text The set of text nodes that have been reported as LCP candidates.
elements_with_pending_rendered_text: HashMap<OpaqueNode, TextRecord>The set of pending text nodes that will fight for LCP candidate.
container_timing_next_uuid: u64Counter for generating unique container timing UUIDs.
container_timing_records: FxHashMap<OpaqueNode, ContainerRecord>Accumulated Container Timing state, keyed by container root node. Persists across display list builds, like the LCP candidate does.
container_timing_pending: FxHashMap<OpaqueNode, PendingContainer>Container Timing state for the display list build currently in progress, keyed by
container root node. Reset every build by Self::finalize_container_timing.
dirty_containers: FxHashSet<OpaqueNode>Container roots whose painted area grew during the display list build currently
in progress. Drained by Self::take_container_timing_records once the build
finishes and the records are handed to script.
Implementations§
Source§impl PaintTimingHandler
impl PaintTimingHandler
pub(crate) fn new(viewport_size: LayoutSize) -> Self
Sourcepub(crate) fn mark_document_is_paintable(&mut self)
pub(crate) fn mark_document_is_paintable(&mut self)
Marks the current display list as containing a paintable item.
Sourcepub(crate) fn mark_document_is_contentful(&mut self)
pub(crate) fn mark_document_is_contentful(&mut self)
Marks the current display list as containing a contentful item.
pub(crate) fn append_image_record( &mut self, tag: Option<Tag>, bounds: LayoutRect, clip_rect: LayoutRect, transform: FastLayoutTransform, url: Option<ServoUrl>, natural_width: Option<Au>, natural_height: Option<Au>, load_time: Option<CrossProcessInstant>, )
pub(crate) fn accumulate_text_rect( &mut self, tag: Tag, rect: LayoutRect, transform: FastLayoutTransform, style: &ServoArc<ComputedValues>, )
Sourcefn paintable_bounding_rect(&self, bounds: LayoutRect) -> LayoutRect
fn paintable_bounding_rect(&self, bounds: LayoutRect) -> LayoutRect
Sourcepub(crate) fn paintable(&self, bounds: LayoutRect, opacity: f32) -> bool
pub(crate) fn paintable(&self, bounds: LayoutRect, opacity: f32) -> bool
Sourcepub(crate) fn check_if_paintable(
&mut self,
bounds: LayoutRect,
opacity: f32,
) -> bool
pub(crate) fn check_if_paintable( &mut self, bounds: LayoutRect, opacity: f32, ) -> bool
Marks wether the document is having paintable element
Sourcefn effective_visual_size(
&self,
intersection_rect: LayoutRect,
candidate_type: LCPCandidateType<'_>,
) -> Option<f32>
fn effective_visual_size( &self, intersection_rect: LayoutRect, candidate_type: LCPCandidateType<'_>, ) -> Option<f32>
Sourcefn compute_new_lcp_candidate(
&mut self,
painted_images: Vec<PendingImageRecord>,
painted_text_nodes: HashMap<OpaqueNode, TextRecord>,
) -> Option<LCPCandidate>
fn compute_new_lcp_candidate( &mut self, painted_images: Vec<PendingImageRecord>, painted_text_nodes: HashMap<OpaqueNode, TextRecord>, ) -> Option<LCPCandidate>
Sourcefn report_largest_contentful_paint(
&mut self,
halt_lcp: bool,
painted_images: Vec<PendingImageRecord>,
painted_text_nodes: HashMap<OpaqueNode, TextRecord>,
)
fn report_largest_contentful_paint( &mut self, halt_lcp: bool, painted_images: Vec<PendingImageRecord>, painted_text_nodes: HashMap<OpaqueNode, TextRecord>, )
Sourcepub(crate) fn update_container_timing(
&mut self,
container_roots: &ContainerTimingRootChain,
node: OpaqueNode,
bounds: LayoutRect,
clip_rect: LayoutRect,
transform: FastLayoutTransform,
natural_width: Option<Au>,
natural_height: Option<Au>,
)
pub(crate) fn update_container_timing( &mut self, container_roots: &ContainerTimingRootChain, node: OpaqueNode, bounds: LayoutRect, clip_rect: LayoutRect, transform: FastLayoutTransform, natural_width: Option<Au>, natural_height: Option<Au>, )
Accumulate a painted text or image fragment, painted by node, into the Container
Timing state of each of the enclosing container_roots.
Called during display list building, unlike the LCP collection which only
accumulates here and computes in Self::mark_paint_timing. Container Timing has
no per-frame winner to pick: each fragment either adds new painted area to its
container or it does not, so the work can be done as fragments are visited.
https://wicg.github.io/container-timing/#maybe-update-last-new-painted-area
Sourcefn finalize_container_timing(&mut self)
fn finalize_container_timing(&mut self)
A node only counts the first time it is ever seen contributing to a container
(tracked by ContainerRecord::contributing_nodes).
pub(crate) fn take_container_timing_records( &mut self, ) -> Vec<ContainerTimingRecord>
Sourcefn should_report_first_contentful_paint(&self) -> bool
fn should_report_first_contentful_paint(&self) -> bool
Sourcepub(crate) fn mark_paint_timing(
&mut self,
paint_timing_eligible: bool,
halt_lcp: bool,
) -> PaintTimingReport
pub(crate) fn mark_paint_timing( &mut self, paint_timing_eligible: bool, halt_lcp: bool, ) -> PaintTimingReport
https://www.w3.org/TR/paint-timing/#mark-paint-timing
Note: Step 10 is not in the current version of the specifications. Refer https://github.com/w3c/paint-timing/issues/122 for details on the issue and for the modified steps yet to be merged.
pub(crate) fn largest_contentful_paint_candidate(&self) -> Option<LCPCandidate>
Auto Trait Implementations§
impl !RefUnwindSafe for PaintTimingHandler
impl !UnwindSafe for PaintTimingHandler
impl Freeze for PaintTimingHandler
impl Send for PaintTimingHandler
impl Sync for PaintTimingHandler
impl Unpin for PaintTimingHandler
impl UnsafeUnpin for PaintTimingHandler
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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