mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
LibWeb: Compute height of absolutely positioned blocks when possible
Section 10.6.4 rule 5 of the CSS height property spec outlines a method to compute the height of an absolutely positioned block when the 'top' and 'bottom' CSS properties are specified.
This commit is contained in:
parent
03990fcb89
commit
74e9a892e3
Notes:
sideshowbarker
2024-07-18 21:04:03 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/74e9a892e36 Pull-request: https://github.com/SerenityOS/serenity/pull/5965
1 changed files with 10 additions and 0 deletions
|
@ -460,6 +460,8 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
auto& computed_values = box.computed_values();
|
||||
auto& containing_block = *box.containing_block();
|
||||
|
||||
CSS::Length specified_top = computed_values.offset().top.resolved_or_auto(box, containing_block.height());
|
||||
CSS::Length specified_bottom = computed_values.offset().bottom.resolved_or_auto(box, containing_block.height());
|
||||
CSS::Length specified_height;
|
||||
|
||||
if (computed_values.height().is_percentage() && !containing_block.computed_values().height().is_absolute()) {
|
||||
|
@ -477,6 +479,14 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
box.box_model().padding.top = computed_values.padding().top.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||
|
||||
if (specified_height.is_auto() && !specified_top.is_auto() && !specified_bottom.is_auto()) {
|
||||
const auto& margin = box.box_model().margin;
|
||||
const auto& padding = box.box_model().padding;
|
||||
const auto& border = box.box_model().border;
|
||||
|
||||
specified_height = CSS::Length(containing_block.height() - specified_top.to_px(box) - margin.top - padding.top - border.top - specified_bottom.to_px(box) - margin.bottom - padding.bottom - border.bottom, CSS::Length::Type::Px);
|
||||
}
|
||||
|
||||
if (!specified_height.is_auto()) {
|
||||
float used_height = specified_height.to_px(box);
|
||||
if (!specified_max_height.is_auto())
|
||||
|
|
Loading…
Add table
Reference in a new issue