diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-29 22:33:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-30 01:12:44 +0200 |
commit | 6a4247bee9fb3bb2788934f1b322a4d1cce18c6c (patch) | |
tree | b2774a9acac7444488bb0d0f6be0310e9c4b3c73 /Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | |
parent | fae8fde913622192143cff59646c1c45dd60fee1 (diff) | |
download | serenity-6a4247bee9fb3bb2788934f1b322a4d1cce18c6c.zip |
LibWeb: Use more precise font metrics when doing inline layout
We now position inline-level boxes based on ascent and descent metrics
from the font in use. This makes our basic text layouts look a lot more
like those produced by other browsers. :^)
I've tried to match the terminology used by the CSS Inline Layout spec.
This will regress Acid2 a little bit, and probably various other sites,
but on the whole it's the direction we should be heading, so let's go.
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting/PaintableBox.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 2225cbf553..12bfabb273 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -451,8 +451,13 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const for (auto& line_box : m_line_boxes) { for (auto& fragment : line_box.fragments()) { - if (context.should_show_line_box_borders()) - context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green); + if (context.should_show_line_box_borders()) { + auto fragment_absolute_rect = fragment.absolute_rect(); + context.painter().draw_rect(enclosing_int_rect(fragment_absolute_rect), Color::Green); + context.painter().draw_line( + fragment_absolute_rect.top_left().translated(0, fragment.baseline()).to_rounded<int>(), + fragment_absolute_rect.top_right().translated(0, fragment.baseline()).to_rounded<int>(), Color::Red); + } if (is<Layout::TextNode>(fragment.layout_node())) paint_text_fragment(context, static_cast<Layout::TextNode const&>(fragment.layout_node()), fragment, phase); } |