Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/CSS/ComputedValues.h (C/C++)

Code before:
    };
    using WillChangeEntry = Variant<Type, PropertyID>;

    WillChange(Vector<WillChangeEntry> values)
        : m_value(move(values))
    {
    }

    static WillChange make_auto() { return WillChange(); }

    bool is_auto() const { return m_value.is_empty(); }
    bool has_contents() const { return m_value.contains_slow(Type::Contents); }
    bool has_scroll_position() const { return m_value.contains_slow(Type::ScrollPosition); }
    bool has_property(PropertyID property_id) const { return m_value.contains_slow(property_id); }

private:
    WillChange()
    {
    }

    Vector<WillChangeEntry> m_value;
};

using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, CursorPredefined>;

using ListStyleType = Variant<Empty, Optional<CounterStyle>, String>;

class InitialValues {
public:
    static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; }
    static CSSPixels font_size() { return 16; }
    static double font_weight() { return 400; }
    static CSSPixels line_height() { return 0; }
    static Float float_() { return Float::None; }
    static Length border_spacing() { return Length::make_px(0); }
    static CaptionSide caption_side() { return CaptionSide::Top; }
    static Color caret_color() { return Color::Black; }
    static Clear clear() { return Clear::None; }
    static Clip clip() { return Clip::make_auto(); }
    static ColorInterpolation color_interpolation() { return ColorInterpolation::Auto; }
    static PreferredColorScheme color_scheme() { return PreferredColorScheme::Auto; }
    static ContentVisibility content_visibility() { return ContentVisibility::Visible; }
    static CursorData cursor() { return { CursorPredefined::Auto }; }
    static WhiteSpaceCollapse white_space_collapse() { return WhiteSpaceCollapse::Collapse; }
    static WordBreak word_break() { return WordBreak::Normal; }
    static CSSPixels word_spacing() { return 0; }
    static CSSPixels letter_spacing() { return 0; }
    static Variant<Length, double> tab_size() { return 8; }
    static TextAlign text_align() { return TextAlign::Start; }
    static TextJustify text_justify() { return TextJustify::Auto; }
    static Positioning position() { return Positioning::Static; }

Review comment (suggestion):
Having to store a full copy of the counter-style on every ComputedValues is pretty unfortunate, especially as the majority of those are an unused copy of `disc`. Maybe locally-defined ones could be stored as an OwnPtr or similar? (Or even better RefPtr if we can share the same one between ComputedValues from the same source declaration.)

Code after:
    };
    using WillChangeEntry = Variant<Type, PropertyID>;

    WillChange(Vector<WillChangeEntry> values)
        : m_value(move(values))
    {
    }

    static WillChange make_auto() { return WillChange(); }

    bool is_auto() const { return m_value.is_empty(); }
    bool has_contents() const { return m_value.contains_slow(Type::Contents); }
    bool has_scroll_position() const { return m_value.contains_slow(Type::ScrollPosition); }
    bool has_property(PropertyID property_id) const { return m_value.contains_slow(property_id); }

private:
    WillChange()
    {
    }

    Vector<WillChangeEntry> m_value;
};

using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, CursorPredefined>;

using ListStyleType = Variant<Empty, RefPtr<CounterStyle const>, String>;

class InitialValues {
public:
    static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; }
    static CSSPixels font_size() { return 16; }
    static double font_weight() { return 400; }
    static CSSPixels line_height() { return 0; }
    static Float float_() { return Float::None; }
    static Length border_spacing() { return Length::make_px(0); }
    static CaptionSide caption_side() { return CaptionSide::Top; }
    static Color caret_color() { return Color::Black; }
    static Clear clear() { return Clear::None; }
    static Clip clip() { return Clip::make_auto(); }
    static ColorInterpolation color_interpolation() { return ColorInterpolation::Auto; }
    static PreferredColorScheme color_scheme() { return PreferredColorScheme::Auto; }
    static ContentVisibility content_visibility() { return ContentVisibility::Visible; }
    static CursorData cursor() { return { CursorPredefined::Auto }; }
    static WhiteSpaceCollapse white_space_collapse() { return WhiteSpaceCollapse::Collapse; }
    static WordBreak word_break() { return WordBreak::Normal; }
    static CSSPixels word_spacing() { return 0; }
    static CSSPixels letter_spacing() { return 0; }
    static Variant<Length, double> tab_size() { return 8; }
    static TextAlign text_align() { return TextAlign::Start; }
    static TextJustify text_justify() { return TextJustify::Auto; }
    static Positioning position() { return Positioning::Static; }