|
Changes to scrollWidth/scrollHeight
|
|
Posted by: stak
Tags: mozilla
Posted on: 2012-06-21 09:33:22
I just landed bug 755971 on mozilla-inbound. Assuming it sticks, it changes the scrollWidth and scrollHeight properties on non-scrollable elements so that it doesn't include the border of the element. This means that for an element that looks like this:
<div style="display: table; overflow: auto; width: 100px; height: 100px; border: 5px solid black">foo</div> the scrollWidth and scrollHeight change from 110 to 100.
This behaviour is poorly specified and not consistent across browsers, but this brings Firefox more in line with the definitions in the CSSOM-View specification. It also makes the behaviour consistent across scrollable and non-scrollable elements - in both cases it now returns the padding box size. The behaviour for scrollable elements is unchanged.
Although this change makes sense in general, the reason it came up is because some of our code tries to detect if elements are scrollable by checking if their scrollWidth (or scrollHeight) is larger than their clientWidth (or clientHeight). This check was returning true in cases where non-scrollable elements had a border. By the looks of some questions on stackoverflow, this seems to be a general problem people are encountering, so it made sense to fix.
|
|
(c) Kartikaya Gupta, 2004-2024. User comments owned by their respective posters. All rights reserved.
You are accessing this website via IPv4. Consider upgrading to IPv6!
|
Addons which replace scrolling (SmoothWheel, all in one gestures, Yet another smooth scroll, etc) deploy a custom built algorithm for that (which are slightly different than each other, and are never working exactly as the built in detection for scrollable element under the mouse pointer), maybe Mozilla can make it easier for addons developers?