mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibWeb: Move box_baseline from LineBuilder.cpp to LayoutState.cpp
This commit is contained in:
parent
2f38f8c84a
commit
ba64d0462c
Notes:
sideshowbarker
2024-07-17 18:46:57 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/ba64d0462c Pull-request: https://github.com/SerenityOS/serenity/pull/16285
|
@ -97,6 +97,32 @@ void LayoutState::commit()
|
|||
text_node->set_paintable(text_node->create_paintable());
|
||||
}
|
||||
|
||||
float box_baseline(LayoutState 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()) {
|
||||
auto const* child_box = box.last_child_of_type<Box>();
|
||||
VERIFY(child_box);
|
||||
return box_baseline(state, *child_box);
|
||||
}
|
||||
return box_state.border_box_height();
|
||||
}
|
||||
|
||||
Gfx::FloatRect margin_box_rect(Box const& box, LayoutState const& state)
|
||||
{
|
||||
auto const& box_state = state.get(box);
|
||||
|
|
|
@ -184,5 +184,6 @@ Gfx::FloatRect border_box_rect(Box const&, LayoutState const&);
|
|||
Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||
Gfx::FloatRect content_box_rect(Box const&, LayoutState const&);
|
||||
Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||
float box_baseline(LayoutState const& state, Box const& box);
|
||||
|
||||
}
|
||||
|
|
|
@ -141,32 +141,6 @@ bool LineBuilder::should_break(float next_item_width)
|
|||
return (current_line_width + next_item_width) > m_available_width_for_current_line;
|
||||
}
|
||||
|
||||
static float box_baseline(LayoutState 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()) {
|
||||
auto const* child_box = box.last_child_of_type<Box>();
|
||||
VERIFY(child_box);
|
||||
return box_baseline(state, *child_box);
|
||||
}
|
||||
return box_state.border_box_height();
|
||||
}
|
||||
|
||||
void LineBuilder::update_last_line()
|
||||
{
|
||||
m_last_line_needs_update = false;
|
||||
|
|
Loading…
Reference in a new issue