Commit Graph

5 Commits

Author SHA1 Message Date
Shubham Gupta
71196c02ea Add basic IDL implementation for LargestContentfulPaint (#39714)
Add basic `IDL` implementation for `LargestContentfulPaint`

Testing: Tested locally
Fixes: N/A

<img width="800" height="210" alt="Screenshot from 2025-11-06 12-56-37"
src="https://github.com/user-attachments/assets/af453b8d-7605-4300-8c87-c2574feff81f"
/>

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2025-11-07 02:56:30 +00:00
WaterWhisperer
158bf97e30 script/dom/: Change some #[allow]s to #[expect]s (#40454)
Removes some unneeded lints, especially `#[allow(unsafe_code)]`.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 11:06:03 +00:00
Simon Wülker
c4ae451612 Turn all commented links before functions into doccomments (#40331)
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.

This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.

Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.

Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-01 05:32:45 +00:00
Shubham Gupta
9eb3a973ae Add support for LargestContentfulPaint PaintMetric (#39384)
Steps for calculating LCP:
1. When the pref for `largest_contentful_paint_enabled` is enabled,
`LargestContentfulPaintCandidateCollector` is created once per
LayoutThread using `viewport_size`.
2. While building the `display_list`, it send the pre-calculated
`clip_rect` and `bounds` to `LCPCollector` along with `transform` and
`LCPCandidateType` for `visual_rect` calculation for `LCPCandidates`.
3. After `visual_rect` calculation, update the `lcp_candidate` based on
`area` of `visual_rect` and send it to `compositor`.
4. Then among `lcp_candidates`, we find out the
`largest_contentful_paint` and send it to `paint_metric`
5. In addition to above `LCP` also uses `PaintMetricState` to save
console from spamming with duplicate entries.



This PR includes following commits better segregation of code
1. Add `LargestContentfulPaintCandidate` struct
2. Add `LargestContentfulPaintCandidateCollector`
6. Collect the `LargestContentfulPaintCandidates`when feature is
enabled.
7. Send the `LargestContentfulPaintCandidates` to compositor
8. Add `LargestContentfulPaintCalculator`
9. Calculates the `LargestContentfulPaint`
10. Send `LCP` to `PaintMetrics`
11. Disable `LCP` feature on user interaction


Elements considered for LCP in this PR:
- Image element
- An element with background image

Reference: https://github.com/servo/servo/pull/38041
Testing: Tested using
[perf-analysis-tools](https://github.com/servo/perf-analysis-tools) See
attached screenshot.
Fixes: None

Perfetto
<img width="2566" height="1151" alt="Screenshot from 2025-10-16
11-37-41"
src="https://github.com/user-attachments/assets/96e4f933-b39c-4ac7-833c-46dcc0c1671e"
/>


Console Output of Metric
<img width="1784" height="282" alt="Screenshot from 2025-10-16 11-33-16"
src="https://github.com/user-attachments/assets/441746a5-92ae-47c6-9022-f49114f23a2d"
/>

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
Co-authored-by: boluochoufeng <1355990831@qq.com>
2025-10-31 08:58:22 +00:00
WaterWhisperer
32c0c41d11 script: Move performance DOM interfaces to script/dom/performance/ (#40262)
Moves interfaces defined by the performance spec to the
`script/dom/performance/` module from `script/dom/`.

Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-10-29 11:41:52 +00:00