Truly independent web browser
LibWeb: Remove dead and duplicated style code from C++
Andreas Klinge2691c33772f
diff --git a/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.cpp b/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.cppindex cb20930da1a..544d4157a2d 100644--- a/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.cpp+++ b/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.cpp@@ -177,16 +177,6 @@ StyleValue const& AnimatedProperties::property(PropertyID property_id) constreturn *wrapper;}-void AnimatedProperties::set_property(PropertyID id, NonnullRefPtr<StyleValue const> value, AnimatedPropertyResultOfTransition animated_property_result_of_transition, ComputedStyleWorkingSet::Inherited inherited)-{- VERIFY(id >= first_longhand_property_id && id <= last_longhand_property_id);-- ComputedValuesFFI::rust_animated_overlay_set(m_overlay, to_underlying(id), value->rust_style_value_data(),- inherited == ComputedStyleWorkingSet::Inherited::Yes,- animated_property_result_of_transition == AnimatedPropertyResultOfTransition::Yes);- m_wrapper_cache.set(id, move(value));-}-RefPtr<AnimatedProperties const> ComputedStyleWorkingSet::animated_properties_snapshot() const{return m_animated_properties;diff --git a/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.h b/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.hindex da209b9f3f1..0c3d192189b 100644--- a/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.h+++ b/Libraries/LibWeb/CSS/ComputedStyleWorkingSet.h@@ -33,11 +33,6 @@ class StyleComputer;namespace Web::CSS {-enum class AnimatedPropertyResultOfTransition : u8 {- No,- Yes-};-// What the host computes an element's style update in on the main thread, as an animation or// transition update or the document's own style does: the style record whose longhands it reads,// what it settles beside them, plus the genuinely-C++ residue no record can carry - the sparse@@ -50,11 +45,6 @@ public:Yes,};- enum class Inherited {- No,- Yes- };-static NonnullRefPtr<ComputedStyleWorkingSet> create_over_record(StyleRecordRef);static NonnullRefPtr<ComputedStyleWorkingSet> create_with_base_values_from(ComputedValues const&);static NonnullRefPtr<ComputedStyleWorkingSet> create_for_animation_update(void const* record, ComputedValuesFFI::AnimatedOverlay const*);@@ -170,7 +160,6 @@ public:bool has_property(PropertyID property_id) const { return entry(property_id); }StyleValue const& property(PropertyID) const;- void set_property(PropertyID, NonnullRefPtr<StyleValue const>, AnimatedPropertyResultOfTransition, ComputedStyleWorkingSet::Inherited);void clear_wrapper_cache() { m_wrapper_cache.clear(); }private:diff --git a/Libraries/LibWeb/CSS/ComputedValues.cpp b/Libraries/LibWeb/CSS/ComputedValues.cppindex 07128b8f944..3555c0f263b 100644--- a/Libraries/LibWeb/CSS/ComputedValues.cpp+++ b/Libraries/LibWeb/CSS/ComputedValues.cpp@@ -113,10 +113,6 @@ static_assert(sizeof(ComputedValues::MiscInteractionValues) == sizeof(ComputedVastatic_assert(alignof(ComputedValues::MiscInteractionValues) == alignof(ComputedValuesFFI::MiscInteractionValues));static_assert(to_underlying(ListStylePosition::Outside) == 1);-static_assert(sizeof(TextIndentData) == sizeof(ComputedValuesFFI::ComputedTextIndent));-static_assert(offsetof(TextIndentData, length_percentage) == offsetof(ComputedValuesFFI::ComputedTextIndent, length_percentage));-static_assert(offsetof(TextIndentData, each_line) == offsetof(ComputedValuesFFI::ComputedTextIndent, each_line));-static_assert(offsetof(TextIndentData, hanging) == offsetof(ComputedValuesFFI::ComputedTextIndent, hanging));static_assert(sizeof(ComputedValues::InheritedTextValues) == sizeof(ComputedValuesFFI::InheritedTextValues));static_assert(alignof(ComputedValues::InheritedTextValues) == alignof(ComputedValuesFFI::InheritedTextValues));static_assert(sizeof(ComputedValues::AnimationValues) == sizeof(ComputedValuesFFI::AnimationValues));@@ -418,9 +414,21 @@ bool ComputedValues::is_property_important(PropertyID property_id) constreturn ComputedValuesFFI::rust_style_record_importance_bits(m_record.get())[index / 8] & (1 << (index % 8));}-void ComputedValues::Mutator::set_animated_properties(AnimatedProperties const* value)+NonnullRefPtr<ComputedValues const> ComputedValues::clone() const{- m_values.m_animated_properties = value;+ auto copy = adopt_ref(*new ComputedValues);+ copy->m_inherited = m_inherited;+ copy->m_noninherited = m_noninherited;+ copy->m_record = m_record;+ if (m_borrowed_base_values)+ copy->m_base_values = m_borrowed_base_values->clone();+ else+ copy->m_base_values = m_base_values;+ copy->m_animated_properties = m_animated_properties;+ copy->m_depends_on_viewport_metrics = m_depends_on_viewport_metrics;+ copy->m_font_metrics_depend_on_viewport_metrics = m_font_metrics_depend_on_viewport_metrics;+ copy->m_in_display_none_subtree = m_in_display_none_subtree;+ return copy;}RefPtr<StyleValue const> ComputedValues::style_value_from_handle(PropertyID property_id, RustStyleValueHandle const& handle) constdiff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.hindex cfc31dc14ce..1d885126f2c 100644--- a/Libraries/LibWeb/CSS/ComputedValues.h+++ b/Libraries/LibWeb/CSS/ComputedValues.h@@ -96,63 +96,6 @@ class ComputedStyleRecordView;class StyleComputer;class StyleScope;-using ClipRule = FillRule;--struct AspectRatio {- bool use_natural_aspect_ratio_if_available;- Optional<Ratio> preferred_ratio;- bool computed_use_natural_aspect_ratio_if_available;- Optional<Ratio> computed_ratio;-- bool operator==(AspectRatio const& other) const- {- // NB: Ratio's own equality is proportional (1 / 2 equals 0.5 / 1), but these ratios are- // observable through serialization, so compare the components exactly.- auto ratios_identical = [](Optional<Ratio> const& a, Optional<Ratio> const& b) {- if (a.has_value() != b.has_value())- return false;- if (!a.has_value())- return true;- return a->numerator() == b->numerator() && a->denominator() == b->denominator();- };- return use_natural_aspect_ratio_if_available == other.use_natural_aspect_ratio_if_available- && computed_use_natural_aspect_ratio_if_available == other.computed_use_natural_aspect_ratio_if_available- && ratios_identical(preferred_ratio, other.preferred_ratio)- && ratios_identical(computed_ratio, other.computed_ratio);- }-};--struct GridAutoFlow {- bool row { true };- bool dense { false };-- bool operator==(GridAutoFlow const&) const = default;-};--struct NormalGap {- bool operator==(NormalGap const&) const = default;-};--struct Position {- PositionEdge edge_x { PositionEdge::Left };- LengthPercentage offset_x { Percentage(50) };- PositionEdge edge_y { PositionEdge::Top };- LengthPercentage offset_y { Percentage(50) };-- bool operator==(Position const&) const = default;-- CSSPixelPoint resolved(CSSPixelRect const& rect) const- {- CSSPixels x = offset_x.to_px(rect.width());- CSSPixels y = offset_y.to_px(rect.height());- if (edge_x == PositionEdge::Right)- x = rect.width() - x;- if (edge_y == PositionEdge::Bottom)- y = rect.height() - y;- return CSSPixelPoint { rect.x() + x, rect.y() + y };- }-};-// https://drafts.csswg.org/css-contain-2/#containment-typesstruct Containment {bool size_containment : 1 { false };@@ -176,29 +119,6 @@ struct ContainerType {bool is_empty() const { return !(is_size_container || is_inline_size_container || is_scroll_state_container); }};-struct ScrollbarColorData {- Color thumb_color { Color::Transparent };- Color track_color { Color::Transparent };- bool is_auto { true };-- bool operator==(ScrollbarColorData const&) const = default;-};--struct TextIndentData {- LengthPercentage length_percentage;- bool each_line { false };- bool hanging { false };-- bool operator==(TextIndentData const&) const = default;-};--struct TextUnderlinePosition {- TextUnderlinePositionHorizontal horizontal { TextUnderlinePositionHorizontal::Auto };- TextUnderlinePositionVertical vertical { TextUnderlinePositionVertical::Auto };-- bool operator==(TextUnderlinePosition const&) const = default;-};-class InitialValues {public:static CSSPixels font_size() { return 16; }@@ -235,7 +155,7 @@ struct TransformOrigin {bool operator==(TransformOrigin const&) const = default;};-// One computed shadow layer, whose color may be `currentcolor`, which `resolved_color()` resolves.+// One computed shadow layer, whose color may be `currentcolor`.struct ShadowData {CSSPixels offset_x { 0 };CSSPixels offset_y { 0 };@@ -244,8 +164,6 @@ struct ShadowData {ComputedValuesFFI::StyleColor color {};ColorSyntax color_syntax { ColorSyntax::Legacy };ShadowPlacement placement { ShadowPlacement::Outer };-- Color resolved_color(Color current_color) const { return resolve_style_color(color, current_color); }};// FIXME: Find a better place for this helper.@@ -394,48 +312,11 @@ inline u8 reset_bits_field(ComputedValuesFFI::ResetBits bits, u32 shift, u32 wid}inline Float float_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<Float>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_FLOAT_SHIFT, ComputedValuesFFI::RESET_BITS_FLOAT_WIDTH)); }-inline Clear clear_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<Clear>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_CLEAR_SHIFT, ComputedValuesFFI::RESET_BITS_CLEAR_WIDTH)); }inline Positioning position_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<Positioning>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_POSITION_SHIFT, ComputedValuesFFI::RESET_BITS_POSITION_WIDTH)); }inline Overflow overflow_x_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<Overflow>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_OVERFLOW_X_SHIFT, ComputedValuesFFI::RESET_BITS_OVERFLOW_X_WIDTH)); }inline Overflow overflow_y_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<Overflow>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_OVERFLOW_Y_SHIFT, ComputedValuesFFI::RESET_BITS_OVERFLOW_Y_WIDTH)); }inline BoxSizing box_sizing_from_reset_bits(ComputedValuesFFI::ResetBits bits) { return static_cast<BoxSizing>(reset_bits_field(bits, ComputedValuesFFI::RESET_BITS_BOX_SIZING_SHIFT, ComputedValuesFFI::RESET_BITS_BOX_SIZING_WIDTH)); }-// The reset bits of the initial style.-constexpr ComputedValuesFFI::ResetBits initial_reset_bits()-{- return static_cast<ComputedValuesFFI::ResetBits>(- (static_cast<u32>(to_underlying(Positioning::Static)) << ComputedValuesFFI::RESET_BITS_POSITION_SHIFT)- | (static_cast<u32>(to_underlying(Float::None)) << ComputedValuesFFI::RESET_BITS_FLOAT_SHIFT)- | (static_cast<u32>(to_underlying(Clear::None)) << ComputedValuesFFI::RESET_BITS_CLEAR_SHIFT)- | (static_cast<u32>(to_underlying(Overflow::Visible)) << ComputedValuesFFI::RESET_BITS_OVERFLOW_X_SHIFT)- | (static_cast<u32>(to_underlying(Overflow::Visible)) << ComputedValuesFFI::RESET_BITS_OVERFLOW_Y_SHIFT)- | (static_cast<u32>(to_underlying(BoxSizing::ContentBox)) << ComputedValuesFFI::RESET_BITS_BOX_SIZING_SHIFT)- | (static_cast<u32>(to_underlying(UnicodeBidi::Normal)) << ComputedValuesFFI::RESET_BITS_UNICODE_BIDI_SHIFT)- | (static_cast<u32>(to_underlying(TableLayout::Auto)) << ComputedValuesFFI::RESET_BITS_TABLE_LAYOUT_SHIFT));-}--// What the inherited set of the initial style holds beside its groups.-constexpr ComputedValuesFFI::InheritedSetValues initial_inherited_set_values()-{- return {- .bits = static_cast<ComputedValuesFFI::InheritedBits>(- (static_cast<u32>(to_underlying(WritingMode::HorizontalTb)) << ComputedValuesFFI::INHERITED_BITS_WRITING_MODE_SHIFT)- | (static_cast<u32>(to_underlying(Direction::Ltr)) << ComputedValuesFFI::INHERITED_BITS_DIRECTION_SHIFT)- | (static_cast<u32>(to_underlying(Visibility::Visible)) << ComputedValuesFFI::INHERITED_BITS_VISIBILITY_SHIFT)- | (static_cast<u32>(to_underlying(TextOrientation::Mixed)) << ComputedValuesFFI::INHERITED_BITS_TEXT_ORIENTATION_SHIFT)- | (static_cast<u32>(to_underlying(PointerEvents::Auto)) << ComputedValuesFFI::INHERITED_BITS_POINTER_EVENTS_SHIFT)- | (static_cast<u32>(to_underlying(ListStylePosition::Outside)) << ComputedValuesFFI::INHERITED_BITS_LIST_STYLE_POSITION_SHIFT)- | (static_cast<u32>(to_underlying(BorderCollapse::Separate)) << ComputedValuesFFI::INHERITED_BITS_BORDER_COLLAPSE_SHIFT)- | (static_cast<u32>(to_underlying(CaptionSide::Top)) << ComputedValuesFFI::INHERITED_BITS_CAPTION_SIDE_SHIFT)- | (static_cast<u32>(to_underlying(EmptyCells::Show)) << ComputedValuesFFI::INHERITED_BITS_EMPTY_CELLS_SHIFT)- | (static_cast<u32>(to_underlying(TextAlign::Start)) << ComputedValuesFFI::INHERITED_BITS_TEXT_ALIGN_SHIFT)- | (static_cast<u32>(to_underlying(WhiteSpaceCollapse::Collapse)) << ComputedValuesFFI::INHERITED_BITS_WHITE_SPACE_COLLAPSE_SHIFT)- | (static_cast<u32>(to_underlying(TextWrapMode::Wrap)) << ComputedValuesFFI::INHERITED_BITS_TEXT_WRAP_MODE_SHIFT)- | (static_cast<u32>(to_underlying(WordBreak::Normal)) << ComputedValuesFFI::INHERITED_BITS_WORD_BREAK_SHIFT)),- .effective_zoom_bits = bit_cast<u32>(1.0f),- };-}-// One counted reference to a style record, or none.class StyleRecordRef {public:@@ -483,16 +364,11 @@ class WEB_API ComputedValues final : public RefCounted<ComputedValues> {AK_MAKE_NONMOVABLE(ComputedValues);public:- class Builder;- class Mutator;-enum class WithAnimationsApplied {No,Yes,};- static constexpr u32 all_style_groups = (1u << to_underlying(StyleGroupIndex::Count)) - 1;-RefPtr<StyleValue const> computed_style_value(PropertyID, WithAnimationsApplied = WithAnimationsApplied::Yes) const;// The stored Rust style value that IS the property's computed value, for the properties that@@ -539,18 +415,17 @@ public:~ComputedValues();-private:-public:+ // A copy of this style that owns references to its groups, so that it outlives the record view it was read from.+ NonnullRefPtr<ComputedValues const> clone() const;+ReadonlySpan<Utf16FlyString> anchor_names() const { return m_noninherited.anchor->anchor_names_span(); }// The animation-name entries other than none.Float float_() const { return float_from_reset_bits(m_noninherited.reset_bits); }- Clear clear() const { return clear_from_reset_bits(m_noninherited.reset_bits); }// https://drafts.csswg.org/css-ui-4/#caret-color// auto: "User agents should use currentColor." It computes to auto, so the element's own color is read here.Color caret_color() const { return m_inherited.ui->caret_color_value(color()); }ColorInterpolation color_interpolation() const { return m_inherited.svg->color_interpolation_value(); }- FillRule fill_rule() const { return m_inherited.svg->fill_rule_value(); }PreferredColorScheme color_scheme() const { return m_inherited.ui->color_scheme_value(); }ContentVisibility content_visibility() const { return static_cast<ContentVisibility>(m_noninherited.misc_layout->content_visibility); }ReadonlySpan<ComputedValuesFFI::ComputedCursor> cursor() const { return m_inherited.ui->cursor_span(); }@@ -561,7 +436,6 @@ public:bool content_uses_list_item_counter() const { return generated_content_facts() & ComputedValuesFFI::GENERATED_CONTENT_SHOWS_LIST_ITEM_COUNTER; }Display display() const { return display_from_ffi_display(m_noninherited.box->display); }Display display_before_box_type_transformation() const { return display_from_ffi_display(m_noninherited.box->display_before_box_type_transformation); }- Color text_decoration_color() const { return resolve_style_color(m_noninherited.text_reset->text_decoration_color, color()); }ReadonlySpan<ShadowData> text_shadow() const { return m_inherited.text->text_shadow_span(); }Positioning position() const { return position_from_reset_bits(m_noninherited.reset_bits); }Appearance appearance() const { return static_cast<Appearance>(m_noninherited.misc_layout->appearance); }@@ -569,7 +443,6 @@ public:Visibility visibility() const { return visibility_from_inherited_bits(m_inherited.values.bits); }ComputedFilterView backdrop_filter() const { return m_noninherited.effects->backdrop_filter_value(); }ComputedFilterView filter() const { return m_noninherited.effects->filter_value(); }- ReadonlySpan<ShadowData> box_shadow() const { return m_noninherited.effects->box_shadow_span(); }ComputedValuesFFI::ComputedSize const& width() const { return m_noninherited.sizing->width; }ComputedValuesFFI::ComputedSize const& height() const { return m_noninherited.sizing->height; }Direction direction() const { return direction_from_inherited_bits(m_inherited.values.bits); }@@ -599,7 +472,6 @@ public:static_assert(sizeof(RustStyleValueHandle) == sizeof(*handle));return style_value_from_handle(property_id, reinterpret_cast<RustStyleValueHandle const&>(*handle));}- LengthBox margin() const { return length_box(m_noninherited.surround->margin); }LengthBox scroll_margin() const { return length_box(m_noninherited.misc_interaction->scroll_margin); }BorderData border_left() const { return m_noninherited.border->border_left_value(color()); }@@ -615,8 +487,6 @@ public:Color background_color() const { return m_noninherited.background->background_color_value(color()); }RefPtr<StyleValue const> background_color_style_value() const;- Color webkit_text_fill_color() const { return m_inherited.text->webkit_text_fill_color_value(); }-void const* list_style_type_data() const { return m_inherited.list_table->list_style_type.pointer; }RefPtr<AbstractImageStyleValue const> list_style_image() const { return m_inherited.list_table->list_style_image_value(); }// Whether this style reads its tree scope's counter-style registry, which a pseudo-element's does for any named@@ -650,8 +520,6 @@ public:double font_weight() const { return m_inherited.font->font_weight; }CSSPixels line_height() const { return m_inherited.font->line_height_used_value(); }- Color outline_color() const { return resolve_style_color(m_noninherited.misc_layout->outline_color, color()); }- Color column_rule_color() const { return resolve_style_color(m_noninherited.misc_layout->column_rule_color, color()); }OutlineStyle outline_style() const { return static_cast<OutlineStyle>(m_noninherited.misc_layout->outline_style); }int math_depth() const { return m_inherited.font->math_depth; }@@ -714,15 +582,6 @@ public:struct InheritedListTableValues : ComputedValuesFFI::InheritedListTableValues {static constexpr size_t style_group_index = to_underlying(StyleGroupIndex::InheritedListTableValues);- bool operator==(InheritedListTableValues const& other) const- {- return list_style_type.pointer == other.list_style_type.pointer- && list_style_image.pointer == other.list_style_image.pointer- && quotes.pointer == other.quotes.pointer- && border_spacing_horizontal == other.border_spacing_horizontal- && border_spacing_vertical == other.border_spacing_vertical;- }-RefPtr<AbstractImageStyleValue const> list_style_image_value() const;};@@ -764,7 +623,6 @@ public:Optional<URL> fill_url_value() const { return paint_url_value(fill); }Optional<URL> stroke_url_value() const { return paint_url_value(stroke); }- FillRule fill_rule_value() const { return static_cast<FillRule>(fill_rule); }ColorInterpolation color_interpolation_value() const { return static_cast<ColorInterpolation>(color_interpolation); }ColorInterpolation color_interpolation_filters_value() const { return static_cast<ColorInterpolation>(color_interpolation_filters); }};@@ -802,7 +660,7 @@ private:StyleStructRef<InheritedTextValues> text;StyleStructRef<FontValues> font;// The inherited longhands held as bits beside the inherited groups, and the effective zoom.- ComputedValuesFFI::InheritedSetValues values { initial_inherited_set_values() };+ ComputedValuesFFI::InheritedSetValues values {};};InheritedValues m_inherited;@@ -1006,7 +864,7 @@ private:StyleStructRef<AnimationValues> animation;StyleStructRef<BoxValues> box;// The properties that do not inherit held as bits in the style's root.- ComputedValuesFFI::ResetBits reset_bits { initial_reset_bits() };+ ComputedValuesFFI::ResetBits reset_bits {};StyleStructRef<SurroundValues> surround;StyleStructRef<SizingValues> sizing;StyleStructRef<MiscLayoutValues> misc_layout;@@ -1151,50 +1009,4 @@ private:InstalledStyle m_style;};-class ComputedValues::Mutator final {-private:- friend class Builder;-- explicit Mutator(ComputedValues& values)- : m_values(values)- {- }--public:- void set_animated_properties(AnimatedProperties const*);-- ComputedValues& m_values;-};--class ComputedValues::Builder {-public:- Builder()- : m_values(adopt_ref(*new ComputedValues))- , m_mutator(*m_values)- {- }-- explicit Builder(ComputedValues const& values)- : Builder()- {- m_values->m_inherited = values.m_inherited;- m_values->m_noninherited = values.m_noninherited;- m_values->m_record = values.m_record;- if (values.m_borrowed_base_values)- m_values->m_base_values = Builder { *values.m_borrowed_base_values }.build();- else- m_values->m_base_values = values.m_base_values;- m_mutator.set_animated_properties(values.m_animated_properties.ptr());- m_values->m_depends_on_viewport_metrics = values.m_depends_on_viewport_metrics;- m_values->m_font_metrics_depend_on_viewport_metrics = values.m_font_metrics_depend_on_viewport_metrics;- m_values->m_in_display_none_subtree = values.m_in_display_none_subtree;- }-- NonnullRefPtr<ComputedValues const> build() && { return move(m_values); }--private:- NonnullRefPtr<ComputedValues> m_values;- Mutator m_mutator;-};-}diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cppindex 414782dc3d7..ad29578d91a 100644--- a/Libraries/LibWeb/CSS/StyleComputer.cpp+++ b/Libraries/LibWeb/CSS/StyleComputer.cpp@@ -106,35 +106,15 @@namespace Web::CSS {-class Fnv1a64 {-public:- void add(u64 value)- {- m_hash ^= value;- m_hash *= 0x100000001b3ull;- }-- u64 value() const { return m_hash; }--private:- u64 m_hash { 0xcbf29ce484222325ull };-};-GC_DEFINE_ALLOCATOR(StyleComputer);StyleComputer::StyleComputer(DOM::Document& document): m_document(document)- , m_default_font_metrics(16, Platform::FontPlugin::the().default_font(16)->pixel_metrics(), normal_line_height(Platform::FontPlugin::the().default_font(16)->pixel_metrics()))- , m_root_element_font_metrics(m_default_font_metrics)+ , m_root_element_font_metrics(16, Platform::FontPlugin::the().default_font(16)->pixel_metrics(), normal_line_height(Platform::FontPlugin::the().default_font(16)->pixel_metrics())), m_style_engine(this){}-void StyleComputer::prepare_for_style_engine_transaction() const-{- sweep_custom_property_environments();-}-void StyleComputer::begin_style_update() const{++m_style_update_depth;@@ -482,11 +462,6 @@ Optional<Utf16String> StyleComputer::user_agent_style_sheet_source(Utf16View namreturn {};}-struct ResolvedScope {- GC::Ptr<DOM::Element const> root;- size_t proximity { NumericLimits<size_t>::max() };-};-static RefPtr<CustomPropertyData const> inheritable_custom_property_data(Layout::BegunRead const& read, DOM::AbstractElement abstract_element){auto data = abstract_element.custom_property_data();@@ -1530,48 +1505,6 @@ CSSPixels StyleComputer::default_user_font_size()}// https://w3c.github.io/csswg-drafts/css-fonts/#absolute-size-mapping-CSSPixels StyleComputer::absolute_size_mapping(AbsoluteSize absolute_size, CSSPixels default_font_size)-{- // An <absolute-size> keyword refers to an entry in a table of font sizes computed and kept by the user agent. See- // § 2.5.1 Absolute Size Keyword Mapping Table.- // INTEROP: Other browsers share this keyword table for integral default sizes from 9px through 16px, so we use- // it instead of the ratios from the spec's guideline table.- static constexpr Array<Array<u8, 8>, 8> font_size_table { {- { 9, 9, 9, 9, 11, 14, 18, 27 },- { 9, 9, 9, 10, 12, 15, 20, 30 },- { 9, 9, 10, 11, 13, 17, 22, 33 },- { 9, 9, 10, 12, 14, 18, 24, 36 },- { 9, 10, 12, 13, 16, 20, 26, 39 },- { 9, 10, 12, 14, 17, 21, 28, 42 },- { 9, 10, 13, 15, 18, 23, 30, 45 },- { 9, 10, 13, 16, 18, 24, 32, 48 },- } };- auto default_size = default_font_size.to_int();- if (default_size >= 9 && default_size <= 16 && default_font_size == CSSPixels(default_size))- return CSSPixels(font_size_table[default_size - 9][to_underlying(absolute_size)]);-- switch (absolute_size) {- case AbsoluteSize::XxSmall:- return default_font_size * CSSPixels(3) / 5;- case AbsoluteSize::XSmall:- return default_font_size * CSSPixels(3) / 4;- case AbsoluteSize::Small:- return default_font_size * CSSPixels(8) / 9;- case AbsoluteSize::Medium:- return default_font_size;- case AbsoluteSize::Large:- return default_font_size * CSSPixels(6) / 5;- case AbsoluteSize::XLarge:- return default_font_size * CSSPixels(3) / 2;- case AbsoluteSize::XxLarge:- return default_font_size * 2;- case AbsoluteSize::XxxLarge:- return default_font_size * 3;- }-- VERIFY_NOT_REACHED();-}-ComputationContext StyleComputer::make_computation_context_for_property(PropertyID property_id, ComputedStyleWorkingSet const& style, Optional<DOM::AbstractElement> abstract_element) const{auto subject_inline_axis_is_horizontal = [&]() {@@ -1642,7 +1575,7 @@ ComputationContext StyleComputer::make_computation_context_for_property(Propertyreturn {.length_resolution_context = {- .viewport_rect = viewport_rect(),+ .viewport_rect = m_viewport_rect,.font_metrics = line_height_font_metrics,.root_font_metrics = is_document_element? line_height_font_metrics@@ -1666,7 +1599,7 @@ ComputationContext StyleComputer::make_computation_context_for_property(Property};return {.length_resolution_context = {- .viewport_rect = viewport_rect(),+ .viewport_rect = m_viewport_rect,.font_metrics = font_metrics,.root_font_metrics = is_document_element ? font_metrics : m_root_element_font_metrics,.font_metrics_depend_on_viewport_metrics = style.font_metrics_depend_on_viewport_metrics(),@@ -1714,7 +1647,7 @@ StyleRecordID StyleComputer::intern_document_style(Layout::BegunRead const& readdocument_supported_color_scheme_codes.unchecked_append(to_underlying(preferred_color_scheme_from_string(scheme)));}auto length_resolution_context = CSS::Length::ResolutionContext::for_document(document());- auto viewport_rect = this->viewport_rect();+ auto viewport_rect = m_viewport_rect;ComputedValuesFFI::FfiDocumentLonghandInput const input {.color_scheme_input = {.preferred_color_scheme = static_cast<u8>(to_underlying(document().page().preferred_color_scheme())),@@ -1819,7 +1752,7 @@ RefPtr<ComputedValues const> StyleComputer::engine_transient_pseudo_element_stylreturn {};auto view = computed_style_record_view(style);// The engine holds the record only until the element's styles are next read or settled.- return ComputedValues::Builder { *view }.build();+ return view->clone();}NonnullRefPtr<ComputedStyleWorkingSet> StyleComputer::reconstruct_computed_properties(ComputedValues const& computed_values) constdiff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.hindex aca0ea2486d..c171974914e 100644--- a/Libraries/LibWeb/CSS/StyleComputer.h+++ b/Libraries/LibWeb/CSS/StyleComputer.h@@ -72,7 +72,6 @@ public:[[nodiscard]] Optional<StyleEngineRuleTarget> style_engine_rule_target(Layout::BegunRead const& read, StyleEngineRuleID rule_id) const;static CSSPixels default_user_font_size();- static CSSPixels absolute_size_mapping(AbsoluteSize, CSSPixels default_font_size);void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }[[nodiscard]] CSSPixelRect const& viewport_rect_for_style_environment() const { return m_viewport_rect; }@@ -86,20 +85,11 @@ public:// The environment as a compositor animation request names it: the document's version and the viewport's.[[nodiscard]] u64 style_environment_version_for_sharing() const;- // Drop caches whose keys contain inputs that are stable only within one engine transaction.- // Style sharing has a self-validating key and survives ordinary transaction boundaries.- void prepare_for_style_engine_transaction() const;-void begin_style_update() const;void end_style_update() const;void begin_inheritance_chain_read() const { ++m_inheritance_chain_read_depth; }void end_inheritance_chain_read() const { --m_inheritance_chain_read_depth; }- struct ComputedStyleInvalidation {- RequiredInvalidationAfterStyleChange invalidation;- bool any_computed_value_changed { false };- };-// Has the engine compose each element's sampled overlay over the record the element installed, which it was sampled// on, compare it with that record and publish it, in one call of the engine, answering each at the same index of// `publications`.@@ -136,15 +126,12 @@ public:// element inherits, which must be the environment the engine resolved it over. Nothing when// the identity is no engine environment or was resolved over another.[[nodiscard]] RefPtr<CustomPropertyData const> engine_custom_property_environment(Layout::BegunRead const& read, u64 identity, RefPtr<CustomPropertyData const> const& inherited) const;- // The environment `environment` was built over: the one the engine resolved it over, or the node its chain lies over.// What a child of an element holding `environment` inherits of it, under the registrations as they are now.[[nodiscard]] RefPtr<CustomPropertyData const> inheritable_custom_property_environment(Layout::BegunRead const& read, CustomPropertyData const& environment) const;// The custom properties the engine's environment `identity` declares of its own, over `inherited` rather than the// environment the engine resolved them over. Nothing where `identity` is not an environment the engine resolved.[[nodiscard]] RefPtr<CustomPropertyData const> engine_custom_property_declarations_over(Layout::BegunRead const& read, u64 identity, RefPtr<CustomPropertyData const> const& inherited) const;- // Refreshes a previously published style outside the drive: re-runs the animated element style- // adjustments and leaves the non-inherited-property inheritance invalidation mark itself.void collect_animations_into(Layout::BegunRead const& read, DOM::AbstractElement, ReadonlySpan<GC::Ref<Animations::KeyframeEffect>>, ComputedStyleWorkingSet&) const;// One element's animations, refreshed over the record it holds as `collect_animations_into()` refreshes them.struct AnimationRefreshRequest {@@ -210,8 +197,6 @@ private:[[nodiscard]] bool has_provisional_transition_states(DOM::AbstractElement) const;void finalize_animated_box_type(Layout::BegunRead const& read, ComputedStyleWorkingSet&, DOM::AbstractElement) const;- [[nodiscard]] CSSPixelRect viewport_rect() const { return m_viewport_rect; }-public:// The document's StyleEngine.[[nodiscard]] StyleEngine& style_engine() { return m_style_engine; }@@ -289,7 +274,6 @@ public:private:GC::Ref<DOM::Document> m_document;- Length::FontMetrics m_default_font_metrics;mutable Length::FontMetrics m_root_element_font_metrics;mutable bool m_root_element_font_metrics_depend_on_viewport_metrics { false };mutable double m_root_element_effective_zoom { 1 };@@ -317,8 +301,6 @@ private:StyleValueFFI::FfiTransitionActionKind action {};bool has_decision { false };};- // Whether the animation collection of the computation in progress resolved a keyframe-borne- // `inherit` for a non-inherited property; folded into the explicit-inheritance bookkeeping.mutable Vector<ProvisionalTransitionState> m_provisional_transition_states;mutable HashMap<u64, size_t> m_provisional_transition_state_indices;mutable HashMap<u64, Vector<size_t>> m_provisional_transition_state_indices_by_target;diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.hindex a0b487435eb..0476dea1b93 100644--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h@@ -225,8 +225,6 @@ public:StyleAtomID intern_atom(Utf16FlyString const&);// Counts the reclaims of this document's atoms, so a cache keyed by atoms can tell when one may have been reused.[[nodiscard]] u64 atom_generation() const;- // Moves a node's record to the environment its inherited custom-property data was refreshed- // to; the record the host holds for the new one, or null when nothing moved.// What a read of an element's style, or one of its pseudo-elements', made before the next style update asks of// the style engine, and the pseudo-element a demand may read.using RecordDemand = StyleEngineFFI::FfiRecordDemand;diff --git a/Libraries/LibWeb/CSS/StyleEngineInput.h b/Libraries/LibWeb/CSS/StyleEngineInput.hindex bb42f8ab96f..66b93061a34 100644--- a/Libraries/LibWeb/CSS/StyleEngineInput.h+++ b/Libraries/LibWeb/CSS/StyleEngineInput.h@@ -184,8 +184,6 @@ WEB_API void prepare_non_author_stylesheets(DOM::Document&);// Called once a sheet has taken its place in the sheet list, so its successor is known.WEB_API void record_stylesheet_attached(StyleSheetState&, DOM::Node& document_or_shadow_root, StyleSheetState* before);-// The order one tree scope declares its qualified cascade layer names in. Rules retain the interned-// names, while StyleEngine derives the scope-local ranks used by every cascade consumer.WEB_API TreeScopeID style_engine_tree_scope_for(DOM::Node&);// A sheet's rules are not immutable, and each of these is one rule moving rather than the sheetdiff --git a/Libraries/LibWeb/CSS/StyleSheetState.cpp b/Libraries/LibWeb/CSS/StyleSheetState.cppindex d5060b9f884..7c14a0194f5 100644--- a/Libraries/LibWeb/CSS/StyleSheetState.cpp+++ b/Libraries/LibWeb/CSS/StyleSheetState.cpp@@ -826,21 +826,6 @@ Parser::ParsingParams StyleSheetState::make_parsing_params() constreturn parsing_params;}-StringView StyleSheetState::loading_state_name(LoadingState loading_state)-{- switch (loading_state) {- case LoadingState::Unloaded:- return "Unloaded"sv;- case LoadingState::Loading:- return "Loading"sv;- case LoadingState::Loaded:- return "Loaded"sv;- case LoadingState::Error:- return "Error"sv;- }- VERIFY_NOT_REACHED();-}-CSSStyleSheet& StyleSheetState::cssom_sheet() const{if (!m_cssom_sheet)diff --git a/Libraries/LibWeb/CSS/StyleSheetState.h b/Libraries/LibWeb/CSS/StyleSheetState.hindex b5146d3bd41..6c47b31c6d8 100644--- a/Libraries/LibWeb/CSS/StyleSheetState.h+++ b/Libraries/LibWeb/CSS/StyleSheetState.h@@ -69,7 +69,6 @@ public:Loaded,Error,};- static StringView loading_state_name(LoadingState);[[nodiscard]] static NonnullRefPtr<StyleSheetState> create(RustRuleList, GC::Ptr<DOM::Document>, RustMediaList, Optional<::URL::URL> location, Optional<ReferrerPolicy::ReferrerPolicy> fetched_referrer_policy = {});static WebIDL::ExceptionOr<NonnullRefPtr<StyleSheetState>> create_constructed(DOM::Document const&, CSSStyleSheetOptions const& options = {});@@ -150,7 +149,6 @@ public:bool constructed() const { return m_native_sheet.flag(RustStyleSheet::Flag::Constructed); }GC::Ptr<DOM::Document const> constructor_document() const { return m_constructor_document; }- GC::Ptr<DOM::Document> parsing_document() const { return m_parsing_document; }void set_constructor_document(GC::Ptr<DOM::Document const> constructor_document) { m_constructor_document = constructor_document; }bool disallow_modification() const { return m_native_sheet.flag(RustStyleSheet::Flag::DisallowModification); }diff --git a/Libraries/LibWeb/CSS/StyleStructRef.h b/Libraries/LibWeb/CSS/StyleStructRef.hindex cdc4893658b..ac1e7b819f4 100644--- a/Libraries/LibWeb/CSS/StyleStructRef.h+++ b/Libraries/LibWeb/CSS/StyleStructRef.h@@ -14,7 +14,7 @@namespace Web::CSS {-// A copy-on-write reference to a style value group struct.+// A reference to a style value group struct.//// The payloads are owned by the Rust side of LibWeb (see computed_values.rs),// which defines each group's layout and lifecycle. Rust places an atomic@@ -24,19 +24,13 @@ namespace Web::CSS {// boundary.//// Copying a StyleStructRef shares the underlying payload by bumping the-// reference count instead of copying the struct. access() returns a mutable-// reference to the payload, cloning it first if it is shared with anyone-// else. A default-constructed ref is empty until a payload is borrowed,-// adopted or assigned.-//-// NB: This models the same copy-on-write scheme as WebKit's DataRef and-// Blink's ComputedStyleBase groups, with Stylo's arrangement of the-// reference count header preceding the payload.+// reference count instead of copying the struct. A default-constructed ref is+// empty until a payload is borrowed or assigned.template<typename T>class StyleStructRef {public:- // NB: An empty reference is borrowed, so that it is filled by borrow(), adopt() or assignment before- // its payload is read.+ // NB: An empty reference is borrowed, so that it is filled by borrow() or assignment before its+ // payload is read.StyleStructRef() = default;StyleStructRef(StyleStructRef const& other)@@ -65,32 +59,9 @@ public:T const& operator*() const { return *m_payload; }T const* operator->() const { return m_payload; }- // Returns a mutable reference to the payload, cloning it first if it is- // shared with anyone else.- T& access()- {- VERIFY(m_payload);- if (m_is_borrowed || refcount().load(AK::memory_order_acquire) != 1) {- auto* clone = clone_payload(m_payload);- deref();- m_payload = clone;- m_is_borrowed = false;- }- return *m_payload;- }-- // Takes ownership of a payload built on the Rust side; the payload- // arrives already carrying this reference.- void adopt(void* payload)- {- deref();- m_payload = static_cast<T*>(payload);- m_is_borrowed = false;- }-- // Borrows a payload retained by a live StyleRecord. Copying or mutating- // this reference first acquires its own payload, so the borrowed state- // never escapes the synchronous record view which created it.+ // Borrows a payload retained by a live StyleRecord. Copying this reference+ // first acquires its own payload, so the borrowed state never escapes the+ // synchronous record view which created it.void borrow(void const* payload){deref();@@ -103,11 +74,6 @@ public:// Whether the payload holds the group's initial values.bool is_default() const { return ComputedValuesFFI::rust_style_group_holds_default_values(T::style_group_index, m_payload); }- bool operator==(StyleStructRef const& other) const- {- return m_payload == other.m_payload || *m_payload == *other.m_payload;- }-private:// NB: Must match header_size() in computed_values.rs.static constexpr size_t payload_header_size = max(alignof(T), sizeof(size_t));@@ -131,11 +97,6 @@ private:ComputedValuesFFI::rust_style_group_free(T::style_group_index, m_payload);}- static T* clone_payload(T const* source)- {- return static_cast<T*>(ComputedValuesFFI::rust_style_group_clone(T::style_group_index, source));- }-T* m_payload { nullptr };bool m_is_borrowed { true };};diff --git a/Libraries/LibWeb/CSS/UpdateStyle.cpp b/Libraries/LibWeb/CSS/UpdateStyle.cppindex adc50fa0598..7af47a24899 100644--- a/Libraries/LibWeb/CSS/UpdateStyle.cpp+++ b/Libraries/LibWeb/CSS/UpdateStyle.cpp@@ -159,7 +159,7 @@ static void prepare_for_style_engine_transaction(Layout::BegunRead const& read,{document.build_registered_properties_cache_for_style_update();document.republish_custom_property_environments_for_style_update(read);- document.style_computer().prepare_for_style_engine_transaction();+ document.style_computer().sweep_custom_property_environments();}// Runs the next style update of this update_style() on the document's render state: the writes recorded since the lastdiff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cppindex 24aa25b1fe1..6446020acf2 100644--- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp@@ -5539,15 +5539,8 @@ CSSPixels font_size_to_pixel_size(Utf16View const& font_size)if (!keyword.has_value())return pixel_size;- // Convert the keyword to an absolute-size- auto absolute_size = CSS::keyword_to_absolute_size(keyword.value());-- // If that failed - give up- if (!absolute_size.has_value())- return pixel_size;-- // Return scaled pixel size- return CSS::StyleComputer::absolute_size_mapping(absolute_size.value(), pixel_size);+ // Return scaled pixel size, or give up if the keyword is not an absolute-size+ return CSSPixels::from_raw(CSS::ComputedValuesFFI::rust_absolute_size_font_mapping(to_underlying(keyword.value()), pixel_size.raw_value()));}void for_each_node_effectively_contained_in_range(GC::Ptr<DOM::Range> range, Function<TraversalDecision(GC::Ref<DOM::Node>)> callback)diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.hindex af63a2c037b..5636ec8ac75 100644--- a/Libraries/LibWeb/Forward.h+++ b/Libraries/LibWeb/Forward.h@@ -377,7 +377,6 @@ enum class LayoutTreeRebuildRoot : u8;enum class MediaFeatureID : u8;enum class PropertyID : u16;enum class ValueType : u8;-enum class AnimatedPropertyResultOfTransition : u8;enum class AbsoluteSize : u8;enum class AnchorSize : u8;@@ -438,7 +437,6 @@ struct ColorResolutionStyle;struct ComputationContext;struct CustomPropertyRegistration;struct LogicalAliasMappingContext;-struct NormalGap;struct RequiredInvalidationAfterStyleChange;// https://drafts.css-houdini.org/css-typed-om-1/#typedefdef-cssnumberishdiff --git a/Libraries/LibWeb/Rust/src/css/animated_overlay.rs b/Libraries/LibWeb/Rust/src/css/animated_overlay.rsindex 513dbf0d1a2..dcad43ba6c4 100644--- a/Libraries/LibWeb/Rust/src/css/animated_overlay.rs+++ b/Libraries/LibWeb/Rust/src/css/animated_overlay.rs@@ -243,19 +243,6 @@ pub extern "C" fn rust_animated_overlay_free(overlay: OwnedBox<AnimatedOverlay>)drop(overlay);}-/// Stores or replaces the overlay entry for a longhand, retaining `value`.-#[unsafe(no_mangle)]-pub extern "C" fn rust_animated_overlay_set(- overlay: &mut AnimatedOverlay,- property: u16,- value: crate::css::style_value_arc::StyleValueRef<'_>,- inherited: bool,- result_of_transition: bool,-) {- let retained = RetainedStyleValueData::from_arc(value.to_arc());- overlay.set_owned(property, retained, inherited, result_of_transition);-}-/// Returns the overlay's borrowed entries, valid until its next mutation.////// # Safetydiff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex a4df7f3d973..0fc8bcfbf34 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -1568,17 +1568,6 @@ pub unsafe extern "C" fn rust_style_group_holds_default_values(group_index: usizunsafe { GroupPayloadRef::new(group_index, payload) }.is_some_and(GroupPayloadRef::holds_the_defaults)}-/// A new payload of the group at `group_index` holding the group's default values, with one-/// reference for the caller.-#[unsafe(no_mangle)]-pub extern "C" fn rust_style_group_create_default(group_index: usize) -> *mut c_void {- let group = style_group(group_index);- let payload = allocate_payload(group, 1);- // SAFETY: The payload was just allocated with the layout of the group's type.- unsafe { default_construct(group, payload) };- payload-}-/// The bytes of the allocation of `payload`, a payload of the group at `group_index`. What the/// payload holds beyond its own size is not counted.pub(crate) fn group_payload_allocation_bytes(group_index: usize, payload: *const c_void) -> usize {@@ -2872,16 +2861,7 @@ fn publish_group_payload<T: StyleGroupPayload>(group_index: usize, built: T) ->}/// Allocates a new payload for `group_index` with a reference count of one,-/// copy-constructed from `source`.-///-/// # Safety-/// `source` must be a valid payload of the same group type.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_style_group_clone(group_index: usize, source: *const c_void) -> *mut c_void {- unsafe { clone_group_payload(group_index, source) }-}--/// The source must be a live payload of the registered group type.+/// copy-constructed from `source`, a live payload of the registered group type.pub(crate) unsafe fn clone_group_payload(group_index: usize, source: *const c_void) -> *mut c_void {let group = style_group(group_index);let payload = allocate_payload(group, 1);@@ -7698,7 +7678,7 @@ mod tests {for group_index in 0..group_index::COUNT {let default = defaults.groups()[group_index].as_ptr();// SAFETY: The default payload is a live payload of its group.- let clone = unsafe { rust_style_group_clone(group_index, default) };+ let clone = unsafe { clone_group_payload(group_index, default) };// SAFETY: The payloads are live defaults and clones of this group.assert!(unsafe { style_group_payloads_equal(group_index, default, clone) });refcount_of(clone, payload_align(style_group(group_index))).store(0, Ordering::Relaxed);@@ -7708,7 +7688,7 @@ mod tests {let table_default = defaults.groups()[group_index::INHERITED_LIST_TABLE].as_ptr();// SAFETY: The default payload is a live payload of its group.- let changed_payload = unsafe { rust_style_group_clone(group_index::INHERITED_LIST_TABLE, table_default) };+ let changed_payload = unsafe { clone_group_payload(group_index::INHERITED_LIST_TABLE, table_default) };// SAFETY: The clone is uniquely owned and a list and table group.unsafe { &mut *changed_payload.cast::<InheritedListTableValues>() }.border_spacing_horizontal = 17;// SAFETY: The payloads are live payloads of this group.diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex d5498dbe174..f15ff391748 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -630,6 +630,14 @@ pub extern "C" fn rust_compute_font_width(absolutized_value: &StyleValueData) ->compute_font_width(absolutized_value).into()}+/// The font size the `<absolute-size>` `keyword` maps to for a default font size of+/// `default_font_size_raw`, both in raw CSS pixels. Any other keyword maps to the default size.+#[unsafe(no_mangle)]+pub extern "C" fn rust_absolute_size_font_mapping(keyword: u16, default_font_size_raw: i32) -> i32 {+ absolute_size_font_mapping(keyword, CssPixels::from_raw(default_font_size_raw))+ .map_or(default_font_size_raw, |size| size.raw_value())+}+/// https://drafts.csswg.org/css-fonts-4/#absolute-size-mapping/// An <absolute-size> keyword refers to an entry in a table of font sizes computed and kept by/// the user agent. See 2.5.1 Absolute Size Keyword Mapping Table.diff --git a/Tests/LibWeb/CMakeLists.txt b/Tests/LibWeb/CMakeLists.txtindex 63d9f2ef048..2a7cb5f39f3 100644--- a/Tests/LibWeb/CMakeLists.txt+++ b/Tests/LibWeb/CMakeLists.txt@@ -60,7 +60,6 @@ if (NOT WIN32)TestCSSSyntaxParser.cppTestLengthAbsolutizeParity.cppTestStylePropertyMetadataParity.cpp- TestStyleStructRef.cpp)endif()diff --git a/Tests/LibWeb/TestStyleStructRef.cpp b/Tests/LibWeb/TestStyleStructRef.cppdeleted file mode 100644index 4f855b52959..00000000000--- a/Tests/LibWeb/TestStyleStructRef.cpp+++ /dev/null@@ -1,160 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibTest/TestCase.h>-#include <LibWeb/CSS/ComputedValues.h>--namespace Web::CSS {--// The referenced payloads are owned by the Rust side and constructed through-// the registered group vtables, so these tests also cover the FFI layout and-// lifecycle contract for real style value group types.--using TableGroup = ComputedValues::InheritedListTableValues;-using TextGroup = ComputedValues::InheritedTextValues;--template<typename T>-static StyleStructRef<T> default_ref()-{- StyleStructRef<T> ref;- ref.adopt(ComputedValuesFFI::rust_style_group_create_default(T::style_group_index));- return ref;-}--TEST_CASE(default_payloads_hold_the_initial_values)-{- auto a = default_ref<TableGroup>();- auto b = default_ref<TableGroup>();- EXPECT(a.is_default());- EXPECT(b.is_default());- EXPECT_EQ(a, b);- EXPECT_EQ(a->border_spacing_horizontal, 0);-}--TEST_CASE(access_clones_when_shared)-{- auto a = default_ref<TableGroup>();- auto untouched = a;-- a.access().border_spacing_horizontal = 7;- EXPECT(!a.is_default());- EXPECT(!a.ptr_equals(untouched));- EXPECT_EQ(a->border_spacing_horizontal, 7);-- // The shared payload must be unaffected by the mutation.- EXPECT(untouched.is_default());- EXPECT_EQ(untouched->border_spacing_horizontal, 0);-}--TEST_CASE(access_does_not_clone_when_unique)-{- auto a = default_ref<TableGroup>();- auto* first = &a.access();- auto* second = &a.access();- EXPECT_EQ(first, second);-}--TEST_CASE(copies_share_until_mutated)-{- auto a = default_ref<TextGroup>();- a.access().text_transform = to_underlying(TextTransform::Uppercase);-- StyleStructRef<TextGroup> b(a);- EXPECT(a.ptr_equals(b));-- b.access().text_transform = to_underlying(TextTransform::Lowercase);- EXPECT(!a.ptr_equals(b));- EXPECT_EQ(a->text_transform, to_underlying(TextTransform::Uppercase));- EXPECT_EQ(b->text_transform, to_underlying(TextTransform::Lowercase));- EXPECT_EQ(b->text_shadow_span().size(), 0u);-}--TEST_CASE(assignment_shares_and_releases_old_payload)-{- auto a = default_ref<TableGroup>();- a.access().border_spacing_horizontal = 7;-- auto b = default_ref<TableGroup>();- b.access().border_spacing_vertical = 5;-- b = a;- EXPECT(a.ptr_equals(b));- EXPECT_EQ(b->border_spacing_horizontal, 7);- EXPECT_EQ(b->border_spacing_vertical, 0);-- auto& self_reference = b;- b = self_reference;- EXPECT(a.ptr_equals(b));-}--TEST_CASE(value_equality_across_distinct_payloads)-{- auto a = default_ref<TableGroup>();- auto b = default_ref<TableGroup>();- a.access().border_spacing_horizontal = 9;- b.access().border_spacing_horizontal = 9;- EXPECT(!a.ptr_equals(b));- EXPECT_EQ(a, b);-- b.access().border_spacing_horizontal = 10;- EXPECT(a != b);-}--TEST_CASE(empty_borrowed_reference_can_be_destroyed)-{- StyleStructRef<TableGroup> empty;-}--TEST_CASE(empty_borrowed_reference_clones_before_mutation)-{- auto source = default_ref<TableGroup>();- source.access().border_spacing_horizontal = 7;- StyleStructRef<TableGroup> borrowed;- borrowed.borrow(&*source);- EXPECT(borrowed.ptr_equals(source));- borrowed.access().border_spacing_horizontal = 3;- EXPECT(!borrowed.ptr_equals(source));- EXPECT_EQ(source->border_spacing_horizontal, 7);- EXPECT_EQ(borrowed->border_spacing_horizontal, 3);-}--TEST_CASE(copy_of_borrowed_reference_outlives_owner)-{- auto copy = [] {- auto owner = default_ref<TableGroup>();- owner.access().border_spacing_horizontal = 7;- StyleStructRef<TableGroup> borrowed;- borrowed.borrow(&*owner);- return StyleStructRef<TableGroup> { borrowed };- }();- EXPECT_EQ(copy->border_spacing_horizontal, 7);- copy.access().border_spacing_horizontal = 3;- EXPECT_EQ(copy->border_spacing_horizontal, 3);-}--TEST_CASE(assignment_initializes_empty_reference_with_owned_payload)-{- auto source = default_ref<TableGroup>();- source.access().border_spacing_horizontal = 7;- StyleStructRef<TableGroup> target;- target = source;- EXPECT(target.ptr_equals(source));- source.access().border_spacing_horizontal = 3;- EXPECT_EQ(target->border_spacing_horizontal, 7);-}--TEST_CASE(assignment_acquires_ownership_of_same_borrowed_payload)-{- auto owner = default_ref<TableGroup>();- owner.access().border_spacing_horizontal = 7;- StyleStructRef<TableGroup> borrowed;- borrowed.borrow(&*owner);- borrowed = owner;- owner.access().border_spacing_horizontal = 3;- EXPECT_EQ(borrowed->border_spacing_horizontal, 7);-}--}