Browse Source

LibWeb: Small fix to height computation for block-with-inline-children

We now compute the used height of height:auto by measuring from the top
content edge (y=0) to the bottom of the bottommost line box within the
block container.

This fixes an issue where we'd fail to account for the topmost line box
being taller than any of its fragments (which can happen if the
line-height is greater than the height of all fragments on the line.)
Andreas Kling 3 years ago
parent
commit
37f0bd0a42
1 changed files with 2 additions and 5 deletions
  1. 2 5
      Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

+ 2 - 5
Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

@@ -194,13 +194,10 @@ float FormattingContext::compute_auto_height_for_block_level_element(Box const&
 
 
     if (box.children_are_inline()) {
     if (box.children_are_inline()) {
         // If it only has inline-level children, the height is the distance between
         // If it only has inline-level children, the height is the distance between
-        // the top of the topmost line box and the bottom of the bottommost line box.
+        // the top content edge and the bottom of the bottommost line box.
         auto& block_container = verify_cast<BlockContainer>(box);
         auto& block_container = verify_cast<BlockContainer>(box);
+        top = 0;
         if (!block_container.line_boxes().is_empty()) {
         if (!block_container.line_boxes().is_empty()) {
-            for (auto& fragment : block_container.line_boxes().first().fragments()) {
-                if (!top.has_value() || fragment.offset().y() < top.value())
-                    top = fragment.offset().y();
-            }
             for (auto& fragment : block_container.line_boxes().last().fragments()) {
             for (auto& fragment : block_container.line_boxes().last().fragments()) {
                 if (!bottom.has_value() || (fragment.offset().y() + fragment.height()) > bottom.value())
                 if (!bottom.has_value() || (fragment.offset().y() + fragment.height()) > bottom.value())
                     bottom = fragment.offset().y() + fragment.height();
                     bottom = fragment.offset().y() + fragment.height();