瀏覽代碼

LibWeb: Treat unresolvable percentage width on inline-block as auto

Andreas Kling 2 年之前
父節點
當前提交
e3b8a8f7c8

+ 21 - 0
Base/res/html/tests/inline-block-treat-100pct-width-as-auto.html

@@ -0,0 +1,21 @@
+
+<!DOCTYPE html><html><head><style>
+      * {
+        border: 1px solid black !important;
+      }
+      .outer {
+        float: left;
+        background: pink;
+      }
+      .first {
+        display: inline-block;
+        width: 100%;
+        background: orange;
+      }
+      .second {
+        width: 50px;
+        height: 50px;
+        background: magenta;
+      }
+    </style>
+  </head><body><div class="outer"><div class="first">programming</div><div class="second"></div>

+ 1 - 1
Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp

@@ -127,7 +127,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l
 
     auto const& width_value = box.computed_values().width();
     float unconstrained_width = 0;
-    if (width_value.is_auto()) {
+    if (should_treat_width_as_auto(box, *m_available_space)) {
         auto result = calculate_shrink_to_fit_widths(box);
 
         auto available_width = m_available_space->width.to_px()