LibWeb: Apply enclosing scroll frame offset to iframe's position

Fixes iframe painting when it's nested into a scrollable box.
This commit is contained in:
Aliaksandr Kalenik 2024-08-07 19:18:41 +03:00 committed by Alexander Kalenik
parent 5865cf5864
commit 9def582fba
Notes: github-actions[bot] 2024-08-07 18:16:53 +00:00
3 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<link rel="match" href="reference/scrollable-contains-iframe-ref.html" />
<style>
* {
scrollbar-width: none;
}
#scrollable {
width: 80%;
height: 300px;
border: 1px solid #000;
overflow: scroll;
}
iframe {
width: 300px;
height: 300px;
}
</style>
<div id="scrollable">
<iframe srcdoc="iframe nested into scrollable"></iframe>
</div>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<link rel="match" href="reference/scrollable-contains-iframe-ref.html" />
<style>
* {
scrollbar-width: none;
}
#scrollable {
width: 80%;
height: 300px;
border: 1px solid #000;
overflow: scroll;
}
iframe {
width: 300px;
height: 300px;
}
</style>
<div id="scrollable">
<div style="height: 200px"></div>
<iframe srcdoc="iframe nested into scrollable"></iframe>
</div>
<script>
const scrollContainer = document.getElementById("scrollable");
scrollContainer.scrollTop = 200;
</script>

View file

@ -40,6 +40,7 @@ void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase pha
if (phase == PaintPhase::Foreground) {
auto absolute_rect = this->absolute_rect();
absolute_rect.translate_by(enclosing_scroll_frame_offset());
auto clip_rect = context.rounded_device_rect(absolute_rect);
ScopedCornerRadiusClip corner_clip { context, clip_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };