w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.51k stars 668 forks source link

[css-inline-3] text-box-trim vs fragmentation #5335

Open fantasai opened 4 years ago

fantasai commented 4 years ago

From https://github.com/w3c/csswg-drafts/issues/3240#issuecomment-433628531

Fragmentation is an interesting case. It's quite reasonable to want the text-trim to take effect at fragmentation breaks in multicol. But for pages, we'd end up trimming any ink that leaks over. We'll either need to adjust css-page-3 to not trim [ink] overflow at fragmentation boundaries or add a page-padding property similar to scroll-padding or something. This is actually necessary for ruby to work properly in Japanese, and many other effects that require the top of the text to line up across fragmentainers but allows some lines to contain content that overflows that visual line.

chrishtr commented 11 months ago

I propose that we apply text-box-trim to multi-column fragmentation, but not to paged media for printing. The rationale is:

The spec would say: if the contents of an element with text-box-trim are fragmented by it or a descendant, then the first or last line (as appropriate to the value specified for text-box-trim) of all such fragments are trimmed. Trimming is done after fragmentation. This behavior does not apply to paged media.

Note: in other words, text-box-trim on an element applies to each of the fragments below it individually, but only if text-box-trim is on a multi-column container or its ancestor.

Note: the second sentence is to avoid a circularity. In terms of implementation, this will require a mechanism to lay out "without trimming" and then adjust layout to take into account trimming, but I think that will be needed anyway in order to detect the "last line to trim" in cases where it isn't clear from markup.

fantasai commented 10 months ago

I can see why trimming at the top of a page might be something to avoid in cases where the browser doesn't know how to draw into the page margin/padding area, so it makes sense to allow it. But I doubt it's ideal, because it doesn't allow authors to control things lining up in such cases. We probably want to (eventually) get trimming to work equally on pages and columns.

Also, there's really two questions here:

  1. Do we trim if the first line happens to land at the top of the page/column?
  2. Do we trim the line box in the middle of a paragraph if it lands at the top of the page/column?

Either way, we probably need to enable ink overflow of line boxes to spill out of the page content area.

chrishtr commented 10 months ago
  • Do we trim if the first line happens to land at the top of the page/column?

I suggest yes, for the column case.

  • Do we trim the line box in the middle of a paragraph if it lands at the top of the page/column?

I suggest no.

css-meeting-bot commented 9 months ago

The CSS Working Group just discussed [css-inline-3] text-box-trim vs fragmentation, and agreed to the following:

The full IRC log of that discussion <Frances> github-bot #335
<Frances> fantasai: One consideration is when requesting text-box:trim, if it lands at the top of the page, we have ink spilling out of the page. Currently gets clipped out. If specifying cap height and land at the top of the page, accent marks will get clipped.
<Frances> fantasai: Do we want to specify that ink-overflow can spill onto the padding area and if so do we want to allow implementations to pull content. How to approach the problem of clipping?
<Frances> fantasai: Trim at the bottom of the page or at the next page? We need some way to control it and make it happen, with a consistent top edge.
<bradk> +1 to allowing ink to spill over, similar to box-shadow
<Rossen_> q?
<Frances> fantasai: Need a way to handle text-box-trim for the correct padding and border of content. Two issues: clipping and separate control for fragmentation breaks.
<fantasai> s/Need a way to handle text-box-trim for the correct padding and border of content./If using text-box-trim for correct spacing between content and border, don't necessarily want to trim at fragmentation breaks/
<Frances> chris h: Bbecause it is more difficult to implement with more complexities, text-box-trim does not apply for printing
<Frances> Rossen: Allows for additive behavior in the future. Need to specify it correctly.
<fantasai> s/Trim at the bottom/Other question is, if the paragraphs fragments in the middle, do we trim at the bottom/
<astearns> -1 to not applying to print. Would there be a way to allow it in print except for at page breaks?
<Frances> Florian: Need to define cleanly the boundary. In typography such as using css to make printed material or like printing. About fragmentation, should not say print, possibly relevant.
<Frances> Florian: Needs to work for printing. We need to work on this and not call the compat trap.
<Frances> fantasai: Shouldn't disable trim for printing, need to spec the ideal behavior to the extent that it can be printed. Might allow user agents that can't do that, shift it down the page to use the text glyphs.
<Rossen_> ack fantasai
<Frances> chris h: The two together sound fine.
<Frances> PROPOSAL: ink-overflow spills out of the page content area into padding and margins, user agents that can't draw paint overflow may shift content down to avoid clipping.
<fantasai> s/paint overflow/ink overflow/
<fantasai> +1
<Frances> rossen: objections?
<Frances> RESOLUTION: ink-overflow spills out of the page content area into padding and margins, user agents that can't draw paint overflow may shift content down to avoid clipping
<Frances> fantasai: A question around text-box-trim taking affect. Should be a separate property to control them indepdently.
<Frances> Chris H: Specify in the property, not overflow between columns.
<Rossen_> s/RESOLUTION/RESOLVED/
<dbaron> s/Specify in the property/just operates at the top of the first fragment and the bottom of the last fragment/
<dbaron> fantasai: I'd want it to follow box-decoration-break
<Frances> PROPOSAL: Should text-box-trim apply at fragmentation breaks, depends on the box-decoration-break property
<Frances> Rossen: Objections?
<Frances> RESOLVED: Should text-box-trim apply at fragmentation breaks, depend on the box-decoration-break property
<chrishtr> Thanks all!
<Frances> fantasai: fragmentation case possibly need an independent control. Could be a separate feature.
<Rossen_> Zakim, end meeting
fantasai commented 2 months ago

@jensimmons and I discussed the related (but now a bit different) question of what text-box-trim should do when it's applied to a multi-column container, and as we propose for margin-trim we think it should apply at the top/bottom of each column box. Agenda+ to discuss.

css-meeting-bot commented 2 months ago

The CSS Working Group just discussed [css-inline-3] text-box-trim vs fragmentation.

The full IRC log of that discussion <astearns> q+
<andreubotella> fantasai: I was chatting with Jen Simmons about how text-box-trim interacts with fragmentation. We have a discussion about setting text-box-trim in a box in the flow that gets fragment, but not on the multicol element. There's a lot of column boxes inside it, should it apply to any of them?
<andreubotella> Probably makes sense to apply to the first and last line box in each column
<andreubotella> assuming there's no intervening padding or borders
<chrishtr> +1
<miriam> +1
<andreubotella> frivoal: makes sense to me
<andreubotella> astearns: I know of a use case where we'd want to trim all of the top and bottom (?) of a column except for the very first and last. But we can handle that with the :column element
<andreubotella> frivoal: I'm aware of that for trimming margins, but this issue is about trimming the top and bottom of lines. Is that correct as well?
<andreubotella> astearns: You might be right that it might apply only to margins. There might also be a usefulness for lines. But yes, it should apply only to the top and bottom if it applies to multicolumn
<andreubotella> bfgeek: My concern is that if applied to the end, it might shorten the column box, which might change the fragmentation point
<andreubotella> fantasai: When fragmenting, you'd have to be aware of whether the line box to add to a page is trimmed or not
<astearns> ack astearns
<andreubotella> bfgeek: It's more complex, because of interactions with collapsing margins at the end
<andreubotella> I dont' know if this is implementable for end trimming
<andreubotella> frivoal: In this issue we're talking about trimming leading in lines, does that also affect?
<dholbert> q+
<andreubotella> astearns: We might need some make-forward-progress algorithm where you decide where the fragmentation break is, then apply the trimming, and not reconsider the break
<andreubotella> fantasai: It's similar to when trying to see if something fits, you truncate the margins. If there are borders or padding, you already cannot trim. It's different between line boxes and at the end of the element, so when you evaluate whether you fit, you trim the line box
<andreubotella> if additional content fits, then you move forwards
<andreubotella> frivoal: it's clear it's desirable, but not clear how doable. Can we edit it later if it's too hard?
<andreubotella> fantasai: I think that's reasonable. Because margins are invisible, it doesn't matter whether you consider the box trim or not. It's only when placing the content and checking wherther it fits before the end of the page is when you need to consider trimming
<andreubotella> bfgeek: What is the behavior with empty elements that are after this?
<andreubotella> If there's a subsequent empty element. That's not considered (?) if there's an empty element afterwards
<andreubotella> That's complex because we don't want to arbitrarily look forwards to see if this is the last
<andreubotella> fantasai: If the bottom edge of my box is 1em from the bottom of the page, but it has a bottom-margin of 2em
<andreubotella> we truncate the margin to the extent necessary to make it fit
<astearns> ack dholbert
<andreubotella> dholbert: when fantasai was talking about how it works in practice, discounting the text-box-trim for the purposes of seeing if the element fits, should it also make the element draw a smaller border box if it happens to fit when this is taken into account?
<andreubotella> should the border box extend to the bottom of the column?
<andreubotella> s/border box/background/
<andreubotella> fantasai: do you mean a block background or an inline background?
<andreubotella> dholbert: if the line of text has a background, i'm thinking of a span that has a background
<andreubotella> ...
<andreubotella> fantasai: as an author, you don't want to combine text-box-trim with a block background
<andreubotella> in the long term, we might want to have a control for this, similar to margin-trim for margins, but this would be the default
<fantasai> s/margin-trim/margin-break/
<andreubotella> astearns: should we specify the behavior as florian suggested, and reopen the issue if there are implementability concerns? or do we take it back to the issue for now?
<andreubotella> fantasai: I think this is what people would want if they set text-box-trim on multicolumn. The alternative is it doesn't apply at all
<andreubotella> frivoal: If it applies only to the first column, it's worse because you have unbalanced columns
<andreubotella> astearns: any objections, dholbert and bfgeek?
<andreubotella> bfgeek; there's some complexity because, the way it works we'd need to backtrack. For example, you place a line box, there's 10px of space remaining. You need to lay out the next line box, because it might only be 8px
<andreubotella> But if it's 12px high, you need to backtrack and go to the previous line box, and then trim it, which is a bit scary
<andreubotella> you don't know if it's the last line box until you lay out the next line
<andreubotella> frivoal: Having it only apply to the first column and not the others will be ugly. In general, for the problem, if we only trim at the first column it's bad
<andreubotella> same for printing and pagination, if you have a multi-page document, you want the top and bottom to match
<andreubotella> bfgeek: At the minimum we'd want trim-top. I'll talk to Morten to see how feasible is trimming the bottom if we have to backtrack
<andreubotella> fantasai: Once you've decided that the line box fits, you can forget about whether you trimmed it. It only matters if you drew a background, and if you do, you have the question of where it ends
<andreubotella> You have to make sure the background doesn't go beyond the fragmentainer edge
<andreubotella> bfgeek: It affects more things than that
<andreubotella> astearns: We should table the discussion of how it should work for now. bfgeek, are you okay having the conversation with Morten before resolving?
<andreubotella> bfgeek: yeah
<andreubotella> frivoal: Can we resolve to do it on the start side and leave the end side open?
<andreubotella> astearns: We'll discuss that next time
<dholbert> fwiw the "in what ways is the column-end-trimming observable [and how do we need to tidy up after ourselves after placing that line]"is the bit that I'm wondering about too
css-meeting-bot commented 1 month ago

The CSS Working Group just discussed [css-inline-3] text-box-trim vs fragmentation, and agreed to the following:

The full IRC log of that discussion <dholbert> fantasai: this issue is the same, but now for text-box-trim
<dholbert> fantasai: if you apply text-box-trim to a multicol container, it applies to the first formatted line of each column, and analogous for the last
<astearns> q?
<dholbert> PROPOSED RESOLUTION: if you apply text-box-trim to a multicol container, it applies to the first formatted line of each column, and analogous for the last
<dholbert> RESOLVED: if you apply text-box-trim to a multicol container, it applies to the first formatted line of each column, and analogous for the last