ladybird/Tests/LibWeb/Ref/input/position-absolute-and-fixed-nested-static-position.html
InvalidUsernameException 70c46e081d LibWeb: Correctly calculate nested positioned elements' static position
If there are multiple nested `position: fixed` or `position: absolute`
elements that are positioned based on their static position due to not
specifying any insets, we sum up all their ancestor offsets to calculate
said static position.

However, these offsets represent the offset to the containing block. So
summing up all the ancestor blocks will count elements multiple times
for cases where the containing block is not based on the closest element
capable of forming a containing block (i.e. absolute and fixed position
elements) when multiple such elements are nested.

With this change we only iterate over ancestors forming containing
blocks instead of over all ancestors boxes. To sum up everything between
the box currently being positioned and its containing block, we start
the iteration on the parent box of the current box.

This fixes 3 WPT tests that I could find. But these tests are not
intended to test the error cases fixed here, they just incidentally rely
on the correct behavior. As such, I have added dedicated tests myself.
Note that two of the tests already pass on master, but they seemed like
a good cases to have anyway.
2025-10-14 10:23:27 +02:00

21 lines
518 B
HTML

<!DOCTYPE html>
<link rel="match" href="../expected/position-absolute-fixed-nested-static-position.html" />
<style>
div {
height: 100px;
width: 100px;
}
.absolute { position: absolute; }
.fixed { position: fixed; }
.outside { background-color: red; }
.inside { background-color: orange; }
.deep { background-color: yellow; }
.deeper { background-color: green; }
</style>
<div class="outside">
<div class="fixed inside">
<div class="deep">
<div class="absolute deeper"></div>
</div>
</div>
</div>