mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibWeb: Make sure CSS::ComputedValues has initial size values
Instead of using Optional<LengthPercentage>, we now use LengthPercentage for these values. The initial values are all `auto`. This avoids having to check `has_value()` in a ton of places.
This commit is contained in:
parent
734ff422ad
commit
cefc931347
9 changed files with 81 additions and 86 deletions
|
@ -50,6 +50,12 @@ public:
|
|||
static CSS::LengthBox inset() { return { CSS::Length::make_auto(), CSS::Length::make_auto(), CSS::Length::make_auto(), CSS::Length::make_auto() }; }
|
||||
static CSS::LengthBox margin() { return { CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0) }; }
|
||||
static CSS::LengthBox padding() { return { CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0) }; }
|
||||
static CSS::Length width() { return CSS::Length::make_auto(); }
|
||||
static CSS::Length min_width() { return CSS::Length::make_auto(); }
|
||||
static CSS::Length max_width() { return CSS::Length::make_auto(); }
|
||||
static CSS::Length height() { return CSS::Length::make_auto(); }
|
||||
static CSS::Length min_height() { return CSS::Length::make_auto(); }
|
||||
static CSS::Length max_height() { return CSS::Length::make_auto(); }
|
||||
};
|
||||
|
||||
struct BackgroundLayerData {
|
||||
|
@ -150,12 +156,12 @@ public:
|
|||
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
|
||||
Vector<ShadowData> const& box_shadow() const { return m_noninherited.box_shadow; }
|
||||
CSS::BoxSizing box_sizing() const { return m_noninherited.box_sizing; }
|
||||
Optional<CSS::LengthPercentage> const& width() const { return m_noninherited.width; }
|
||||
Optional<CSS::LengthPercentage> const& min_width() const { return m_noninherited.min_width; }
|
||||
Optional<CSS::LengthPercentage> const& max_width() const { return m_noninherited.max_width; }
|
||||
Optional<CSS::LengthPercentage> const& height() const { return m_noninherited.height; }
|
||||
Optional<CSS::LengthPercentage> const& min_height() const { return m_noninherited.min_height; }
|
||||
Optional<CSS::LengthPercentage> const& max_height() const { return m_noninherited.max_height; }
|
||||
CSS::LengthPercentage const& width() const { return m_noninherited.width; }
|
||||
CSS::LengthPercentage const& min_width() const { return m_noninherited.min_width; }
|
||||
CSS::LengthPercentage const& max_width() const { return m_noninherited.max_width; }
|
||||
CSS::LengthPercentage const& height() const { return m_noninherited.height; }
|
||||
CSS::LengthPercentage const& min_height() const { return m_noninherited.min_height; }
|
||||
CSS::LengthPercentage const& max_height() const { return m_noninherited.max_height; }
|
||||
Variant<CSS::VerticalAlign, CSS::LengthPercentage> const& vertical_align() const { return m_noninherited.vertical_align; }
|
||||
|
||||
CSS::LengthBox const& inset() const { return m_noninherited.inset; }
|
||||
|
@ -232,12 +238,12 @@ protected:
|
|||
Color text_decoration_color { InitialValues::color() };
|
||||
Vector<ShadowData> text_shadow {};
|
||||
CSS::Position position { InitialValues::position() };
|
||||
Optional<CSS::LengthPercentage> width;
|
||||
Optional<CSS::LengthPercentage> min_width;
|
||||
Optional<CSS::LengthPercentage> max_width;
|
||||
Optional<CSS::LengthPercentage> height;
|
||||
Optional<CSS::LengthPercentage> min_height;
|
||||
Optional<CSS::LengthPercentage> max_height;
|
||||
CSS::LengthPercentage width { InitialValues::width() };
|
||||
CSS::LengthPercentage min_width { InitialValues::min_width() };
|
||||
CSS::LengthPercentage max_width { InitialValues::max_width() };
|
||||
CSS::LengthPercentage height { InitialValues::height() };
|
||||
CSS::LengthPercentage min_height { InitialValues::min_height() };
|
||||
CSS::LengthPercentage max_height { InitialValues::max_height() };
|
||||
CSS::LengthBox inset { InitialValues::inset() };
|
||||
CSS::LengthBox margin { InitialValues::margin() };
|
||||
CSS::LengthBox padding { InitialValues::padding() };
|
||||
|
|
|
@ -205,25 +205,17 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
|
|||
return StyleValueList::create(move(box_shadow), StyleValueList::Separator::Comma);
|
||||
}
|
||||
case CSS::PropertyID::Width:
|
||||
return style_value_for_length_percentage(layout_node.computed_values().width().value_or(Length::make_auto()));
|
||||
return style_value_for_length_percentage(layout_node.computed_values().width());
|
||||
case CSS::PropertyID::MinWidth:
|
||||
if (!layout_node.computed_values().min_width().has_value())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::Auto);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_width().value());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_width());
|
||||
case CSS::PropertyID::MaxWidth:
|
||||
if (!layout_node.computed_values().max_width().has_value())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::None);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_width().value());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_width());
|
||||
case CSS::PropertyID::Height:
|
||||
return style_value_for_length_percentage(layout_node.computed_values().height().value_or(Length::make_auto()));
|
||||
return style_value_for_length_percentage(layout_node.computed_values().height());
|
||||
case CSS::PropertyID::MinHeight:
|
||||
if (!layout_node.computed_values().min_height().has_value())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::Auto);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_height().value());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_height());
|
||||
case CSS::PropertyID::MaxHeight:
|
||||
if (!layout_node.computed_values().max_height().has_value())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::None);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_height().value());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_height());
|
||||
case CSS::PropertyID::Margin: {
|
||||
auto margin = layout_node.computed_values().margin();
|
||||
auto values = NonnullRefPtrVector<StyleValue> {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue