diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 4c0ee04fc35..1f1684fb492 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -921,13 +921,13 @@ void KeyframeEffect::update_computed_properties() if (!target) return; - Optional style = {}; + GC::Ptr style = {}; if (!pseudo_element_type().has_value()) - style = target->computed_css_values(); + style = target->computed_properties(); else - style = target->pseudo_element_computed_css_values(pseudo_element_type().value()); + style = target->pseudo_element_computed_properties(pseudo_element_type().value()); - if (!style.has_value()) + if (!style) return; auto animated_properties_before_update = style->animated_property_values(); @@ -937,8 +937,8 @@ void KeyframeEffect::update_computed_properties() // Traversal of the subtree is necessary to update the animated properties inherited from the target element. target->for_each_in_subtree_of_type([&](auto& element) { - auto element_style = element.computed_css_values(); - if (!element_style.has_value() || !element.layout_node()) + auto element_style = element.computed_properties(); + if (!element_style || !element.layout_node()) return TraversalDecision::Continue; for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) { diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index bbe2b29a3ca..87b75c197a8 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -42,91 +43,89 @@ namespace Web::CSS { -NonnullRefPtr ComputedProperties::Data::clone() const +GC_DEFINE_ALLOCATOR(ComputedProperties); + +ComputedProperties::ComputedProperties() = default; + +ComputedProperties::~ComputedProperties() = default; + +void ComputedProperties::visit_edges(Visitor& visitor) { - auto clone = adopt_ref(*new ComputedProperties::Data); - clone->m_animation_name_source = m_animation_name_source; - clone->m_transition_property_source = m_transition_property_source; - clone->m_property_values = m_property_values; - clone->m_property_important = m_property_important; - clone->m_property_inherited = m_property_inherited; - clone->m_animated_property_values = m_animated_property_values; - clone->m_math_depth = m_math_depth; - clone->m_font_list = m_font_list; - clone->m_line_height = m_line_height; - return clone; + Base::visit_edges(visitor); + visitor.visit(m_animation_name_source); + visitor.visit(m_transition_property_source); } bool ComputedProperties::is_property_important(CSS::PropertyID property_id) const { size_t n = to_underlying(property_id); - return m_data->m_property_important[n / 8] & (1 << (n % 8)); + return m_property_important[n / 8] & (1 << (n % 8)); } void ComputedProperties::set_property_important(CSS::PropertyID property_id, Important important) { size_t n = to_underlying(property_id); if (important == Important::Yes) - m_data->m_property_important[n / 8] |= (1 << (n % 8)); + m_property_important[n / 8] |= (1 << (n % 8)); else - m_data->m_property_important[n / 8] &= ~(1 << (n % 8)); + m_property_important[n / 8] &= ~(1 << (n % 8)); } bool ComputedProperties::is_property_inherited(CSS::PropertyID property_id) const { size_t n = to_underlying(property_id); - return m_data->m_property_inherited[n / 8] & (1 << (n % 8)); + return m_property_inherited[n / 8] & (1 << (n % 8)); } void ComputedProperties::set_property_inherited(CSS::PropertyID property_id, Inherited inherited) { size_t n = to_underlying(property_id); if (inherited == Inherited::Yes) - m_data->m_property_inherited[n / 8] |= (1 << (n % 8)); + m_property_inherited[n / 8] |= (1 << (n % 8)); else - m_data->m_property_inherited[n / 8] &= ~(1 << (n % 8)); + m_property_inherited[n / 8] &= ~(1 << (n % 8)); } void ComputedProperties::set_property(CSS::PropertyID id, NonnullRefPtr value, Inherited inherited, Important important) { - m_data->m_property_values[to_underlying(id)] = move(value); + m_property_values[to_underlying(id)] = move(value); set_property_important(id, important); set_property_inherited(id, inherited); } void ComputedProperties::revert_property(CSS::PropertyID id, ComputedProperties const& style_for_revert) { - m_data->m_property_values[to_underlying(id)] = style_for_revert.m_data->m_property_values[to_underlying(id)]; + m_property_values[to_underlying(id)] = style_for_revert.m_property_values[to_underlying(id)]; set_property_important(id, style_for_revert.is_property_important(id) ? Important::Yes : Important::No); set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No); } void ComputedProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr value) { - m_data->m_animated_property_values.set(id, move(value)); + m_animated_property_values.set(id, move(value)); } void ComputedProperties::reset_animated_properties() { - m_data->m_animated_property_values.clear(); + m_animated_property_values.clear(); } CSSStyleValue const& ComputedProperties::property(CSS::PropertyID property_id, WithAnimationsApplied return_animated_value) const { if (return_animated_value == WithAnimationsApplied::Yes) { - if (auto animated_value = m_data->m_animated_property_values.get(property_id); animated_value.has_value()) + if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value()) return *animated_value.value(); } // By the time we call this method, all properties have values assigned. - return *m_data->m_property_values[to_underlying(property_id)]; + return *m_property_values[to_underlying(property_id)]; } CSSStyleValue const* ComputedProperties::maybe_null_property(CSS::PropertyID property_id) const { - if (auto animated_value = m_data->m_animated_property_values.get(property_id); animated_value.has_value()) + if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value()) return animated_value.value(); - return m_data->m_property_values[to_underlying(property_id)]; + return m_property_values[to_underlying(property_id)]; } Variant ComputedProperties::gap_value(CSS::PropertyID id) const @@ -270,7 +269,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r auto resolved = line_height.as_calculated().resolve_number(); if (!resolved.has_value()) { dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal)); - return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing()); + return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing()); } return Length(resolved.value(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics); } @@ -278,7 +277,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r auto resolved = line_height.as_calculated().resolve_length(Length::ResolutionContext { viewport_rect, font_metrics, root_font_metrics }); if (!resolved.has_value()) { dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal)); - return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing()); + return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing()); } return resolved->to_px(viewport_rect, font_metrics, root_font_metrics); } @@ -740,12 +739,12 @@ Optional ComputedProperties::position() const bool ComputedProperties::operator==(ComputedProperties const& other) const { - if (m_data->m_property_values.size() != other.m_data->m_property_values.size()) + if (m_property_values.size() != other.m_property_values.size()) return false; - for (size_t i = 0; i < m_data->m_property_values.size(); ++i) { - auto const& my_style = m_data->m_property_values[i]; - auto const& other_style = other.m_data->m_property_values[i]; + for (size_t i = 0; i < m_property_values.size(); ++i) { + auto const& my_style = m_property_values[i]; + auto const& other_style = other.m_property_values[i]; if (!my_style) { if (other_style) return false; @@ -1421,7 +1420,7 @@ Color ComputedProperties::stop_color() const void ComputedProperties::set_math_depth(int math_depth) { - m_data->m_math_depth = math_depth; + m_math_depth = math_depth; // Make our children inherit our computed value, not our specified value. set_property(PropertyID::MathDepth, MathDepthStyleValue::create_integer(IntegerStyleValue::create(math_depth))); } diff --git a/Libraries/LibWeb/CSS/ComputedProperties.h b/Libraries/LibWeb/CSS/ComputedProperties.h index d01143af750..e3e39c4890d 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.h +++ b/Libraries/LibWeb/CSS/ComputedProperties.h @@ -8,10 +8,12 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -19,41 +21,21 @@ namespace Web::CSS { -class ComputedProperties { +class ComputedProperties final : public JS::Cell { + GC_CELL(ComputedProperties, JS::Cell); + GC_DECLARE_ALLOCATOR(ComputedProperties); + public: static constexpr size_t number_of_properties = to_underlying(CSS::last_property_id) + 1; -private: - struct Data : public RefCounted { - friend class StyleComputer; - - NonnullRefPtr clone() const; - - // FIXME: These need protection from GC! - GC::Ptr m_animation_name_source; - GC::Ptr m_transition_property_source; - - Array, number_of_properties> m_property_values; - Array m_property_important {}; - Array m_property_inherited {}; - - HashMap> m_animated_property_values; - - int m_math_depth { InitialValues::math_depth() }; - mutable RefPtr m_font_list; - - Optional m_line_height; - }; - -public: - ComputedProperties() = default; + virtual ~ComputedProperties() override; template inline void for_each_property(Callback callback) const { - for (size_t i = 0; i < m_data->m_property_values.size(); ++i) { - if (m_data->m_property_values[i]) - callback((CSS::PropertyID)i, *m_data->m_property_values[i]); + for (size_t i = 0; i < m_property_values.size(); ++i) { + if (m_property_values[i]) + callback((CSS::PropertyID)i, *m_property_values[i]); } } @@ -62,7 +44,7 @@ public: Yes }; - HashMap> const& animated_property_values() const { return m_data->m_animated_property_values; } + HashMap> const& animated_property_values() const { return m_animated_property_values; } void reset_animated_properties(); bool is_property_important(CSS::PropertyID property_id) const; @@ -80,11 +62,11 @@ public: CSSStyleValue const* maybe_null_property(CSS::PropertyID) const; void revert_property(CSS::PropertyID, ComputedProperties const& style_for_revert); - GC::Ptr animation_name_source() const { return m_data->m_animation_name_source; } - void set_animation_name_source(GC::Ptr declaration) { m_data->m_animation_name_source = declaration; } + GC::Ptr animation_name_source() const { return m_animation_name_source; } + void set_animation_name_source(GC::Ptr declaration) { m_animation_name_source = declaration; } - GC::Ptr transition_property_source() const { return m_data->m_transition_property_source; } - void set_transition_property_source(GC::Ptr declaration) { m_data->m_transition_property_source = declaration; } + GC::Ptr transition_property_source() const { return m_transition_property_source; } + void set_transition_property_source(GC::Ptr declaration) { m_transition_property_source = declaration; } CSS::Size size_value(CSS::PropertyID) const; [[nodiscard]] Variant gap_value(CSS::PropertyID) const; @@ -196,23 +178,23 @@ public: Optional fill_rule() const; Optional clip_rule() const; - Gfx::Font const& first_available_computed_font() const { return m_data->m_font_list->first(); } + Gfx::Font const& first_available_computed_font() const { return m_font_list->first(); } Gfx::FontCascadeList const& computed_font_list() const { - VERIFY(m_data->m_font_list); - return *m_data->m_font_list; + VERIFY(m_font_list); + return *m_font_list; } void set_computed_font_list(NonnullRefPtr font_list) const { - m_data->m_font_list = move(font_list); + m_font_list = move(font_list); } [[nodiscard]] CSSPixels compute_line_height(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const; - [[nodiscard]] CSSPixels line_height() const { return *m_data->m_line_height; } - void set_line_height(Badge const&, CSSPixels line_height) { m_data->m_line_height = line_height; } + [[nodiscard]] CSSPixels line_height() const { return *m_line_height; } + void set_line_height(Badge const&, CSSPixels line_height) { m_line_height = line_height; } bool operator==(ComputedProperties const&) const; @@ -220,7 +202,7 @@ public: Optional z_index() const; void set_math_depth(int math_depth); - int math_depth() const { return m_data->m_math_depth; } + int math_depth() const { return m_math_depth; } QuotesData quotes() const; Vector counter_data(PropertyID) const; @@ -234,10 +216,26 @@ public: private: friend class StyleComputer; + ComputedProperties(); + + virtual void visit_edges(Visitor&) override; + Optional overflow(CSS::PropertyID) const; Vector shadow(CSS::PropertyID, Layout::Node const&) const; - AK::CopyOnWrite m_data; + GC::Ptr m_animation_name_source; + GC::Ptr m_transition_property_source; + + Array, number_of_properties> m_property_values; + Array m_property_important {}; + Array m_property_inherited {}; + + HashMap> m_animated_property_values; + + int m_math_depth { InitialValues::math_depth() }; + mutable RefPtr m_font_list; + + Optional m_line_height; }; } diff --git a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 5415ac89288..836017e3aa0 100644 --- a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -196,8 +196,8 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert auto get_computed_value = [this](PropertyID property_id) -> auto const& { if (m_pseudo_element.has_value()) - return m_element->pseudo_element_computed_css_values(m_pseudo_element.value())->property(property_id); - return m_element->computed_css_values()->property(property_id); + return m_element->pseudo_element_computed_properties(m_pseudo_element.value())->property(property_id); + return m_element->computed_properties()->property(property_id); }; // A limited number of properties have special rules for producing their "resolved value". @@ -554,7 +554,7 @@ Optional ResolvedCSSStyleDeclaration::property(PropertyID propert auto style = m_element->document().style_computer().compute_style(const_cast(*m_element), m_pseudo_element); // FIXME: This is a stopgap until we implement shorthand -> longhand conversion. - auto const* value = style.maybe_null_property(property_id); + auto const* value = style->maybe_null_property(property_id); if (!value) { dbgln("FIXME: ResolvedCSSStyleDeclaration::property(property_id={:#x}) No value for property ID in newly computed style case.", to_underlying(property_id)); return {}; diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 655304ffb2c..36b84c0fa47 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1215,7 +1215,7 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM auto const source_declaration = style.transition_property_source(); if (!source_declaration) return; - if (!element.computed_css_values().has_value()) + if (!element.computed_properties()) return; if (source_declaration == element.cached_transition_property_source()) return; @@ -1590,16 +1590,16 @@ NonnullRefPtr StyleComputer::get_inherit_value(CSS::Propert { auto* parent_element = element_to_inherit_style_from(element, pseudo_element); - if (!parent_element || !parent_element->computed_css_values().has_value()) + if (!parent_element || !parent_element->computed_properties()) return property_initial_value(property_id); - return parent_element->computed_css_values()->property(property_id); + return parent_element->computed_properties()->property(property_id); } void StyleComputer::compute_defaulted_property_value(ComputedProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional pseudo_element) const { // FIXME: If we don't know the correct initial value for a property, we fall back to `initial`. - auto& value_slot = style.m_data->m_property_values[to_underlying(property_id)]; + auto& value_slot = style.m_property_values[to_underlying(property_id)]; if (!value_slot) { if (is_inherited_property(property_id)) { style.set_property( @@ -1780,14 +1780,14 @@ RefPtr StyleComputer::compute_font_for_style_values( CSSPixels font_size_in_px = 16; Gfx::FontPixelMetrics font_pixel_metrics; - if (parent_element && parent_element->computed_css_values().has_value()) - font_pixel_metrics = parent_element->computed_css_values()->first_available_computed_font().pixel_metrics(); + if (parent_element && parent_element->computed_properties()) + font_pixel_metrics = parent_element->computed_properties()->first_available_computed_font().pixel_metrics(); else font_pixel_metrics = Platform::FontPlugin::the().default_font().pixel_metrics(); auto parent_font_size = [&]() -> CSSPixels { - if (!parent_element || !parent_element->computed_css_values().has_value()) + if (!parent_element || !parent_element->computed_properties()) return font_size_in_px; - auto const& value = parent_element->computed_css_values()->property(CSS::PropertyID::FontSize); + auto const& value = parent_element->computed_properties()->property(CSS::PropertyID::FontSize); if (value.is_length()) { auto length = value.as_length().length(); if (length.is_absolute() || length.is_relative()) { @@ -1836,8 +1836,8 @@ RefPtr StyleComputer::compute_font_for_style_values( // If the specified value font-size is math then the computed value of font-size is obtained by multiplying // the inherited value of font-size by a nonzero scale factor calculated by the following procedure: // 1. Let A be the inherited math-depth value, B the computed math-depth value, C be 0.71 and S be 1.0 - int inherited_math_depth = parent_element && parent_element->computed_css_values().has_value() - ? parent_element->computed_css_values()->math_depth() + int inherited_math_depth = parent_element && parent_element->computed_properties() + ? parent_element->computed_properties()->math_depth() : InitialValues::math_depth(); int computed_math_depth = math_depth; auto size_ratio = 0.71; @@ -1876,8 +1876,8 @@ RefPtr StyleComputer::compute_font_for_style_values( // larger may compute the font size to the next entry in the table, // and smaller may compute the font size to the previous entry in the table. if (keyword == Keyword::Smaller || keyword == Keyword::Larger) { - if (parent_element && parent_element->computed_css_values().has_value()) { - font_size_in_px = CSSPixels::nearest_value_for(parent_element->computed_css_values()->first_available_computed_font().pixel_metrics().size); + if (parent_element && parent_element->computed_properties()) { + font_size_in_px = CSSPixels::nearest_value_for(parent_element->computed_properties()->first_available_computed_font().pixel_metrics().size); } } font_size_in_px *= get_absolute_size_mapping(keyword); @@ -2077,7 +2077,7 @@ void StyleComputer::absolutize_values(ComputedProperties& style) const // We have to resolve them right away, so that the *computed* line-height is ready for inheritance. // We can't simply absolutize *all* percentage values against the font size, // because most percentages are relative to containing block metrics. - auto& line_height_value_slot = style.m_data->m_property_values[to_underlying(CSS::PropertyID::LineHeight)]; + auto& line_height_value_slot = style.m_property_values[to_underlying(CSS::PropertyID::LineHeight)]; if (line_height_value_slot && line_height_value_slot->is_percentage()) { line_height_value_slot = LengthStyleValue::create( Length::make_px(CSSPixels::nearest_value_for(font_size * static_cast(line_height_value_slot->as_percentage().percentage().as_fraction())))); @@ -2090,8 +2090,8 @@ void StyleComputer::absolutize_values(ComputedProperties& style) const if (line_height_value_slot && line_height_value_slot->is_length()) line_height_value_slot = LengthStyleValue::create(Length::make_px(line_height)); - for (size_t i = 0; i < style.m_data->m_property_values.size(); ++i) { - auto& value_slot = style.m_data->m_property_values[i]; + for (size_t i = 0; i < style.m_property_values.size(); ++i) { + auto& value_slot = style.m_property_values[i]; if (!value_slot) continue; value_slot = value_slot->absolutized(viewport_rect(), font_metrics, m_root_element_font_metrics); @@ -2145,8 +2145,8 @@ static BoxTypeTransformation required_box_type_transformation(ComputedProperties auto const* parent = pseudo_element.has_value() ? &element : element.parent_element(); // A parent with a grid or flex display value blockifies the box’s display type. [CSS-GRID-1] [CSS-FLEXBOX-1] - if (parent && parent->computed_css_values().has_value()) { - auto const& parent_display = parent->computed_css_values()->display(); + if (parent && parent->computed_properties()) { + auto const& parent_display = parent->computed_properties()->display(); if (parent_display.is_grid_inside() || parent_display.is_flex_inside()) return BoxTypeTransformation::Blockify; } @@ -2244,30 +2244,30 @@ void StyleComputer::transform_box_type_if_needed(ComputedProperties& style, DOM: style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display)); } -ComputedProperties StyleComputer::create_document_style() const +GC::Ref StyleComputer::create_document_style() const { - ComputedProperties style = {}; + auto style = document().heap().allocate(); compute_math_depth(style, nullptr, {}); compute_font(style, nullptr, {}); compute_defaulted_values(style, nullptr, {}); absolutize_values(style); - style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width()))); - style.set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height()))); - style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block))); + style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width()))); + style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height()))); + style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block))); return style; } -ComputedProperties StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const +GC::Ref StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const { - return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal).release_value(); + return *compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal); } -Optional StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const +GC::Ptr StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const { return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::CreatePseudoElementStyleIfNeeded); } -Optional StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const +GC::Ptr StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const { build_rule_cache_if_needed(); @@ -2279,7 +2279,7 @@ Optional StyleComputer::compute_style_impl(DOM::Element& ele // Merge back inline styles if (auto inline_style = element.inline_style()) { for (auto const& property : inline_style->properties()) - style.set_property(property.property_id, property.value); + style->set_property(property.property_id, property.value); } return style; } @@ -2324,9 +2324,9 @@ Optional StyleComputer::compute_style_impl(DOM::Element& ele return compute_properties(element, pseudo_element, cascaded_properties); } -ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Optional pseudo_element, CascadedProperties& cascaded_properties) const +GC::Ref StyleComputer::compute_properties(DOM::Element& element, Optional pseudo_element, CascadedProperties& cascaded_properties) const { - ComputedProperties computed_style; + auto computed_style = document().heap().allocate(); for (auto i = to_underlying(first_longhand_property_id); i <= to_underlying(last_longhand_property_id); ++i) { auto property_id = static_cast(i); @@ -2334,7 +2334,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti if ((!value && is_inherited_property(property_id)) || (value && value->is_inherit())) { if (auto inheritance_parent = element_to_inherit_style_from(&element, pseudo_element)) { - value = inheritance_parent->computed_css_values()->property(property_id); + value = inheritance_parent->computed_properties()->property(property_id); } else { value = property_initial_value(property_id); } @@ -2350,19 +2350,19 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti value = CSSKeywordValue::create(Keyword::Initial); } - computed_style.set_property(property_id, value.release_nonnull()); + computed_style->set_property(property_id, value.release_nonnull()); if (property_id == PropertyID::AnimationName) { - computed_style.set_animation_name_source(cascaded_properties.property_source(property_id)); + computed_style->set_animation_name_source(cascaded_properties.property_source(property_id)); } if (property_id == PropertyID::TransitionProperty) { - computed_style.set_transition_property_source(cascaded_properties.property_source(property_id)); + computed_style->set_transition_property_source(cascaded_properties.property_source(property_id)); } } // Animation declarations [css-animations-2] auto animation_name = [&]() -> Optional { - auto const animation_name = computed_style.maybe_null_property(PropertyID::AnimationName); + auto const animation_name = computed_style->maybe_null_property(PropertyID::AnimationName); if (!animation_name) return OptionalNone {}; if (animation_name->is_string()) @@ -2371,7 +2371,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti }(); if (animation_name.has_value()) { - if (auto source_declaration = computed_style.animation_name_source()) { + if (auto source_declaration = computed_style->animation_name_source()) { auto& realm = element.realm(); if (source_declaration != element.cached_animation_name_source(pseudo_element)) { @@ -2450,7 +2450,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti // 9. Transition declarations [css-transitions-1] // Theoretically this should be part of the cascade, but it works with computed values, which we don't have until now. compute_transitioned_properties(computed_style, element, pseudo_element); - if (auto previous_style = element.computed_css_values(); previous_style.has_value()) { + if (auto previous_style = element.computed_properties(); previous_style) { start_needed_transitions(*previous_style, computed_style, element, pseudo_element); } @@ -2912,7 +2912,7 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element c auto inherited_math_depth = [&]() { if (!element || !element->parent_element()) return InitialValues::math_depth(); - return element->parent_element()->computed_css_values()->math_depth(); + return element->parent_element()->computed_properties()->math_depth(); }; auto const& value = style.property(CSS::PropertyID::MathDepth); diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.h index 159e676bcb4..c3566b3384d 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Libraries/LibWeb/CSS/StyleComputer.h @@ -141,10 +141,10 @@ public: void push_ancestor(DOM::Element const&); void pop_ancestor(DOM::Element const&); - ComputedProperties create_document_style() const; + [[nodiscard]] GC::Ref create_document_style() const; - ComputedProperties compute_style(DOM::Element&, Optional = {}) const; - Optional compute_pseudo_element_style_if_needed(DOM::Element&, Optional) const; + [[nodiscard]] GC::Ref compute_style(DOM::Element&, Optional = {}) const; + [[nodiscard]] GC::Ptr compute_pseudo_element_style_if_needed(DOM::Element&, Optional) const; Vector collect_matching_rules(DOM::Element const&, CascadeOrigin, Optional, FlyString const& qualified_layer_name = {}) const; @@ -173,7 +173,7 @@ public: size_t number_of_css_font_faces_with_loading_in_progress() const; - [[nodiscard]] ComputedProperties compute_properties(DOM::Element&, Optional, CascadedProperties&) const; + [[nodiscard]] GC::Ref compute_properties(DOM::Element&, Optional, CascadedProperties&) const; private: enum class ComputeStyleMode { @@ -185,7 +185,7 @@ private: [[nodiscard]] bool should_reject_with_ancestor_filter(Selector const&) const; - Optional compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; + [[nodiscard]] GC::Ptr compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; [[nodiscard]] GC::Ref compute_cascaded_values(DOM::Element&, Optional, bool& did_match_any_pseudo_element_rules, ComputeStyleMode) const; static RefPtr find_matching_font_weight_ascending(Vector const& candidates, int target_weight, float font_size_in_pt, bool inclusive); static RefPtr find_matching_font_weight_descending(Vector const& candidates, int target_weight, float font_size_in_pt, bool inclusive); diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 581f27a97ec..ca3b69549b1 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -1298,7 +1298,7 @@ void Document::update_layout() if (needs_full_style_update || node.needs_style_update()) { invalidation |= static_cast(node).recompute_style(); } - is_display_none = static_cast(node).computed_css_values()->display().is_none(); + is_display_none = static_cast(node).computed_properties()->display().is_none(); } node.set_needs_style_update(false); diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index a45efb27bfd..89f751f36ce 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -102,9 +102,11 @@ void Element::visit_edges(Cell::Visitor& visitor) visitor.visit(m_shadow_root); visitor.visit(m_custom_element_definition); visitor.visit(m_cascaded_properties); + visitor.visit(m_computed_properties); if (m_pseudo_element_data) { for (auto& pseudo_element : *m_pseudo_element_data) { visitor.visit(pseudo_element.cascaded_properties); + visitor.visit(pseudo_element.computed_properties); visitor.visit(pseudo_element.layout_node); } } @@ -388,16 +390,16 @@ Vector Element::get_attribute_names() const return names; } -GC::Ptr Element::create_layout_node(CSS::ComputedProperties style) +GC::Ptr Element::create_layout_node(GC::Ref style) { if (local_name() == "noscript" && document().is_scripting_enabled()) return nullptr; - auto display = style.display(); - return create_layout_node_for_display_type(document(), display, move(style), this); + auto display = style->display(); + return create_layout_node_for_display_type(document(), display, style, this); } -GC::Ptr Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, CSS::ComputedProperties style, Element* element) +GC::Ptr Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, GC::Ref style, Element* element) { if (display.is_table_inside() || display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group() || display.is_table_row()) return document.heap().allocate(document, element, move(style)); @@ -478,40 +480,40 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() VERIFY(parent()); auto& style_computer = document().style_computer(); - auto new_computed_css_values = style_computer.compute_style(*this); + auto new_computed_properties = style_computer.compute_style(*this); // Tables must not inherit -libweb-* values for text-align. // FIXME: Find the spec for this. if (is(*this)) { - auto text_align = new_computed_css_values.text_align(); + auto text_align = new_computed_properties->text_align(); if (text_align.has_value() && (text_align.value() == CSS::TextAlign::LibwebLeft || text_align.value() == CSS::TextAlign::LibwebCenter || text_align.value() == CSS::TextAlign::LibwebRight)) - new_computed_css_values.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Start)); + new_computed_properties->set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Start)); } CSS::RequiredInvalidationAfterStyleChange invalidation; - if (m_computed_css_values.has_value()) - invalidation = compute_required_invalidation(*m_computed_css_values, new_computed_css_values); + if (m_computed_properties) + invalidation = compute_required_invalidation(*m_computed_properties, new_computed_properties); else invalidation = CSS::RequiredInvalidationAfterStyleChange::full(); if (!invalidation.is_none()) - set_computed_css_values(move(new_computed_css_values)); + set_computed_properties(move(new_computed_properties)); // Any document change that can cause this element's style to change, could also affect its pseudo-elements. auto recompute_pseudo_element_style = [&](CSS::Selector::PseudoElement::Type pseudo_element) { style_computer.push_ancestor(*this); - auto pseudo_element_style = pseudo_element_computed_css_values(pseudo_element); + auto pseudo_element_style = pseudo_element_computed_properties(pseudo_element); auto new_pseudo_element_style = style_computer.compute_pseudo_element_style_if_needed(*this, pseudo_element); // TODO: Can we be smarter about invalidation? - if (pseudo_element_style.has_value() && new_pseudo_element_style.has_value()) { + if (pseudo_element_style && new_pseudo_element_style) { invalidation |= compute_required_invalidation(*pseudo_element_style, *new_pseudo_element_style); - } else if (pseudo_element_style.has_value() || new_pseudo_element_style.has_value()) { + } else if (pseudo_element_style || new_pseudo_element_style) { invalidation = CSS::RequiredInvalidationAfterStyleChange::full(); } - set_pseudo_element_computed_css_values(pseudo_element, move(new_pseudo_element_style)); + set_pseudo_element_computed_properties(pseudo_element, move(new_pseudo_element_style)); style_computer.pop_ancestor(*this); }; @@ -526,7 +528,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() if (!invalidation.rebuild_layout_tree && layout_node()) { // If we're keeping the layout tree, we can just apply the new style to the existing layout tree. - layout_node()->apply_style(*m_computed_css_values); + layout_node()->apply_style(*m_computed_properties); if (invalidation.repaint && paintable()) paintable()->set_needs_display(); @@ -537,8 +539,8 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() if (!pseudo_element.has_value() || !pseudo_element->layout_node) continue; - auto pseudo_element_style = pseudo_element_computed_css_values(pseudo_element_type); - if (!pseudo_element_style.has_value()) + auto pseudo_element_style = pseudo_element_computed_properties(pseudo_element_type); + if (!pseudo_element_style) continue; if (auto* node_with_style = dynamic_cast(pseudo_element->layout_node.ptr())) { @@ -552,17 +554,17 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() return invalidation; } -CSS::ComputedProperties Element::resolved_css_values(Optional type) +GC::Ref Element::resolved_css_values(Optional type) { auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this, type); - CSS::ComputedProperties properties = {}; + auto properties = heap().allocate(); for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) { auto property_id = (CSS::PropertyID)i; auto maybe_value = element_computed_style->property(property_id); if (!maybe_value.has_value()) continue; - properties.set_property(property_id, maybe_value.release_value().value); + properties->set_property(property_id, maybe_value.release_value().value); } return properties; @@ -570,9 +572,9 @@ CSS::ComputedProperties Element::resolved_css_values(Optionalreset_animated_properties(); + m_computed_properties->reset_animated_properties(); } DOMTokenList* Element::class_list() @@ -2297,29 +2299,29 @@ void Element::set_cascaded_properties(Optional style) +void Element::set_computed_properties(GC::Ptr style) { - m_computed_css_values = move(style); - computed_css_values_changed(); + m_computed_properties = style; + computed_properties_changed(); } -void Element::set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type pseudo_element, Optional style) +void Element::set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type pseudo_element, GC::Ptr style) { - if (!m_pseudo_element_data && !style.has_value()) + if (!m_pseudo_element_data && !style) return; if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element)) { return; } - ensure_pseudo_element(pseudo_element).computed_css_values = move(style); + ensure_pseudo_element(pseudo_element).computed_properties = style; } -Optional Element::pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type type) +GC::Ptr Element::pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type type) { auto pseudo_element = get_pseudo_element(type); if (pseudo_element.has_value()) - return pseudo_element->computed_css_values; + return pseudo_element->computed_properties; return {}; } @@ -2491,7 +2493,7 @@ bool Element::check_visibility(Optional options) // 2. If an ancestor of this in the flat tree has content-visibility: hidden, return false. for (auto* element = parent_element(); element; element = element->parent_element()) { - if (element->computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden) + if (element->computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden) return false; } @@ -2502,14 +2504,14 @@ bool Element::check_visibility(Optional options) // 3. If either the opacityProperty or the checkOpacity dictionary members of options are true, and this, or an ancestor of this in the flat tree, has a computed opacity value of 0, return false. if (options->opacity_property || options->check_opacity) { for (auto* element = this; element; element = element->parent_element()) { - if (element->computed_css_values()->opacity() == 0.0f) + if (element->computed_properties()->opacity() == 0.0f) return false; } } // 4. If either the visibilityProperty or the checkVisibilityCSS dictionary members of options are true, and this is invisible, return false. if (options->visibility_property || options->check_visibility_css) { - if (computed_css_values()->visibility() == CSS::Visibility::Hidden) + if (computed_properties()->visibility() == CSS::Visibility::Hidden) return false; } @@ -2518,7 +2520,7 @@ bool Element::check_visibility(Optional options) auto const skipped_contents_due_to_content_visibility_auto = false; if (options->content_visibility_auto && skipped_contents_due_to_content_visibility_auto) { for (auto* element = this; element; element = element->parent_element()) { - if (element->computed_css_values()->content_visibility() == CSS::ContentVisibility::Auto) + if (element->computed_properties()->content_visibility() == CSS::ContentVisibility::Auto) return false; } } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 8efe63889b3..96dd9472b1d 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -185,16 +185,16 @@ public: GC::Ptr layout_node(); GC::Ptr layout_node() const; - Optional& computed_css_values() { return m_computed_css_values; } - Optional const& computed_css_values() const { return m_computed_css_values; } - void set_computed_css_values(Optional); - CSS::ComputedProperties resolved_css_values(Optional = {}); + GC::Ptr computed_properties() { return m_computed_properties; } + GC::Ptr computed_properties() const { return m_computed_properties; } + void set_computed_properties(GC::Ptr); + GC::Ref resolved_css_values(Optional = {}); [[nodiscard]] GC::Ptr cascaded_properties(Optional) const; void set_cascaded_properties(Optional, GC::Ptr); - void set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type, Optional); - Optional pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type); + void set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type, GC::Ptr); + GC::Ptr pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type); void reset_animated_css_properties(); @@ -240,13 +240,13 @@ public: GC::Ref get_bounding_client_rect() const; GC::Ref get_client_rects() const; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties); + virtual GC::Ptr create_layout_node(GC::Ref); virtual void adjust_computed_style(CSS::ComputedProperties&) { } virtual void did_receive_focus() { } virtual void did_lose_focus() { } - static GC::Ptr create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, CSS::ComputedProperties, Element*); + static GC::Ptr create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, GC::Ref, Element*); void set_pseudo_element_node(Badge, CSS::Selector::PseudoElement::Type, GC::Ptr); GC::Ptr get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const; @@ -384,7 +384,7 @@ protected: // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext virtual void attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); - virtual void computed_css_values_changed() { } + virtual void computed_properties_changed() { } virtual void visit_edges(Cell::Visitor&) override; @@ -415,14 +415,13 @@ private: GC::Ptr m_shadow_root; GC::Ptr m_cascaded_properties; - - Optional m_computed_css_values; + GC::Ptr m_computed_properties; HashMap m_custom_properties; struct PseudoElement { GC::Ptr layout_node; GC::Ptr cascaded_properties; - Optional computed_css_values; + GC::Ptr computed_properties; HashMap custom_properties; }; // TODO: CSS::Selector::PseudoElement::Type includes a lot of pseudo-elements that exist in shadow trees, diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index a333691dddd..aa9d5f08663 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -397,13 +397,13 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho } } - if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast(layout_node.dom_node())->computed_css_values().has_value()) { + if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast(layout_node.dom_node())->computed_properties()) { struct NameAndValue { FlyString name; String value; }; Vector properties; - verify_cast(*layout_node.dom_node()).computed_css_values()->for_each_property([&](auto property_id, auto& value) { + verify_cast(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) { properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::CSSStyleValue::SerializationMode::Normal) }); }); quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; }); diff --git a/Libraries/LibWeb/HTML/HTMLAudioElement.cpp b/Libraries/LibWeb/HTML/HTMLAudioElement.cpp index 4be43f437fc..fe6f2410ded 100644 --- a/Libraries/LibWeb/HTML/HTMLAudioElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLAudioElement.cpp @@ -29,7 +29,7 @@ void HTMLAudioElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLAudioElement); } -GC::Ptr HTMLAudioElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLAudioElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLAudioElement.h b/Libraries/LibWeb/HTML/HTMLAudioElement.h index ae8642a65cb..93acb9ff72b 100644 --- a/Libraries/LibWeb/HTML/HTMLAudioElement.h +++ b/Libraries/LibWeb/HTML/HTMLAudioElement.h @@ -25,7 +25,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; virtual void on_playing() override; diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Libraries/LibWeb/HTML/HTMLBRElement.cpp index 29b4ddd5d8c..c6b8adaa68c 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -27,7 +27,7 @@ void HTMLBRElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement); } -GC::Ptr HTMLBRElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLBRElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.h b/Libraries/LibWeb/HTML/HTMLBRElement.h index a35c68c61c9..2fb9ceb66f1 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -17,7 +17,7 @@ class HTMLBRElement final : public HTMLElement { public: virtual ~HTMLBRElement() override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; private: diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 2af037a5808..f6eb984fb4d 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -175,7 +175,7 @@ WebIDL::ExceptionOr HTMLCanvasElement::set_height(WebIDL::UnsignedLong val return {}; } -GC::Ptr HTMLCanvasElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLCanvasElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Libraries/LibWeb/HTML/HTMLCanvasElement.h index 18d5d33b03b..639b47de3b7 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -54,7 +54,7 @@ private: virtual void apply_presentational_hints(GC::Ref) const override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; template diff --git a/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp b/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp index 0d869d7c35a..57e07f7b698 100644 --- a/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp @@ -83,7 +83,7 @@ Layout::FieldSetBox* HTMLFieldSetElement::layout_node() return static_cast(Node::layout_node()); } -GC::Ptr HTMLFieldSetElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLFieldSetElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, style); } diff --git a/Libraries/LibWeb/HTML/HTMLFieldSetElement.h b/Libraries/LibWeb/HTML/HTMLFieldSetElement.h index c23bc59a15d..de7d57dcf4e 100644 --- a/Libraries/LibWeb/HTML/HTMLFieldSetElement.h +++ b/Libraries/LibWeb/HTML/HTMLFieldSetElement.h @@ -42,7 +42,7 @@ public: virtual Optional default_role() const override { return ARIA::Role::group; } - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; Layout::FieldSetBox* layout_node(); Layout::FieldSetBox const* layout_node() const; diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index e301b47c6ae..f0db6c9996b 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -34,7 +34,7 @@ void HTMLIFrameElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLIFrameElement); } -GC::Ptr HTMLIFrameElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLIFrameElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index ddf7b9ab939..cefa15e8e88 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -23,7 +23,7 @@ class HTMLIFrameElement final public: virtual ~HTMLIFrameElement() override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; void set_current_navigation_was_lazy_loaded(bool value); diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 110f11c391b..486b1280b3e 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -134,7 +134,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const } } -GC::Ptr HTMLImageElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLImageElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style), *this); } diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.h b/Libraries/LibWeb/HTML/HTMLImageElement.h index b10a77dc977..0cd5a86d46e 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -126,7 +126,7 @@ private: // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:dimension-attributes virtual bool supports_dimension_attributes() const override { return true; } - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; virtual void did_set_viewport_rect(CSSPixelRect const&) override; diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 154c0123d12..a1dfa695d49 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -99,7 +99,7 @@ GC::Ref HTMLInputElement::validity() const return realm.create(realm); } -GC::Ptr HTMLInputElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLInputElement::create_layout_node(GC::Ref style) { if (type_state() == TypeAttributeState::Hidden) return nullptr; @@ -114,8 +114,8 @@ GC::Ptr HTMLInputElement::create_layout_node(CSS::ComputedProperti // This specification introduces the appearance property to provide some control over this behavior. // In particular, using appearance: none allows authors to suppress the native appearance of widgets, // giving them a primitive appearance where CSS can be used to restyle them. - if (style.appearance() == CSS::Appearance::None) { - return Element::create_layout_node_for_display_type(document(), style.display(), style, this); + if (style->appearance() == CSS::Appearance::None) { + return Element::create_layout_node_for_display_type(document(), style->display(), style, this); } if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton) @@ -127,7 +127,7 @@ GC::Ptr HTMLInputElement::create_layout_node(CSS::ComputedProperti if (type_state() == TypeAttributeState::RadioButton) return heap().allocate(document(), *this, move(style)); - return Element::create_layout_node_for_display_type(document(), style.display(), style, this); + return Element::create_layout_node_for_display_type(document(), style->display(), style, this); } void HTMLInputElement::adjust_computed_style(CSS::ComputedProperties& style) @@ -1123,16 +1123,16 @@ void HTMLInputElement::create_range_input_shadow_tree() add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback)); } -void HTMLInputElement::computed_css_values_changed() +void HTMLInputElement::computed_properties_changed() { - auto appearance = computed_css_values()->appearance(); + auto appearance = computed_properties()->appearance(); if (!appearance.has_value() || *appearance == CSS::Appearance::None) return; auto palette = document().page().palette(); auto accent_color = palette.color(ColorRole::Accent).to_string(); - auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor); + auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor); if (accent_color_property.has_color()) accent_color = accent_color_property.to_string(CSS::CSSStyleValue::SerializationMode::Normal); diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.h b/Libraries/LibWeb/HTML/HTMLInputElement.h index 3af6b799330..6f6d20f4c73 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -58,7 +58,7 @@ class HTMLInputElement final public: virtual ~HTMLInputElement() override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; enum class TypeAttributeState { @@ -241,7 +241,7 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; - virtual void computed_css_values_changed() override; + virtual void computed_properties_changed() override; // https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):dimension-attributes virtual bool supports_dimension_attributes() const override { return type_state() == TypeAttributeState::ImageButton; } diff --git a/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index 6407b83c52b..4665d298c08 100644 --- a/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -27,7 +27,7 @@ void HTMLLabelElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLabelElement); } -GC::Ptr HTMLLabelElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLLabelElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLLabelElement.h b/Libraries/LibWeb/HTML/HTMLLabelElement.h index 012c5de57b6..9ce52c7fed7 100644 --- a/Libraries/LibWeb/HTML/HTMLLabelElement.h +++ b/Libraries/LibWeb/HTML/HTMLLabelElement.h @@ -17,7 +17,7 @@ class HTMLLabelElement final : public HTMLElement { public: virtual ~HTMLLabelElement() override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; Optional for_() const { return attribute(HTML::AttributeNames::for_); } diff --git a/Libraries/LibWeb/HTML/HTMLLegendElement.cpp b/Libraries/LibWeb/HTML/HTMLLegendElement.cpp index 37a534e0876..5a77eef7830 100644 --- a/Libraries/LibWeb/HTML/HTMLLegendElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLegendElement.cpp @@ -40,7 +40,7 @@ HTMLFormElement* HTMLLegendElement::form() return nullptr; } -GC::Ptr HTMLLegendElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLLegendElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLLegendElement.h b/Libraries/LibWeb/HTML/HTMLLegendElement.h index 4548c063e50..f79387e49d1 100644 --- a/Libraries/LibWeb/HTML/HTMLLegendElement.h +++ b/Libraries/LibWeb/HTML/HTMLLegendElement.h @@ -20,7 +20,7 @@ public: HTMLFormElement* form(); - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; Layout::LegendBox* layout_node(); Layout::LegendBox const* layout_node() const; diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index f44dc5cf214..d29e6cd88cd 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -158,7 +158,7 @@ String HTMLObjectElement::data() const return document().encoding_parse_url(*data).to_string(); } -GC::Ptr HTMLObjectElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLObjectElement::create_layout_node(GC::Ref style) { switch (m_representation) { case Representation::Children: diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Libraries/LibWeb/HTML/HTMLObjectElement.h index 3294b3f3328..3d07dcce970 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -56,7 +56,7 @@ private: virtual void apply_presentational_hints(GC::Ref) const override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const; diff --git a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index 4594deb4505..f4252e1ec50 100644 --- a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -130,12 +130,12 @@ void HTMLProgressElement::update_progress_value_element() MUST(m_progress_value_element->style_for_bindings()->set_property(CSS::PropertyID::Width, MUST(String::formatted("{}%", position() * 100)))); } -void HTMLProgressElement::computed_css_values_changed() +void HTMLProgressElement::computed_properties_changed() { auto palette = document().page().palette(); auto accent_color = palette.color(ColorRole::Accent).to_string(); - auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor); + auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor); if (accent_color_property.has_color()) accent_color = accent_color_property.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); diff --git a/Libraries/LibWeb/HTML/HTMLProgressElement.h b/Libraries/LibWeb/HTML/HTMLProgressElement.h index 1988089f0cf..771e22b3e1d 100644 --- a/Libraries/LibWeb/HTML/HTMLProgressElement.h +++ b/Libraries/LibWeb/HTML/HTMLProgressElement.h @@ -44,7 +44,7 @@ private: // ^DOM::Node virtual bool is_html_progress_element() const final { return true; } - virtual void computed_css_values_changed() override; + virtual void computed_properties_changed() override; virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index df55ff61470..3a0607d6415 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -516,11 +516,11 @@ void HTMLSelectElement::form_associated_element_was_removed(DOM::Node*) set_shadow_root(nullptr); } -void HTMLSelectElement::computed_css_values_changed() +void HTMLSelectElement::computed_properties_changed() { // Hide chevron icon when appearance is none if (m_chevron_icon_element) { - auto appearance = computed_css_values()->appearance(); + auto appearance = computed_properties()->appearance(); if (appearance.has_value() && *appearance == CSS::Appearance::None) { MUST(m_chevron_icon_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "none"_string)); } else { diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Libraries/LibWeb/HTML/HTMLSelectElement.h index c89d64e94ac..616a025046b 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -105,7 +105,7 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; - virtual void computed_css_values_changed() override; + virtual void computed_properties_changed() override; virtual void children_changed() override; diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 6df0194feaf..328e47bd8f8 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -99,7 +99,7 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(style_property, CSS::CSSKeywordValue::create(CSS::Keyword::Inset)); cascaded_properties->set_property_from_presentational_hint(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1))); - cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_css_values()->property(color_property)); + cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_properties()->property(color_property)); }; apply_border_style(CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor); apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor); diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index a224506ec7f..0eff6090c5b 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -63,7 +63,7 @@ void HTMLVideoElement::attribute_changed(FlyString const& name, Optional } } -GC::Ptr HTMLVideoElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr HTMLVideoElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Libraries/LibWeb/HTML/HTMLVideoElement.h index 6f1ec417b1b..dd2ade6efa1 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.h @@ -60,7 +60,7 @@ private: // https://html.spec.whatwg.org/multipage/media.html#the-video-element:dimension-attributes virtual bool supports_dimension_attributes() const override { return true; } - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void adjust_computed_style(CSS::ComputedProperties&) override; virtual void on_playing() override; diff --git a/Libraries/LibWeb/Layout/AudioBox.cpp b/Libraries/LibWeb/Layout/AudioBox.cpp index 13e897654c5..015ab7f65ea 100644 --- a/Libraries/LibWeb/Layout/AudioBox.cpp +++ b/Libraries/LibWeb/Layout/AudioBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(AudioBox); -AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) +AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : ReplacedBox(document, element, move(style)) { set_natural_width(300); diff --git a/Libraries/LibWeb/Layout/AudioBox.h b/Libraries/LibWeb/Layout/AudioBox.h index ab9e5d8d634..2f5c53e7a81 100644 --- a/Libraries/LibWeb/Layout/AudioBox.h +++ b/Libraries/LibWeb/Layout/AudioBox.h @@ -23,7 +23,7 @@ public: virtual GC::Ptr create_paintable() const override; private: - AudioBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties); + AudioBox(DOM::Document&, DOM::Element&, GC::Ref); }; } diff --git a/Libraries/LibWeb/Layout/BlockContainer.cpp b/Libraries/LibWeb/Layout/BlockContainer.cpp index 15c052cb8c9..1ea8b2bbad3 100644 --- a/Libraries/LibWeb/Layout/BlockContainer.cpp +++ b/Libraries/LibWeb/Layout/BlockContainer.cpp @@ -9,7 +9,7 @@ namespace Web::Layout { -BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style) +BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, GC::Ref style) : Box(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/BlockContainer.h b/Libraries/LibWeb/Layout/BlockContainer.h index cd2f819a321..dd91d2932dc 100644 --- a/Libraries/LibWeb/Layout/BlockContainer.h +++ b/Libraries/LibWeb/Layout/BlockContainer.h @@ -16,7 +16,7 @@ class BlockContainer : public Box { GC_CELL(BlockContainer, Box); public: - BlockContainer(DOM::Document&, DOM::Node*, CSS::ComputedProperties); + BlockContainer(DOM::Document&, DOM::Node*, GC::Ref); BlockContainer(DOM::Document&, DOM::Node*, NonnullOwnPtr); virtual ~BlockContainer() override; diff --git a/Libraries/LibWeb/Layout/Box.cpp b/Libraries/LibWeb/Layout/Box.cpp index 922ea44873c..ad66c92023f 100644 --- a/Libraries/LibWeb/Layout/Box.cpp +++ b/Libraries/LibWeb/Layout/Box.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { -Box::Box(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style) +Box::Box(DOM::Document& document, DOM::Node* node, GC::Ref style) : NodeWithStyleAndBoxModelMetrics(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/Box.h b/Libraries/LibWeb/Layout/Box.h index 7713744c673..a10fb48c42c 100644 --- a/Libraries/LibWeb/Layout/Box.h +++ b/Libraries/LibWeb/Layout/Box.h @@ -55,7 +55,7 @@ public: virtual void visit_edges(Cell::Visitor&) override; protected: - Box(DOM::Document&, DOM::Node*, CSS::ComputedProperties); + Box(DOM::Document&, DOM::Node*, GC::Ref); Box(DOM::Document&, DOM::Node*, NonnullOwnPtr); private: diff --git a/Libraries/LibWeb/Layout/BreakNode.cpp b/Libraries/LibWeb/Layout/BreakNode.cpp index 0303f6cc83f..431ccd9217c 100644 --- a/Libraries/LibWeb/Layout/BreakNode.cpp +++ b/Libraries/LibWeb/Layout/BreakNode.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(BreakNode); -BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, CSS::ComputedProperties style) +BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, GC::Ref style) : Layout::NodeWithStyleAndBoxModelMetrics(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/BreakNode.h b/Libraries/LibWeb/Layout/BreakNode.h index eaf757c8c16..6b7c24cfd83 100644 --- a/Libraries/LibWeb/Layout/BreakNode.h +++ b/Libraries/LibWeb/Layout/BreakNode.h @@ -16,7 +16,7 @@ class BreakNode final : public NodeWithStyleAndBoxModelMetrics { GC_DECLARE_ALLOCATOR(BreakNode); public: - BreakNode(DOM::Document&, HTML::HTMLBRElement&, CSS::ComputedProperties); + BreakNode(DOM::Document&, HTML::HTMLBRElement&, GC::Ref); virtual ~BreakNode() override; const HTML::HTMLBRElement& dom_node() const { return verify_cast(*Node::dom_node()); } diff --git a/Libraries/LibWeb/Layout/CanvasBox.cpp b/Libraries/LibWeb/Layout/CanvasBox.cpp index eae30c346a8..603bcc7cb15 100644 --- a/Libraries/LibWeb/Layout/CanvasBox.cpp +++ b/Libraries/LibWeb/Layout/CanvasBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(CanvasBox); -CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, CSS::ComputedProperties style) +CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, GC::Ref style) : ReplacedBox(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/CanvasBox.h b/Libraries/LibWeb/Layout/CanvasBox.h index c9ed27ec490..35db61ede58 100644 --- a/Libraries/LibWeb/Layout/CanvasBox.h +++ b/Libraries/LibWeb/Layout/CanvasBox.h @@ -16,7 +16,7 @@ class CanvasBox final : public ReplacedBox { GC_DECLARE_ALLOCATOR(CanvasBox); public: - CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, CSS::ComputedProperties); + CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, GC::Ref); virtual ~CanvasBox() override; virtual void prepare_for_replaced_layout() override; diff --git a/Libraries/LibWeb/Layout/CheckBox.cpp b/Libraries/LibWeb/Layout/CheckBox.cpp index c7d7a289f9e..865b8af040f 100644 --- a/Libraries/LibWeb/Layout/CheckBox.cpp +++ b/Libraries/LibWeb/Layout/CheckBox.cpp @@ -13,7 +13,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(CheckBox); -CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, CSS::ComputedProperties style) +CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, GC::Ref style) : FormAssociatedLabelableNode(document, element, move(style)) { set_natural_width(13); diff --git a/Libraries/LibWeb/Layout/CheckBox.h b/Libraries/LibWeb/Layout/CheckBox.h index 43b84f7b919..2670322757e 100644 --- a/Libraries/LibWeb/Layout/CheckBox.h +++ b/Libraries/LibWeb/Layout/CheckBox.h @@ -16,7 +16,7 @@ class CheckBox final : public FormAssociatedLabelableNode { GC_DECLARE_ALLOCATOR(CheckBox); public: - CheckBox(DOM::Document&, HTML::HTMLInputElement&, CSS::ComputedProperties); + CheckBox(DOM::Document&, HTML::HTMLInputElement&, GC::Ref); virtual ~CheckBox() override; private: diff --git a/Libraries/LibWeb/Layout/FieldSetBox.cpp b/Libraries/LibWeb/Layout/FieldSetBox.cpp index 65f27ab416f..f12f6e232c2 100644 --- a/Libraries/LibWeb/Layout/FieldSetBox.cpp +++ b/Libraries/LibWeb/Layout/FieldSetBox.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(FieldSetBox); -FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) +FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : BlockContainer(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/FieldSetBox.h b/Libraries/LibWeb/Layout/FieldSetBox.h index 3bab35d5c97..540b9ab0699 100644 --- a/Libraries/LibWeb/Layout/FieldSetBox.h +++ b/Libraries/LibWeb/Layout/FieldSetBox.h @@ -16,7 +16,7 @@ class FieldSetBox final : public BlockContainer { GC_DECLARE_ALLOCATOR(FieldSetBox); public: - FieldSetBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties); + FieldSetBox(DOM::Document&, DOM::Element&, GC::Ref); virtual ~FieldSetBox() override; DOM::Element& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h b/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h index 4f9ed37dc50..01460993441 100644 --- a/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h +++ b/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h @@ -21,7 +21,7 @@ public: HTML::FormAssociatedElement& dom_node() { return dynamic_cast(LabelableNode::dom_node()); } protected: - FormAssociatedLabelableNode(DOM::Document& document, HTML::FormAssociatedElement& element, CSS::ComputedProperties style) + FormAssociatedLabelableNode(DOM::Document& document, HTML::FormAssociatedElement& element, GC::Ref style) : LabelableNode(document, element.form_associated_element_to_html_element(), move(style)) { } diff --git a/Libraries/LibWeb/Layout/ImageBox.cpp b/Libraries/LibWeb/Layout/ImageBox.cpp index f4548b7a4ab..d946f7b1c42 100644 --- a/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Libraries/LibWeb/Layout/ImageBox.cpp @@ -15,7 +15,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(ImageBox); -ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style, ImageProvider const& image_provider) +ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, GC::Ref style, ImageProvider const& image_provider) : ReplacedBox(document, element, move(style)) , m_image_provider(image_provider) { diff --git a/Libraries/LibWeb/Layout/ImageBox.h b/Libraries/LibWeb/Layout/ImageBox.h index 2854c50a2c9..294960d3663 100644 --- a/Libraries/LibWeb/Layout/ImageBox.h +++ b/Libraries/LibWeb/Layout/ImageBox.h @@ -16,7 +16,7 @@ class ImageBox final : public ReplacedBox { GC_DECLARE_ALLOCATOR(ImageBox); public: - ImageBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties, ImageProvider const&); + ImageBox(DOM::Document&, DOM::Element&, GC::Ref, ImageProvider const&); virtual ~ImageBox() override; virtual void prepare_for_replaced_layout() override; diff --git a/Libraries/LibWeb/Layout/InlineNode.cpp b/Libraries/LibWeb/Layout/InlineNode.cpp index e34c3cd2bc1..5eef94e691b 100644 --- a/Libraries/LibWeb/Layout/InlineNode.cpp +++ b/Libraries/LibWeb/Layout/InlineNode.cpp @@ -16,7 +16,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(InlineNode); -InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, CSS::ComputedProperties style) +InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, GC::Ref style) : Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/InlineNode.h b/Libraries/LibWeb/Layout/InlineNode.h index fbfe06c9240..49030d16aad 100644 --- a/Libraries/LibWeb/Layout/InlineNode.h +++ b/Libraries/LibWeb/Layout/InlineNode.h @@ -15,7 +15,7 @@ class InlineNode final : public NodeWithStyleAndBoxModelMetrics { GC_DECLARE_ALLOCATOR(InlineNode); public: - InlineNode(DOM::Document&, DOM::Element*, CSS::ComputedProperties); + InlineNode(DOM::Document&, DOM::Element*, GC::Ref); virtual ~InlineNode() override; GC::Ptr create_paintable_for_line_with_index(size_t line_index) const; diff --git a/Libraries/LibWeb/Layout/Label.cpp b/Libraries/LibWeb/Layout/Label.cpp index e992ab4bec9..11fdfe5facf 100644 --- a/Libraries/LibWeb/Layout/Label.cpp +++ b/Libraries/LibWeb/Layout/Label.cpp @@ -17,7 +17,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(Label); -Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, CSS::ComputedProperties style) +Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, GC::Ref style) : BlockContainer(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/Label.h b/Libraries/LibWeb/Layout/Label.h index adbd359b735..5ba546938d0 100644 --- a/Libraries/LibWeb/Layout/Label.h +++ b/Libraries/LibWeb/Layout/Label.h @@ -16,7 +16,7 @@ class Label final : public BlockContainer { GC_DECLARE_ALLOCATOR(Label); public: - Label(DOM::Document&, HTML::HTMLLabelElement*, CSS::ComputedProperties); + Label(DOM::Document&, HTML::HTMLLabelElement*, GC::Ref); virtual ~Label() override; static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint); diff --git a/Libraries/LibWeb/Layout/LabelableNode.h b/Libraries/LibWeb/Layout/LabelableNode.h index 02dea4a9cb7..a052bcd6ab8 100644 --- a/Libraries/LibWeb/Layout/LabelableNode.h +++ b/Libraries/LibWeb/Layout/LabelableNode.h @@ -19,7 +19,7 @@ public: Painting::LabelablePaintable const* paintable() const; protected: - LabelableNode(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) + LabelableNode(DOM::Document& document, DOM::Element& element, GC::Ref style) : ReplacedBox(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LegendBox.cpp b/Libraries/LibWeb/Layout/LegendBox.cpp index 7d6e8f9b1d7..387cf4af1f6 100644 --- a/Libraries/LibWeb/Layout/LegendBox.cpp +++ b/Libraries/LibWeb/Layout/LegendBox.cpp @@ -10,7 +10,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(LegendBox); -LegendBox::LegendBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) +LegendBox::LegendBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : BlockContainer(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LegendBox.h b/Libraries/LibWeb/Layout/LegendBox.h index 41627f66619..40d01ab0197 100644 --- a/Libraries/LibWeb/Layout/LegendBox.h +++ b/Libraries/LibWeb/Layout/LegendBox.h @@ -15,7 +15,7 @@ class LegendBox final : public BlockContainer { GC_DECLARE_ALLOCATOR(LegendBox); public: - LegendBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties); + LegendBox(DOM::Document&, DOM::Element&, GC::Ref); virtual ~LegendBox() override; DOM::Element& dom_node() { return static_cast(*Box::dom_node()); } diff --git a/Libraries/LibWeb/Layout/ListItemBox.cpp b/Libraries/LibWeb/Layout/ListItemBox.cpp index fc5cea5e896..baf8e9de9c9 100644 --- a/Libraries/LibWeb/Layout/ListItemBox.cpp +++ b/Libraries/LibWeb/Layout/ListItemBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(ListItemBox); -ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, CSS::ComputedProperties style) +ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, GC::Ref style) : Layout::BlockContainer(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/ListItemBox.h b/Libraries/LibWeb/Layout/ListItemBox.h index e7cf790fc38..58dc4a8550a 100644 --- a/Libraries/LibWeb/Layout/ListItemBox.h +++ b/Libraries/LibWeb/Layout/ListItemBox.h @@ -16,7 +16,7 @@ class ListItemBox final : public BlockContainer { GC_DECLARE_ALLOCATOR(ListItemBox); public: - ListItemBox(DOM::Document&, DOM::Element*, CSS::ComputedProperties); + ListItemBox(DOM::Document&, DOM::Element*, GC::Ref); virtual ~ListItemBox() override; DOM::Element& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp b/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp index a7014bad4fe..fc812051431 100644 --- a/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp +++ b/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(ListItemMarkerBox); -ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, CSS::ComputedProperties style) +ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, GC::Ref style) : Box(document, nullptr, move(style)) , m_list_style_type(style_type) , m_list_style_position(style_position) diff --git a/Libraries/LibWeb/Layout/ListItemMarkerBox.h b/Libraries/LibWeb/Layout/ListItemMarkerBox.h index ffa01c8417b..7a9609ad763 100644 --- a/Libraries/LibWeb/Layout/ListItemMarkerBox.h +++ b/Libraries/LibWeb/Layout/ListItemMarkerBox.h @@ -16,7 +16,7 @@ class ListItemMarkerBox final : public Box { GC_DECLARE_ALLOCATOR(ListItemMarkerBox); public: - explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, CSS::ComputedProperties); + explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, GC::Ref); virtual ~ListItemMarkerBox() override; Optional const& text() const { return m_text; } diff --git a/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp index d014f4c9239..d6485262faa 100644 --- a/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp @@ -16,7 +16,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(NavigableContainerViewport); -NavigableContainerViewport::NavigableContainerViewport(DOM::Document& document, HTML::NavigableContainer& element, CSS::ComputedProperties style) +NavigableContainerViewport::NavigableContainerViewport(DOM::Document& document, HTML::NavigableContainer& element, GC::Ref style) : ReplacedBox(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/NavigableContainerViewport.h b/Libraries/LibWeb/Layout/NavigableContainerViewport.h index c2c2a6e63c0..616e63d578f 100644 --- a/Libraries/LibWeb/Layout/NavigableContainerViewport.h +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.h @@ -16,7 +16,7 @@ class NavigableContainerViewport final : public ReplacedBox { GC_DECLARE_ALLOCATOR(NavigableContainerViewport); public: - NavigableContainerViewport(DOM::Document&, HTML::NavigableContainer&, CSS::ComputedProperties); + NavigableContainerViewport(DOM::Document&, HTML::NavigableContainer&, GC::Ref); virtual ~NavigableContainerViewport() override; virtual void prepare_for_replaced_layout() override; diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index cc5c5b1bde4..bb885a3d0e7 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -276,7 +276,7 @@ bool Node::is_sticky_position() const return position == CSS::Positioning::Sticky; } -NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties computed_style) +NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, GC::Ref computed_style) : Node(document, node) , m_computed_values(make()) { diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h index 1681ef48181..85a272f79ff 100644 --- a/Libraries/LibWeb/Layout/Node.h +++ b/Libraries/LibWeb/Layout/Node.h @@ -238,7 +238,7 @@ public: virtual void visit_edges(Cell::Visitor& visitor) override; protected: - NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedProperties); + NodeWithStyle(DOM::Document&, DOM::Node*, GC::Ref); NodeWithStyle(DOM::Document&, DOM::Node*, NonnullOwnPtr); private: @@ -257,8 +257,8 @@ public: BoxModelMetrics const& box_model() const { return m_box_model; } protected: - NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style) - : NodeWithStyle(document, node, move(style)) + NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, GC::Ref style) + : NodeWithStyle(document, node, style) { } diff --git a/Libraries/LibWeb/Layout/RadioButton.cpp b/Libraries/LibWeb/Layout/RadioButton.cpp index 0fda5b1e116..58d179ca076 100644 --- a/Libraries/LibWeb/Layout/RadioButton.cpp +++ b/Libraries/LibWeb/Layout/RadioButton.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(RadioButton); -RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, CSS::ComputedProperties style) +RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, GC::Ref style) : FormAssociatedLabelableNode(document, element, move(style)) { set_natural_width(12); diff --git a/Libraries/LibWeb/Layout/RadioButton.h b/Libraries/LibWeb/Layout/RadioButton.h index dbce67f0aee..461faa37d9f 100644 --- a/Libraries/LibWeb/Layout/RadioButton.h +++ b/Libraries/LibWeb/Layout/RadioButton.h @@ -16,7 +16,7 @@ class RadioButton final : public FormAssociatedLabelableNode { GC_DECLARE_ALLOCATOR(RadioButton); public: - RadioButton(DOM::Document&, HTML::HTMLInputElement&, CSS::ComputedProperties); + RadioButton(DOM::Document&, HTML::HTMLInputElement&, GC::Ref); virtual ~RadioButton() override; private: diff --git a/Libraries/LibWeb/Layout/ReplacedBox.cpp b/Libraries/LibWeb/Layout/ReplacedBox.cpp index 7a3f0cee961..a829e7ad391 100644 --- a/Libraries/LibWeb/Layout/ReplacedBox.cpp +++ b/Libraries/LibWeb/Layout/ReplacedBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { -ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) +ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : Box(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/ReplacedBox.h b/Libraries/LibWeb/Layout/ReplacedBox.h index 548854d1596..9572462a0cd 100644 --- a/Libraries/LibWeb/Layout/ReplacedBox.h +++ b/Libraries/LibWeb/Layout/ReplacedBox.h @@ -15,7 +15,7 @@ class ReplacedBox : public Box { GC_CELL(ReplacedBox, Box); public: - ReplacedBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties); + ReplacedBox(DOM::Document&, DOM::Element&, GC::Ref); virtual ~ReplacedBox() override; DOM::Element const& dom_node() const { return verify_cast(*Node::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGBox.cpp b/Libraries/LibWeb/Layout/SVGBox.cpp index 84a72f09772..5e8886a6b53 100644 --- a/Libraries/LibWeb/Layout/SVGBox.cpp +++ b/Libraries/LibWeb/Layout/SVGBox.cpp @@ -8,7 +8,7 @@ namespace Web::Layout { -SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, CSS::ComputedProperties style) +SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, GC::Ref style) : Box(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/SVGBox.h b/Libraries/LibWeb/Layout/SVGBox.h index 1732a7d3680..4a01aac1be5 100644 --- a/Libraries/LibWeb/Layout/SVGBox.h +++ b/Libraries/LibWeb/Layout/SVGBox.h @@ -16,7 +16,7 @@ class SVGBox : public Box { GC_CELL(SVGBox, Box); public: - SVGBox(DOM::Document&, SVG::SVGElement&, CSS::ComputedProperties); + SVGBox(DOM::Document&, SVG::SVGElement&, GC::Ref); virtual ~SVGBox() override = default; SVG::SVGElement& dom_node() { return verify_cast(*Box::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGClipBox.cpp b/Libraries/LibWeb/Layout/SVGClipBox.cpp index 4e590e92573..6896b309f29 100644 --- a/Libraries/LibWeb/Layout/SVGClipBox.cpp +++ b/Libraries/LibWeb/Layout/SVGClipBox.cpp @@ -12,8 +12,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGClipBox); -SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, CSS::ComputedProperties properties) - : SVGBox(document, element, properties) +SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, GC::Ref style) + : SVGBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGClipBox.h b/Libraries/LibWeb/Layout/SVGClipBox.h index 12d1bfad30c..6ca5ad15284 100644 --- a/Libraries/LibWeb/Layout/SVGClipBox.h +++ b/Libraries/LibWeb/Layout/SVGClipBox.h @@ -17,7 +17,7 @@ class SVGClipBox : public SVGBox { GC_DECLARE_ALLOCATOR(SVGClipBox); public: - SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, CSS::ComputedProperties); + SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, GC::Ref); virtual ~SVGClipBox() override = default; SVG::SVGClipPathElement& dom_node() { return verify_cast(SVGBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp b/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp index 32f72f91011..6eb8ac9b081 100644 --- a/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp +++ b/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp @@ -12,8 +12,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGForeignObjectBox); -SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, CSS::ComputedProperties properties) - : BlockContainer(document, &element, properties) +SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, GC::Ref style) + : BlockContainer(document, &element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGForeignObjectBox.h b/Libraries/LibWeb/Layout/SVGForeignObjectBox.h index 7f8667303ef..ce8ebd96cc4 100644 --- a/Libraries/LibWeb/Layout/SVGForeignObjectBox.h +++ b/Libraries/LibWeb/Layout/SVGForeignObjectBox.h @@ -18,7 +18,7 @@ class SVGForeignObjectBox final : public BlockContainer { GC_DECLARE_ALLOCATOR(SVGForeignObjectBox); public: - SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, CSS::ComputedProperties); + SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, GC::Ref); virtual ~SVGForeignObjectBox() override = default; SVG::SVGForeignObjectElement& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGGeometryBox.cpp b/Libraries/LibWeb/Layout/SVGGeometryBox.cpp index ec5b7e01246..1290097058c 100644 --- a/Libraries/LibWeb/Layout/SVGGeometryBox.cpp +++ b/Libraries/LibWeb/Layout/SVGGeometryBox.cpp @@ -14,8 +14,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGGeometryBox); -SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, CSS::ComputedProperties properties) - : SVGGraphicsBox(document, element, properties) +SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, GC::Ref style) + : SVGGraphicsBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGGeometryBox.h b/Libraries/LibWeb/Layout/SVGGeometryBox.h index c60d4e09910..848a706210d 100644 --- a/Libraries/LibWeb/Layout/SVGGeometryBox.h +++ b/Libraries/LibWeb/Layout/SVGGeometryBox.h @@ -17,7 +17,7 @@ class SVGGeometryBox final : public SVGGraphicsBox { GC_DECLARE_ALLOCATOR(SVGGeometryBox); public: - SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, CSS::ComputedProperties); + SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, GC::Ref); virtual ~SVGGeometryBox() override = default; SVG::SVGGeometryElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp b/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp index f4e51be040b..d19e16215e5 100644 --- a/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp +++ b/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp @@ -10,8 +10,8 @@ namespace Web::Layout { -SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::ComputedProperties properties) - : SVGBox(document, element, properties) +SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, GC::Ref style) + : SVGBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGGraphicsBox.h b/Libraries/LibWeb/Layout/SVGGraphicsBox.h index 2db75309dcd..024f302bfac 100644 --- a/Libraries/LibWeb/Layout/SVGGraphicsBox.h +++ b/Libraries/LibWeb/Layout/SVGGraphicsBox.h @@ -16,7 +16,7 @@ class SVGGraphicsBox : public SVGBox { GC_CELL(SVGGraphicsBox, SVGBox); public: - SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::ComputedProperties); + SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, GC::Ref); virtual ~SVGGraphicsBox() override = default; SVG::SVGGraphicsElement& dom_node() { return verify_cast(SVGBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGImageBox.cpp b/Libraries/LibWeb/Layout/SVGImageBox.cpp index cefbac7ba13..e3c33a9ef77 100644 --- a/Libraries/LibWeb/Layout/SVGImageBox.cpp +++ b/Libraries/LibWeb/Layout/SVGImageBox.cpp @@ -11,8 +11,8 @@ namespace Web::Layout { -SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::ComputedProperties properties) - : SVGGraphicsBox(document, element, properties) +SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, GC::Ref style) + : SVGGraphicsBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGImageBox.h b/Libraries/LibWeb/Layout/SVGImageBox.h index a43ec4fac25..c07b94f596e 100644 --- a/Libraries/LibWeb/Layout/SVGImageBox.h +++ b/Libraries/LibWeb/Layout/SVGImageBox.h @@ -16,7 +16,7 @@ class SVGImageBox : public SVGGraphicsBox { GC_CELL(SVGImageBox, SVGGraphicsBox); public: - SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::ComputedProperties); + SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, GC::Ref); virtual ~SVGImageBox() override = default; SVG::SVGImageElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGMaskBox.cpp b/Libraries/LibWeb/Layout/SVGMaskBox.cpp index 74758f7200b..f1ec31d91c0 100644 --- a/Libraries/LibWeb/Layout/SVGMaskBox.cpp +++ b/Libraries/LibWeb/Layout/SVGMaskBox.cpp @@ -12,8 +12,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGMaskBox); -SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, CSS::ComputedProperties properties) - : SVGGraphicsBox(document, element, properties) +SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, GC::Ref style) + : SVGGraphicsBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGMaskBox.h b/Libraries/LibWeb/Layout/SVGMaskBox.h index bbdbcec895f..8f50fefb8d8 100644 --- a/Libraries/LibWeb/Layout/SVGMaskBox.h +++ b/Libraries/LibWeb/Layout/SVGMaskBox.h @@ -17,7 +17,7 @@ class SVGMaskBox : public SVGGraphicsBox { GC_DECLARE_ALLOCATOR(SVGMaskBox); public: - SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, CSS::ComputedProperties); + SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, GC::Ref); virtual ~SVGMaskBox() override = default; virtual bool is_svg_mask_box() const override { return true; } diff --git a/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Libraries/LibWeb/Layout/SVGSVGBox.cpp index f56772592dd..0f198a15e38 100644 --- a/Libraries/LibWeb/Layout/SVGSVGBox.cpp +++ b/Libraries/LibWeb/Layout/SVGSVGBox.cpp @@ -15,8 +15,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGSVGBox); -SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, CSS::ComputedProperties properties) - : ReplacedBox(document, element, move(properties)) +SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, GC::Ref style) + : ReplacedBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGSVGBox.h b/Libraries/LibWeb/Layout/SVGSVGBox.h index 448218a6dc1..3eb664fb906 100644 --- a/Libraries/LibWeb/Layout/SVGSVGBox.h +++ b/Libraries/LibWeb/Layout/SVGSVGBox.h @@ -16,7 +16,7 @@ class SVGSVGBox final : public ReplacedBox { GC_DECLARE_ALLOCATOR(SVGSVGBox); public: - SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, CSS::ComputedProperties); + SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, GC::Ref); virtual ~SVGSVGBox() override = default; SVG::SVGSVGElement& dom_node() { return verify_cast(ReplacedBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGTextBox.cpp b/Libraries/LibWeb/Layout/SVGTextBox.cpp index 6aaafb9cc67..c4a77530e2e 100644 --- a/Libraries/LibWeb/Layout/SVGTextBox.cpp +++ b/Libraries/LibWeb/Layout/SVGTextBox.cpp @@ -12,8 +12,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGTextBox); -SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, CSS::ComputedProperties properties) - : SVGGraphicsBox(document, element, properties) +SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, GC::Ref style) + : SVGGraphicsBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGTextBox.h b/Libraries/LibWeb/Layout/SVGTextBox.h index 472f738344e..0ca7e4c085a 100644 --- a/Libraries/LibWeb/Layout/SVGTextBox.h +++ b/Libraries/LibWeb/Layout/SVGTextBox.h @@ -17,7 +17,7 @@ class SVGTextBox final : public SVGGraphicsBox { GC_DECLARE_ALLOCATOR(SVGTextBox); public: - SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, CSS::ComputedProperties); + SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, GC::Ref); virtual ~SVGTextBox() override = default; SVG::SVGTextPositioningElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/SVGTextPathBox.cpp b/Libraries/LibWeb/Layout/SVGTextPathBox.cpp index c3592ec459a..602cc4e013d 100644 --- a/Libraries/LibWeb/Layout/SVGTextPathBox.cpp +++ b/Libraries/LibWeb/Layout/SVGTextPathBox.cpp @@ -11,8 +11,8 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(SVGTextPathBox); -SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, CSS::ComputedProperties properties) - : SVGGraphicsBox(document, element, properties) +SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, GC::Ref style) + : SVGGraphicsBox(document, element, style) { } diff --git a/Libraries/LibWeb/Layout/SVGTextPathBox.h b/Libraries/LibWeb/Layout/SVGTextPathBox.h index a8ad77903be..690c577d507 100644 --- a/Libraries/LibWeb/Layout/SVGTextPathBox.h +++ b/Libraries/LibWeb/Layout/SVGTextPathBox.h @@ -16,7 +16,7 @@ class SVGTextPathBox final : public SVGGraphicsBox { GC_DECLARE_ALLOCATOR(SVGTextPathBox); public: - SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, CSS::ComputedProperties); + SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, GC::Ref); virtual ~SVGTextPathBox() override = default; SVG::SVGTextPathElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Libraries/LibWeb/Layout/TableWrapper.cpp b/Libraries/LibWeb/Layout/TableWrapper.cpp index 0b8029a783d..600aaf34609 100644 --- a/Libraries/LibWeb/Layout/TableWrapper.cpp +++ b/Libraries/LibWeb/Layout/TableWrapper.cpp @@ -10,7 +10,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(TableWrapper); -TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style) +TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, GC::Ref style) : BlockContainer(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/TableWrapper.h b/Libraries/LibWeb/Layout/TableWrapper.h index 49f50cf2fb1..84ec288e03e 100644 --- a/Libraries/LibWeb/Layout/TableWrapper.h +++ b/Libraries/LibWeb/Layout/TableWrapper.h @@ -15,7 +15,7 @@ class TableWrapper : public BlockContainer { GC_DECLARE_ALLOCATOR(TableWrapper); public: - TableWrapper(DOM::Document&, DOM::Node*, CSS::ComputedProperties); + TableWrapper(DOM::Document&, DOM::Node*, GC::Ref); TableWrapper(DOM::Document&, DOM::Node*, NonnullOwnPtr); virtual ~TableWrapper() override; diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index e3ed43b5ed3..1b30cd09cb2 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -196,8 +196,8 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se { auto& document = element.document(); - auto pseudo_element_style = element.pseudo_element_computed_css_values(pseudo_element); - if (!pseudo_element_style.has_value()) + auto pseudo_element_style = element.pseudo_element_computed_properties(pseudo_element); + if (!pseudo_element_style) return; auto initial_quote_nesting_level = m_quote_nesting_level; @@ -346,14 +346,14 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& auto& document = dom_node.document(); auto& style_computer = document.style_computer(); - Optional style; + GC::Ptr style; CSS::Display display; if (is(dom_node)) { auto& element = static_cast(dom_node); element.clear_pseudo_element_nodes({}); VERIFY(!element.needs_style_update()); - style = element.computed_css_values(); + style = element.computed_properties(); element.resolve_counters(*style); display = style->display(); if (display.is_none()) @@ -396,7 +396,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& auto element_has_content_visibility_hidden = [&dom_node]() { if (is(dom_node)) { auto& element = static_cast(dom_node); - return element.computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden; + return element.computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden; } return false; }(); @@ -443,7 +443,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& if (is(dom_node)) { auto& slot_element = static_cast(dom_node); - if (slot_element.computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden) + if (slot_element.computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden) return; auto slottables = slot_element.assigned_nodes_internal(); diff --git a/Libraries/LibWeb/Layout/VideoBox.cpp b/Libraries/LibWeb/Layout/VideoBox.cpp index ca5dfabac85..a21df46938e 100644 --- a/Libraries/LibWeb/Layout/VideoBox.cpp +++ b/Libraries/LibWeb/Layout/VideoBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(VideoBox); -VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style) +VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : ReplacedBox(document, element, move(style)) { document.register_viewport_client(*this); diff --git a/Libraries/LibWeb/Layout/VideoBox.h b/Libraries/LibWeb/Layout/VideoBox.h index 21a5f60af30..063752de864 100644 --- a/Libraries/LibWeb/Layout/VideoBox.h +++ b/Libraries/LibWeb/Layout/VideoBox.h @@ -27,7 +27,7 @@ public: virtual GC::Ptr create_paintable() const override; private: - VideoBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties); + VideoBox(DOM::Document&, DOM::Element&, GC::Ref); // ^Document::ViewportClient virtual void did_set_viewport_rect(CSSPixelRect const&) final; diff --git a/Libraries/LibWeb/Layout/Viewport.cpp b/Libraries/LibWeb/Layout/Viewport.cpp index a58e172a9ce..d1386f43362 100644 --- a/Libraries/LibWeb/Layout/Viewport.cpp +++ b/Libraries/LibWeb/Layout/Viewport.cpp @@ -16,7 +16,7 @@ namespace Web::Layout { GC_DEFINE_ALLOCATOR(Viewport); -Viewport::Viewport(DOM::Document& document, CSS::ComputedProperties style) +Viewport::Viewport(DOM::Document& document, GC::Ref style) : BlockContainer(document, &document, move(style)) { } diff --git a/Libraries/LibWeb/Layout/Viewport.h b/Libraries/LibWeb/Layout/Viewport.h index 8cfc172530e..f947d4fca53 100644 --- a/Libraries/LibWeb/Layout/Viewport.h +++ b/Libraries/LibWeb/Layout/Viewport.h @@ -16,7 +16,7 @@ class Viewport final : public BlockContainer { GC_DECLARE_ALLOCATOR(Viewport); public: - explicit Viewport(DOM::Document&, CSS::ComputedProperties); + explicit Viewport(DOM::Document&, GC::Ref); virtual ~Viewport() override; struct TextPosition { diff --git a/Libraries/LibWeb/SVG/SVGAElement.cpp b/Libraries/LibWeb/SVG/SVGAElement.cpp index 061fd9b88df..a2eaff81332 100644 --- a/Libraries/LibWeb/SVG/SVGAElement.cpp +++ b/Libraries/LibWeb/SVG/SVGAElement.cpp @@ -63,7 +63,7 @@ GC::Ref SVGAElement::rel_list() return *m_rel_list; } -GC::Ptr SVGAElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGAElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGAElement.h b/Libraries/LibWeb/SVG/SVGAElement.h index d085c7af2c5..b33e887f643 100644 --- a/Libraries/LibWeb/SVG/SVGAElement.h +++ b/Libraries/LibWeb/SVG/SVGAElement.h @@ -23,7 +23,7 @@ public: GC::Ref rel_list(); - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; private: SVGAElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index d580ac87cbd..a4d8d2610ef 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -36,7 +36,7 @@ void SVGClipPathElement::attribute_changed(FlyString const& name, Optional SVGClipPathElement::create_layout_node(CSS::ComputedProperties) +GC::Ptr SVGClipPathElement::create_layout_node(GC::Ref) { // Clip paths are handled as a special case in the TreeBuilder. return nullptr; diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Libraries/LibWeb/SVG/SVGClipPathElement.h index aa3312eed03..e3ccb9e9815 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -40,7 +40,7 @@ public: return m_clip_path_units.value_or(ClipPathUnits::UserSpaceOnUse); } - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; private: SVGClipPathElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 03fbc209156..9b5e347997b 100644 --- a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -133,8 +133,8 @@ Optional SVGDecodedImageData::intrinsic_width() const { // https://www.w3.org/TR/SVG2/coords.html#SizingSVGInCSS m_document->update_style(); - auto const root_element_style = m_root_element->computed_css_values(); - VERIFY(root_element_style.has_value()); + auto const root_element_style = m_root_element->computed_properties(); + VERIFY(root_element_style); auto const& width_value = root_element_style->size_value(CSS::PropertyID::Width); if (width_value.is_length() && width_value.length().is_absolute()) return width_value.length().absolute_length_to_px(); @@ -145,8 +145,8 @@ Optional SVGDecodedImageData::intrinsic_height() const { // https://www.w3.org/TR/SVG2/coords.html#SizingSVGInCSS m_document->update_style(); - auto const root_element_style = m_root_element->computed_css_values(); - VERIFY(root_element_style.has_value()); + auto const root_element_style = m_root_element->computed_properties(); + VERIFY(root_element_style); auto const& height_value = root_element_style->size_value(CSS::PropertyID::Height); if (height_value.is_length() && height_value.length().is_absolute()) return height_value.length().absolute_length_to_px(); diff --git a/Libraries/LibWeb/SVG/SVGDefsElement.h b/Libraries/LibWeb/SVG/SVGDefsElement.h index 9ed0ee6e0d9..354ff4c54d8 100644 --- a/Libraries/LibWeb/SVG/SVGDefsElement.h +++ b/Libraries/LibWeb/SVG/SVGDefsElement.h @@ -17,7 +17,7 @@ class SVGDefsElement final : public SVGGraphicsElement { public: virtual ~SVGDefsElement(); - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override + virtual GC::Ptr create_layout_node(GC::Ref) override { return nullptr; } diff --git a/Libraries/LibWeb/SVG/SVGDescElement.cpp b/Libraries/LibWeb/SVG/SVGDescElement.cpp index dcbb5739320..bdba46490eb 100644 --- a/Libraries/LibWeb/SVG/SVGDescElement.cpp +++ b/Libraries/LibWeb/SVG/SVGDescElement.cpp @@ -25,7 +25,7 @@ void SVGDescElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGDescElement); } -GC::Ptr SVGDescElement::create_layout_node(CSS::ComputedProperties) +GC::Ptr SVGDescElement::create_layout_node(GC::Ref) { return nullptr; } diff --git a/Libraries/LibWeb/SVG/SVGDescElement.h b/Libraries/LibWeb/SVG/SVGDescElement.h index 6181fd2f689..50a58cfb172 100644 --- a/Libraries/LibWeb/SVG/SVGDescElement.h +++ b/Libraries/LibWeb/SVG/SVGDescElement.h @@ -19,7 +19,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; }; } diff --git a/Libraries/LibWeb/SVG/SVGElement.cpp b/Libraries/LibWeb/SVG/SVGElement.cpp index 98f092d3651..538767205e0 100644 --- a/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGElement.cpp @@ -130,8 +130,8 @@ GC::Ref SVGElement::svg_animated_length_for_property(CSS::Pro { // FIXME: Create a proper animated value when animations are supported. auto make_length = [&] { - if (auto const style = computed_css_values(); style.has_value()) { - if (auto length = style->length_percentage(property); length.has_value()) + if (auto const computed_properties = this->computed_properties()) { + if (auto length = computed_properties->length_percentage(property); length.has_value()) return SVGLength::from_length_percentage(realm(), *length); } return SVGLength::create(realm(), 0, 0.0f); diff --git a/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index 9a4b26109e2..2fdb2dacfaf 100644 --- a/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -47,7 +47,7 @@ void SVGForeignObjectElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_height); } -GC::Ptr SVGForeignObjectElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGForeignObjectElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGForeignObjectElement.h b/Libraries/LibWeb/SVG/SVGForeignObjectElement.h index 771149f1ccf..c0338bc1e47 100644 --- a/Libraries/LibWeb/SVG/SVGForeignObjectElement.h +++ b/Libraries/LibWeb/SVG/SVGForeignObjectElement.h @@ -18,7 +18,7 @@ class SVGForeignObjectElement final : public SVGGraphicsElement { public: virtual ~SVGForeignObjectElement() override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; GC::Ref x(); GC::Ref y(); diff --git a/Libraries/LibWeb/SVG/SVGGElement.cpp b/Libraries/LibWeb/SVG/SVGGElement.cpp index a850f4f567e..8e634caa1fc 100644 --- a/Libraries/LibWeb/SVG/SVGGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGElement.cpp @@ -26,7 +26,7 @@ void SVGGElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGGElement); } -GC::Ptr SVGGElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGGElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGGElement.h b/Libraries/LibWeb/SVG/SVGGElement.h index 11744adde96..109c7bd69c1 100644 --- a/Libraries/LibWeb/SVG/SVGGElement.h +++ b/Libraries/LibWeb/SVG/SVGGElement.h @@ -17,7 +17,7 @@ class SVGGElement final : public SVGGraphicsElement { public: virtual ~SVGGElement() override = default; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; private: SVGGElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 60bee2f4d79..3f5e831801b 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -22,7 +22,7 @@ void SVGGeometryElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGGeometryElement); } -GC::Ptr SVGGeometryElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGGeometryElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Libraries/LibWeb/SVG/SVGGeometryElement.h index ad9d2cf9463..39e4aa52824 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -16,7 +16,7 @@ class SVGGeometryElement : public SVGGraphicsElement { WEB_PLATFORM_OBJECT(SVGGeometryElement, SVGGraphicsElement); public: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) = 0; diff --git a/Libraries/LibWeb/SVG/SVGImageElement.cpp b/Libraries/LibWeb/SVG/SVGImageElement.cpp index effd7a5b44b..81e15f7630a 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.cpp +++ b/Libraries/LibWeb/SVG/SVGImageElement.cpp @@ -179,7 +179,7 @@ void SVGImageElement::fetch_the_document(URL::URL const& url) } } -GC::Ptr SVGImageElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGImageElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGImageElement.h b/Libraries/LibWeb/SVG/SVGImageElement.h index aa3b6c0ce5a..fd674d8a28d 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.h +++ b/Libraries/LibWeb/SVG/SVGImageElement.h @@ -48,7 +48,7 @@ protected: void fetch_the_document(URL::URL const& url); private: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; void animate(); GC::Ptr m_x; diff --git a/Libraries/LibWeb/SVG/SVGMaskElement.cpp b/Libraries/LibWeb/SVG/SVGMaskElement.cpp index 59e3bba9822..1743efbd7d3 100644 --- a/Libraries/LibWeb/SVG/SVGMaskElement.cpp +++ b/Libraries/LibWeb/SVG/SVGMaskElement.cpp @@ -27,7 +27,7 @@ void SVGMaskElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGMaskElement); } -GC::Ptr SVGMaskElement::create_layout_node(CSS::ComputedProperties) +GC::Ptr SVGMaskElement::create_layout_node(GC::Ref) { // Masks are handled as a special case in the TreeBuilder. return nullptr; diff --git a/Libraries/LibWeb/SVG/SVGMaskElement.h b/Libraries/LibWeb/SVG/SVGMaskElement.h index f8ab653b3b5..a3158c6e9df 100644 --- a/Libraries/LibWeb/SVG/SVGMaskElement.h +++ b/Libraries/LibWeb/SVG/SVGMaskElement.h @@ -38,7 +38,7 @@ public: virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; CSSPixelRect resolve_masking_area(CSSPixelRect const& mask_target) const; diff --git a/Libraries/LibWeb/SVG/SVGMetadataElement.cpp b/Libraries/LibWeb/SVG/SVGMetadataElement.cpp index 22c5519d843..86782b22033 100644 --- a/Libraries/LibWeb/SVG/SVGMetadataElement.cpp +++ b/Libraries/LibWeb/SVG/SVGMetadataElement.cpp @@ -25,7 +25,7 @@ void SVGMetadataElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGMetadataElement); } -GC::Ptr SVGMetadataElement::create_layout_node(CSS::ComputedProperties) +GC::Ptr SVGMetadataElement::create_layout_node(GC::Ref) { return nullptr; } diff --git a/Libraries/LibWeb/SVG/SVGMetadataElement.h b/Libraries/LibWeb/SVG/SVGMetadataElement.h index 76e8d28a400..a77e5cc3c8b 100644 --- a/Libraries/LibWeb/SVG/SVGMetadataElement.h +++ b/Libraries/LibWeb/SVG/SVGMetadataElement.h @@ -20,7 +20,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; }; } diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 154157e2d61..30fb6c26f0c 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -42,7 +42,7 @@ void SVGSVGElement::visit_edges(Visitor& visitor) visitor.visit(m_view_box_for_bindings); } -GC::Ptr SVGSVGElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGSVGElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.h index b07b3cbd53a..ead9d4ef374 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -29,7 +29,7 @@ class SVGSVGElement final : public SVGGraphicsElement GC_DECLARE_ALLOCATOR(SVGSVGElement); public: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void apply_presentational_hints(GC::Ref) const override; diff --git a/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Libraries/LibWeb/SVG/SVGStopElement.cpp index 43296f6a3b7..5fe260b48b0 100644 --- a/Libraries/LibWeb/SVG/SVGStopElement.cpp +++ b/Libraries/LibWeb/SVG/SVGStopElement.cpp @@ -49,15 +49,15 @@ void SVGStopElement::apply_presentational_hints(GC::Ref Gfx::Color SVGStopElement::stop_color() const { - if (auto css_values = computed_css_values(); css_values.has_value()) - return css_values->stop_color(); + if (auto computed_properties = this->computed_properties()) + return computed_properties->stop_color(); return Color::Black; } float SVGStopElement::stop_opacity() const { - if (auto css_values = computed_css_values(); css_values.has_value()) - return css_values->stop_opacity(); + if (auto computed_properties = this->computed_properties()) + return computed_properties->stop_opacity(); return 1; } diff --git a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index cfaa1a8c3c9..ce07a9dea68 100644 --- a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -75,7 +75,7 @@ bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const return is(host); } -GC::Ptr SVGSymbolElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGSymbolElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGSymbolElement.h b/Libraries/LibWeb/SVG/SVGSymbolElement.h index 8405b26f7fb..eb3b2c3565a 100644 --- a/Libraries/LibWeb/SVG/SVGSymbolElement.h +++ b/Libraries/LibWeb/SVG/SVGSymbolElement.h @@ -36,7 +36,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; bool is_direct_child_of_use_shadow_tree() const; diff --git a/Libraries/LibWeb/SVG/SVGTSpanElement.cpp b/Libraries/LibWeb/SVG/SVGTSpanElement.cpp index 7d6661d2cf1..ec9970370ed 100644 --- a/Libraries/LibWeb/SVG/SVGTSpanElement.cpp +++ b/Libraries/LibWeb/SVG/SVGTSpanElement.cpp @@ -24,7 +24,7 @@ void SVGTSpanElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTSpanElement); } -GC::Ptr SVGTSpanElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGTSpanElement::create_layout_node(GC::Ref style) { // Text must be within an SVG element. if (shadow_including_first_ancestor_of_type()) diff --git a/Libraries/LibWeb/SVG/SVGTSpanElement.h b/Libraries/LibWeb/SVG/SVGTSpanElement.h index a198005d6a4..5e597e371fc 100644 --- a/Libraries/LibWeb/SVG/SVGTSpanElement.h +++ b/Libraries/LibWeb/SVG/SVGTSpanElement.h @@ -17,7 +17,7 @@ class SVGTSpanElement : public SVGTextPositioningElement { GC_DECLARE_ALLOCATOR(SVGTSpanElement); public: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; protected: SVGTSpanElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/SVG/SVGTextElement.cpp b/Libraries/LibWeb/SVG/SVGTextElement.cpp index 436c60e87b7..8e74a1f761f 100644 --- a/Libraries/LibWeb/SVG/SVGTextElement.cpp +++ b/Libraries/LibWeb/SVG/SVGTextElement.cpp @@ -23,7 +23,7 @@ void SVGTextElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTextElement); } -GC::Ptr SVGTextElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGTextElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGTextElement.h b/Libraries/LibWeb/SVG/SVGTextElement.h index 2f8d530e478..eb7852f3326 100644 --- a/Libraries/LibWeb/SVG/SVGTextElement.h +++ b/Libraries/LibWeb/SVG/SVGTextElement.h @@ -17,7 +17,7 @@ class SVGTextElement : public SVGTextPositioningElement { GC_DECLARE_ALLOCATOR(SVGTextElement); public: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; protected: SVGTextElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/SVG/SVGTextPathElement.cpp b/Libraries/LibWeb/SVG/SVGTextPathElement.cpp index 0ce93311d32..044cab2b026 100644 --- a/Libraries/LibWeb/SVG/SVGTextPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGTextPathElement.cpp @@ -40,7 +40,7 @@ void SVGTextPathElement::visit_edges(Cell::Visitor& visitor) SVGURIReferenceMixin::visit_edges(visitor); } -GC::Ptr SVGTextPathElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGTextPathElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGTextPathElement.h b/Libraries/LibWeb/SVG/SVGTextPathElement.h index d1f4882a122..4f7d83e32f2 100644 --- a/Libraries/LibWeb/SVG/SVGTextPathElement.h +++ b/Libraries/LibWeb/SVG/SVGTextPathElement.h @@ -20,7 +20,7 @@ class SVGTextPathElement GC_DECLARE_ALLOCATOR(SVGTextPathElement); public: - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; GC::Ptr path_or_shape() const; diff --git a/Libraries/LibWeb/SVG/SVGTitleElement.cpp b/Libraries/LibWeb/SVG/SVGTitleElement.cpp index 39713f5256b..7d3e5066f30 100644 --- a/Libraries/LibWeb/SVG/SVGTitleElement.cpp +++ b/Libraries/LibWeb/SVG/SVGTitleElement.cpp @@ -25,7 +25,7 @@ void SVGTitleElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTitleElement); } -GC::Ptr SVGTitleElement::create_layout_node(CSS::ComputedProperties) +GC::Ptr SVGTitleElement::create_layout_node(GC::Ref) { return nullptr; } diff --git a/Libraries/LibWeb/SVG/SVGTitleElement.h b/Libraries/LibWeb/SVG/SVGTitleElement.h index 3f12e9c5f98..a2cf46f2642 100644 --- a/Libraries/LibWeb/SVG/SVGTitleElement.h +++ b/Libraries/LibWeb/SVG/SVGTitleElement.h @@ -19,7 +19,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; virtual void children_changed() override; }; diff --git a/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Libraries/LibWeb/SVG/SVGUseElement.cpp index 659b851e2d9..15cc49717b7 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -235,7 +235,7 @@ GC::Ptr SVGUseElement::animated_instance_root() const return instance_root(); } -GC::Ptr SVGUseElement::create_layout_node(CSS::ComputedProperties style) +GC::Ptr SVGUseElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); } diff --git a/Libraries/LibWeb/SVG/SVGUseElement.h b/Libraries/LibWeb/SVG/SVGUseElement.h index 7f2d58ac794..5e839c05fae 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Libraries/LibWeb/SVG/SVGUseElement.h @@ -48,7 +48,7 @@ private: virtual bool is_svg_use_element() const override { return true; } - virtual GC::Ptr create_layout_node(CSS::ComputedProperties) override; + virtual GC::Ptr create_layout_node(GC::Ref) override; void process_the_url(Optional const& href); diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index a1f8ea7a5b4..006665efa5e 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -353,7 +353,7 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString const& request, auto styles = doc->style_computer().compute_style(*static_cast(element)); dbgln("+ Element {}", element->debug_description()); for (size_t i = 0; i < Web::CSS::ComputedProperties::number_of_properties; ++i) { - auto property = styles.maybe_null_property(static_cast(i)); + auto property = styles->maybe_null_property(static_cast(i)); dbgln("| {} = {}", Web::CSS::string_from_property_id(static_cast(i)), property ? property->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal) : ""_string); } dbgln("---"); @@ -506,7 +506,7 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const if (node->is_element()) { auto& element = verify_cast(*node); - if (!element.computed_css_values().has_value()) { + if (!element.computed_properties()) { async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {}, {}); return; } @@ -615,7 +615,7 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const return; } - auto pseudo_element_style = element.pseudo_element_computed_css_values(pseudo_element.value()); + auto pseudo_element_style = element.pseudo_element_computed_properties(pseudo_element.value()); ByteString computed_values = serialize_json(*pseudo_element_style); ByteString resolved_values = serialize_json(element.resolved_css_values(pseudo_element.value())); ByteString custom_properties_json = serialize_custom_properties_json(element, pseudo_element); @@ -626,12 +626,12 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const return; } - ByteString computed_values = serialize_json(*element.computed_css_values()); + ByteString computed_values = serialize_json(*element.computed_properties()); ByteString resolved_values = serialize_json(element.resolved_css_values()); ByteString custom_properties_json = serialize_custom_properties_json(element, {}); ByteString node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node()); ByteString aria_properties_state_json = serialize_aria_properties_state_json(element); - ByteString fonts_json = serialize_fonts_json(*element.computed_css_values()); + ByteString fonts_json = serialize_fonts_json(*element.computed_properties()); async_did_inspect_dom_node(page_id, true, move(computed_values), move(resolved_values), move(custom_properties_json), move(node_box_sizing_json), move(aria_properties_state_json), move(fonts_json)); return; diff --git a/Services/WebContent/WebDriverConnection.cpp b/Services/WebContent/WebDriverConnection.cpp index e549fb5c035..5ef59f3a3e3 100644 --- a/Services/WebContent/WebDriverConnection.cpp +++ b/Services/WebContent/WebDriverConnection.cpp @@ -1386,8 +1386,8 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e // computed value of parameter URL variables["property name"] from element's style declarations. if (auto property = Web::CSS::property_id_from_string(name); property.has_value()) { - if (auto computed_values = element->computed_css_values(); computed_values.has_value()) - computed_value = computed_values->property(property.value()).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); + if (auto computed_properties = element->computed_properties()) + computed_value = computed_properties->property(property.value()).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); } } // -> Otherwise