Skip to content

[css-ruby] Style of intra-annotation white spaces #5962

Open

Description

@frivoal

(Initially reported by @upsuper in https://www.w3.org/Mail/flatten/index?subject=https%3A%2F%2Flists.w3.org%2FArchives%2FPublic%2Fwww-style/2014Nov/0408.html )

I notice a problem when I implement the vertical positioning of ruby annotations. The problem is that, the intra-annotation white spaces cannot be properly styled, which makes the height of text container look incorrect. For example, there is a piece of code in the spec:

<ruby>
  <rb>one</rb> <rb>two</rb>
  <rt>1</rt> <rt>2</rt>
</ruby>

After generating anonymous boxes, the frame tree is similar to:

<ruby>
  <pseudo-rbc><rb>one</rb><pseudo-rb> <pseudo-rb><rb>two</rb></pseudo-rbc>
  <pseudo-rtc><rt>1</rt><pseudo-rt> </pseudo-rt><rt>2</rt></psedudo-rtc>
</ruby>

Here, authors cannot specify any style for the pseudo-rt. It won't have a problem in normal case if UA gives the elements a proper default style. But in some cases, author may want to specify different style to annotations, for example, "rt { font-size: 30%; }". Then the boxes for the intra-annotation white space would be taller than its neighbors.

Activity

  1. frivoal commented on Feb 9, 2021

    @frivoal
    CollaboratorAuthor

    I think we could solve this in one of two ways:

    • the anonymous boxes holding inter-annotation spaces are made to inherit from the previous annotation (in document order)
    • the anonymous boxes holding inter-annotation spaces (and possbly all anonymous annotation boxes) inherit from the annotation container, but if that container is itself anonymous it is inheritsfrom its first non-anonymous child annotation (while all its non-anonymous children continue to inherit from their ruby container grandparent).

    The first of these two seems simpler. The second one would give more consistent spacing when some bases have a different size / font, which might be nice, but it's unclear how much that matters.

    Directly messing with their height contribution is probably not the answer here, as that wouldn't take care of how wide the space should be, which is also font / font-size dependent.

  2. frivoal commented on Feb 9, 2021

    @frivoal
    CollaboratorAuthor

    (also, this was discussed in the 2015 Sydney F2F)

  3. TalbotG commented on Jul 28, 2021

    @TalbotG
    Collaborator

    @upsuper , I noticed such issue myself in your own test:

    http://wpt.live/css/css-ruby/ruby-intra-level-whitespace-001.html

    I created a more revealing test out of it:

    http://www.gtalbot.org/BrowserBugsSection/CSS3Ruby/ruby-intra-level-whitespace-001-GT.html

    It won't have a problem in normal case if UA gives the elements a proper default style.

    The default font size of rt element in the user agent style sheet is 50%. Anonymous rt elements will inherit their font size from the ruby container which uses a font size of 100%. So, there will be a height difference all the time.

  4. upsuper commented on Jul 31, 2021

    @upsuper
    Member

    The default font size of rt element in the user agent style sheet is 50%. Anonymous rt elements will inherit their font size from the ruby container which uses a font size of 100%. So, there will be a height difference all the time.

    I forgot the whole context of that sentence when I sent it initially, but I'd like to note that it is possible for UA to style specific anonymous box they generate in a way which normal content is not able to access, i.e. if we want, I think it's possible to say that anonymous ruby annotation has 50% of the font size. But that has two problems:

    1. if it's inside an rtc with 50% font size, it would become 25% of the base font size, and it may not be easy to fix because anonymous box is usually special, so it may not have the full selector support
    2. if user wants a different font size, the anonymous box's style would change with that.

    I think in most common use cases, i.e. Japanese's kana annotation, it is not a problem, because there is generally no whitespace within the annotation between characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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