1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 03:48:13 +00:00

LibWeb: Hoist an early return in Layout::BlockBox::paint()

This commit is contained in:
Andreas Kling 2020-12-03 17:17:11 +01:00
parent 194d7d3471
commit 17e9a5e0c5

View file

@ -54,32 +54,31 @@ void BlockBox::paint(PaintContext& context, PaintPhase phase)
Box::paint(context, phase); Box::paint(context, phase);
if (!children_are_inline())
return;
// FIXME: Inline backgrounds etc. // FIXME: Inline backgrounds etc.
if (phase == PaintPhase::Foreground) { if (phase == PaintPhase::Foreground) {
if (children_are_inline()) { for (auto& line_box : m_line_boxes) {
for (auto& line_box : m_line_boxes) { for (auto& fragment : line_box.fragments()) {
for (auto& fragment : line_box.fragments()) { if (context.should_show_line_box_borders())
if (context.should_show_line_box_borders()) context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green);
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green); fragment.paint(context);
fragment.paint(context);
}
} }
} }
} }
if (phase == PaintPhase::FocusOutline) { if (phase == PaintPhase::FocusOutline) {
if (children_are_inline()) { for (auto& line_box : m_line_boxes) {
for (auto& line_box : m_line_boxes) { for (auto& fragment : line_box.fragments()) {
for (auto& fragment : line_box.fragments()) { auto* node = fragment.layout_node().dom_node();
auto* node = fragment.layout_node().dom_node(); if (!node)
if (!node) continue;
continue; auto* parent = node->parent_element();
auto* parent = node->parent_element(); if (!parent)
if (!parent) continue;
continue; if (parent->is_focused())
if (parent->is_focused()) context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), context.palette().focus_outline());
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), context.palette().focus_outline());
}
} }
} }
} }