Skip to content

Conversation

@lukewarlow
Copy link
Contributor

Implement ToggleEvent and use for details element

Testing: Covered by existing WPTs

@lukewarlow lukewarlow requested a review from gterzian as a code owner October 29, 2025 20:37
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 29, 2025
@mrobinson mrobinson changed the title Implement ToggleEvent and use for details element script: Implement ToggleEvent and use for <details> element Oct 29, 2025
Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

Looks good. Just a few nits:

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 29, 2025
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 30, 2025
@lukewarlow
Copy link
Contributor Author

lukewarlow commented Oct 30, 2025

I've pushed those changes up, I squashed because of my WebKit brain, is there a preference to squash or push up seperate commites to address comments for servo?

@mrobinson
Copy link
Member

There's no preference. Squashing is fine. I usually squash, but now and then I leave them as separate commits if the original PR is very large and I think it will possibly make a followup review easier.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 30, 2025
@mrobinson mrobinson added this pull request to the merge queue Oct 30, 2025
@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 Oct 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 30, 2025
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 30, 2025
@mukilan mukilan added this pull request to the merge queue Oct 31, 2025
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Oct 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 31, 2025
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 31, 2025
@jdm
Copy link
Member

jdm commented Oct 31, 2025

   ▶ TIMEOUT [expected OK] /html/semantics/interactive-elements/the-details-element/name-attribute.html
  │   ▶ TIMEOUT [expected FAIL] handling of insertion of elements into group
  │   │   → Test timed out
  └   └ NOTRUN [expected FAIL] basic handling of mutually exclusive details when the element isn't connected

Also need to update

with the new ToggleEvent interface name.

@lukewarlow
Copy link
Contributor Author

It seems odd that this changes the results of that exclusivity test, I'll take a look, it's possible it previously failed because of the incorrect event type and now it's getting further.

@simonwuelker
Copy link
Contributor

I don't think we support mutually exclusive details elements yet.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Some nits, mostly curious why parts of the spec aren't implemented. Not sure about the status of this PR though, given that it was scheduled for merge before. So feel free to ignore these for now and fix them in a follow-up PR.

Comment on lines 127 to 142
self.source.as_ref()?;

if let Some(current_target) = self.event.GetCurrentTarget() {
return self.source.as_ref().and_then(|source| {
let retargeted = source.upcast::<EventTarget>().retarget(&current_target);
retargeted.downcast::<Element>().map(DomRoot::from_ref)
});
}

self.source.as_ref().and_then(|source| {
let document = source.upcast::<Node>().GetOwnerDocument().unwrap();
let retargeted = source
.upcast::<EventTarget>()
.retarget(document.upcast::<EventTarget>());
retargeted.downcast::<Element>().map(DomRoot::from_ref)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

The spec doesn't state that we should use the owner document if currentTarget is null. Should we instead return None when that's the case? E.g. something like

Suggested change
self.source.as_ref()?;
if let Some(current_target) = self.event.GetCurrentTarget() {
return self.source.as_ref().and_then(|source| {
let retargeted = source.upcast::<EventTarget>().retarget(&current_target);
retargeted.downcast::<Element>().map(DomRoot::from_ref)
});
}
self.source.as_ref().and_then(|source| {
let document = source.upcast::<Node>().GetOwnerDocument().unwrap();
let retargeted = source
.upcast::<EventTarget>()
.retarget(document.upcast::<EventTarget>());
retargeted.downcast::<Element>().map(DomRoot::from_ref)
})
let source = self.source.as_ref()?;
let current_target = self.event.GetCurrentTarget()?;
let retargeted = source.upcast::<EventTarget>().retarget(&current_target);
retargeted.downcast::<Element>().map(DomRoot::from_ref)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is based on the WebKit implementation for command event which uses the same spec language and that in turn was based on I think chromium behaviour. I'll double check if this is erroneous or not.

@servo-highfive servo-highfive added the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Nov 2, 2025
@lukewarlow
Copy link
Contributor Author

Ah yeah that test uses oldState and newState so was failing and is now timing out. I'll update the expectations file now.

@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 2, 2025
@TimvdLippe
Copy link
Contributor

You also need to update

per the above comment

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Merging as-is and feedback will be addressed in a follow-up

Comment on lines +137 to +141
let document = source.upcast::<Node>().GetOwnerDocument().unwrap();
let retargeted = source
.upcast::<EventTarget>()
.retarget(document.upcast::<EventTarget>());
retargeted.downcast::<Element>().map(DomRoot::from_ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you file a spec bug that this should be updated in the spec given all major browsers implement it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'll double check what the state of things is and file an appropriate issue.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Nov 2, 2025
@TimvdLippe TimvdLippe added this pull request to the merge queue Nov 2, 2025
@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 Nov 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 2, 2025
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 2, 2025
@TimvdLippe
Copy link
Contributor

Tests with unexpected results:
  ▶ TIMEOUT [expected OK] /html/semantics/interactive-elements/the-details-element/name-attribute.html

Hm I guess this is intermittent flaky :/ Will file an issue

@TimvdLippe TimvdLippe added this pull request to the merge queue Nov 2, 2025
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 2, 2025
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 2, 2025
@lukewarlow
Copy link
Contributor Author

Hopefully the pr to implement that behaviour as a follow up will resolve it quite quickly.

@TimvdLippe TimvdLippe added this pull request to the merge queue Nov 2, 2025
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 2, 2025
Merged via the queue into servo:main with commit 8ca4ecb Nov 2, 2025
44 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 Nov 2, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 4, 2025
…ee (#40314)

Within the same tree, only one `<details>` element with the same name
may be open at a time. Before this change, this invariant was not
enforced.

I've added a `HashMap` to `Document` and `ShadowRoot` which maps from a
name to the a list of details elements with the same name. This map
allows us to find conflicting details elements without having to
traverse the whole tree. Of course this only works when the tree is a
document tree or a shadow tree, so we still have to fall back to
`traverse_preorder` in some cases (which I believe to be uncommon).

This is ready for review, but I'd like to wait until
#40271 is merged to not cause
unnecessary merge conflicts.

Testing: New web platform tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
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.

6 participants