paint_api/
largest_contentful_paint_candidate.rs1use base::cross_process_instant::CrossProcessInstant;
8use serde::{Deserialize, Serialize};
9use servo_url::ServoUrl;
10
11#[derive(Clone, Debug, Deserialize, Serialize)]
13pub struct LCPCandidate {
14 pub id: LCPCandidateID,
16 pub area: usize,
18 pub url: Option<ServoUrl>,
20}
21
22impl LCPCandidate {
23 pub fn new(id: LCPCandidateID, area: usize, url: Option<ServoUrl>) -> Self {
24 Self { id, area, url }
25 }
26}
27
28#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
29pub struct LCPCandidateID(pub usize);
30
31#[derive(Clone, Debug)]
32pub struct LargestContentfulPaint {
33 pub id: LCPCandidateID,
34 pub area: usize,
35 pub paint_time: CrossProcessInstant,
36 pub url: Option<ServoUrl>,
37}
38
39impl LargestContentfulPaint {
40 pub fn from(lcp_candidate: LCPCandidate, paint_time: CrossProcessInstant) -> Self {
41 Self {
42 id: lcp_candidate.id,
43 area: lcp_candidate.area,
44 paint_time,
45 url: lcp_candidate.url,
46 }
47 }
48}