Closed Bug 1761043 Opened 3 years ago Closed 3 months ago

Implement hidden=until-found attribute and beforematch event

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox139 --- fixed

People

(Reporter: jarhar, Assigned: jjaschke)

References

(Depends on 2 open bugs, Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, parity-chrome)

User Story

platform-scheduled: 2025-09-30

Attachments

(7 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.46 Safari/537.36

Steps to reproduce:

This feature was added to the HTML spec here: https://github.com/whatwg/html/pull/7475
Here is an explainer: https://github.com/WICG/display-locking/blob/main/explainers/hidden-content-explainer.md

The "until-found" value for the hidden attribute should make the element content-visibility:hidden instead of display:none. When the browser searches for text via find-in-page or ScrollToTextFragment, it should also search for text in hidden=until-found elements. If find-in-page or ScrollToTextFragment want to scroll to a match inside a hidden=until-found element, it should remove the hidden attribute from the element and fire the "beforematch" event on it in order to reveal the match.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
See Also: → 1767180

Wikipedia uses this attribute now which means find in page works much better in Chrome on Android than in Firefox

I've found one more use case where hidden=until-found is very helpful which I described here: https://schepp.dev/posts/rethinking-find-in-page-accessibility-making-hidden-text-work-for-everyone/

I'm aware that this feature is part of Interop 2025 via <details> element, but maybe we can get this quicker than end of this year?

Depends on: 1760492
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → jjaschke
User Story: (updated)

To allow hidden=until-found, the webidl attribute must allow additional data types 0.
Therefore, this patch sets its type to Any,
and implements setter and getter logic that allows
setting the value directly (div.hidden="until-found"
and indirectly (div.setAttribute("hidden", "until-found").

This fixes Text Fragments tests as well since
that feature relies on nsFind.

hidden-until-found-002.html needs to use \ue004
instead of \t to work in Gecko.

hidden-ua-stylesheet.html gets additional asserts that
ensure that setting hidden=until-found is set properly
when using setAttribute() with case-insensitive values.

Depends on: 1954305

I filed bug 1955379 to enable the pref (the one added in part 1 here) when we're ready, so that we've got that tracked as still needed in order to pass the associated tests on wpt.fyi.

Pushed by jjaschke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b8e79fffd79a part 1 - hidden=until-found: Add pref `dom.hidden_until_found.enabled`. r=emilio https://hg.mozilla.org/integration/autoland/rev/815d42c71c38 part 2 - hidden=until-found: Implemented webidl changes. r=emilio https://hg.mozilla.org/integration/autoland/rev/e842c0154a9a part 3 - hidden=until-found: Setting `hidden=until-found` elements as `content-visibility: hidden` instead of `display: none`. r=emilio https://hg.mozilla.org/integration/autoland/rev/c365b9156d01 part 4 - hidden=until-found: Implement reveal algorithm and the beforematch event. r=emilio https://hg.mozilla.org/integration/autoland/rev/adc25f3f0b31 part 5 - hidden=until-found: Implement fragment navigation. r=emilio https://hg.mozilla.org/integration/autoland/rev/8319cbeffeb5 part 6 - hidden=until-found: Implemented`hidden=until-found` in `nsFind`. r=emilio https://hg.mozilla.org/integration/autoland/rev/6c11ac0d8fda part 7 - hidden=until-found: Updated some WPTs. r=emilio,smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/51790 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
See Also: → 1958287

Release Note Request (optional, but appreciated)
[Why is this notable]: hidden=until-found allows content to be found via find-in-page when it's hidden by default. This feature is for example used by the mobile version of Wikipedia.
[Affects Firefox for Android]: Yes
[Suggested wording]:
[Links (documentation, blog post, etc)]: https://github.com/WICG/display-locking/blob/main/explainers/hidden-content-explainer.md

Blocks: 1958287

Added to the nightly relnotes.

Removing from the Nightly release notes for Fx140+
This was enabled by default for Fx139 under Bug 1955379

QA Whiteboard: [qa-triage-done-c140/b139]

MDN changes for this (and the pref 'dom.hidden_until_found.enabled' bug https://bugzilla.mozilla.org/show_bug.cgi?id=1955379) can be tracked in the following GitHub issue: https://github.com/mdn/content/issues/39306

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: