paint_api/
largest_contentful_paint_candidate.rs1use malloc_size_of_derive::MallocSizeOf;
8use serde::{Deserialize, Serialize};
9use servo_base::cross_process_instant::CrossProcessInstant;
10use servo_url::ServoUrl;
11
12#[derive(Clone, Debug, Deserialize, Serialize)]
14pub struct LCPCandidate {
15 pub id: LCPCandidateID,
17 pub area: usize,
19 pub url: Option<ServoUrl>,
21}
22
23impl LCPCandidate {
24 pub fn new(id: LCPCandidateID, area: usize, url: Option<ServoUrl>) -> Self {
25 Self { id, area, url }
26 }
27}
28
29#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
31pub struct LCPCandidateID(pub u64);
32
33#[derive(Clone, Debug)]
34pub struct LargestContentfulPaint {
35 pub id: LCPCandidateID,
36 pub area: usize,
37 pub paint_time: CrossProcessInstant,
38 pub url: Option<ServoUrl>,
39}
40
41impl LargestContentfulPaint {
42 pub fn from(candidate: LCPCandidate, paint_time: CrossProcessInstant) -> Self {
43 Self {
44 id: candidate.id,
45 area: candidate.area,
46 paint_time,
47 url: candidate.url,
48 }
49 }
50}