LibWeb: Rename Layout::Box absolute rect helpers

- padded_rect() -> absolute_padding_box_rect()
- bordered_rect() -> absolute_border_box_rect()
This commit is contained in:
Andreas Kling 2022-02-11 21:57:56 +01:00
parent 9a92236a24
commit 63345c4dfc
Notes: sideshowbarker 2024-07-17 19:00:01 +09:00
4 changed files with 12 additions and 12 deletions

View file

@ -46,7 +46,7 @@ void BlockContainer::paint(PaintContext& context, PaintPhase phase)
if (should_clip_overflow()) { if (should_clip_overflow()) {
context.painter().save(); context.painter().save();
// FIXME: Handle overflow-x and overflow-y being different values. // FIXME: Handle overflow-x and overflow-y being different values.
context.painter().add_clip_rect(enclosing_int_rect(padded_rect())); context.painter().add_clip_rect(enclosing_int_rect(absolute_padding_box_rect()));
context.painter().translate(-m_scroll_offset.to_type<int>()); context.painter().translate(-m_scroll_offset.to_type<int>());
} }

View file

@ -544,7 +544,7 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
float bottom_edge = 0; float bottom_edge = 0;
float right_edge = 0; float right_edge = 0;
icb.for_each_in_subtree_of_type<Box>([&](Box& child) { icb.for_each_in_subtree_of_type<Box>([&](Box& child) {
auto child_rect = child.bordered_rect(); auto child_rect = child.absolute_border_box_rect();
bottom_edge = max(bottom_edge, child_rect.bottom()); bottom_edge = max(bottom_edge, child_rect.bottom());
right_edge = max(right_edge, child_rect.right()); right_edge = max(right_edge, child_rect.right());
return IterationDecision::Continue; return IterationDecision::Continue;

View file

@ -44,7 +44,7 @@ void Box::paint(PaintContext& context, PaintPhase phase)
margin_rect.set_height(content_height() + margin_box.top + margin_box.bottom); margin_rect.set_height(content_height() + margin_box.top + margin_box.bottom);
context.painter().draw_rect(enclosing_int_rect(margin_rect), Color::Yellow); context.painter().draw_rect(enclosing_int_rect(margin_rect), Color::Yellow);
context.painter().draw_rect(enclosing_int_rect(padded_rect()), Color::Cyan); context.painter().draw_rect(enclosing_int_rect(absolute_padding_box_rect()), Color::Cyan);
context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta); context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
} }
@ -61,7 +61,7 @@ void Box::paint_border(PaintContext& context)
.bottom = computed_values().border_bottom(), .bottom = computed_values().border_bottom(),
.left = computed_values().border_left(), .left = computed_values().border_left(),
}; };
Painting::paint_all_borders(context, bordered_rect(), normalized_border_radius_data(), borders_data); Painting::paint_all_borders(context, absolute_border_box_rect(), normalized_border_radius_data(), borders_data);
} }
void Box::paint_background(PaintContext& context) void Box::paint_background(PaintContext& context)
@ -85,13 +85,13 @@ void Box::paint_background(PaintContext& context)
background_color = document().background_color(context.palette()); background_color = document().background_color(context.palette());
} }
} else { } else {
background_rect = enclosing_int_rect(padded_rect()); background_rect = enclosing_int_rect(absolute_padding_box_rect());
} }
// HACK: If the Box has a border, use the bordered_rect to paint the background. // HACK: If the Box has a border, use the bordered_rect to paint the background.
// This way if we have a border-radius there will be no gap between the filling and actual border. // This way if we have a border-radius there will be no gap between the filling and actual border.
if (computed_values().border_top().width || computed_values().border_right().width || computed_values().border_bottom().width || computed_values().border_left().width) if (computed_values().border_top().width || computed_values().border_right().width || computed_values().border_bottom().width || computed_values().border_left().width)
background_rect = enclosing_int_rect(bordered_rect()); background_rect = enclosing_int_rect(absolute_border_box_rect());
Painting::paint_background(context, *this, background_rect, background_color, background_layers, normalized_border_radius_data()); Painting::paint_background(context, *this, background_rect, background_color, background_layers, normalized_border_radius_data());
} }
@ -113,12 +113,12 @@ void Box::paint_box_shadow(PaintContext& context)
static_cast<int>(layer.spread_distance.resolved_or_zero(*this).to_px(*this)), static_cast<int>(layer.spread_distance.resolved_or_zero(*this).to_px(*this)),
layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner); layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner);
} }
Painting::paint_box_shadow(context, enclosing_int_rect(bordered_rect()), resolved_box_shadow_data); Painting::paint_box_shadow(context, enclosing_int_rect(absolute_border_box_rect()), resolved_box_shadow_data);
} }
Painting::BorderRadiusData Box::normalized_border_radius_data() Painting::BorderRadiusData Box::normalized_border_radius_data()
{ {
return Painting::normalized_border_radius_data(*this, bordered_rect(), return Painting::normalized_border_radius_data(*this, absolute_border_box_rect(),
computed_values().border_top_left_radius(), computed_values().border_top_left_radius(),
computed_values().border_top_right_radius(), computed_values().border_top_right_radius(),
computed_values().border_bottom_right_radius(), computed_values().border_bottom_right_radius(),
@ -235,7 +235,7 @@ void Box::before_children_paint(PaintContext& context, PaintPhase phase)
// FIXME: Support more overflow variations. // FIXME: Support more overflow variations.
if (computed_values().overflow_x() == CSS::Overflow::Hidden && computed_values().overflow_y() == CSS::Overflow::Hidden) { if (computed_values().overflow_x() == CSS::Overflow::Hidden && computed_values().overflow_y() == CSS::Overflow::Hidden) {
context.painter().save(); context.painter().save();
context.painter().add_clip_rect(enclosing_int_rect(bordered_rect())); context.painter().add_clip_rect(enclosing_int_rect(absolute_border_box_rect()));
} }
} }

View file

@ -37,7 +37,7 @@ public:
float content_width() const { return m_content_size.width(); } float content_width() const { return m_content_size.width(); }
float content_height() const { return m_content_size.height(); } float content_height() const { return m_content_size.height(); }
Gfx::FloatRect padded_rect() const Gfx::FloatRect absolute_padding_box_rect() const
{ {
auto absolute_rect = this->absolute_rect(); auto absolute_rect = this->absolute_rect();
Gfx::FloatRect rect; Gfx::FloatRect rect;
@ -48,9 +48,9 @@ public:
return rect; return rect;
} }
Gfx::FloatRect bordered_rect() const Gfx::FloatRect absolute_border_box_rect() const
{ {
auto padded_rect = this->padded_rect(); auto padded_rect = this->absolute_padding_box_rect();
Gfx::FloatRect rect; Gfx::FloatRect rect;
rect.set_x(padded_rect.x() - box_model().border.left); rect.set_x(padded_rect.x() - box_model().border.left);
rect.set_width(padded_rect.width() + box_model().border.left + box_model().border.right); rect.set_width(padded_rect.width() + box_model().border.left + box_model().border.right);