diff --git a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp index afcd4de35f7..a606ef8f0d9 100644 --- a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -954,13 +954,13 @@ void KeyframeEffect::update_style_properties() if (!target) return; - CSS::StyleProperties* style = nullptr; + Optional style = {}; if (!pseudo_element_type().has_value()) style = target->computed_css_values(); else style = target->pseudo_element_computed_css_values(pseudo_element_type().value()); - if (!style) + if (!style.has_value()) return; auto animated_properties_before_update = style->animated_property_values(); @@ -970,8 +970,8 @@ void KeyframeEffect::update_style_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 || !element.layout_node()) + auto element_style = element.computed_css_values(); + if (!element_style.has_value() || !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/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index cd81b5c0d54..74b9aa2650a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -520,8 +520,7 @@ WebIDL::ExceptionOr ElementInlineCSSStyleDeclaration::set_css_text(StringV // 3. Parse the given value and, if the return value is not the empty list, insert the items in the list into the declarations, in specified order. auto style = parse_css_style_attribute(CSS::Parser::ParsingContext(m_element->document()), css_text, *m_element.ptr()); - auto custom_properties = TRY_OR_THROW_OOM(vm(), style->custom_properties().clone()); - set_the_declarations(style->properties(), move(custom_properties)); + set_the_declarations(style->properties(), style->custom_properties()); // 4. Update style attribute for the CSS declaration block. update_style_attribute(); diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index fa3eb60b533..e90ac84099e 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -581,7 +581,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 value = style->maybe_null_property(property_id); + auto 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/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 91ce32b3ee7..6b21c634b4a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1172,7 +1172,7 @@ static void compute_transitioned_properties(StyleProperties const& style, DOM::E auto const source_declaration = style.transition_property_source(); if (!source_declaration) return; - if (!element.computed_css_values()) + if (!element.computed_css_values().has_value()) return; if (source_declaration == element.cached_transition_property_source()) return; @@ -1482,13 +1482,13 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element // Then we apply the declarations from the matched rules in cascade order: // Normal user agent declarations - auto previous_origin_style = style.clone(); - auto previous_layer_style = style.clone(); + auto previous_origin_style = style; + auto previous_layer_style = style; cascade_declarations(style, element, pseudo_element, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::No, previous_origin_style, previous_layer_style); // Normal user declarations - previous_origin_style = style.clone(); - previous_layer_style = style.clone(); + previous_origin_style = style; + previous_layer_style = style; cascade_declarations(style, element, pseudo_element, matching_rule_set.user_rules, CascadeOrigin::User, Important::No, previous_origin_style, previous_layer_style); // Author presentational hints @@ -1497,7 +1497,7 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element // however for the purpose of the revert keyword (but not for the revert-layer keyword) it is considered // part of the author origin." // https://drafts.csswg.org/css-cascade-5/#author-presentational-hint-origin - previous_origin_style = style.clone(); + previous_origin_style = style; if (!pseudo_element.has_value()) { element.apply_presentational_hints(style); @@ -1520,7 +1520,7 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element // Normal author declarations, ordered by @layer, with un-@layer-ed rules last for (auto const& layer : matching_rule_set.author_rules) { - previous_layer_style = style.clone(); + previous_layer_style = style; cascade_declarations(style, element, pseudo_element, layer.rules, CascadeOrigin::Author, Important::No, previous_origin_style, previous_layer_style); } @@ -1587,20 +1587,20 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element } // Important author declarations, with un-@layer-ed rules first, followed by each @layer in reverse order. - previous_origin_style = style.clone(); + previous_origin_style = style; for (auto const& layer : matching_rule_set.author_rules.in_reverse()) { - previous_layer_style = style.clone(); + previous_layer_style = style; cascade_declarations(style, element, pseudo_element, layer.rules, CascadeOrigin::Author, Important::Yes, previous_origin_style, previous_layer_style); } // Important user declarations - previous_origin_style = style.clone(); - previous_layer_style = style.clone(); + previous_origin_style = style; + previous_layer_style = style; cascade_declarations(style, element, pseudo_element, matching_rule_set.user_rules, CascadeOrigin::User, Important::Yes, previous_origin_style, previous_layer_style); // Important user agent declarations - previous_origin_style = style.clone(); - previous_layer_style = style.clone(); + previous_origin_style = style; + previous_layer_style = style; cascade_declarations(style, element, pseudo_element, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::Yes, previous_origin_style, previous_layer_style); // Transition declarations [css-transitions-1] @@ -1624,7 +1624,7 @@ NonnullRefPtr StyleComputer::get_inherit_value(JS::Realm& i { auto* parent_element = element_to_inherit_style_from(element, pseudo_element); - if (!parent_element || !parent_element->computed_css_values()) + if (!parent_element || !parent_element->computed_css_values().has_value()) return property_initial_value(initial_value_context_realm, property_id); return parent_element->computed_css_values()->property(property_id); } @@ -1814,12 +1814,12 @@ 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()) + if (parent_element && parent_element->computed_css_values().has_value()) font_pixel_metrics = parent_element->computed_css_values()->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()) + if (!parent_element || !parent_element->computed_css_values().has_value()) return font_size_in_px; auto value = parent_element->computed_css_values()->property(CSS::PropertyID::FontSize); if (value->is_length()) { @@ -1870,7 +1870,7 @@ 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() + int inherited_math_depth = parent_element && parent_element->computed_css_values().has_value() ? parent_element->computed_css_values()->math_depth() : InitialValues::math_depth(); int computed_math_depth = math_depth; @@ -1910,7 +1910,7 @@ 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()) { + 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); } } @@ -2172,7 +2172,7 @@ static BoxTypeTransformation required_box_type_transformation(StyleProperties co 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()) { + if (parent && parent->computed_css_values().has_value()) { auto const& parent_display = parent->computed_css_values()->display(); if (parent_display.is_grid_inside() || parent_display.is_flex_inside()) return BoxTypeTransformation::Blockify; @@ -2271,30 +2271,30 @@ void StyleComputer::transform_box_type_if_needed(StyleProperties& style, DOM::El style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display)); } -NonnullRefPtr StyleComputer::create_document_style() const +StyleProperties StyleComputer::create_document_style() const { - auto style = StyleProperties::create(); + StyleProperties style = {}; 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; } -NonnullRefPtr StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const +StyleProperties StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const { - return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal).release_nonnull(); + return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal).release_value(); } -RefPtr StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const +Optional StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const { return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::CreatePseudoElementStyleIfNeeded); } -RefPtr StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const +Optional StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const { build_rule_cache_if_needed(); @@ -2306,14 +2306,14 @@ RefPtr StyleComputer::compute_style_impl(DOM::Element& element, // 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; } ScopeGuard guard { [&element]() { element.set_needs_style_update(false); } }; - auto style = StyleProperties::create(); + StyleProperties style = {}; // 1. Perform the cascade. This produces the "specified style" bool did_match_any_pseudo_element_rules = false; compute_cascaded_values(style, element, pseudo_element, did_match_any_pseudo_element_rules, mode); @@ -2323,17 +2323,17 @@ RefPtr StyleComputer::compute_style_impl(DOM::Element& element, // Bail if no pseudo-element rules matched. if (!did_match_any_pseudo_element_rules) - return nullptr; + return {}; // Bail if no pseudo-element would be generated due to... // - content: none // - content: normal (for ::before and ::after) bool content_is_normal = false; - if (auto content_value = style->maybe_null_property(CSS::PropertyID::Content)) { + if (auto content_value = style.maybe_null_property(CSS::PropertyID::Content)) { if (content_value->is_keyword()) { auto content = content_value->as_keyword().keyword(); if (content == CSS::Keyword::None) - return nullptr; + return {}; content_is_normal = content == CSS::Keyword::Normal; } else { content_is_normal = false; @@ -2343,7 +2343,7 @@ RefPtr StyleComputer::compute_style_impl(DOM::Element& element, content_is_normal = true; } if (content_is_normal && first_is_one_of(*pseudo_element, CSS::Selector::PseudoElement::Type::Before, CSS::Selector::PseudoElement::Type::After)) { - return nullptr; + return {}; } } @@ -2371,7 +2371,7 @@ RefPtr StyleComputer::compute_style_impl(DOM::Element& element, // 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(style, element, pseudo_element); - if (auto const* previous_style = element.computed_css_values()) { + if (auto previous_style = element.computed_css_values(); previous_style.has_value()) { start_needed_transitions(*previous_style, style, element, pseudo_element); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.h b/Userland/Libraries/LibWeb/CSS/StyleComputer.h index 80d53a5e0e4..fb6226e2abb 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.h @@ -134,10 +134,10 @@ public: void push_ancestor(DOM::Element const&); void pop_ancestor(DOM::Element const&); - NonnullRefPtr create_document_style() const; + StyleProperties create_document_style() const; - NonnullRefPtr compute_style(DOM::Element&, Optional = {}) const; - RefPtr compute_pseudo_element_style_if_needed(DOM::Element&, Optional) const; + StyleProperties compute_style(DOM::Element&, Optional = {}) const; + Optional 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; @@ -176,7 +176,7 @@ private: [[nodiscard]] bool should_reject_with_ancestor_filter(Selector const&) const; - RefPtr compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; + Optional compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; void compute_cascaded_values(StyleProperties&, 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/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 62eea1997d1..5e8b081a564 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -53,13 +53,6 @@ NonnullRefPtr StyleProperties::Data::clone() const return clone; } -NonnullRefPtr StyleProperties::clone() const -{ - auto cloned = adopt_ref(*new StyleProperties); - cloned->m_data = m_data; - return cloned; -} - bool StyleProperties::is_property_important(CSS::PropertyID property_id) const { size_t n = to_underlying(property_id); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index 38e0b79fb15..50cd2eb1776 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -19,7 +19,7 @@ namespace Web::CSS { -class StyleProperties : public RefCounted { +class StyleProperties { public: static constexpr size_t number_of_properties = to_underlying(CSS::last_property_id) + 1; @@ -48,9 +48,6 @@ private: public: StyleProperties() = default; - static NonnullRefPtr create() { return adopt_ref(*new StyleProperties); } - NonnullRefPtr clone() const; - template inline void for_each_property(Callback callback) const { diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 834442bdc32..4bcec44e8ed 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -385,16 +385,16 @@ Vector Element::get_attribute_names() const return names; } -JS::GCPtr Element::create_layout_node(NonnullRefPtr style) +JS::GCPtr Element::create_layout_node(CSS::StyleProperties style) { if (local_name() == "noscript" && document().is_scripting_enabled()) return nullptr; - auto display = style->display(); + auto display = style.display(); return create_layout_node_for_display_type(document(), display, move(style), this); } -JS::GCPtr Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, NonnullRefPtr style, Element* element) +JS::GCPtr Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, CSS::StyleProperties 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_without_realm(document, element, move(style)); @@ -540,14 +540,14 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() // 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_css_values.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_css_values.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Start)); } CSS::RequiredInvalidationAfterStyleChange invalidation; - if (m_computed_css_values) - invalidation = compute_required_invalidation(*m_computed_css_values, *new_computed_css_values); + if (m_computed_css_values.has_value()) + invalidation = compute_required_invalidation(*m_computed_css_values, new_computed_css_values); else invalidation = CSS::RequiredInvalidationAfterStyleChange::full(); @@ -562,9 +562,9 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() 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 && new_pseudo_element_style) { + if (pseudo_element_style.has_value() && new_pseudo_element_style.has_value()) { invalidation |= compute_required_invalidation(*pseudo_element_style, *new_pseudo_element_style); - } else if (pseudo_element_style || new_pseudo_element_style) { + } else if (pseudo_element_style.has_value() || new_pseudo_element_style.has_value()) { invalidation = CSS::RequiredInvalidationAfterStyleChange::full(); } @@ -595,7 +595,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() continue; auto pseudo_element_style = pseudo_element_computed_css_values(pseudo_element_type); - if (!pseudo_element_style) + if (!pseudo_element_style.has_value()) continue; if (auto* node_with_style = dynamic_cast(pseudo_element->layout_node.ptr())) { @@ -609,17 +609,17 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() return invalidation; } -NonnullRefPtr Element::resolved_css_values(Optional type) +CSS::StyleProperties Element::resolved_css_values(Optional type) { auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this, type); - auto properties = CSS::StyleProperties::create(); + CSS::StyleProperties properties = {}; 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; @@ -627,7 +627,7 @@ NonnullRefPtr Element::resolved_css_values(Optionalreset_animated_properties(); } @@ -2273,25 +2273,25 @@ size_t Element::attribute_list_size() const return m_attributes->length(); } -void Element::set_computed_css_values(RefPtr style) +void Element::set_computed_css_values(Optional style) { m_computed_css_values = move(style); computed_css_values_changed(); } -void Element::set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type pseudo_element, RefPtr style) +void Element::set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type pseudo_element, Optional style) { - if (!m_pseudo_element_data && !style) + if (!m_pseudo_element_data && !style.has_value()) return; ensure_pseudo_element(pseudo_element).computed_css_values = move(style); } -RefPtr Element::pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type type) +Optional Element::pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type type) { auto pseudo_element = get_pseudo_element(type); if (pseudo_element.has_value()) return pseudo_element->computed_css_values; - return nullptr; + return {}; } Optional Element::get_pseudo_element(CSS::Selector::PseudoElement::Type type) const diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index f0640bb5cd2..a54d38b8708 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -14,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -183,13 +185,13 @@ public: JS::GCPtr layout_node(); JS::GCPtr layout_node() const; - CSS::StyleProperties* computed_css_values() { return m_computed_css_values.ptr(); } - CSS::StyleProperties const* computed_css_values() const { return m_computed_css_values.ptr(); } - void set_computed_css_values(RefPtr); - NonnullRefPtr resolved_css_values(Optional = {}); + 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::StyleProperties resolved_css_values(Optional = {}); - void set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type, RefPtr); - RefPtr pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type); + void set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type, Optional); + Optional pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type); void reset_animated_css_properties(); @@ -235,13 +237,13 @@ public: JS::NonnullGCPtr get_bounding_client_rect() const; JS::NonnullGCPtr get_client_rects() const; - virtual JS::GCPtr create_layout_node(NonnullRefPtr); + virtual JS::GCPtr create_layout_node(CSS::StyleProperties); virtual void adjust_computed_style(CSS::StyleProperties&) { } virtual void did_receive_focus() { } virtual void did_lose_focus() { } - static JS::GCPtr create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, NonnullRefPtr, Element*); + static JS::GCPtr create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, CSS::StyleProperties, Element*); void set_pseudo_element_node(Badge, CSS::Selector::PseudoElement::Type, JS::GCPtr); JS::GCPtr get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const; @@ -456,12 +458,12 @@ private: JS::GCPtr m_class_list; JS::GCPtr m_shadow_root; - RefPtr m_computed_css_values; + Optional m_computed_css_values; HashMap m_custom_properties; struct PseudoElement { JS::GCPtr layout_node; - RefPtr computed_css_values; + Optional computed_css_values; HashMap custom_properties; }; // TODO: CSS::Selector::PseudoElement::Type includes a lot of pseudo-elements that exist in shadow trees, diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 851e531bda2..17ad3bf0b63 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -394,7 +394,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho } } - if (show_specified_style && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast(layout_node.dom_node())->computed_css_values()) { + if (show_specified_style && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast(layout_node.dom_node())->computed_css_values().has_value()) { struct NameAndValue { FlyString name; String value; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp index cb8c7877f1d..e6bfd27b7d6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp @@ -28,7 +28,7 @@ void HTMLAudioElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLAudioElement); } -JS::GCPtr HTMLAudioElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLAudioElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h index b171e0d506c..e43f9cf0697 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h @@ -25,7 +25,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void on_playing() override; virtual void on_paused() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp index 3ddb441792c..37e2869874f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -26,7 +26,7 @@ void HTMLBRElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement); } -JS::GCPtr HTMLBRElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLBRElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h index 7b9d195dc28..4483de9297b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -17,7 +17,7 @@ class HTMLBRElement final : public HTMLElement { public: virtual ~HTMLBRElement() override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; private: virtual bool is_html_br_element() const override { return true; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 3bd716495b7..ebdc90843f9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -128,7 +128,7 @@ WebIDL::ExceptionOr HTMLCanvasElement::set_height(unsigned value) return {}; } -JS::GCPtr HTMLCanvasElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLCanvasElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h index a53c56004e4..62e8ffa1982 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -47,7 +47,7 @@ private: virtual void apply_presentational_hints(CSS::StyleProperties&) const override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; enum class HasOrCreatedContext { No, diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 1fc92d6a7b3..544febf8bf6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -32,7 +32,7 @@ void HTMLIFrameElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLIFrameElement); } -JS::GCPtr HTMLIFrameElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLIFrameElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 243746168d5..432f6d8d82d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -23,7 +23,7 @@ class HTMLIFrameElement final public: virtual ~HTMLIFrameElement() override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; void set_current_navigation_was_lazy_loaded(bool value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 1ac132a94ef..13c8c9d066b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -110,7 +110,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const } } -JS::GCPtr HTMLImageElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLImageElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style), *this); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index baed3ad5e38..2c1c03d15d7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -123,7 +123,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 JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void did_set_viewport_rect(CSSPixelRect const&) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 7ad76e08511..d10bb54b6c1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -98,7 +98,7 @@ JS::NonnullGCPtr HTMLInputElement::validity() const return vm.heap().allocate(realm, realm); } -JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLInputElement::create_layout_node(CSS::StyleProperties style) { if (type_state() == TypeAttributeState::Hidden) return nullptr; @@ -113,8 +113,8 @@ JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtrappearance() == 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) @@ -126,7 +126,7 @@ JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtr(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::StyleProperties& style) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 4d53b1ebed9..6789e31e40d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -59,7 +59,7 @@ class HTMLInputElement final public: virtual ~HTMLInputElement() override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void adjust_computed_style(CSS::StyleProperties&) override; enum class TypeAttributeState { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index cacff5ff2c4..2c9a5a48021 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -27,7 +27,7 @@ void HTMLLabelElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLabelElement); } -JS::GCPtr HTMLLabelElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLLabelElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h index 56e1e41d816..ee02b60f52e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h @@ -17,7 +17,7 @@ class HTMLLabelElement final : public HTMLElement { public: virtual ~HTMLLabelElement() override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; Optional for_() const { return attribute(HTML::AttributeNames::for_); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 9bf7a77d3f5..18bc6218921 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -136,7 +136,7 @@ String HTMLObjectElement::data() const return MUST(document().parse_url(*data).to_string()); } -JS::GCPtr HTMLObjectElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLObjectElement::create_layout_node(CSS::StyleProperties style) { switch (m_representation) { case Representation::Children: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index 1ea99519433..5a17b596df6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -58,7 +58,7 @@ private: virtual void apply_presentational_hints(CSS::StyleProperties&) const override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index 9d445ecdd79..1a0a86cbb26 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -62,7 +62,7 @@ void HTMLVideoElement::attribute_changed(FlyString const& name, Optional } } -JS::GCPtr HTMLVideoElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr HTMLVideoElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h index a5b8582077d..50c886643ec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Userland/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 JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void on_playing() override; virtual void on_paused() override; diff --git a/Userland/Libraries/LibWeb/Layout/AudioBox.cpp b/Userland/Libraries/LibWeb/Layout/AudioBox.cpp index bf662af57a4..fee0c2589dd 100644 --- a/Userland/Libraries/LibWeb/Layout/AudioBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/AudioBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(AudioBox); -AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) +AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { set_natural_width(300); diff --git a/Userland/Libraries/LibWeb/Layout/AudioBox.h b/Userland/Libraries/LibWeb/Layout/AudioBox.h index 326f3de34f9..8f192411280 100644 --- a/Userland/Libraries/LibWeb/Layout/AudioBox.h +++ b/Userland/Libraries/LibWeb/Layout/AudioBox.h @@ -23,7 +23,7 @@ public: virtual JS::GCPtr create_paintable() const override; private: - AudioBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + AudioBox(DOM::Document&, DOM::Element&, CSS::StyleProperties); }; } diff --git a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp index af5ee42cb34..d709579464e 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp @@ -9,7 +9,7 @@ namespace Web::Layout { -BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, NonnullRefPtr style) +BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, CSS::StyleProperties style) : Box(document, node, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/BlockContainer.h b/Userland/Libraries/LibWeb/Layout/BlockContainer.h index 88a7e7a649f..14ef8661104 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockContainer.h +++ b/Userland/Libraries/LibWeb/Layout/BlockContainer.h @@ -16,7 +16,7 @@ class BlockContainer : public Box { JS_CELL(BlockContainer, Box); public: - BlockContainer(DOM::Document&, DOM::Node*, NonnullRefPtr); + BlockContainer(DOM::Document&, DOM::Node*, CSS::StyleProperties); BlockContainer(DOM::Document&, DOM::Node*, NonnullOwnPtr); virtual ~BlockContainer() override; diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index e89583b3e24..6533845cab9 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/Userland/Libraries/LibWeb/Layout/Box.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { -Box::Box(DOM::Document& document, DOM::Node* node, NonnullRefPtr style) +Box::Box(DOM::Document& document, DOM::Node* node, CSS::StyleProperties style) : NodeWithStyleAndBoxModelMetrics(document, node, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/Box.h b/Userland/Libraries/LibWeb/Layout/Box.h index be8e29bd523..2e0dce9a0a3 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.h +++ b/Userland/Libraries/LibWeb/Layout/Box.h @@ -55,7 +55,7 @@ public: virtual void visit_edges(Cell::Visitor&) override; protected: - Box(DOM::Document&, DOM::Node*, NonnullRefPtr); + Box(DOM::Document&, DOM::Node*, CSS::StyleProperties); Box(DOM::Document&, DOM::Node*, NonnullOwnPtr); private: diff --git a/Userland/Libraries/LibWeb/Layout/BreakNode.cpp b/Userland/Libraries/LibWeb/Layout/BreakNode.cpp index 3c599439cd2..ede3e6bffc2 100644 --- a/Userland/Libraries/LibWeb/Layout/BreakNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/BreakNode.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(BreakNode); -BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, NonnullRefPtr style) +BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, CSS::StyleProperties style) : Layout::NodeWithStyleAndBoxModelMetrics(document, &element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/BreakNode.h b/Userland/Libraries/LibWeb/Layout/BreakNode.h index 42c9566bfcf..63707996bd0 100644 --- a/Userland/Libraries/LibWeb/Layout/BreakNode.h +++ b/Userland/Libraries/LibWeb/Layout/BreakNode.h @@ -16,7 +16,7 @@ class BreakNode final : public NodeWithStyleAndBoxModelMetrics { JS_DECLARE_ALLOCATOR(BreakNode); public: - BreakNode(DOM::Document&, HTML::HTMLBRElement&, NonnullRefPtr); + BreakNode(DOM::Document&, HTML::HTMLBRElement&, CSS::StyleProperties); virtual ~BreakNode() override; const HTML::HTMLBRElement& dom_node() const { return verify_cast(*Node::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp b/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp index 418de71e6ff..25608e11112 100644 --- a/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(CanvasBox); -CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, NonnullRefPtr style) +CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/CanvasBox.h b/Userland/Libraries/LibWeb/Layout/CanvasBox.h index 373f0dc8f86..3f541ce0c11 100644 --- a/Userland/Libraries/LibWeb/Layout/CanvasBox.h +++ b/Userland/Libraries/LibWeb/Layout/CanvasBox.h @@ -16,7 +16,7 @@ class CanvasBox final : public ReplacedBox { JS_DECLARE_ALLOCATOR(CanvasBox); public: - CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, NonnullRefPtr); + CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, CSS::StyleProperties); virtual ~CanvasBox() override; virtual void prepare_for_replaced_layout() override; diff --git a/Userland/Libraries/LibWeb/Layout/CheckBox.cpp b/Userland/Libraries/LibWeb/Layout/CheckBox.cpp index f7e19bc20f7..c727912f81a 100644 --- a/Userland/Libraries/LibWeb/Layout/CheckBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/CheckBox.cpp @@ -13,7 +13,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(CheckBox); -CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, NonnullRefPtr style) +CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, CSS::StyleProperties style) : FormAssociatedLabelableNode(document, element, move(style)) { set_natural_width(13); diff --git a/Userland/Libraries/LibWeb/Layout/CheckBox.h b/Userland/Libraries/LibWeb/Layout/CheckBox.h index 4dcc62407a2..43d9632f57c 100644 --- a/Userland/Libraries/LibWeb/Layout/CheckBox.h +++ b/Userland/Libraries/LibWeb/Layout/CheckBox.h @@ -16,7 +16,7 @@ class CheckBox final : public FormAssociatedLabelableNode { JS_DECLARE_ALLOCATOR(CheckBox); public: - CheckBox(DOM::Document&, HTML::HTMLInputElement&, NonnullRefPtr); + CheckBox(DOM::Document&, HTML::HTMLInputElement&, CSS::StyleProperties); virtual ~CheckBox() override; private: diff --git a/Userland/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h b/Userland/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h index 44ee62981fe..60d547311e8 100644 --- a/Userland/Libraries/LibWeb/Layout/FormAssociatedLabelableNode.h +++ b/Userland/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, NonnullRefPtr style) + FormAssociatedLabelableNode(DOM::Document& document, HTML::FormAssociatedElement& element, CSS::StyleProperties style) : LabelableNode(document, element.form_associated_element_to_html_element(), move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp index 48c91ceb81c..309543184d0 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp @@ -13,7 +13,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(FrameBox); -FrameBox::FrameBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) +FrameBox::FrameBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.h b/Userland/Libraries/LibWeb/Layout/FrameBox.h index 13e8a9d7203..525a76b55f4 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.h +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.h @@ -16,7 +16,7 @@ class FrameBox final : public ReplacedBox { JS_DECLARE_ALLOCATOR(FrameBox); public: - FrameBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + FrameBox(DOM::Document&, DOM::Element&, CSS::StyleProperties); virtual ~FrameBox() override; virtual void prepare_for_replaced_layout() override; diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index aaafdda53b3..aa45774aaa1 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -15,7 +15,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(ImageBox); -ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style, ImageProvider const& image_provider) +ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style, ImageProvider const& image_provider) : ReplacedBox(document, element, move(style)) , m_image_provider(image_provider) { diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.h b/Userland/Libraries/LibWeb/Layout/ImageBox.h index 931c59509ef..9277a7e8af5 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.h +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.h @@ -16,7 +16,7 @@ class ImageBox final : public ReplacedBox { JS_DECLARE_ALLOCATOR(ImageBox); public: - ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr, ImageProvider const&); + ImageBox(DOM::Document&, DOM::Element&, CSS::StyleProperties, ImageProvider const&); virtual ~ImageBox() override; virtual void prepare_for_replaced_layout() override; diff --git a/Userland/Libraries/LibWeb/Layout/InlineNode.cpp b/Userland/Libraries/LibWeb/Layout/InlineNode.cpp index 5e5fadaff1c..64053c5e030 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineNode.cpp @@ -16,7 +16,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(InlineNode); -InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) +InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, CSS::StyleProperties style) : Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/InlineNode.h b/Userland/Libraries/LibWeb/Layout/InlineNode.h index 14687d6fa0e..23023c1fc59 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineNode.h +++ b/Userland/Libraries/LibWeb/Layout/InlineNode.h @@ -15,7 +15,7 @@ class InlineNode final : public NodeWithStyleAndBoxModelMetrics { JS_DECLARE_ALLOCATOR(InlineNode); public: - InlineNode(DOM::Document&, DOM::Element*, NonnullRefPtr); + InlineNode(DOM::Document&, DOM::Element*, CSS::StyleProperties); virtual ~InlineNode() override; JS::GCPtr create_paintable_for_line_with_index(size_t line_index) const; diff --git a/Userland/Libraries/LibWeb/Layout/Label.cpp b/Userland/Libraries/LibWeb/Layout/Label.cpp index caf98e28de3..6a5ef121934 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.cpp +++ b/Userland/Libraries/LibWeb/Layout/Label.cpp @@ -17,7 +17,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(Label); -Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, NonnullRefPtr style) +Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, CSS::StyleProperties style) : BlockContainer(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/Label.h b/Userland/Libraries/LibWeb/Layout/Label.h index e11a07fcc52..19abd65abe6 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.h +++ b/Userland/Libraries/LibWeb/Layout/Label.h @@ -16,7 +16,7 @@ class Label final : public BlockContainer { JS_DECLARE_ALLOCATOR(Label); public: - Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr); + Label(DOM::Document&, HTML::HTMLLabelElement*, CSS::StyleProperties); virtual ~Label() override; static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint); diff --git a/Userland/Libraries/LibWeb/Layout/LabelableNode.h b/Userland/Libraries/LibWeb/Layout/LabelableNode.h index 28f566b8dd8..b0f282b9a40 100644 --- a/Userland/Libraries/LibWeb/Layout/LabelableNode.h +++ b/Userland/Libraries/LibWeb/Layout/LabelableNode.h @@ -19,7 +19,7 @@ public: Painting::LabelablePaintable const* paintable() const; protected: - LabelableNode(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) + LabelableNode(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp index f4eda06f0c3..46b46cfbf24 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(ListItemBox); -ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) +ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, CSS::StyleProperties style) : Layout::BlockContainer(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.h b/Userland/Libraries/LibWeb/Layout/ListItemBox.h index e8e7a2e7e54..00250cefcaf 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemBox.h +++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.h @@ -16,7 +16,7 @@ class ListItemBox final : public BlockContainer { JS_DECLARE_ALLOCATOR(ListItemBox); public: - ListItemBox(DOM::Document&, DOM::Element*, NonnullRefPtr); + ListItemBox(DOM::Document&, DOM::Element*, CSS::StyleProperties); virtual ~ListItemBox() override; DOM::Element& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp index 560876d1f57..8dc8b86caf9 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(ListItemMarkerBox); -ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, NonnullRefPtr style) +ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, CSS::StyleProperties style) : Box(document, nullptr, move(style)) , m_list_style_type(style_type) , m_list_style_position(style_position) diff --git a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h index 5da1be0baa0..8f5485c285a 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h +++ b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h @@ -16,7 +16,7 @@ class ListItemMarkerBox final : public Box { JS_DECLARE_ALLOCATOR(ListItemMarkerBox); public: - explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, NonnullRefPtr); + explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, CSS::StyleProperties); virtual ~ListItemMarkerBox() override; Optional const& text() const { return m_text; } diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index f199dd9dd49..d0ce10c9124 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -261,12 +261,12 @@ bool Node::is_sticky_position() const return position == CSS::Positioning::Sticky; } -NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, NonnullRefPtr computed_style) +NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, CSS::StyleProperties computed_style) : Node(document, node) , m_computed_values(make()) { m_has_style = true; - apply_style(*computed_style); + apply_style(computed_style); } NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, NonnullOwnPtr computed_values) diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index ff8404dc072..f9d87d91ecd 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -228,7 +228,7 @@ public: virtual void visit_edges(Cell::Visitor& visitor) override; protected: - NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr); + NodeWithStyle(DOM::Document&, DOM::Node*, CSS::StyleProperties); NodeWithStyle(DOM::Document&, DOM::Node*, NonnullOwnPtr); private: @@ -247,7 +247,7 @@ public: BoxModelMetrics const& box_model() const { return m_box_model; } protected: - NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, NonnullRefPtr style) + NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, CSS::StyleProperties style) : NodeWithStyle(document, node, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/RadioButton.cpp b/Userland/Libraries/LibWeb/Layout/RadioButton.cpp index 6202219ae8a..60755ca5487 100644 --- a/Userland/Libraries/LibWeb/Layout/RadioButton.cpp +++ b/Userland/Libraries/LibWeb/Layout/RadioButton.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(RadioButton); -RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, NonnullRefPtr style) +RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, CSS::StyleProperties style) : FormAssociatedLabelableNode(document, element, move(style)) { set_natural_width(12); diff --git a/Userland/Libraries/LibWeb/Layout/RadioButton.h b/Userland/Libraries/LibWeb/Layout/RadioButton.h index 45d456ef578..f685af94119 100644 --- a/Userland/Libraries/LibWeb/Layout/RadioButton.h +++ b/Userland/Libraries/LibWeb/Layout/RadioButton.h @@ -16,7 +16,7 @@ class RadioButton final : public FormAssociatedLabelableNode { JS_DECLARE_ALLOCATOR(RadioButton); public: - RadioButton(DOM::Document&, HTML::HTMLInputElement&, NonnullRefPtr); + RadioButton(DOM::Document&, HTML::HTMLInputElement&, CSS::StyleProperties); virtual ~RadioButton() override; private: diff --git a/Userland/Libraries/LibWeb/Layout/ReplacedBox.cpp b/Userland/Libraries/LibWeb/Layout/ReplacedBox.cpp index e61f4e79f2f..b210043a979 100644 --- a/Userland/Libraries/LibWeb/Layout/ReplacedBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ReplacedBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { -ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) +ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : Box(document, &element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h index a4c8dce38b5..579b2e26961 100644 --- a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h +++ b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h @@ -15,7 +15,7 @@ class ReplacedBox : public Box { JS_CELL(ReplacedBox, Box); public: - ReplacedBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + ReplacedBox(DOM::Document&, DOM::Element&, CSS::StyleProperties); virtual ~ReplacedBox() override; DOM::Element const& dom_node() const { return verify_cast(*Node::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGBox.cpp index d5d63b084d8..3df18c1140f 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGBox.cpp @@ -8,7 +8,7 @@ namespace Web::Layout { -SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, NonnullRefPtr style) +SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, CSS::StyleProperties style) : Box(document, &element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGBox.h b/Userland/Libraries/LibWeb/Layout/SVGBox.h index 69bd8212792..9607141687e 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGBox.h @@ -16,7 +16,7 @@ class SVGBox : public Box { JS_CELL(SVGBox, Box); public: - SVGBox(DOM::Document&, SVG::SVGElement&, NonnullRefPtr); + SVGBox(DOM::Document&, SVG::SVGElement&, CSS::StyleProperties); virtual ~SVGBox() override = default; SVG::SVGElement& dom_node() { return verify_cast(*Box::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGClipBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGClipBox.cpp index 4a1c8968446..8b1d03b757b 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGClipBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGClipBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGClipBox); -SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, NonnullRefPtr properties) +SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, CSS::StyleProperties properties) : SVGBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGClipBox.h b/Userland/Libraries/LibWeb/Layout/SVGClipBox.h index db7d20a0f8c..121af6ff9ae 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGClipBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGClipBox.h @@ -17,7 +17,7 @@ class SVGClipBox : public SVGBox { JS_DECLARE_ALLOCATOR(SVGClipBox); public: - SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, NonnullRefPtr); + SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, CSS::StyleProperties); virtual ~SVGClipBox() override = default; SVG::SVGClipPathElement& dom_node() { return verify_cast(SVGBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp index 5569a6127f0..dd695fa47dd 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGForeignObjectBox); -SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, NonnullRefPtr properties) +SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, CSS::StyleProperties properties) : BlockContainer(document, &element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.h b/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.h index 5e9412bc0dc..5a98e100ce9 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGForeignObjectBox.h @@ -18,7 +18,7 @@ class SVGForeignObjectBox final : public BlockContainer { JS_DECLARE_ALLOCATOR(SVGForeignObjectBox); public: - SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, NonnullRefPtr); + SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, CSS::StyleProperties); virtual ~SVGForeignObjectBox() override = default; SVG::SVGForeignObjectElement& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp index c745c5ead20..0a1fdbb5fbe 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp @@ -14,7 +14,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGGeometryBox); -SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, NonnullRefPtr properties) +SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, CSS::StyleProperties properties) : SVGGraphicsBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h index c4ce6c63c9c..6076345f613 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h @@ -17,7 +17,7 @@ class SVGGeometryBox final : public SVGGraphicsBox { JS_DECLARE_ALLOCATOR(SVGGeometryBox); public: - SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, NonnullRefPtr); + SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, CSS::StyleProperties); virtual ~SVGGeometryBox() override = default; SVG::SVGGeometryElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp index 8b1d01632de..be8a716cd07 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp @@ -10,7 +10,7 @@ namespace Web::Layout { -SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, NonnullRefPtr properties) +SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::StyleProperties properties) : SVGBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.h b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.h index 9d223980a0c..14d915ef657 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.h @@ -16,7 +16,7 @@ class SVGGraphicsBox : public SVGBox { JS_CELL(SVGGraphicsBox, SVGBox); public: - SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, NonnullRefPtr); + SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::StyleProperties); virtual ~SVGGraphicsBox() override = default; SVG::SVGGraphicsElement& dom_node() { return verify_cast(SVGBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGImageBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGImageBox.cpp index e79b66da6d8..73b6c243e03 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGImageBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { -SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, NonnullRefPtr properties) +SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::StyleProperties properties) : SVGGraphicsBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGImageBox.h b/Userland/Libraries/LibWeb/Layout/SVGImageBox.h index 7163eda6b82..b5aee89e085 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGImageBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGImageBox.h @@ -16,7 +16,7 @@ class SVGImageBox : public SVGGraphicsBox { JS_CELL(SVGImageBox, SVGGraphicsBox); public: - SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, NonnullRefPtr); + SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::StyleProperties); virtual ~SVGImageBox() override = default; SVG::SVGImageElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGMaskBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGMaskBox.cpp index 7d6f9bcc147..b06ec858dfb 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGMaskBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGMaskBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGMaskBox); -SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, NonnullRefPtr properties) +SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, CSS::StyleProperties properties) : SVGGraphicsBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGMaskBox.h b/Userland/Libraries/LibWeb/Layout/SVGMaskBox.h index 5a5ac629fa7..0a70dd007c1 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGMaskBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGMaskBox.h @@ -17,7 +17,7 @@ class SVGMaskBox : public SVGGraphicsBox { JS_DECLARE_ALLOCATOR(SVGMaskBox); public: - SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, NonnullRefPtr); + SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, CSS::StyleProperties); virtual ~SVGMaskBox() override = default; virtual bool is_svg_mask_box() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp index 57092de820a..78ddfb5307f 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp @@ -15,7 +15,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGSVGBox); -SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, NonnullRefPtr properties) +SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, CSS::StyleProperties properties) : ReplacedBox(document, element, move(properties)) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h index b52a9d81442..d2ff206616c 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h @@ -16,7 +16,7 @@ class SVGSVGBox final : public ReplacedBox { JS_DECLARE_ALLOCATOR(SVGSVGBox); public: - SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr); + SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, CSS::StyleProperties); virtual ~SVGSVGBox() override = default; SVG::SVGSVGElement& dom_node() { return verify_cast(ReplacedBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGTextBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGTextBox.cpp index 50d9f89a819..75e9ecacc5a 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGTextBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGTextBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGTextBox); -SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, NonnullRefPtr properties) +SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, CSS::StyleProperties properties) : SVGGraphicsBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGTextBox.h b/Userland/Libraries/LibWeb/Layout/SVGTextBox.h index 104250daba0..75f9aa2a76c 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGTextBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGTextBox.h @@ -17,7 +17,7 @@ class SVGTextBox final : public SVGGraphicsBox { JS_DECLARE_ALLOCATOR(SVGTextBox); public: - SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, NonnullRefPtr); + SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, CSS::StyleProperties); virtual ~SVGTextBox() override = default; SVG::SVGTextPositioningElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.cpp index 58aace23302..f5ebdda2248 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(SVGTextPathBox); -SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, NonnullRefPtr properties) +SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, CSS::StyleProperties properties) : SVGGraphicsBox(document, element, properties) { } diff --git a/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.h b/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.h index 4f0a0a76616..686d49506ea 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.h +++ b/Userland/Libraries/LibWeb/Layout/SVGTextPathBox.h @@ -16,7 +16,7 @@ class SVGTextPathBox final : public SVGGraphicsBox { JS_DECLARE_ALLOCATOR(SVGTextPathBox); public: - SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, NonnullRefPtr); + SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, CSS::StyleProperties); virtual ~SVGTextPathBox() override = default; SVG::SVGTextPathElement& dom_node() { return static_cast(SVGGraphicsBox::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/TableWrapper.cpp b/Userland/Libraries/LibWeb/Layout/TableWrapper.cpp index bdc3bf482ba..5cc8ddb4610 100644 --- a/Userland/Libraries/LibWeb/Layout/TableWrapper.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableWrapper.cpp @@ -10,7 +10,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(TableWrapper); -TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, NonnullRefPtr style) +TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, CSS::StyleProperties style) : BlockContainer(document, node, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/TableWrapper.h b/Userland/Libraries/LibWeb/Layout/TableWrapper.h index 2cbb3416260..31b68585783 100644 --- a/Userland/Libraries/LibWeb/Layout/TableWrapper.h +++ b/Userland/Libraries/LibWeb/Layout/TableWrapper.h @@ -15,7 +15,7 @@ class TableWrapper : public BlockContainer { JS_DECLARE_ALLOCATOR(TableWrapper); public: - TableWrapper(DOM::Document&, DOM::Node*, NonnullRefPtr); + TableWrapper(DOM::Document&, DOM::Node*, CSS::StyleProperties); TableWrapper(DOM::Document&, DOM::Node*, NonnullOwnPtr); virtual ~TableWrapper() override; diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index bee86fbef8e..37ba54eb5b7 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -193,7 +193,7 @@ 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) + if (!pseudo_element_style.has_value()) return; auto initial_quote_nesting_level = m_quote_nesting_level; @@ -221,7 +221,7 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se pseudo_element_node->computed_values().list_style_type(), pseudo_element_node->computed_values().list_style_position(), 0, - *marker_style); + marker_style); static_cast(*pseudo_element_node).set_marker(list_item_marker); element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Type::Marker, list_item_marker); pseudo_element_node->append_child(*list_item_marker); @@ -341,7 +341,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& auto& document = dom_node.document(); auto& style_computer = document.style_computer(); - RefPtr style; + Optional style; CSS::Display display; if (is(dom_node)) { @@ -429,7 +429,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& if (is(*layout_node)) { auto& element = static_cast(dom_node); auto marker_style = style_computer.compute_style(element, CSS::Selector::PseudoElement::Type::Marker); - auto list_item_marker = document.heap().allocate_without_realm(document, layout_node->computed_values().list_style_type(), layout_node->computed_values().list_style_position(), calculate_list_item_index(dom_node), *marker_style); + auto list_item_marker = document.heap().allocate_without_realm(document, layout_node->computed_values().list_style_type(), layout_node->computed_values().list_style_position(), calculate_list_item_index(dom_node), marker_style); static_cast(*layout_node).set_marker(list_item_marker); element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Type::Marker, list_item_marker); layout_node->append_child(*list_item_marker); diff --git a/Userland/Libraries/LibWeb/Layout/VideoBox.cpp b/Userland/Libraries/LibWeb/Layout/VideoBox.cpp index 548dca736aa..6b45c1673b9 100644 --- a/Userland/Libraries/LibWeb/Layout/VideoBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/VideoBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(VideoBox); -VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) +VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { document.register_viewport_client(*this); diff --git a/Userland/Libraries/LibWeb/Layout/VideoBox.h b/Userland/Libraries/LibWeb/Layout/VideoBox.h index 03490c04cad..f158b9d200b 100644 --- a/Userland/Libraries/LibWeb/Layout/VideoBox.h +++ b/Userland/Libraries/LibWeb/Layout/VideoBox.h @@ -27,7 +27,7 @@ public: virtual JS::GCPtr create_paintable() const override; private: - VideoBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + VideoBox(DOM::Document&, DOM::Element&, CSS::StyleProperties); // ^Document::ViewportClient virtual void did_set_viewport_rect(CSSPixelRect const&) final; diff --git a/Userland/Libraries/LibWeb/Layout/Viewport.cpp b/Userland/Libraries/LibWeb/Layout/Viewport.cpp index d77b7cd5ee2..97498b4acfe 100644 --- a/Userland/Libraries/LibWeb/Layout/Viewport.cpp +++ b/Userland/Libraries/LibWeb/Layout/Viewport.cpp @@ -16,7 +16,7 @@ namespace Web::Layout { JS_DEFINE_ALLOCATOR(Viewport); -Viewport::Viewport(DOM::Document& document, NonnullRefPtr style) +Viewport::Viewport(DOM::Document& document, CSS::StyleProperties style) : BlockContainer(document, &document, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/Viewport.h b/Userland/Libraries/LibWeb/Layout/Viewport.h index 7158871fc6b..d93e11c7295 100644 --- a/Userland/Libraries/LibWeb/Layout/Viewport.h +++ b/Userland/Libraries/LibWeb/Layout/Viewport.h @@ -16,7 +16,7 @@ class Viewport final : public BlockContainer { JS_DECLARE_ALLOCATOR(Viewport); public: - explicit Viewport(DOM::Document&, NonnullRefPtr); + explicit Viewport(DOM::Document&, CSS::StyleProperties); virtual ~Viewport() override; struct TextPosition { diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp index 33962d19cf7..e1a06d9f6c5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp @@ -59,7 +59,7 @@ JS::NonnullGCPtr SVGAElement::rel_list() return *m_rel_list; } -JS::GCPtr SVGAElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGAElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.h b/Userland/Libraries/LibWeb/SVG/SVGAElement.h index 486f4e206f7..18d5b197741 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.h @@ -23,7 +23,7 @@ public: JS::NonnullGCPtr rel_list(); - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; private: SVGAElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index 94b2ca4ea42..76fc4546d7e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -35,7 +35,7 @@ void SVGClipPathElement::attribute_changed(FlyString const& name, Optional SVGClipPathElement::create_layout_node(NonnullRefPtr) +JS::GCPtr SVGClipPathElement::create_layout_node(CSS::StyleProperties) { // Clip paths are handled as a special case in the TreeBuilder. return nullptr; diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h index d6c10c10643..c64b664d7cd 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -40,7 +40,7 @@ public: return m_clip_path_units.value_or(ClipPathUnits::UserSpaceOnUse); } - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; private: SVGClipPathElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 6f9f45da5c0..96feea68da3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/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); + auto const root_element_style = m_root_element->computed_css_values(); + VERIFY(root_element_style.has_value()); 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); + auto const root_element_style = m_root_element->computed_css_values(); + VERIFY(root_element_style.has_value()); 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/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h index ed4297b3a2c..e23149d081e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h @@ -17,7 +17,7 @@ class SVGDefsElement final : public SVGGraphicsElement { public: virtual ~SVGDefsElement(); - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override { return nullptr; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDescElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGDescElement.cpp index 651978675b7..827d9f20903 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDescElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDescElement.cpp @@ -25,7 +25,7 @@ void SVGDescElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGDescElement); } -JS::GCPtr SVGDescElement::create_layout_node(NonnullRefPtr) +JS::GCPtr SVGDescElement::create_layout_node(CSS::StyleProperties) { return nullptr; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDescElement.h b/Userland/Libraries/LibWeb/SVG/SVGDescElement.h index 9e5ccd8b48e..a818fb46c55 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDescElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDescElement.h @@ -19,7 +19,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index d0d8be96b82..4b66d7eb010 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -139,7 +139,7 @@ JS::NonnullGCPtr SVGElement::svg_animated_length_for_property { // FIXME: Create a proper animated value when animations are supported. auto make_length = [&] { - if (auto const* style = computed_css_values(); style) { + if (auto const style = computed_css_values(); style.has_value()) { if (auto length = style->length_percentage(property); length.has_value()) return SVGLength::from_length_percentage(realm(), *length); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index ad52d6846d2..879b2713a62 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -47,7 +47,7 @@ void SVGForeignObjectElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_height); } -JS::GCPtr SVGForeignObjectElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGForeignObjectElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h index 3e02f2b20fd..af26d27a7f3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h @@ -18,7 +18,7 @@ class SVGForeignObjectElement final : public SVGGraphicsElement { public: virtual ~SVGForeignObjectElement() override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; JS::NonnullGCPtr x(); JS::NonnullGCPtr y(); diff --git a/Userland/Libraries/LibWeb/SVG/SVGGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGElement.cpp index 9c64665046d..92205249744 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGElement.cpp @@ -26,7 +26,7 @@ void SVGGElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGGElement); } -JS::GCPtr SVGGElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGGElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGElement.h b/Userland/Libraries/LibWeb/SVG/SVGGElement.h index a44a408655b..72be16dbfed 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGElement.h @@ -17,7 +17,7 @@ class SVGGElement final : public SVGGraphicsElement { public: virtual ~SVGGElement() override = default; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; private: SVGGElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 98b19d40fdf..964de1180e0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -22,7 +22,7 @@ void SVGGeometryElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGGeometryElement); } -JS::GCPtr SVGGeometryElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGGeometryElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h index 5d39a0840ac..23bbb06eb52 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -16,7 +16,7 @@ class SVGGeometryElement : public SVGGraphicsElement { WEB_PLATFORM_OBJECT(SVGGeometryElement, SVGGraphicsElement); public: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) = 0; diff --git a/Userland/Libraries/LibWeb/SVG/SVGImageElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGImageElement.cpp index a684d51708c..fb522385729 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGImageElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGImageElement.cpp @@ -178,7 +178,7 @@ void SVGImageElement::fetch_the_document(URL::URL const& url) } } -JS::GCPtr SVGImageElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGImageElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGImageElement.h b/Userland/Libraries/LibWeb/SVG/SVGImageElement.h index be4b787b893..a792ed5c262 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGImageElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGImageElement.h @@ -57,7 +57,7 @@ protected: void fetch_the_document(URL::URL const& url); private: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; void animate(); JS::GCPtr m_x; diff --git a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp index a12d815d778..f6f8cd0f97d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp @@ -27,7 +27,7 @@ void SVGMaskElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGMaskElement); } -JS::GCPtr SVGMaskElement::create_layout_node(NonnullRefPtr) +JS::GCPtr SVGMaskElement::create_layout_node(CSS::StyleProperties) { // Masks are handled as a special case in the TreeBuilder. return nullptr; diff --git a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h index 3088f3cd631..2e66c821873 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h @@ -38,7 +38,7 @@ public: virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; CSSPixelRect resolve_masking_area(CSSPixelRect const& mask_target) const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.cpp index e9127f78f7a..253668d056b 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.cpp @@ -25,7 +25,7 @@ void SVGMetadataElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGMetadataElement); } -JS::GCPtr SVGMetadataElement::create_layout_node(NonnullRefPtr) +JS::GCPtr SVGMetadataElement::create_layout_node(CSS::StyleProperties) { return nullptr; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.h b/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.h index 76ff35e3104..891c07bcb8a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGMetadataElement.h @@ -20,7 +20,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 6e80053f8df..39ea53fb74e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -42,7 +42,7 @@ void SVGSVGElement::visit_edges(Visitor& visitor) visitor.visit(m_view_box_for_bindings); } -JS::GCPtr SVGSVGElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGSVGElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h index 7b90256cde4..d2a22ce6752 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -29,7 +29,7 @@ class SVGSVGElement final : public SVGGraphicsElement JS_DECLARE_ALLOCATOR(SVGSVGElement); public: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp index 845ea1e6cc6..9835ee00fd5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp @@ -48,14 +48,14 @@ void SVGStopElement::apply_presentational_hints(CSS::StyleProperties& style) con Gfx::Color SVGStopElement::stop_color() const { - if (auto css_values = computed_css_values()) + if (auto css_values = computed_css_values(); css_values.has_value()) return css_values->stop_color(); return Color::Black; } float SVGStopElement::stop_opacity() const { - if (auto css_values = computed_css_values()) + if (auto css_values = computed_css_values(); css_values.has_value()) return css_values->stop_opacity(); return 1; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index 3312cc32aec..6ac13575f42 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -74,7 +74,7 @@ bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const return is(host); } -JS::GCPtr SVGSymbolElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGSymbolElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h index 317684b5cd2..ce3122326ea 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h @@ -36,7 +36,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; bool is_direct_child_of_use_shadow_tree() const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp index fcd0c2c9a2d..17b63ce0612 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.cpp @@ -24,7 +24,7 @@ void SVGTSpanElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTSpanElement); } -JS::GCPtr SVGTSpanElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGTSpanElement::create_layout_node(CSS::StyleProperties style) { // Text must be within an SVG element. if (shadow_including_first_ancestor_of_type()) diff --git a/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.h b/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.h index 114e5232264..358daffe9b5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTSpanElement.h @@ -17,7 +17,7 @@ class SVGTSpanElement : public SVGTextPositioningElement { JS_DECLARE_ALLOCATOR(SVGTSpanElement); public: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; protected: SVGTSpanElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextElement.cpp index 5ba42add2e7..0aaa7945154 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextElement.cpp @@ -23,7 +23,7 @@ void SVGTextElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTextElement); } -JS::GCPtr SVGTextElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGTextElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextElement.h index 5e6f924297a..65e4d0ff141 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextElement.h @@ -17,7 +17,7 @@ class SVGTextElement : public SVGTextPositioningElement { JS_DECLARE_ALLOCATOR(SVGTextElement); public: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; protected: SVGTextElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp index 388e9b69aa6..d69c7626da9 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp @@ -40,7 +40,7 @@ void SVGTextPathElement::visit_edges(Cell::Visitor& visitor) SVGURIReferenceMixin::visit_edges(visitor); } -JS::GCPtr SVGTextPathElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGTextPathElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.h index cd03760ff00..95c153dcc7d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.h @@ -20,7 +20,7 @@ class SVGTextPathElement JS_DECLARE_ALLOCATOR(SVGTextPathElement); public: - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; JS::GCPtr path_or_shape() const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGTitleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTitleElement.cpp index ad311b7318b..3af95755173 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTitleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTitleElement.cpp @@ -25,7 +25,7 @@ void SVGTitleElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTitleElement); } -JS::GCPtr SVGTitleElement::create_layout_node(NonnullRefPtr) +JS::GCPtr SVGTitleElement::create_layout_node(CSS::StyleProperties) { return nullptr; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTitleElement.h b/Userland/Libraries/LibWeb/SVG/SVGTitleElement.h index 09ee74776ee..48d5f926ee1 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTitleElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTitleElement.h @@ -19,7 +19,7 @@ private: virtual void initialize(JS::Realm&) override; - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; virtual void children_changed() override; }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index 10a5156c6e0..ab4bda8bc46 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -235,7 +235,7 @@ JS::GCPtr SVGUseElement::animated_instance_root() const return instance_root(); } -JS::GCPtr SVGUseElement::create_layout_node(NonnullRefPtr style) +JS::GCPtr SVGUseElement::create_layout_node(CSS::StyleProperties style) { return heap().allocate_without_realm(document(), *this, move(style)); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h index 95f02af14ec..407826f86f0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h @@ -49,7 +49,7 @@ private: virtual bool is_svg_use_element() const override { return true; } - virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; + virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; void process_the_url(Optional const& href); diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index c3c15d02778..20731ad16de 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -342,7 +342,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::StyleProperties::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() : ""_string); } dbgln("---"); @@ -470,7 +470,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()) { + if (!element.computed_css_values().has_value()) { async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {}, {}); return; } @@ -581,7 +581,7 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const auto pseudo_element_style = element.pseudo_element_computed_css_values(pseudo_element.value()); ByteString computed_values = serialize_json(*pseudo_element_style); - ByteString resolved_values = serialize_json(*element.resolved_css_values(pseudo_element.value())); + ByteString resolved_values = serialize_json(element.resolved_css_values(pseudo_element.value())); ByteString custom_properties_json = serialize_custom_properties_json(element, pseudo_element); ByteString node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr()); ByteString fonts_json = serialize_fonts_json(*pseudo_element_style); diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index bbd7b34edbc..9e7287f221d 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -1184,7 +1184,7 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e if (!current_browsing_context().active_document()->is_xml_document()) { // computed value of parameter property name from element’s style declarations. property name is obtained from url variables. if (auto property = Web::CSS::property_id_from_string(name); property.has_value()) { - if (auto* computed_values = element->computed_css_values()) + if (auto computed_values = element->computed_css_values(); computed_values.has_value()) computed_value = computed_values->property(property.value())->to_string().to_byte_string(); } }