Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
upsuper opened this issue May 25, 2019 · 4 comments
Open

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

upsuper opened this issue May 25, 2019 · 4 comments
Labels
css-ruby-1 Current Work

Comments

@upsuper
Copy link
Member

upsuper commented May 25, 2019

@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.

@upsuper upsuper added the css-ruby-1 Current Work label May 25, 2019
@frivoal
Copy link
Collaborator

frivoal commented Feb 10, 2021

Another thing we should define is what happens when the base/annotation contain replace elements (in particular images).

  • Should they be ignored altoghether?
  • Should they be compared by their text content in the DOM
  • Compare replaced elements by their replaced content (with or without fetching external resources)?
  • Compare e.g. img elements by using their alt text?
  • Treat as not equal as soon as there's a replaced element?
  • Something else?

Probably the right answer is to do the simplest thing for implementations.

@upsuper
Copy link
Member Author

upsuper commented Feb 13, 2021

The simplest thing is likely to just ignore them all.

@fantasai
Copy link
Collaborator

@upsuper Current spec wording is

The content comparison for this auto-hiding behavior takes place prior to white space collapsing (white-space) and text transformation (text-transform) and ignores elements (considers only the textContent of the boxes).

What would you propose we replace it with?

@upsuper
Copy link
Member Author

upsuper commented Feb 16, 2021

Probably some thing like

ignores elements (considers ...) and any content inside display: none or out-of-flow elements.

How does that sound?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-ruby-1 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants