[csswg-drafts] [css-ruby] "consecutive" in the Anonymous Ruby Box Generation, and out of flow (#4959)

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

== [css-ruby] "consecutive" in the Anonymous Ruby Box Generation, and out of flow ==
Several steps of the [ruby box fixup](https://drafts.csswg.org/css-ruby-1/#box-fixup) use the notion of "consecutive" boxes. Consecutive is defined by [CSS2 in the anonymous table object section](https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes):
> Two sibling boxes are consecutive if they have no intervening siblings other than, optionally, an anonymous inline containing only white spaces. A sequence of sibling boxes is consecutive if each box in the sequence is consecutive to the one before it in the sequence.

([css-tables agrees with that definition](https://drafts.csswg.org/css-tables/#consecutive-boxes))

Importantly, this does not say that two boxes are consecutive when the only thing that separates them is an out-of-flow box. Leaving aside whether that's a good idea for tables (tables are weird anyway), it has odd consequences for ruby (in decreasing order of weirdness, in my opinion):

> 8. Generate anonymous level containers: Any consecutive sequence of ruby bases [...] not parented by a ruby base container is wrapped in an anonymous ruby base container. Similarly, any consecutive sequence of ruby annotations [...] not parented by a ruby annotation container is wrapped in an anonymous ruby annotation container. 

Thus, in the following example, the two `<rt>`are not consecutive, and end up in two different anonymous ruby annotation container, and thus two different levels:

```html
<style>i { position: absolute; }</style>
<ruby><rb>b</rb><rt>a1</rt><i></i><rt>a2</rt></ruby>
```

> 3. Wrap misparented inline-level content: Any consecutive sequence of text and inline-level boxes directly parented by a ruby container or ruby base container is wrapped in an anonymous ruby base. […]

Thus, in the following example, the two spaces are not consecutive, and end up in two different anonymous ruby bases (only one of which will be removed by step 4's trimming of leading white space):

```html
<style>i { position: absolute; }</style>
<ruby> <i></i> <rb>b</rb><rt>a1</rt></ruby>
```

> 2. Generate anonymous ruby containers: Any consecutive sequence of improperly-contained ruby base containers, ruby annotation containers, ruby bases, and/or ruby annotations (and any intervening white space) is wrapped in an anonymous ruby container.

Thus, in the following example, we would end up with two ruby containers: one containing the first base only, and one containing the other base and the two annotations.

```html
<style>i { position: absolute; }</style>
<rb>b1</rb><i></i><rb>b2</rb>
<rt>a1</rt><rt>a2</rt>
```

This is all technically possible, and anchoring out of flow elements in the middle of a ruby structure is an odd case anyway, so maybe it doesn't matter, but it doesn't seem to me to be inherently wrong to attach abspos elements pretty much anywhere (maybe they're being used for tooltips?) in the document, and I would not expect them to disturb the layout of the elements they're being anchored in.

Assuming that we cannot change what consecutive means for tables, how about coining a different term which would allow intervening out of flow element? Maybe contiguous?

> Two sibling boxes are contiguous if they have no intervening siblings other than, optionally, any combination of anonymous inline boxes containing only white-space, and out-of-flow boxes. A sequence of sibling boxes is contiguous if each box in the sequence is contiguous to the one before it in the sequence.


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

Received on Thursday, 16 April 2020 07:20:25 UTC