Skip to content

[css-ruby] Autohiding text comparison and display: none elements #3972

@upsuper

Description

@upsuper

@dholbert filed a Gecko bug (about a wpt failure due to our autohiding implementation) which brought my attention to an early discussion about autohiding and out-of-flows.

In that thread, @fantasai mentioned 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, 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: nones 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: nones so I suggest we exclude them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions