Skip to content

layout: Consider Text as LCP candidate - #47212

Merged
jdm merged 7 commits into
servo:mainfrom
shubhamg13:lcp_text
Aug 18, 2026
Merged

jdm merged 7 commits into
servo:mainfrom
shubhamg13:lcp_text

Conversation

@shubhamg13

@shubhamg13 shubhamg13 commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Since the spec says, for text nodes we need to do union of border box per element.

  • Adding containing_element_tag for making this union.
  • Adding TextRecord to store TextNodes related to an Element.

Note: Please view using Hide whitespace option.

Testing: More WPT Passed

Fixes: Part of #42000

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#61911) with upstreamable changes.

@shubhamg13
shubhamg13 marked this pull request as draft August 13, 2026 08:36
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

pull Bot pushed a commit to Patreos998/servo that referenced this pull request Aug 16, 2026
Adding a struct `PendingImageRecord`. 
Add complimentary `W3C` spec steps.
Pre-requisite for servo#47212

Testing: WPT Unchanged.
Fixes: Part of servo#42000

---------

Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
@shubhamg13 shubhamg13 changed the title Consider Text as LCP candidate layout: Consider Text as LCP candidate Aug 17, 2026
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61911) title and body.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61911) title and body.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

// Width of at least 100 px.
// TODO: find a good way to bound text width.
assert_greater_than_equal(entry.size, 1200);
assert_equals(entry.loadTime, 0);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still Fails because of loadTime. It will be fixed in follow-up

@shubhamg13
shubhamg13 marked this pull request as ready for review August 17, 2026 10:00
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61911) title and body.

@@ -0,0 +1,3 @@
[transparent-text.html]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as earlier text was not considered so it passed.

Now, text is considered but transparent is not checked.

This will be fixed soon.

@@ -1,4 +1,4 @@
[larger-text.html]
expected: TIMEOUT
expected: ERROR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you wrap the forEach callback at

entryList.getEntries().forEach(entry => {
in a t.step_func to make this test behave better when it fails?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite Insightful suggestion :)

@@ -1,4 +1,4 @@
[text-fragment-union.html]
expected: TIMEOUT
expected: ERROR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for a t.step_func:

new PerformanceObserver((entryList, observer) => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yups 💯


// PaintTimingMixin
assert_greater_than_equal(entry.paintTime, beforeRender, 'paintTime should represent the time when the UA started painting');
if ("paintTime" in entry && entry.paintTime !== null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't great, because it silently ignores a feature if it's not supported. We should either accept that the test will fail until we implement this feature, or we should split it out into a separate test that we will fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is same for presentationTime below.

paintTime and presentationTime are in same interface and treated together under PaintTimingMixin IIRC.

That's why I did this. WDYS?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Ok, no objection if there's prior art in the same test file, I guess!

@jdm jdm Aug 17, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me, but I'd like someone more experienced with layout to verify the logic for the new containing_element_tag.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61911) title and body.

Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

1 similar comment
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#61911).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61911) title and body.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Aug 18, 2026
@shubhamg13

Copy link
Copy Markdown
Member Author

Yayyyyy! Thanks

@jdm
jdm added this pull request to the merge queue Aug 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 18, 2026
Merged via the queue into servo:main with commit 6de1edc Aug 18, 2026
34 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 18, 2026
@shubhamg13
shubhamg13 deleted the lcp_text branch August 19, 2026 01:10
@shubhamg13

Copy link
Copy Markdown
Member Author

@servo-highfive monthly update

@servo-highfive

Copy link
Copy Markdown

Someone thinks this change could be added to the monthly blog post! To help with this, we need someone to answer the following questions: 😄

  1. Who is most impacted by this change: users, Servo developers, embedders, or some other group?
  2. What observable difference does this change make?
  3. What preferences (if any) need to be enabled to observe this difference?
  4. What (if any) specific URLs are affected?

If this change is part of a broader feature/project please make sure the PR description contains a Fixes: #12345 or Part of: #12345 issue reference.

Please add @servo-highfive monthly update answer when answering these questions so the bot notices your answer (or just quote this comment).

Thanks for helping us prepare the monthly blog post! ❤️

@shubhamg13

Copy link
Copy Markdown
Member Author

@servo-highfive monthly update answer

  1. Web Developers and performance tooling that consume LCP
  2. Text prominent Pages, pages whose LCP is text.
  3. largest_content_paint_enabled
  4. No particular domains — any page where the largest contentful item is text can be affected.

RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
Adding a struct `PendingImageRecord`. 
Add complimentary `W3C` spec steps.
Pre-requisite for servo#47212

Testing: WPT Unchanged.
Fixes: Part of servo#42000

---------

Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
Since the spec says, for text nodes we need to do union of border box
per element.

-  Adding `containing_element_tag` for making this union.
 - Adding `TextRecord` to store `TextNodes` related to an `Element`.
 

> Note: Please view using `Hide whitespace` option.

Testing: More WPT Passed
- Added a specific test to verify union logic of rect - size calculation
is correct in WPT
- `tests/wpt/tests/largest-contentful-paint/text-fragment-union.html`-
web-platform-tests/wpt#61873
- (_TODO: set loadTime to zero for text, other failing tests will also
pass #47315_)



Fixes: Part of servo#42000

---------

Signed-off-by: Shubham Gupta <shubhamg13.work@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants