compositing_traits/
largest_contentful_paint_candidate.rs1use base::cross_process_instant::CrossProcessInstant;
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
11pub enum LargestContentfulPaintType {
12 BackgroundImage,
13 Image,
14}
15
16#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
18pub struct LCPCandidate {
19 pub id: LCPCandidateID,
21 pub area: usize,
23 pub lcp_type: LargestContentfulPaintType,
25}
26
27impl LCPCandidate {
28 pub fn new(id: LCPCandidateID, lcp_type: LargestContentfulPaintType, area: usize) -> Self {
29 Self { id, lcp_type, area }
30 }
31}
32
33#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
34pub struct LCPCandidateID(pub usize);
35
36#[derive(Clone, Copy, Debug)]
37pub struct LargestContentfulPaint {
38 pub id: LCPCandidateID,
39 pub area: usize,
40 pub lcp_type: LargestContentfulPaintType,
41 pub paint_time: CrossProcessInstant,
42}
43
44impl LargestContentfulPaint {
45 pub fn from(lcp_candidate: LCPCandidate, paint_time: CrossProcessInstant) -> Self {
46 Self {
47 id: lcp_candidate.id,
48 lcp_type: lcp_candidate.lcp_type,
49 area: lcp_candidate.area,
50 paint_time,
51 }
52 }
53}