Bug 157577
Summary: | getBoundingClientRect should use the first rect if all rects are empty | ||
---|---|---|---|
Product: | WebKit | Reporter: | Simon Pieters (:zcorpan) <zcorpan> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED CONFIGURATION CHANGED | ||
Severity: | Normal | CC: | ahmad.saleem792, ap, bfulgham, cdumez, rniwa, simon.fraser |
Priority: | P2 | Keywords: | FromImplementor |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Simon Pieters (:zcorpan)
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
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Ahmad Saleem
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!