1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 15:18:11 +00:00

LibWeb: Allow <svg> to act as a containing block

This change makes overflow clipping work correctly for children of svg
element.

Fixes following example:
```html
<!doctype html><style>
    body {
        width: 300px;
        height: 300px;
        position: relative;
        overflow: hidden;
        border: 1px solid black;
    }
    svg {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 100%;
        height: 100%;
        transform: translate(-50%, -50%);
    }
</style>
<body>
<svg viewBox="0 0 100 100">
   <g>
     <rect x="0" y="0" width="100" height="100" fill="green"></rect>
   </g>
</svg>
```
This commit is contained in:
Aliaksandr Kalenik 2023-07-28 14:23:12 +02:00 committed by Andreas Kling
parent c8d7bcede6
commit 38edab09a0

View file

@ -90,7 +90,8 @@ static Box const* nearest_ancestor_capable_of_forming_a_containing_block(Node co
for (auto const* ancestor = node.parent(); ancestor; ancestor = ancestor->parent()) {
if (ancestor->is_block_container()
|| ancestor->display().is_flex_inside()
|| ancestor->display().is_grid_inside()) {
|| ancestor->display().is_grid_inside()
|| ancestor->is_svg_svg_box()) {
return verify_cast<Box>(ancestor);
}
}