mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Remove absolute positioning logic from LayoutReplaced
Absolutely positioned elements are placed by their containing block. Instead of trying to compute its own position, LayoutReplaced will now simply add itself as an absolutely positioned descendant of its containing block.
This commit is contained in:
parent
137f6d44ec
commit
f3ea8d49a9
Notes:
sideshowbarker
2024-07-19 05:42:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f3ea8d49a9e
1 changed files with 6 additions and 8 deletions
|
@ -123,17 +123,11 @@ float LayoutReplaced::calculate_height() const
|
|||
|
||||
Gfx::FloatPoint LayoutReplaced::calculate_position()
|
||||
{
|
||||
ASSERT(!is_absolutely_positioned());
|
||||
auto& style = this->style();
|
||||
auto zero_value = Length(0, Length::Type::Px);
|
||||
auto& containing_block = *this->containing_block();
|
||||
|
||||
if (style.position() == CSS::Position::Absolute) {
|
||||
box_model().offset().top = style.length_or_fallback(CSS::PropertyID::Top, zero_value, containing_block.height());
|
||||
box_model().offset().right = style.length_or_fallback(CSS::PropertyID::Right, zero_value, containing_block.width());
|
||||
box_model().offset().bottom = style.length_or_fallback(CSS::PropertyID::Bottom, zero_value, containing_block.height());
|
||||
box_model().offset().left = style.length_or_fallback(CSS::PropertyID::Left, zero_value, containing_block.width());
|
||||
}
|
||||
|
||||
box_model().margin().top = style.length_or_fallback(CSS::PropertyID::MarginTop, zero_value, containing_block.width());
|
||||
box_model().margin().bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, zero_value, containing_block.width());
|
||||
box_model().border().top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, zero_value);
|
||||
|
@ -158,7 +152,11 @@ void LayoutReplaced::layout(LayoutMode layout_mode)
|
|||
|
||||
LayoutBox::layout(layout_mode);
|
||||
|
||||
set_offset(calculate_position());
|
||||
if (is_absolutely_positioned()) {
|
||||
const_cast<LayoutBlock*>(containing_block())->add_absolutely_positioned_descendant(*this);
|
||||
} else {
|
||||
set_offset(calculate_position());
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutReplaced::split_into_lines(LayoutBlock& container, LayoutMode layout_mode)
|
||||
|
|
Loading…
Add table
Reference in a new issue