New issue
Advanced search Search tips

Issue 724255 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

Non-overlay scrollbars cause misbehavior when the container is smaller than the scrollbar

Reported by msten...@opera.com, May 18 2017

Issue description

On 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.
 
tc.html
1.2 KB View Download
Cc: bokan@chromium.org
Labels: Hotlist-Input-Dev
Owner: chaopeng@chromium.org
Status: Assigned (was: Untriaged)
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.
Screen Shot 2017-05-19 at 11.30.26.png
17.1 KB View Download

Comment 3 Deleted

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?

Comment 5 by msten...@opera.com, 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.

Comment 6 Deleted

Comment 7 by bokan@chromium.org, Jun 5 2017

Cc: chaopeng@chromium.org
Components: Blink>Layout>Scrollbars
Owner: ----
Status: Untriaged (was: Assigned)
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.

Comment 8 by e...@chromium.org, Jun 5 2017

Owner: szager@chromium.org
Status: Assigned (was: Untriaged)

Comment 9 by msten...@opera.com, 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.
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.
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.
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.

Comment 13 by e...@chromium.org, May 29 2018

Cc: mstensho@chromium.org szager@chromium.org
Owner: ----
Status: Avilable (was: Assigned)
Status: Available (was: Avilable)

Sign in to add a comment