LibWeb: Convert fragment's enclosing device rect to IntRect just once

No functional changes.
This commit is contained in:
Jelle Raaijmakers 2025-08-20 12:21:02 +02:00 committed by Jelle Raaijmakers
parent 51ce46859e
commit 9887b52663

View File

@ -925,10 +925,10 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con
if (phase == PaintPhase::Foreground) {
auto fragment_absolute_rect = fragment.absolute_rect();
auto fragment_absolute_device_rect = context.enclosing_device_rect(fragment_absolute_rect);
auto fragment_enclosing_device_rect = context.enclosing_device_rect(fragment_absolute_rect).to_type<int>();
if (paintable.document().highlighted_layout_node() == &paintable.layout_node())
context.display_list_recorder().draw_rect(fragment_absolute_device_rect.to_type<int>(), Color::Magenta);
context.display_list_recorder().draw_rect(fragment_enclosing_device_rect, Color::Magenta);
auto glyph_run = fragment.glyph_run();
if (!glyph_run)
@ -939,14 +939,14 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con
fragment_absolute_rect.x().to_float(),
fragment_absolute_rect.y().to_float() + fragment.baseline().to_float(),
} * scale;
painter.draw_glyph_run(baseline_start, *glyph_run, paintable.computed_values().webkit_text_fill_color(), fragment_absolute_device_rect.to_type<int>(), scale, fragment.orientation());
painter.draw_glyph_run(baseline_start, *glyph_run, paintable.computed_values().webkit_text_fill_color(), fragment_enclosing_device_rect, scale, fragment.orientation());
auto selection_rect = context.enclosing_device_rect(fragment.selection_rect()).to_type<int>();
if (!selection_rect.is_empty()) {
painter.fill_rect(selection_rect, CSS::SystemColor::highlight(paintable.computed_values().color_scheme()));
DisplayListRecorderStateSaver saver(painter);
painter.add_clip_rect(selection_rect);
painter.draw_glyph_run(baseline_start, *glyph_run, CSS::SystemColor::highlight_text(paintable.computed_values().color_scheme()), fragment_absolute_device_rect.to_type<int>(), scale, fragment.orientation());
painter.draw_glyph_run(baseline_start, *glyph_run, CSS::SystemColor::highlight_text(paintable.computed_values().color_scheme()), fragment_enclosing_device_rect, scale, fragment.orientation());
}
paint_text_decoration(context, paintable, fragment);