Skip to content

[css-text] Interaction of text-wrap-style: balance and fragmentation #9431

@jfkthame

Description

@jfkthame

The spec for text-wrap-style: balance does not say anything about how it interacts with fragmentation, but I think it probably should.

What happens when a block with, say, four lines of text and text -wrap-style: balance applied is broken across pages? The point of balance is to improve the visual appearance of the block as a whole by harmonizing its line lengths (as far as possible), but if the block is broken into two (or more!) fragments, they are probably not visually adjacent and I'm not sure "balancing" the entire block makes much sense.

The implementation of balance recently landed in Gecko explicitly disables balancing for fragmented blocks. This is at least easy to understand, and probably won't interfere with most real-world uses of balance, but might sometimes be a frustrating limitation.

Experimentation indicates that Blink's current behavior is (IMO) a bit weird: when the block is fragmented, the first fragment gets the line-breaks that would result from applying balance to the entire (unfragmented) block (so e.g. what appears on the first page is affected by how full the lines on the second page would have been); but the subsequent fragment(s) get the default greedy line-breaking applied to whatever text was left.

What behavior do we actually want here? I can think of a few possibilities that could make sense to authors:

(1) balance does not apply to fragmented blocks
(2) balance applies before fragmentation, and fragmentation does not affect its outcome
(3) balance applies after fragmentation, so the lines within each fragment are balanced independently

My gut feeling is that (3) would be the most desirable behavior, but it may be trickier to implement and I'm not sure the use case (balancing lines in blocks that are being fragmented) is strong enough to warrant a more complex implementation. (1) is what Gecko's initial implementation does. Blink seems to start out trying to do (2), but then re-wraps the content after the fragmentation break, which doesn't make sense to me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions