Open fantasai opened 4 years ago
what we want to say is that the box is treated as fixed-size for the purposes of fragmentation (it cannot get larger, only split across pages)
Well, yes we mean that, but also:
As long as that's respected, when we do fragment, we don't have to visually slice the content, and we could break it cleanly between lines or at otherwise allowed fragmentation points. However, both are kind of bad (which is why we should avoid fragmenting in the first place when possible), so I'd be inclined to let that up to the UA though: If the box is more than tall enough to fit all its content, it's best to do fragmentation of the content cleanly. But this might underfill the first(s) fragments, and put too much content in the last one. If that last fragment isn't tall enough to accommodate all that's pushed into it, it might be ok to let it overflow, or it might have been better to slice the content instead of fragmenting it cleanly if that would avoid overflow.
For instance, if the unfragmented box is just tall enough to fit 3 lines, and it gets fragmented in 2 equal parts, you can either put 1 line in the first and 2 in the second letting that last line overflow (and possibly overlap with subsequent content), or you can put 1.5 lines in each. Both seem bad, so I'm not sure I want to force UA's hand.
So, overall, I think calling them monolithic is the right call, but we might want to add an allowance UA discretion about how they slice or fragment the contents when they do need to fragment.
Yeah, Florian covered all the points. We did indeed intend for them to be monolithic, as that's the closest concept we have to the "contents don't matter" constraint that we want.
@fantasai, are you OK with the conclusion above?
Closing, and moved the discussion of whether we want to do anything smart inside of a broken monolithic element to https://github.com/w3c/csswg-drafts/issues/6326
Well, yes we mean that, but also:
- that you should avoid fragmenting them if possible (see below for why)
- and if you do fragment them, the point at which the box is split should not depend on the layout of its content. The size of each fragment should only depend on the size and position of the box, not what's in it.
In that case
break-inside: avoid
.So, overall, I think calling them monolithic is the right call, but we might want to add an allowance UA discretion about how they slice or fragment the contents when they do need to fragment.
Monolithic items by definition do not fragment the content inside them. They can only slice. If you want to fragment, you can't call them monolithic.
break-inside: avoid
isn't break-inside: impossible
. It will do the part about avoiding fragmentation if possible, but it doesn't do the part where if you do have to break, you're not allowed to break it in a way that:
We have to add additional constraints for that. Monolithic achieves that.
I do agree that it is more constraining than strictly necessary: an alternative strategy could be to have each fragment be sized exactly as if you had sliced, but within that space, to allow for ordinary fragmentation. In under-filled elements, that could give better results. However, nobody is doing that today. I'd rather keep it simple for L1, and possibly relax things a little in later levels.
@frivoal As I said twice earlier (and you keep ignoring), if you have a fixed-size box, the total size does not change based on the fragmentation of its content. contain: size
is never auto-sized, so regardless of being monolithic or not the total size won't change. But if you classify it as monolithic, it's not allowed to fragment its contents.
As I said twice earlier (and you keep ignoring)
I have not been ignoring that. There's another requirement I have pointed to, which you seem to have missed:
The size of each fragment should only depend on the size and position of the box, not what's in it
&
you're not allowed to break it in a way that […] makes the size of each fragment depend on the content
Merely having a fixed-size box does not guarantee that. See http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=10671
If you hover over the boxes, you'll see that the size of the fragments does vary based on the content (even though the total size does indeed not vary).
The CSS Working Group just discussed [css-contain-1] contain:size shouldn't fragment as monolithic
, and agreed to the following:
RESOLVED: Not make any changes to css-contain-1, possibly relax the monolithic requirement in later levels
So, while this issue is handled (by deferring it) for L1, in L2 and later, we could relax the requirement a little.
Currently, we have:
I believe we could replace that with:
and define quasi-monolithic boxes as something like:
Quasi-monolithic boxes are similar to monolithic boxes:
- forced breaks within a quasi-monolithic box must be ignored by the box’s own fragmentation context
- quasi-monolithic boxes should not be fragmented
- if a quasi-monolithic box needs to be fragmented, the box is sliced at a point which does not depend on the box's content, only on its size and its position within its fragmentation context.
However, unlike monolithic boxes, when a quasi-monolithic box is thus broken up, its content may be fragmented and laid out normally within each of the fragments instead of being graphically sliced—although graphically slicing is also allowed.
We could obviously do the same thing without introducing the new term and inlining the effects into size containment, but I suspect it's easier to read if framed this way.
it should be drawing the box all the way to the bottom of the page, and not leaving a gap when it fragments
For the given example this would only be true if multi-col had column-fill:auto instead of column-fill:balance as is the fragment is consuming up until the fragmentation line.
@bfgeek To me, the point is: without additional constraints, it may be true that the fragment consumes all the space, but it may not be. And not only is the actual space consumed dependent on the properties of the fragmentation context (which is fine), it also depends (at least in some cases) on the content of the fragmented box, which is not fine in the case of size containment.
Making size contained elements monolithic is sufficient to solve the issue, but is more than strictly necessary.
I think that creating a notion of quasi-monolithic (roughly) defined as above, and calling for size-contained elements to be that would dial down the requirements to what is strictly necessary, while keeping them sufficient.
Agenda+ to propose https://github.com/w3c/csswg-drafts/issues/5648#issuecomment-1240067326
The CSS Working Group just discussed [css-contain-2] contain:size shouldn't fragment as monolithic
.
With 'app' style layouts with independently scrolling sections, it's entirely possible that 2-axis size containment will become more popular as well as 1-axis. Those layouts aren't generally relying on fragmentation, but that could become an issue when printing. I do tend to lean towards improving fragmentation wherever we can. From my perspective, the fact that fragmentation is poorly supported and not interoperable today is a problem we should be fixing, not a solid argument against making additional improvements.
As long as size containment is used, there will be cases where people end up having both size containment and fragmentation happen together, at the very least because people occasionally print stuff. I think the behavior proposed here is strictly superior to what the spec currently says: it would allow what the spec currently says anyway, but would also allow browsers to not slice lines in cases where that's practical.
For instance, if the unfragmented box is just tall enough to fit 3 lines, and it gets fragmented in 2 equal parts, you can either put 1 line in the first and 2 in the second letting that last line overflow, and possibly overlap with subsequent content, or you can put 1.5 lines in each, slicing the second one. For that case, both approaches are bad. Depending on context, overflowing might be better than slicing, but it's not guaranteed.
However, if the unfragmented box is 3.5 lines tall or more, and the fragmentation point is 1.5 lines in, then clearly having one line in the first fragment and 2 in the second one is better: nothing is sliced, nothing overflows. Allowing that is a strict improvement.
Based on that, I'm in favor of adopting the change. It doesn't force anyone to do anything, since it's merely an allowance.
The CSS Working Group just discussed [css-contain-2] contain:size shouldn't fragment as monolithic
.
iank_: in some cases Chromium is the only implementation that treats break-inside as non-monolithic. advised people to use contain: size for some cases. [...] correcting earlier notes, iank had actually said "Chromium is the only implementation to treat `break-inside:avoid` as monolithic"
Sorry, my last-minute correction^ (attempting to answer an emote-question from @fantasai) was misguided. After the meeting ended, @bfgeek (iank) mentioned that he did actually mean non-monolithic
@bfgeek: question for you -- do you have a testcase to demonstrate what you're talking about there? (sorry for the diversion; it seems sorta-relevant since break-inside:avoid
is kind-of like the behavior that @frivoal is suggesting here.)
I tested Firefox vs. Chrome on these testcases:
block:
data:text/html,Hello<div style="break-inside:avoid; border: 10px solid black;font:6in monospace">A<br>B<br>C
flex:
data:text/html,Hello<div style="display:flex;flex-direction:column;break-inside:avoid; border: 10px solid black;font:6in monospace"><div>A</div><div>B</div><div>C</div>
...and both Firefox and Chrome push the div to the second page, but don't slice the lines of text in half. So we're both treating it as sort-of-but-not-quite-monotonic, in the same way. :) Could you clarify what situation you're talking about where Chrome is the only engine to do the right non-monotonic thing with break-inside:avoid
?
Currently the spec says:
I think what we want to say is that the box is treated as fixed-size for the purposes of fragmentation (it cannot get larger, only split across pages), but the content inside it can fragment normally.