ladybird/Tests/LibWeb/Text/input/DOM/range-get-client-rects.html
Annya 75c7dbc5d2 LibWeb: Implement Range's extension method
This patch implements `Range::getClientRects` and
`Range::getBoundingClientRect`. Since the rects returned by invoking
getClientRects can be accessed without adding them to the Selection,
`ViewportPaintable::recompute_selection_states` has been updated to
accept a Range as a parameter, rather than acquiring it through the
Document's Selection.

With this change, the following tests now pass:

- wpt[css/cssom-view/range-bounding-client-rect-with-nested-text.html]
- wpt[css/cssom-view/DOMRectList.html]

Note: The test
"css/cssom-view/range-bounding-client-rect-with-display-contents.html"
still fails due to an issue with Element::getClientRects, which will
be addressed in a future commit.
2024-09-20 19:58:20 +02:00

19 lines
548 B
HTML

<!--refer to https://wpt.live/css/cssom-view/DOMRectList.html -->
<body>
<div id="x">x</div>
<script src="../include.js"></script>
<script>
function print_class_string(object) {
println({}.toString.call(object));
}
test(() => {
const x = document.getElementById("x");
const range = document.createRange();
range.selectNodeContents(x);
const domRectList = range.getClientRects();
print_class_string(domRectList);
print_class_string(domRectList.item(0));
});
</script>
</body>