1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:07:35 +00:00

LibWeb/Painting: Rename StackingContext::paintable{ => _box}()

It returns a PaintableBox, not any Paintable.
This commit is contained in:
Linus Groh 2023-04-20 16:00:21 +01:00 committed by Andreas Kling
parent e6be5c37c0
commit ec37b55777
2 changed files with 14 additions and 14 deletions

View file

@ -247,7 +247,7 @@ Gfx::FloatMatrix4x4 StackingContext::get_transformation_matrix(CSS::Transformati
}); });
}; };
auto reference_box = paintable().absolute_rect(); auto reference_box = paintable_box().absolute_rect();
auto width = CSS::Length::make_px(reference_box.width()); auto width = CSS::Length::make_px(reference_box.width());
auto height = CSS::Length::make_px(reference_box.height()); auto height = CSS::Length::make_px(reference_box.height());
@ -378,7 +378,7 @@ void StackingContext::paint(PaintContext& context) const
if (opacity < 1.0f || !affine_transform.is_identity_or_translation()) { if (opacity < 1.0f || !affine_transform.is_identity_or_translation()) {
auto transform_origin = this->transform_origin(); auto transform_origin = this->transform_origin();
auto source_rect = context.enclosing_device_rect(paintable().absolute_paint_rect()).to_type<int>().to_type<float>().translated(-transform_origin); auto source_rect = context.enclosing_device_rect(paintable_box().absolute_paint_rect()).to_type<int>().to_type<float>().translated(-transform_origin);
auto transformed_destination_rect = affine_transform.map(source_rect).translated(transform_origin); auto transformed_destination_rect = affine_transform.map(source_rect).translated(transform_origin);
auto destination_rect = transformed_destination_rect.to_rounded<int>(); auto destination_rect = transformed_destination_rect.to_rounded<int>();
@ -408,7 +408,7 @@ void StackingContext::paint(PaintContext& context) const
return; return;
auto bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); auto bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
Gfx::Painter painter(bitmap); Gfx::Painter painter(bitmap);
painter.translate(context.rounded_device_point(-paintable().absolute_paint_rect().location() + destination_clipped_fixup).to_type<int>()); painter.translate(context.rounded_device_point(-paintable_box().absolute_paint_rect().location() + destination_clipped_fixup).to_type<int>());
auto paint_context = context.clone(painter); auto paint_context = context.clone(painter);
paint_internal(paint_context); paint_internal(paint_context);
@ -427,7 +427,7 @@ Gfx::FloatPoint StackingContext::compute_transform_origin() const
{ {
auto style_value = m_box->computed_values().transform_origin(); auto style_value = m_box->computed_values().transform_origin();
// FIXME: respect transform-box property // FIXME: respect transform-box property
auto reference_box = paintable().absolute_border_box_rect(); auto reference_box = paintable_box().absolute_border_box_rect();
auto x = reference_box.left() + style_value.x.resolved(m_box, CSS::Length::make_px(reference_box.width())).to_px(m_box); auto x = reference_box.left() + style_value.x.resolved(m_box, CSS::Length::make_px(reference_box.width())).to_px(m_box);
auto y = reference_box.top() + style_value.y.resolved(m_box, CSS::Length::make_px(reference_box.height())).to_px(m_box); auto y = reference_box.top() + style_value.y.resolved(m_box, CSS::Length::make_px(reference_box.height())).to_px(m_box);
return { x, y }; return { x, y };
@ -477,8 +477,8 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
auto transformed_position = affine_transform_matrix().inverse().value_or({}).map(offset_position).to_type<CSSPixels>() + transform_origin; auto transformed_position = affine_transform_matrix().inverse().value_or({}).map(offset_position).to_type<CSSPixels>() + transform_origin;
// FIXME: Support more overflow variations. // FIXME: Support more overflow variations.
if (paintable().computed_values().overflow_x() == CSS::Overflow::Hidden && paintable().computed_values().overflow_y() == CSS::Overflow::Hidden) { if (paintable_box().computed_values().overflow_x() == CSS::Overflow::Hidden && paintable_box().computed_values().overflow_y() == CSS::Overflow::Hidden) {
if (!paintable().absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) if (!paintable_box().absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value()))
return {}; return {};
} }
@ -498,7 +498,7 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
// 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0. // 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
Optional<HitTestResult> result; Optional<HitTestResult> result;
for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable(), [&](PaintableBox const& paint_box) { for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable_box(), [&](PaintableBox const& paint_box) {
// FIXME: Support more overflow variations. // FIXME: Support more overflow variations.
if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) { if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) {
if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value()))
@ -532,13 +532,13 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
// 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks. // 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks.
if (m_box->children_are_inline() && is<Layout::BlockContainer>(*m_box)) { if (m_box->children_are_inline() && is<Layout::BlockContainer>(*m_box)) {
auto result = paintable().hit_test(transformed_position, type); auto result = paintable_box().hit_test(transformed_position, type);
if (result.has_value() && result->paintable->visible_for_hit_testing()) if (result.has_value() && result->paintable->visible_for_hit_testing())
return result; return result;
} }
// 4. the non-positioned floats. // 4. the non-positioned floats.
for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable(), [&](auto const& paint_box) { for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable_box(), [&](auto const& paint_box) {
// FIXME: Support more overflow variations. // FIXME: Support more overflow variations.
if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) { if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) {
if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value()))
@ -559,7 +559,7 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
// 3. the in-flow, non-inline-level, non-positioned descendants. // 3. the in-flow, non-inline-level, non-positioned descendants.
if (!m_box->children_are_inline()) { if (!m_box->children_are_inline()) {
for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable(), [&](auto const& paint_box) { for_each_in_subtree_of_type_within_same_stacking_context_in_reverse<PaintableBox>(paintable_box(), [&](auto const& paint_box) {
// FIXME: Support more overflow variations. // FIXME: Support more overflow variations.
if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) { if (paint_box.computed_values().overflow_x() == CSS::Overflow::Hidden && paint_box.computed_values().overflow_y() == CSS::Overflow::Hidden) {
if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) if (!paint_box.absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value()))
@ -591,9 +591,9 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
} }
// 1. the background and borders of the element forming the stacking context. // 1. the background and borders of the element forming the stacking context.
if (paintable().absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) { if (paintable_box().absolute_border_box_rect().contains(transformed_position.x().value(), transformed_position.y().value())) {
return HitTestResult { return HitTestResult {
.paintable = const_cast<PaintableBox&>(paintable()), .paintable = const_cast<PaintableBox&>(paintable_box()),
}; };
} }
@ -605,7 +605,7 @@ void StackingContext::dump(int indent) const
StringBuilder builder; StringBuilder builder;
for (int i = 0; i < indent; ++i) for (int i = 0; i < indent; ++i)
builder.append(' '); builder.append(' ');
builder.appendff("SC for {} {} [children: {}] (z-index: ", m_box->debug_description(), paintable().absolute_rect(), m_children.size()); builder.appendff("SC for {} {} [children: {}] (z-index: ", m_box->debug_description(), paintable_box().absolute_rect(), m_children.size());
if (m_box->computed_values().z_index().has_value()) if (m_box->computed_values().z_index().has_value())
builder.appendff("{}", m_box->computed_values().z_index().value()); builder.appendff("{}", m_box->computed_values().z_index().value());
else else

View file

@ -20,7 +20,7 @@ public:
StackingContext* parent() { return m_parent; } StackingContext* parent() { return m_parent; }
StackingContext const* parent() const { return m_parent; } StackingContext const* parent() const { return m_parent; }
PaintableBox const& paintable() const { return *m_box->paint_box(); } PaintableBox const& paintable_box() const { return *m_box->paint_box(); }
enum class StackingContextPaintPhase { enum class StackingContextPaintPhase {
BackgroundAndBorders, BackgroundAndBorders,