summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-24 22:56:06 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-24 22:57:01 +0100
commit6cffabef03837b52a260508c676566a273c24c69 (patch)
treecff54cccd4e707b995f798491541d0b8ce53447c /Userland/Libraries/LibWeb
parent195ef5e26fc5c38b6a37ec8d0b28ee6fad142fab (diff)
downloadserenity-6cffabef03837b52a260508c676566a273c24c69.zip
LibWeb: Support CSS vertical-align values "top" and "bottom"
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/LineBuilder.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
index b55e0b10d7..9f4e36350a 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
@@ -97,6 +97,19 @@ bool LineBuilder::should_break(LayoutMode layout_mode, float next_item_width, bo
static float box_baseline(FormattingState const& state, Box const& box)
{
auto const& box_state = state.get(box);
+
+ auto const& vertical_align = box.computed_values().vertical_align();
+ if (vertical_align.has<CSS::VerticalAlign>()) {
+ switch (vertical_align.get<CSS::VerticalAlign>()) {
+ case CSS::VerticalAlign::Top:
+ return box_state.border_box_top();
+ case CSS::VerticalAlign::Bottom:
+ return box_state.content_height + box_state.border_box_bottom();
+ default:
+ break;
+ }
+ }
+
if (!box_state.line_boxes.is_empty())
return box_state.border_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline();
if (box.has_children() && !box.children_are_inline()) {
@@ -178,13 +191,15 @@ void LineBuilder::update_last_line()
auto y_value_for_alignment = [&](CSS::VerticalAlign vertical_align) {
switch (vertical_align) {
case CSS::VerticalAlign::Baseline:
- case CSS::VerticalAlign::Bottom:
+ return m_current_y + line_box_baseline - fragment_baseline(fragment) + fragment.border_box_top();
+ case CSS::VerticalAlign::Top:
+ return m_current_y + fragment.border_box_top();
case CSS::VerticalAlign::Middle:
+ case CSS::VerticalAlign::Bottom:
case CSS::VerticalAlign::Sub:
case CSS::VerticalAlign::Super:
case CSS::VerticalAlign::TextBottom:
case CSS::VerticalAlign::TextTop:
- case CSS::VerticalAlign::Top:
// FIXME: These are all 'baseline'
return m_current_y + line_box_baseline - fragment_baseline(fragment) + fragment.border_box_top();
}