Non-overlay scrollbars cause misbehavior when the container is smaller than the scrollbar
Reported by
msten...@opera.com,
May 18 2017
|
|||||
Issue descriptionOn systems that let scrollbars take up layout space (i.e. when overlay scrollbars are NOT enabled), and the scrollable container is smaller than the width of a scrollbar, it's possible to set a scroll position that's larger than the width/height of the scrollable content. In such situations rendering is also suboptimal; all available border-box space is taken up by scrollbars, leaving nothing to the content. Discovered while working on issue 720227 . The RTL scroll type detection script at https://github.com/othree/jquery.rtl-scroll-type causes such a situation, although it's rather harmless in that case.
,
May 19 2017
Hi mstensho, sorry I am not clear why the scrollLeft and scrollTop should be 5 after "Set large scroll position". I think 3 px is correct because the child element height is 5 and parent height is 2, when parent scroll to end (parent bottom match child bottom), scroll position is 3. See attachment. I copy your sample to https://jsfiddle.net/otcjL4ur/. I got 3px at Chrome/Safari/FireFox when Mac Overlay Scrollbar enabled.
,
May 19 2017
For overlay scrollbar disabled, the scroll position returns 18. I am not sure what should it be since the container is small than a scrollbar (width 15 px). bokan@ WDYT?
,
May 19 2017
Actually, with the current rendering, it should be 5. We reserve space for scrollbars first, and, if there's anything left, that remaining space goes to the padding/content box. In other words, if the width of the scrollbar is 15px and the width of the scrollable container is 2px, we give 2px to the scrollbar and clip the rest of it, and we give 0px to the content, which in turn means that maximum scrollLeft should be 5. That said, this is pretty lousy behavior (if we REALLY care about this corner-case, that is). Completely hiding the content in a 0x0 scrollable area seems suboptimal.
,
Jun 5 2017
I'm not sure what we want to do here, if anything - I'm not sure it's worth spending time on this. Over to layout team since this really lays in their jurisdiction.
,
Jun 5 2017
,
Jun 6 2017
I think the acceptable long-term solution is to always ensure that the border box be large enough to hold the scrollbars. Experimented here https://codereview.chromium.org/2897033002/ and the test results don't look horrible, at least.
,
Jun 6 2017
FYI I don't think expanding the border box is correct. If it has a declared size in CSS we need to honor that. Is there something special about RTL here? I think the result should be the same no matter which side the scrollbar is on.
,
Jun 6 2017
Yeah, I was skeptical too, but cbiesinger convinced me that we should at least consider it: https://codereview.chromium.org/2893833004#msg10 Also note that we already do expand the border box in some cases; if we have box-sizing:border-box and border+padding is larger than specified width. For example: <div style="box-sizing:border-box; width:5px; border:4px solid; padding:3px;"></div> The width of the content-box cannot be negative. The size of the border box is specified as 5px. The total width of border and padding is 4+3+3+4 = 14px. 14px is what we need the border box to be to avoid a negative content box width, i.e. to make it 0. The code that does this is what I'm extending in the https://codereview.chromium.org/2897033002/ experimental CL, to also make it aware of scrollbars, not just border and padding.
,
Jun 6 2017
Oh, and RTL: Nothing special, apart from the fact that we need to offset the left padding edge by the width of the scrollbar. We got negative values where they weren't expected, and some calculations went bananas.
,
May 29 2018
,
Jul 11
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by dtapu...@chromium.org
, May 19 2017Labels: Hotlist-Input-Dev
Owner: chaopeng@chromium.org
Status: Assigned (was: Untriaged)