[csswg-drafts] [css-contain-2] Proposal: content-visibility: hidden-matchable (#5595)

josepharhar has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-contain-2] Proposal: content-visibility: hidden-matchable ==
I would like to propose a new value for the `content-visibility` CSS property: `hidden-matchable`.

`content-visibility: hidden-matchable` would function the same as `content-visibility: hidden` but also allow the browser to search for text inside the hidden content during find-in-page and ScrollToTextFragment. When used in conjunction with the [proposed beforematch event](https://github.com/whatwg/html/issues/6040), this would enable pages to reveal text in response to find-in-page before the browser scrolls and therefore make hidden sections which are searchable.

An example usage of this feature would be to search the content of hidden, collapsed sections of mobile wikipedia, which are [not currently searchable](https://phabricator.wikimedia.org/T216789).

Non-hidden content is already searchable and so no event or CSS property is needed to expose it to user agent algorithms.

This is related to #3460, but is concerned with making hidden text searchable, rather than making visible text non-searchable.

**Why `content-visibility` and not other “hidden content” mechanisms like `display: none` or `visibility: hidden`?**

Hidden content is usually put in `display:none` subtrees on sites today (for example, this is what mobile wikipedia does), to avoid rendering costs associated with the hidden content. However, `display: none` content cannot actually be searched properly, because searching depends on certain features of styling to determine critical features such as word breaks, and `display: none` elements do not have CSS boxes. `visibility: hidden` has several performance problems, such as being overridable in subtrees and not allowing the browser to avoid rendering work when hidden.

The current values of content-visibility are in the [css-contain-2](https://www.w3.org/TR/css-contain-2/#content-visibility) spec.

Sketch of edits to spec

'hidden-matchable':
This value behaves very similarly to 'hidden'. That is, the element [skips its contents](https://www.w3.org/TR/css-contain-2/#skips-its-contents).
The skipped contents must not be accessible to user-agent features such as tab-order navigation, nor be selectable or focusable.
However, unlike 'hidden', the skipped contents must be accessible to the find-in-page algorithm in order to allow the beforematch event to fire.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5595 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 8 October 2020 01:07:37 UTC