Bug 90546

Summary: Scrollbar width is not applied when element hidden
Product: WebKit Reporter: Allan Jardine <allan.jardine>
Component: New BugsAssignee: gur.trio
Severity: Normal CC: bdakin, commit-queue, darin, esprehn+autocc, glenn, gur.trio, hyatt, kondapallykalyan, pravind, simon.fraser, zachlloyd
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Description Flags
Patch none

Description Allan Jardine 2012-07-04 05:35:16 PDT
I have a function which attempts to calculate the width of a scrollbar by putting two elements on to the page, one inside the other and forcing the inner element to a larger height than the outer which is overflow: auto; Then by subtracting the outer width from the inner we get the scrollbar width.

This works in nearly all applications, apparent from when -webkit-scrollbar styles are applied to the scrolling element, and the element is visibility: hidden (note that if the element is visible, then it works as expected).

Test case with element visible - works as expected: http://sprymedia.co.uk/media/misc/webkit/custom_scroll_visible.html
Test case with element hidden - doesn't work: http://sprymedia.co.uk/media/misc/webkit/custom_scroll_hidden.html

If -webkit-scrollbar styles are not applied, then it will work regardless of visibility.

Tested in WebKit r121825 and shipping Safari 5.1.7 (7534.57.2).

Filed in 'New Bugs' as I'm not sure if this is a Javascript or rendering engine issue.
Comment 1 gur.trio 2013-09-05 00:18:53 PDT
Created attachment 210584 [details]
Comment 2 gur.trio 2013-09-05 00:24:16 PDT
(In reply to comment #1)
> Created an attachment (id=210584) [details]
> Patch

Incase of custom-scrollbars webkit considers the visibility property and incase its hidden doesnot apply the scollbars properties.
Same is not for non-customscrollbars. In either case scrollbar properties are applied.
Behaviour should be same for both since even if element visibility:hidden space is set for that element.
Comment 3 gur.trio 2013-09-05 19:54:19 PDT
(In reply to comment #1)
> Created an attachment (id=210584) [details]
> Patch

Hi Darin. Can you please review this patch?
Comment 4 Darin Adler 2013-09-06 12:30:39 PDT
I don’t think I have the expertise to review this. Maybe Beth Dakin, Simon Fraser, or Hyatt?
Comment 5 Simon Fraser (smfr) 2013-09-06 17:17:56 PDT
Comment on attachment 210584 [details]

Seems reasonable.
Comment 6 gur.trio 2013-09-08 23:16:10 PDT
(In reply to comment #5)
> (From update of attachment 210584 [details])
> Seems reasonable.

Thanks for the review Simon. Anything else needs to be done?
Comment 7 WebKit Commit Bot 2013-09-08 23:53:03 PDT
Comment on attachment 210584 [details]

Clearing flags on attachment: 210584

Committed r155323: <http://trac.webkit.org/changeset/155323>
Comment 8 WebKit Commit Bot 2013-09-08 23:53:06 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 gur.trio 2013-10-15 04:30:47 PDT
*** Bug 66306 has been marked as a duplicate of this bug. ***