Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/Painting/Paintable.cpp (C++)

Code before:
{
    if (is_paintable_box())
        return static_cast<PaintableBox const&>(*this).stacking_context();
    return false;
}

StackingContext* Paintable::enclosing_stacking_context()
{
    for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
        if (!ancestor->is_paintable_box())
            continue;
        if (auto* stacking_context = static_cast<PaintableBox&>(*ancestor).stacking_context())
            return const_cast<StackingContext*>(stacking_context);
    }
    // We should always reach the viewport's stacking context.
    VERIFY_NOT_REACHED();
}

void Paintable::set_needs_display(InvalidateDisplayList should_invalidate_display_list)
{
    auto& document = const_cast<DOM::Document&>(this->document());
    if (should_invalidate_display_list == InvalidateDisplayList::Yes)
        document.invalidate_display_list();

    auto* parent = as_if<Painting::PaintableWithLines>(this->parent());
    if (!parent)
        return;
    for (auto const& fragment : parent->fragments()) {
        document.set_needs_display(fragment.absolute_rect(), InvalidateDisplayList::No);
    };
}

CSSPixelPoint Paintable::box_type_agnostic_position() const
{
    if (is_paintable_box())
        return static_cast<PaintableBox const*>(this)->absolute_position();

    VERIFY(is_inline());

    CSSPixelPoint position;
    if (auto const* block = containing_block(); block && is<Painting::PaintableWithLines>(*block)) {
        auto const& fragments = static_cast<Painting::PaintableWithLines const&>(*block).fragments();
        if (!fragments.is_empty()) {
            position = fragments[0].absolute_rect().location();
        }
    }

    return position;
}

Gfx::AffineTransform Paintable::compute_combined_css_transform() const

Review comment (suggestion):
Commit message: please don't [use weasel-words such as "fix"](https://github.com/LadybirdBrowser/ladybird/blob/master/CONTRIBUTING.md#code-submission-policy), but rather describe what you changed and why.

Code after:
    return false;
}

StackingContext* Paintable::enclosing_stacking_context()
{
    for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
        if (!ancestor->is_paintable_box())
            continue;
        if (auto* stacking_context = static_cast<PaintableBox&>(*ancestor).stacking_context())
            return const_cast<StackingContext*>(stacking_context);
    }
    // We should always reach the viewport's stacking context.
    VERIFY_NOT_REACHED();
}

void Paintable::set_needs_display(InvalidateDisplayList should_invalidate_display_list)
{
    auto& document = const_cast<DOM::Document&>(this->document());
    if (should_invalidate_display_list == InvalidateDisplayList::Yes)
        document.invalidate_display_list();

    auto* containing_block = this->containing_block();
    if (!containing_block)
        return;

    if (!is<Painting::PaintableWithLines>(*containing_block))
        return;
    for (auto const& fragment : static_cast<Painting::PaintableWithLines const&>(*containing_block).fragments()) {
        document.set_needs_display(fragment.absolute_rect(), InvalidateDisplayList::No);
    };
}

CSSPixelPoint Paintable::box_type_agnostic_position() const
{
    if (is_paintable_box())
        return static_cast<PaintableBox const*>(this)->absolute_position();

    VERIFY(is_inline());

    CSSPixelPoint position;
    if (auto const* block = containing_block(); block && is<Painting::PaintableWithLines>(*block)) {
        auto const& fragments = static_cast<Painting::PaintableWithLines const&>(*block).fragments();
        if (!fragments.is_empty()) {
            position = fragments[0].absolute_rect().location();
        }
    }

    return position;
}

Gfx::AffineTransform Paintable::compute_combined_css_transform() const