[csswg-drafts] [css-ruby] Autohiding text comparison and `display: none` elements (#3972)

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

== [css-ruby] Autohiding text comparison and `display: none` elements ==
@dholbert filed [a Gecko bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1554327) (about a wpt failure due to our autohiding implementation) which brought my attention to [an early discussion](https://lists.w3.org/Archives/Public/www-style/2014Dec/0074.html) about autohiding and out-of-flows.

In that thread, @fantasai [mentioned](https://lists.w3.org/Archives/Public/www-style/2015Feb/0158.html) that the comparison currently should also include `display: none` elements, but it's open to change based on implementation feedback.

After looking into Gecko's implementation as well as the spec, I think `display: none` element should be excluded from the text comparison of autohiding.

The reason is that [ruby boxes can be generated from other boxes](https://drafts.csswg.org/css-ruby-1/#box-fixup), and the generated boxes can involve in autohiding. At the ruby box generation time, `display: none` elements are already dropped. In this sense, I don't think the generated boxes include `display: none` elements conceptually.

Currently, Gecko get the text to compare via traversing the rendering tree (frame tree in Gecko's term) and collecting text from text nodes mapped from there. It has several implications:
* it ignores `display: none` nodes since they are not in the rendering tree,
* it includes contents from psuedo-elements,
* it ignores out-of-flows (this can be trivially fixed, though).

Although it is theoretically possible to find the complete corresponding content of a generated box, it could be more work to do especially considering `display: none` elements on the boundary of the boxes (There would be a spec question for this: are they included? If so we need to try find them somehow since they have been excluded from box generation. If not, why? With `display: none`s in the middle being included, that would feel inconsistent.)

So, I think it would be easier both conceptually and implementation-wise to exclude `display: none` elements.

That brings another question, what should we do with out-of-flows? Gecko currently ignores them in text comparison but hides them with autohiding (which feels rather unfortunate to be honest), but it can be trivially fixed. However, if we use the text based on rendering tree, then are out-of-flows still considered boxes from the ruby boxes?

If there is nothing conceptually wrong to continue including out-of-flows, I'm happy to have Gecko fixed for this case. But it is less trivial to handle `display: none`s so I suggest we exclude them.

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

Received on Saturday, 25 May 2019 00:52:34 UTC