mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibWeb: Use CSS text-indent property on input type="submit" elements
This commit is contained in:
parent
a89e95f57c
commit
148d74b103
1 changed files with 14 additions and 2 deletions
|
@ -43,17 +43,29 @@ void ButtonPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
|
||||
auto const& dom_node = layout_box().dom_node();
|
||||
if (is<HTML::HTMLInputElement>(dom_node) && phase == PaintPhase::Foreground) {
|
||||
auto text_rect = context.enclosing_device_rect(absolute_rect());
|
||||
auto button_rect = context.enclosing_device_rect(absolute_rect());
|
||||
auto text_rect = button_rect;
|
||||
|
||||
// Apply CSS text-indent property to text rect
|
||||
auto text_indent = computed_values().text_indent().to_px(layout_box(), CSSPixels());
|
||||
text_rect.translate_by(text_indent.to_int(), 0);
|
||||
|
||||
// Apply button pressed state offset
|
||||
if (being_pressed()) {
|
||||
auto offset = context.rounded_device_pixels(1);
|
||||
text_rect.translate_by(offset, offset);
|
||||
}
|
||||
context.painter().draw_text(
|
||||
|
||||
// Paint button text clipped to button rect
|
||||
auto& painter = context.painter();
|
||||
painter.add_clip_rect(button_rect.to_type<int>());
|
||||
painter.draw_text(
|
||||
text_rect.to_type<int>(),
|
||||
static_cast<HTML::HTMLInputElement const&>(dom_node).value(),
|
||||
FontCache::the().scaled_font(layout_box().font(), context.device_pixels_per_css_pixel()),
|
||||
Gfx::TextAlignment::Center,
|
||||
computed_values().color());
|
||||
painter.clear_clip_rect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue