`range.getBoundingClientRect()` has 0 width/height for `content-visibility: hidden`
Categories
(Core :: Layout, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox147 | --- | fixed |
People
(Reporter: nolan, Assigned: sickl8, Mentored)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug)
Attachments
(5 files)
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
Steps to reproduce:
- Open the attached
index.htmlfile - The reported width/height should be non-zero, but in Firefox they are both zero.
Minimal repro:
<div style="content-visibility: hidden; contain-intrinsic-size: 100px 100px;">
<span id="span">Hello</span>
</div>
<script>
const range = document.createRange()
range.selectNode(span.firstChild)
console.log(range.getBoundingClientRect().width) // 0
</script>
Actual results:
The width/height of the reported bounding rect are both 0.
Expected results:
Per the CSS containment spec 1, layout should be forced on content-visibility: hidden elements if their size is requested by script, e.g. using getBoundingClientRect(). This works correctly in Firefox when calling getBoundingClientRect() on an element, but not on a Range that selects a text node (as in this repro).
Browsers that fail the test:
- Firefox Nightly 132.0a1 (2024-09-09) (64-bit)
Browsers that pass the test:
- Chromium 128.0.6613.119
- Safari Technology Preview 202 (Safari 18.0 WebKit 19620.1.4.8)
| Reporter | ||
Comment 1•1 year ago
|
||
| Reporter | ||
Comment 2•1 year ago
|
||
| Reporter | ||
Comment 3•1 year ago
|
||
Comment 4•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 5•1 year ago
|
||
A trivial fix could be something like changing this by aStartContainer->GetPrimaryFrame(FlushType::Layout);... That should cover most cases, though I suspect dealing with cases where the range spans different boundaries would be fun.
We should probably at least do that tho.
Updated•1 year ago
|
Comment 6•1 year ago
|
||
aStartContainer doesn't have a method called GetPrimaryFrame.
| Assignee | ||
Comment 7•12 days ago
|
||
Updated•12 days ago
|
Comment 10•11 days ago
|
||
| bugherder | ||
Updated•7 hours ago
|
Description
•