W3C home > Mailing lists > Public > www-style@w3.org > December 2015

Re: [cssom-view] Which APIs should be 'double' vs. 'long'

From: Simon Pieters <simonp@opera.com>
Date: Mon, 21 Dec 2015 09:33:27 +0100
To: "Trav Stone" <travtrilogi@gmail.com>, "Rick Byers" <rbyers@chromium.org>
Cc: "www-style@w3.org" <www-style@w3.org>, "Emil A Eklund" <eae@chromium.org>, "Boris Zbarsky" <bzbarsky@mit.edu>, "Robert O'Callahan" <robert@ocallahan.org>
Message-ID: <op.x9zjd1wcidj3kv@simons-mbp>
On Fri, 18 Dec 2015 18:55:20 +0100, Trav Stone <travtrilogi@gmail.com>  
wrote:

> Hi Simon,
>
> Many thanks! Had no idea Range existed, but it does indeed return the  
> value
> I need. I'd still argue that your proposed API is a bit easier to use  
> than
> Range, but perhaps I'm in the minority with that viewpoint.
>
> At any rate, I really appreciate your response- very helpful!

The proposed API is not at all instead of Range. It's instead of  
Element#scrollWidth etc.


On Fri, 18 Dec 2015 19:08:41 +0100, Rick Byers <rbyers@chromium.org> wrote:

> I had thought an API like getScrollRect wasn't necessary because
> getBoundingClientRect + fractional scrollTop/scrollLeft covered all the
> scenarios.  But if there are scenarios that need fractional
> scrollHeight/scrollWidth (or maybe even if it's demonstrably easier to  
> use
> getScrollRect), then I'd certainly support your getScrollRect proposal.

Consider Trav's case, but there is a scrollbar visible. Then  
getBoundingClientRect doesn't return the width you want. You want the  
width excluding the scrollbar, if there is one.

Or if there's a border, then getBoundingClientRect includes the border.  
But getBoxQuads() lets you select the content box... An alternative would  
be to extend getBoxQuads() with a way to get the "content minus  
scrollbars" box.

     elm.getBoxQuads({box: 'scroll'})[0].getBounds().width

It's more wordy than elm.scrollWidth (and elm.getScrollRect().width),  
although you can support transformed boxes.

-- 
Simon Pieters
Opera Software
Received on Monday, 21 December 2015 08:34:01 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:31 UTC