summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorEgor Ananyin <ananinegor@gmail.com>2021-04-29 18:20:56 +0300
committerAndreas Kling <kling@serenityos.org>2021-04-30 15:25:35 +0200
commit3ca6d7dd366ec5a06d43610323d1ea9efe650fd2 (patch)
treed176acf7db6674e101252627b8d304ab1f6b5162 /Userland/Libraries/LibWeb
parent5ae2774018f8d5b8e18fe7d37568fae54477ad3d (diff)
downloadserenity-3ca6d7dd366ec5a06d43610323d1ea9efe650fd2.zip
LibWeb: Use min-height in calculating block box height
Now we use min-height for calculating the height of block boxes. Besides, now we check if min-height/max-height are percentage values and don't use them if parent's height isn't explicitly set (CSS 2.1 section 10.7).
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index 3d782d29b7..a93207c9c0 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -314,26 +314,23 @@ void BlockFormattingContext::compute_height(Box& box)
if (is<ReplacedBox>(box)) {
height = compute_height_for_replaced_element(downcast<ReplacedBox>(box));
} else {
- if (box.computed_values().height().is_undefined_or_auto()) {
+ if (box.computed_values().height().is_undefined_or_auto()
+ || (computed_values.height().is_percentage() && !containing_block.computed_values().height().is_absolute())) {
height = compute_auto_height_for_block_level_element(box);
} else {
- CSS::Length specified_height;
- if (computed_values.height().is_percentage() && !containing_block.computed_values().height().is_absolute()) {
- specified_height = CSS::Length::make_auto();
- } else {
- specified_height = computed_values.height().resolved_or_auto(box, containing_block.height());
- }
-
- auto specified_max_height = computed_values.max_height().resolved_or_auto(box, containing_block.height());
- if (!specified_height.is_auto()) {
- float used_height = specified_height.to_px(box);
- if (!specified_max_height.is_auto())
- used_height = min(used_height, specified_max_height.to_px(box));
- height = used_height;
- }
+ height = computed_values.height().resolved_or_auto(box, containing_block.height()).to_px(box);
}
}
+ auto specified_max_height = computed_values.max_height().resolved_or_auto(box, containing_block.height());
+ if (!specified_max_height.is_auto()
+ && !(computed_values.max_height().is_percentage() && !containing_block.computed_values().height().is_absolute()))
+ height = min(height, specified_max_height.to_px(box));
+ auto specified_min_height = computed_values.min_height().resolved_or_auto(box, containing_block.height());
+ if (!specified_min_height.is_auto()
+ && !(computed_values.min_height().is_percentage() && !containing_block.computed_values().height().is_absolute()))
+ height = max(height, specified_min_height.to_px(box));
+
box.set_height(height);
}