[Webkit-unassigned] [Bug 44398] getComputedStyle height/width substracts scrollbar size

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 24 19:32:52 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=44398

--- Comment #5 from Karl Dubost <karlcow at apple.com> ---
Firefox
GetComputedStyle:          Width: 100px Height: 150px
BoundingClientRect         Width: 100px Height: 150px
clientWidth/clientHeight:  Width: 85px  Height: 135px

Chrome/Safari:
GetComputedStyle:          Width: 85px  Height: 135px
BoundingClientRect         Width: 100px Height: 150px
clientWidth/clientHeight:  Width: 85px  Height: 135px


In https://drafts.csswg.org/cssom-view/#dom-element-clientwidth

> Return the width of the padding edge 
>   **excluding the width of any rendered scrollbar** 
> between the padding edge and the border edge, 
> ignoring any transforms that apply to the element 
> and its ancestors.

so this is clear. 

First of all 
https://drafts.csswg.org/css-overflow-3/#scrollbar-gutter-property

> The space between the inner border edge and the outer padding edge which user agents may reserve to display the scrollbar is called the scrollbar gutter.

Then

> Whether classic scrollbars or overlay scrollbars are used, the appearance and size of the scrollbar, and whether scrollbars appear on the start or end edge of the box, is UA defined.


but nothing is said on how it affects the reported width of the container. 

That said I'm not sure this is fixable in any way both for Firefox and Safari/Chrome without unleashing webcompat hell on the Web.

It's better to use getBoundingClientRect and clientWidth for these.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220725/3a2ab52b/attachment-0001.htm>


More information about the webkit-unassigned mailing list