Bug 157577 - getBoundingClientRect should use the first rect if all rects are empty
Summary: getBoundingClientRect should use the first rect if all rects are empty
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: FromImplementor
Depends on:
Blocks:
 
Reported: 2016-05-11 11:57 PDT by Simon Pieters (:zcorpan)
Modified: 2022-07-28 13:08 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pieters (:zcorpan) 2016-05-11 11:57:27 PDT
Test

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4189

<!DOCTYPE html>
<div id=x>123</div>
<script>
var r = new Range();
r.setStart(x.firstChild, 1);
r.setEnd(x.firstChild, 1);
w(r.getBoundingClientRect());
</script>


Actual result:

log: object "[object ClientRect]" (6 props: top=0, right=0, bottom=0, left=0...)

Expected result:

log: object "[object ClientRect]" (6 props: top=8, right=16, bottom=26, left=16...)
(this is what I get in Chromium, but actual numbers might depend on fonts etc.)

Spec:
https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
https://drafts.csswg.org/cssom-view/#dom-range-getboundingclientrect

Related Chromium issue:
https://bugs.chromium.org/p/chromium/issues/detail?id=606662#c9

Recent spec change (because of the Chromium issue above)
https://github.com/w3c/csswg-drafts/commit/0e7a5cbdea19397086e9423b508fe6f41decdcec
Comment 1 Ahmad Saleem 2022-07-28 13:05:20 PDT
Safari 15.6 results following:

log: object "[object DOMRect]" (9 props: x=16, y=8, width=0, height=18...)

Firefox Nightly 105:

log: object "[object DOMRect]" (9 props: x=16, y=9.600006103515625, width=0, height=16...)

Chrome Canary 106:

log: object "[object DOMRect]" (9 props: x=16, y=8, width=0, height=18.5...)
r

_____________

I think this can be marked as "RESOLVED CONFIGURATION CHANGED", since now Safari does not show [0] etc. in the attached test case and work as other browsers (with slight differences). Thanks!