mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 22:59:13 +00:00
Overflow clipping is currently implemented as: 1. Create clip frame for each box with hidden overflow 2. Calculate clip rect for each clip frame by intersecting padding boxes of all boxes with hidden overflow in containing block chain 3. Assign enclosing clip frame (closest clip frame in containing block chain) to each PaintableBox 4. Apply clip rect of enclosing clip frame in Paintable::before_paint() It breaks when any CSS transform other than simple translation is lying between box with hidden overflow and a clipped box, because clip rectangle will be applied when transform has already changed. The fix is implemented by relying on the following rule: "For elements whose layout is governed by the CSS box model, any value other than none for the transform also causes the element to establish a containing block for all descendants." It means everything nested into a stacking context with CSS transform can't escape its clip, so it's safe to apply its clip for all children.
39 lines
913 B
C++
39 lines
913 B
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Painting/ClippableAndScrollable.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
Optional<int> ClippableAndScrollable::scroll_frame_id() const
|
|
{
|
|
if (m_enclosing_scroll_frame)
|
|
return m_enclosing_scroll_frame->id;
|
|
return {};
|
|
}
|
|
|
|
Optional<CSSPixelPoint> ClippableAndScrollable::enclosing_scroll_frame_offset() const
|
|
{
|
|
if (m_enclosing_scroll_frame)
|
|
return m_enclosing_scroll_frame->offset;
|
|
return {};
|
|
}
|
|
|
|
Optional<CSSPixelRect> ClippableAndScrollable::clip_rect() const
|
|
{
|
|
if (m_enclosing_clip_frame)
|
|
return m_enclosing_clip_frame->rect();
|
|
return {};
|
|
}
|
|
|
|
Span<BorderRadiiClip const> ClippableAndScrollable::border_radii_clips() const
|
|
{
|
|
if (m_enclosing_clip_frame)
|
|
return m_enclosing_clip_frame->border_radii_clips();
|
|
return {};
|
|
}
|
|
|
|
}
|