mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 22:42:18 +00:00
LibWeb: Don't wrap result in optional in enclosing_scroll_frame_offset()
Instead return (0, 0) if a box does not have an offset.
This commit is contained in:
parent
4ec3968178
commit
1163ff21d7
Notes:
github-actions[bot]
2024-08-07 16:15:36 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 1163ff21d7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1000
6 changed files with 10 additions and 16 deletions
|
@ -165,10 +165,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
CSSPixelPoint enclosing_scroll_offset;
|
CSSPixelPoint enclosing_scroll_offset;
|
||||||
if (is<PaintableBox>(layout_node.paintable())) {
|
if (is<PaintableBox>(layout_node.paintable())) {
|
||||||
auto const& paintable_box = static_cast<PaintableBox const&>(*layout_node.paintable());
|
auto const& paintable_box = static_cast<PaintableBox const&>(*layout_node.paintable());
|
||||||
enclosing_scroll_offset = paintable_box.enclosing_scroll_frame_offset().value_or({});
|
enclosing_scroll_offset = paintable_box.enclosing_scroll_frame_offset();
|
||||||
} else if (is<InlinePaintable>(layout_node.paintable())) {
|
} else if (is<InlinePaintable>(layout_node.paintable())) {
|
||||||
auto const& inline_paintable = static_cast<InlinePaintable const&>(*layout_node.paintable());
|
auto const& inline_paintable = static_cast<InlinePaintable const&>(*layout_node.paintable());
|
||||||
enclosing_scroll_offset = inline_paintable.enclosing_scroll_frame_offset().value_or({});
|
enclosing_scroll_offset = inline_paintable.enclosing_scroll_frame_offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Background layers are ordered front-to-back, so we paint them in reverse
|
// Note: Background layers are ordered front-to-back, so we paint them in reverse
|
||||||
|
|
|
@ -15,7 +15,7 @@ Optional<int> ClippableAndScrollable::scroll_frame_id() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<CSSPixelPoint> ClippableAndScrollable::enclosing_scroll_frame_offset() const
|
CSSPixelPoint ClippableAndScrollable::enclosing_scroll_frame_offset() const
|
||||||
{
|
{
|
||||||
if (m_enclosing_scroll_frame)
|
if (m_enclosing_scroll_frame)
|
||||||
return m_enclosing_scroll_frame->offset;
|
return m_enclosing_scroll_frame->offset;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
void set_enclosing_clip_frame(RefPtr<ClipFrame> clip_frame) { m_enclosing_clip_frame = clip_frame; }
|
void set_enclosing_clip_frame(RefPtr<ClipFrame> clip_frame) { m_enclosing_clip_frame = clip_frame; }
|
||||||
|
|
||||||
[[nodiscard]] Optional<int> scroll_frame_id() const;
|
[[nodiscard]] Optional<int> scroll_frame_id() const;
|
||||||
[[nodiscard]] Optional<CSSPixelPoint> enclosing_scroll_frame_offset() const;
|
[[nodiscard]] CSSPixelPoint enclosing_scroll_frame_offset() const;
|
||||||
[[nodiscard]] Optional<CSSPixelRect> clip_rect() const;
|
[[nodiscard]] Optional<CSSPixelRect> clip_rect() const;
|
||||||
[[nodiscard]] Span<BorderRadiiClip const> border_radii_clips() const;
|
[[nodiscard]] Span<BorderRadiiClip const> border_radii_clips() const;
|
||||||
|
|
||||||
|
|
|
@ -193,8 +193,7 @@ TraversalDecision InlinePaintable::hit_test(CSSPixelPoint position, HitTestType
|
||||||
return TraversalDecision::Continue;
|
return TraversalDecision::Continue;
|
||||||
|
|
||||||
auto position_adjusted_by_scroll_offset = position;
|
auto position_adjusted_by_scroll_offset = position;
|
||||||
if (enclosing_scroll_frame_offset().has_value())
|
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset());
|
||||||
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset().value());
|
|
||||||
|
|
||||||
for (auto const& fragment : m_fragments) {
|
for (auto const& fragment : m_fragments) {
|
||||||
if (fragment.paintable().stacking_context())
|
if (fragment.paintable().stacking_context())
|
||||||
|
|
|
@ -161,9 +161,7 @@ CSSPixelRect PaintableBox::compute_absolute_rect() const
|
||||||
CSSPixelRect PaintableBox::compute_absolute_padding_rect_with_scroll_offset_applied() const
|
CSSPixelRect PaintableBox::compute_absolute_padding_rect_with_scroll_offset_applied() const
|
||||||
{
|
{
|
||||||
auto rect = absolute_rect();
|
auto rect = absolute_rect();
|
||||||
auto scroll_offset = this->enclosing_scroll_frame_offset();
|
rect.translate_by(enclosing_scroll_frame_offset());
|
||||||
if (scroll_offset.has_value())
|
|
||||||
rect.translate_by(scroll_offset.value());
|
|
||||||
|
|
||||||
CSSPixelRect padding_rect;
|
CSSPixelRect padding_rect;
|
||||||
padding_rect.set_x(rect.x() - box_model().padding.left);
|
padding_rect.set_x(rect.x() - box_model().padding.left);
|
||||||
|
@ -700,8 +698,7 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
|
||||||
context.display_list_recorder().save();
|
context.display_list_recorder().save();
|
||||||
// FIXME: Handle overflow-x and overflow-y being different values.
|
// FIXME: Handle overflow-x and overflow-y being different values.
|
||||||
auto clip_box_with_enclosing_scroll_frame_offset = clip_box;
|
auto clip_box_with_enclosing_scroll_frame_offset = clip_box;
|
||||||
if (enclosing_scroll_frame_offset().has_value())
|
clip_box_with_enclosing_scroll_frame_offset.translate_by(enclosing_scroll_frame_offset());
|
||||||
clip_box_with_enclosing_scroll_frame_offset.translate_by(enclosing_scroll_frame_offset().value());
|
|
||||||
context.display_list_recorder().add_clip_rect(context.rounded_device_rect(clip_box_with_enclosing_scroll_frame_offset).to_type<int>());
|
context.display_list_recorder().add_clip_rect(context.rounded_device_rect(clip_box_with_enclosing_scroll_frame_offset).to_type<int>());
|
||||||
|
|
||||||
auto border_radii = normalized_border_radii_data(ShrinkRadiiForBorders::Yes);
|
auto border_radii = normalized_border_radii_data(ShrinkRadiiForBorders::Yes);
|
||||||
|
@ -850,8 +847,7 @@ TraversalDecision PaintableBox::hit_test(CSSPixelPoint position, HitTestType typ
|
||||||
return TraversalDecision::Continue;
|
return TraversalDecision::Continue;
|
||||||
|
|
||||||
auto position_adjusted_by_scroll_offset = position;
|
auto position_adjusted_by_scroll_offset = position;
|
||||||
if (enclosing_scroll_frame_offset().has_value())
|
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset());
|
||||||
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset().value());
|
|
||||||
|
|
||||||
if (!is_visible())
|
if (!is_visible())
|
||||||
return TraversalDecision::Continue;
|
return TraversalDecision::Continue;
|
||||||
|
@ -904,8 +900,7 @@ TraversalDecision PaintableWithLines::hit_test(CSSPixelPoint position, HitTestTy
|
||||||
return TraversalDecision::Continue;
|
return TraversalDecision::Continue;
|
||||||
|
|
||||||
auto position_adjusted_by_scroll_offset = position;
|
auto position_adjusted_by_scroll_offset = position;
|
||||||
if (enclosing_scroll_frame_offset().has_value())
|
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset());
|
||||||
position_adjusted_by_scroll_offset.translate_by(-enclosing_scroll_frame_offset().value());
|
|
||||||
|
|
||||||
if (!layout_box().children_are_inline() || m_fragments.is_empty()) {
|
if (!layout_box().children_are_inline() || m_fragments.is_empty()) {
|
||||||
return PaintableBox::hit_test(position, type, callback);
|
return PaintableBox::hit_test(position, type, callback);
|
||||||
|
|
|
@ -33,7 +33,7 @@ void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase ph
|
||||||
return;
|
return;
|
||||||
context.display_list_recorder().save();
|
context.display_list_recorder().save();
|
||||||
auto clip_rect = absolute_rect();
|
auto clip_rect = absolute_rect();
|
||||||
clip_rect.translate_by(enclosing_scroll_frame_offset().value_or({}));
|
clip_rect.translate_by(enclosing_scroll_frame_offset());
|
||||||
context.display_list_recorder().add_clip_rect(context.enclosing_device_rect(clip_rect).to_type<int>());
|
context.display_list_recorder().add_clip_rect(context.enclosing_device_rect(clip_rect).to_type<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue