Skip to content

script: Generate custom fields also, for interfaces inheriting from PerformanceEntry, from impl_performance_entry_struct!#44289

Merged
jdm merged 2 commits into
servo:mainfrom
shubhamg13:impl_performance_entry_struct
Apr 17, 2026
Merged

script: Generate custom fields also, for interfaces inheriting from PerformanceEntry, from impl_performance_entry_struct!#44289
jdm merged 2 commits into
servo:mainfrom
shubhamg13:impl_performance_entry_struct

Conversation

@shubhamg13
Copy link
Copy Markdown
Member

Add definition for generation of custom fields for interfaces inheriting from PerformanceEntry.

Testing: More WPT Tests Passed

@shubhamg13 shubhamg13 requested a review from gterzian as a code owner April 17, 2026 03:08
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 17, 2026
@shubhamg13 shubhamg13 changed the title Generate Implementation for custom fields also from impl_performance_entry_struct! Generate custom fields also for interfaces inheriting from PerformanceEntry from impl_performance_entry_struct! Apr 17, 2026

[Exposed=(Window,Worker)]
interface PerformanceMeasure : PerformanceEntry {
readonly attribute any detail;
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.

Right now, we are passing default value.

Will keep separate PR for serialization logic of same. And we have separate WPT tests to verify that too.

@shubhamg13 shubhamg13 changed the title Generate custom fields also for interfaces inheriting from PerformanceEntry from impl_performance_entry_struct! script: Generate custom fields also for interfaces inheriting from PerformanceEntry from impl_performance_entry_struct! Apr 17, 2026
Copy link
Copy Markdown
Contributor

@xiaochengh xiaochengh left a comment

Choose a reason for hiding this comment

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

Looks OK but I got a question.

Comment thread components/script/dom/macros.rs Outdated
/// DOM struct implementation for simple interfaces inheriting from PerformanceEntry.
macro_rules! impl_performance_entry_struct(
($binding:ident, $struct:ident, $type:path) => (
($binding:ident, $struct:ident, $type:path, { $($field_name:ident : $field_type:ty),* $(,)? }) => (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the consideration for leaving a general custom field here instead of just detail?

Are there more custom fields expected here?

Copy link
Copy Markdown
Member Author

@shubhamg13 shubhamg13 Apr 17, 2026

Choose a reason for hiding this comment

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

Yes, There are quite a list of interfaces inheriting from PerformanceEntry. Like LargestContentfulPaint, PerformanceLongAnimationFrameTiming e.t.c. This can be very useful.

Very few Implemented in Servo yet. Probably port existing ones to use this macro sooner.

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.

I would prefer to go the other way and remove this macro. It already is confusing because the implementations look different than every other DOM interface, and I think extending the macro to support additional fields does not improve the situation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion on this but starting with something straightforward usually doesn't hurt.

@shubhamg13 shubhamg13 changed the title script: Generate custom fields also for interfaces inheriting from PerformanceEntry from impl_performance_entry_struct! script: Generate custom fields also, for interfaces inheriting from PerformanceEntry, from impl_performance_entry_struct! Apr 17, 2026
@shubhamg13 shubhamg13 changed the title script: Generate custom fields also, for interfaces inheriting from PerformanceEntry, from impl_performance_entry_struct! script: Generate custom fields also, for interfaces inheriting from PerformanceEntry, from impl_performance_entry_struct! Apr 17, 2026
EntryType::Measure
EntryType::Measure,
{
detail: RootedTraceableBox<Heap<JSVal>>,
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.

We should only use Heap<JSVal> here; the RootedTraceableBox in a member like this can lead to unbreakable GC cycles.

Copy link
Copy Markdown
Member Author

@shubhamg13 shubhamg13 Apr 17, 2026

Choose a reason for hiding this comment

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

Updated the attribute.

@shubhamg13 shubhamg13 marked this pull request as draft April 17, 2026 09:28
@shubhamg13 shubhamg13 force-pushed the impl_performance_entry_struct branch from b1b10ff to b0d6942 Compare April 17, 2026 09:38
@shubhamg13 shubhamg13 marked this pull request as ready for review April 17, 2026 09:38
@shubhamg13 shubhamg13 requested review from jdm and xiaochengh April 17, 2026 09:40
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 17, 2026
@jdm jdm added this pull request to the merge queue Apr 17, 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 Apr 17, 2026
Merged via the queue into servo:main with commit 53d7a0e Apr 17, 2026
30 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 Apr 17, 2026
@shubhamg13 shubhamg13 deleted the impl_performance_entry_struct branch April 17, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants