Re: [csswg-drafts] [css-sizing-4] Scrollbars when intrinsic-width is > width? (#4415)

The CSS Working Group just discussed `Scrollbars when intrinsic-width is > width?`, and agreed to the following:

* `RESOLVED: contain-intrinsic-size defines scrollable overflow area for purpose of intrinsic sizing (including adding scrollbars if so required); is ignored for the actual scrollable overflow area during layout`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: Scrollbars when intrinsic-width is > width?<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/4415#issuecomment-614345165<br>
&lt;tantek> wow this seems like a historically painful one<br>
&lt;fantasai> TabAtkins: Following along from the linked "top of thread"<br>
&lt;fantasai> TabAtkins: now that contain-intrinsic-size defined to give result of doing child layout<br>
&lt;fantasai> TabAtkins: basically, pretend that bounding box of your laid-out contents is this size<br>
&lt;fantasai> TabAtkins: Should that trigger scrollbars or not?<br>
&lt;fantasai> TabAtkins: we think it should<br>
&lt;fantasai> TabAtkins: because if the contents were that large, they would indeed create scrollbars<br>
&lt;fantasai> TabAtkins: And we're saying, here's a shortcut to running your layout<br>
&lt;fantasai> TabAtkins: biesi brought up question of what does this mean for intrinsic size?<br>
&lt;fantasai> TabAtkins: is the intrinsic size that plus crollbars or what?<br>
&lt;fantasai> TabAtkins: Have a specified width, contain-intrinsic-size is wider than that, adds a scrollbar to the bottom<br>
&lt;fantasai> s/width/width and auto height/<br>
&lt;fantasai> TabAtkins: Result of applying that is that width is specified width, auto height is resolved according to 'contain-intrinsic-size' plus mbp<br>
&lt;fantasai> TabAtkins: if you add 'overflow: auto'<br>
&lt;fantasai> TabAtkins: contents wider than box would add a horizontal scrollbar to the bottom<br>
&lt;fantasai> TabAtkins: would height of scrollbar be added to the auto height?<br>
&lt;fantasai> s/height/height (based on contain-intrinsic-size)/<br>
&lt;fantasai> cbiesinger: There was a proposal in the issue that the used size should be max of actual content size and contain-intrinsic size, and that is where it gets complicated<br>
&lt;fantasai> cbiesinger: because then you need to know the actual content size to know whether there's a scrollbar<br>
&lt;fantasai> iank_: For purposes of layout overflow calcualtion, the content size rectangle is unioned with previous calc?<br>
&lt;fantasai> TabAtkins: stepping away from contain-itnrinsic-size for the moment<br>
&lt;fantasai> TabAtkins: if you have contain + overflow: auto<br>
&lt;fantasai> TabAtkins: assume zero size content<br>
&lt;fantasai> TabAtkins: if you add content, can you not scroll to it?<br>
&lt;fantasai> iank_: depends on impl<br>
&lt;fantasai> iank_: we will currently add scrollbars, rerun layout<br>
&lt;fantasai> iank_: This will affect intrinsic size of the box<br>
&lt;fantasai> iank_: unsure what ff does<br>
&lt;fantasai> dholbert: we do not do that relayout<br>
&lt;fantasai> dholbert: we treat it as zero height / width as if explicitly specified<br>
&lt;fantasai> dholbert: in the case of zero width/height, you wouldn't see it<br>
&lt;fantasai> cbiesinger: Don't remember how we handle this, we maybe increase the size of the element<br>
&lt;fantasai> TabAtkins: dholbert, if you have 'contain: size' element with specified height of '100px' and ?<br>
&lt;fantasai> TabAtkins: would you say that ff wont' show scrollbars?<br>
&lt;fantasai> dholbert: if we have space to show scrollbars we will<br>
&lt;fantasai> dholbert: just won't influence sizing of the box<br>
&lt;fantasai> TabAtkins: That's reasonable to me, and if that's what we want to be more specific about, I'm fine with doing that<br>
&lt;fantasai> cbiesinger: I think that's more reasonable behavior<br>
&lt;fantasai> AmeliaBR: Balance of that is, if there is room for scrollbars we will put them<br>
&lt;fantasai> AmeliaBR: if the intrinsic size is bigger than contain size<br>
&lt;fantasai> AmeliaBR: [...]<br>
&lt;fantasai> cbiesinger: Downside is that you'll definitely get scrollbars in the other side, too<br>
&lt;fantasai> TabAtkins: oh, yes, becaue if you say `contain-intrinsic-size: 200px`<br>
&lt;fantasai> TabAtkins: ...<br>
&lt;fantasai> AmeliaBR: proposal I suggested was that, as soon as you know you have scrollbars, you only do either the intrinsic sizing or the content and the intrinsic size goes away<br>
&lt;fantasai> AmeliaBR: Another thing I just thought of is we have an option for an overflow value where the scrollbars never take away content size<br>
&lt;fantasai> AmeliaBR: is there a way maybe to say, for the purpose of the 'contain-intrinsic-size' calculation, we always treat as overlay scrollbar instead of as scrollbar that takes away content size?<br>
&lt;fantasai> AmeliaBR: while still laying out content size as normal?<br>
&lt;fantasai> TabAtkins: in other words, treat 'contain-intrinsic-size' rectangle as ignoring scrollbar for determining if there's overflow in a given axis<br>
&lt;AmeliaBR> s/content size/the actual content/<br>
&lt;TabAtkins> SCribeNick: TabAtkins<br>
&lt;TabAtkins> fantasai: I think we should say the actual scrollable overflow area is the union of the content and c-i-s<br>
&lt;TabAtkins> fantasai: But size the box as if the scrollable overflow area is only the area given by c-i-s<br>
&lt;TabAtkins> fantasai: You'll possibly need to add a scrollbar then, but it's only dependent on c-i-s, not content<br>
&lt;AmeliaBR> s/[...]/then there will be scrollbars, the same as for content larger than for the contained size/<br>
&lt;astearns> ack fantasai<br>
&lt;tantek> I was only able to follow partially as well.<br>
&lt;TabAtkins> fantasai: If your c-i-s is accurate (matches content size), you'll get scrollbars, and size will accommodate the scrollbars as you'd expect<br>
&lt;TabAtkins> fantasai: if c-i-s is too big, you'll get to scroll to more area than the contenta ctually takes<br>
&lt;tantek> As much as we want to avoid having unviewable content, I'd also like to see us adopt a principle of making it *easy* for web authors to avoid automatic scrollbars showing up especially when "it doesn't seem like they should be needed"<br>
&lt;TabAtkins> fantasai: if c-i-s is too small, you might get two scrollbars rathe rthan one, but you'll still bea ble to scroll to everyone<br>
&lt;TabAtkins> cbiesinger: The scrollbar is still in the area defined by c-i-s, right?<br>
&lt;TabAtkins> fantasai: If you have an element sized to fit content exactly, and then you set that size explicitly, then add more content that creates a scrollbar, you end up adding a scrollbar to the bottom as well.<br>
&lt;tantek> yeah I pretty much hate this problem<br>
&lt;TabAtkins> fantasai: So you can still scroll to see everything, but one of the scrollbars might just be scrolling a tiny bit<br>
&lt;TabAtkins> fantasai: You'll get into that situation if your c-i-s is inaccurate.<br>
&lt;TabAtkins> cbiesinger: I think if you overflow in one direction, you'll alway sget two scrollbars.<br>
&lt;tantek> would really prefer to avoid situations where we make the layout so scrollbar-fragile that it's too easy to cause scrollbars<br>
&lt;dholbert> q+<br>
&lt;TabAtkins> fantasai: Say you have 100x100 box, c-i-s is 200px tall, ou'll get a vertical scrollbar<br>
&lt;TabAtkins> cbiesinger: If your scrollable area is the union of content and c-i-s<br>
&lt;TabAtkins> cbiesinger: Then c-i-s needs to be scrollable-to. And since scrollbar is in that area defined by c-i-s, you'll always need a scrollbar for it.<br>
&lt;tantek> in particular when a vertical scrollbar shows up e.g. due to fantasai's example, it should not *also* cause a horizontal scrollbar<br>
&lt;tantek> that's a particularly bad side-effect to avoid<br>
&lt;fantasai> ScribeNick: fantasai<br>
&lt;fantasai> fantasai: No, that's not what I'm saying<br>
&lt;fantasai> fantasai: What I'm saying is, you size based on c-i-size<br>
&lt;cbiesinger> &lt;div style="width: 100px; contain-intrinsic-size: 100px 100px; overflow: auto;">&lt;div style="width: 120px;">&lt;/div>&lt;/div><br>
&lt;fantasai> fantasai: and c-i-size increases size of scrollable overflow area<br>
&lt;fantasai> fantasai: potentially causing scrollbars, which get accounted for<br>
&lt;fantasai> fantasai: based on that, you size the box.<br>
&lt;cbiesinger> you get a horiz scrollbar. this covers up the bottom 15px or so of the 100px c-i-s<br>
&lt;fantasai> fantasai: then after you lay out the contents, you increase the scrollable overflow area (if needed) to fit the contents, so that you're not clipping anything<br>
&lt;cbiesinger> but the scrollable area is the union of actual contant and c-i-s<br>
&lt;fantasai> fantasai: this increases the size of the scrollable overflow area, but does not change the size ofthe box<br>
&lt;cbiesinger> so you need to be able to scroll to that<br>
&lt;cbiesinger> no?<br>
&lt;fantasai> fantasai: so you might get extra scrollbars added if your c-i-s value wasn't accurate. But at least you can see all the contents<br>
&lt;fantasai> TabAtkins: So, example here, you have a float<br>
&lt;fantasai> TabAtkins: it as contain-intrinsic-size of 200px x 200px<br>
&lt;fantasai> TabAtkins: specified height of 100px<br>
&lt;fantasai> TabAtkins: this should create a vertical scrollbaron the right<br>
&lt;fantasai> TabAtkins: what should be the float's width, assuming no mbp?<br>
&lt;fantasai> TabAtkins: Should it be 200px or 216px, to account for scrollbar<br>
&lt;tantek> Thank you Tabatkings, that's exactly the problem I was referring to<br>
&lt;cbiesinger> yes, that's what I was asking too<br>
&lt;fantasai> fantasai: Yes, it would be 216px<br>
&lt;tantek> s/Tabatkings/TabAtkins<br>
&lt;TabAtkins> cbiesinger: How can that be 216px if the scrollbar doesn't affec the size of the box?<br>
&lt;fantasai> AmeliaBR: ...<br>
&lt;fantasai> AmeliaBR: but if scrollbar is created by c-i-s, that affects the size of the box<br>
&lt;TabAtkins> AmeliaBR: So a scrollbar form content shouldn't affect the size of the box, but a scrollbar from c-i-s should affect the size of the box?<br>
&lt;fantasai> AmeliaBR: if we're in a context where just the dimensions that we have on the container, combination of explicit sizes plus contain-itnrinsic-size are enough to create a scrollbar<br>
&lt;fantasai> AmeliaBR: and usually scrollbar would be outside the content<br>
&lt;fantasai> AmeliaBR: normally a scrollbar would go inside defined widht of container<br>
&lt;fantasai> AmeliaBR: but not necessarily in something like a float, which doesn't have a defined width<br>
&lt;cbiesinger> &lt;div style="width: 100px; contain-intrinsic-size: 100px 100px; overflow: auto;">&lt;div style="width: 120px;">&lt;/div>&lt;/div><br>
&lt;fantasai> fantasai: ...<br>
&lt;TabAtkins> fantasai: In that example,<br>
&lt;fantasai> cbiesinger: You end up a horizontal and a vertical scrollbar<br>
&lt;TabAtkins> fantasai: Your width is specified, so it won't grow. cis width is fine. There's no height specified, so it sizes to 100px tall.<br>
&lt;iank_> https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=8034<br>
&lt;fantasai> cbiesinger: because horizontal scrollbar takes up space<br>
&lt;iank_> (view in chrome canary)<br>
&lt;fantasai> fantasai: yes. But size of box would be 100px, doesn't grow<br>
&lt;TabAtkins> cbiesinger: Right, then the content is 120px tall, so you need a vertical scrollbar. And that covers up part of the 100px cis, so you get a horiz scrollbar too<br>
&lt;TabAtkins> fantasai: yes<br>
&lt;fantasai> dholbert: I think mental model of it that makes sense:<br>
&lt;fantasai> dholbert: sounds like we size scrollable overflow area as if only one child size of c-i-s<br>
&lt;fantasai> dholbert: other elements are sized similar to abspos, don't affect sizing<br>
&lt;fantasai> dholbert: I think that approximately matches<br>
&lt;fantasai> TabAtkins: Problem with children, grid + multicol act very differently if have one child<br>
&lt;fantasai> TabAtkins: if ignore that, prtend block layout with one child, that works<br>
&lt;fantasai> cbiesinger: so Ian's testcase, Chrome is wrong<br>
&lt;fantasai> iank_: so width of this element should be 100px?<br>
&lt;fantasai> fantasai: that's what I'm saying<br>
&lt;cbiesinger> Ian's testcase would get two scrollbars, then<br>
&lt;fantasai> fantasai: the point of the feature was that box doens't resize in response to contents<br>
&lt;fantasai> fantasai: so should not change size<br>
&lt;fantasai> fantasai: but also should not clip contents, or make them inaccessible underneath scrollbars<br>
&lt;fantasai> TabAtkins: so use c-i-s to figure out if you need to add a scrollabr<br>
&lt;fantasai> TabAtkins: but then when do layout, then ignore c-i-s for purpose of scrollbar<br>
&lt;fantasai> TabAtkins: so adding vertical scrollbar for excess content won't change the size<br>
&lt;fantasai> TabAtkins: but won't trigger extra scrollbars due to c-i-s<br>
&lt;fantasai> TabAtkins: want content to be reflowable, and avoid unnecessary scrollbars<br>
&lt;fantasai> TabAtkins: so c-i-s should factor into scrollable overflow area during intrinsic sizing<br>
&lt;fantasai> TabAtkins: but not affect the scrollable overflow area when actually laying out the content<br>
&lt;fantasai> cbiesinger: makes sense<br>
&lt;fantasai> fantasai: +1<br>
&lt;fantasai> iank_: So during intrinsic sizes phase, if we have size containment, we ignore the scrollbar, but if not we include?<br>
&lt;fantasai> cbiesinger: in intrinsic size phase, include scrollbar iff contain-intrinic-size triggers overflow<br>
&lt;fantasai> cbiesinger: for actual layout, do what we do today<br>
&lt;fantasai> TabAtkins: I think we fall back to model where post doing intrinsic size layout, lay out as if that was an explicit width + height<br>
&lt;fantasai> TabAtkins: proposed resolution is, 'contain-intrinsic-size' is used to figure out whether or not scrollbars should show up during sizing of container. Scorllbars that would appear are factored in.<br>
&lt;fantasai> TabAtkins: but when doing layout of interior contents, 'contain-intrinsic-size' has no effect -- cannot trigger additional scrollbars. Only the actual contents affects scrollbars<br>
&lt;tantek> I agree with the resolution, and let's explicitly capture the principle that no additional scrollbars should appear<br>
&lt;fantasai> RESOLVED: contain-intrinsic-size defines scrollable overflow area for purpose of intrinsic sizing (including adding scrollbars if so required); is ignored for the actual scrollable overflow area during layout<br>
&lt;fantasai> cbiesinger: there can be actual scrollbars depending on the actual contents, just not based on contain-intrinsic-size<br>
&lt;tantek> right what Tab said, not caused by the c-i-s value<br>
&lt;fantasai> astearns: let's get testcases<br>
&lt;fantasai> AmeliaBR: scrollbars should not be caused by interaction of actual content and c-i-s<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4415#issuecomment-621360752 using your GitHub account

Received on Wednesday, 29 April 2020 17:41:30 UTC