Skip to content

Commit f9b4fa9

Browse files
committed
LibWeb: Add CSS::Size::is_intrinsic_sizing_constraint()
1 parent 8d81421 commit f9b4fa9

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

Libraries/LibWeb/CSS/Size.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Size {
4747
bool is_none() const { return m_type == Type::None; }
4848
Type type() const { return m_type; }
4949

50+
bool is_intrinsic_sizing_constraint() const { return is_min_content() || is_max_content() || is_fit_content(); }
5051
bool is_length_percentage() const { return is_length() || is_percentage() || is_calculated(); }
5152

5253
[[nodiscard]] CSSPixels to_px(Layout::Node const&, CSSPixels reference_value) const;

Libraries/LibWeb/Layout/FlexFormattingContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ void FlexFormattingContext::determine_flex_base_size(FlexItem& item)
618618
if (!flex_basis.has<CSS::Size>())
619619
return false;
620620
auto const& size = flex_basis.get<CSS::Size>();
621-
if (size.is_auto() || size.is_min_content() || size.is_max_content() || size.is_fit_content())
621+
if (size.is_auto() || size.is_intrinsic_sizing_constraint())
622622
return false;
623623
if (size.is_length())
624624
return true;

Libraries/LibWeb/Layout/FormattingContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,8 +1711,7 @@ bool FormattingContext::should_treat_width_as_auto(Box const& box, AvailableSpac
17111711
return true;
17121712
}
17131713
// AD-HOC: If the box has a preferred aspect ratio and an intrinsic keyword for width...
1714-
if (box.has_preferred_aspect_ratio()
1715-
&& (computed_width.is_min_content() || computed_width.is_max_content() || computed_width.is_fit_content())) {
1714+
if (box.has_preferred_aspect_ratio() && computed_width.is_intrinsic_sizing_constraint()) {
17161715
// If the box has no natural height to resolve the aspect ratio, we treat the width as auto.
17171716
if (!box.has_natural_height())
17181717
return true;
@@ -1744,8 +1743,7 @@ bool FormattingContext::should_treat_height_as_auto(Box const& box, AvailableSpa
17441743
}
17451744

17461745
// AD-HOC: If the box has a preferred aspect ratio and an intrinsic keyword for height...
1747-
if (box.has_preferred_aspect_ratio()
1748-
&& (computed_height.is_min_content() || computed_height.is_max_content() || computed_height.is_fit_content())) {
1746+
if (box.has_preferred_aspect_ratio() && computed_height.is_intrinsic_sizing_constraint()) {
17491747
// If the box has no natural width to resolve the aspect ratio, we treat the height as auto.
17501748
if (!box.has_natural_width())
17511749
return true;

0 commit comments

Comments
 (0)