Open fantasai opened 8 months ago
The simplest solution would be to disallow breaking within ruby bases (as a layout constraint), but this means the author has no way to allow it if that's needed.
The alternative solution, which would allow the author to override as necessary (easily if they use rb
, less so if they don't), would be to
text-wrap-mode: nowrap
to anonymous basesruby > :not(rb, rbc, rtc, ruby) { text-wrap-mode: nowrap; }
to the stylesheet since children like SPAN can't inherit from anonymous boxesCould we add a pseudo-element that matches any ruby base, be they explicit or implicit? Then the UA sheet could simply say ::ruby-base { display: ruby-base; white-space: nowrap; }
and this could be overrideable by authors.
That wouldn't solve the <ruby><span>don't break me</span><rt>annotation</rtr></ruby>
case without something additional because white-space: nowrap
wouldn't inherit from the pseudo element to the span and it would still break.
Also I don't see the need. If an author wants more control they could use explicit <rb>
.
That wouldn't solve the
<ruby><span>don't break me</span><rt>annotation</rtr></ruby>
case without something additional becausewhite-space: nowrap
wouldn't inherit from the pseudo element to the span and it would still break.
Ugh, yeah, good point.
Also I don't see the need. If an author wants more control they could use explicit
<rb>
.
I suppose we ought to add <rb>
to HTML, then. :)
Elements inherit from ::first-line
so if we were to define ::ruby-base
we would want to define it that way. (Otherwise a lot of things won't work properly, e.g. color
or font
.) But it maybe depends how much appetite implementers have for implementing such a pseudo-element.
The CSS Working Group just discussed [css-ruby-1] Breaks within implicit bases is not Web-compatible
, and agreed to the following:
RESOLVED: Style anonymous bases with text-wrap-mode: nowrap as described in https://github.com/w3c/csswg-drafts/issues/10073#issuecomment-1995455391
RESOLVED: unresolve previous resolution
If ruby > :not(rb, rbc, rtc, ruby) { text-wrap-mode: nowrap; }
is problematic from a performance point of view, could we go with:
ruby > * { text-wrap-mode: nowrap; }
ruby, rbc, rtc { text-wrap-mode: inherit; }
or is that no better?
I'm not sure that's much better. The problem IIRC is the child selector lookup on a universal subject (?).
(Also it would have to be ruby, rbc, rtc { text-wrap-mode: inherit; }
or unset
, not wrap
.)
ruby > :not(rb, rbc, rtc, ruby)
is ok from perf perspective because it is easily eliminated by the ancestor filter in non-ruby subtrees. I think this is true for all engines.
The suggested UA default stylesheet for ruby includes
but this is not sufficient because it doesn't disable wrapping within implicit ruby bases (which is required for Web-compat).