mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Make CSS::ComputedProperties GC-allocated
This commit is contained in:
parent
c1cad8fa0e
commit
74469a0c1f
Notes:
github-actions[bot]
2024-12-22 09:13:42 +00:00
Author: https://github.com/awesomekling
Commit: 74469a0c1f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2995
138 changed files with 337 additions and 339 deletions
|
@ -29,7 +29,7 @@ void HTMLAudioElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLAudioElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLAudioElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLAudioElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::AudioBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void on_playing() override;
|
||||
|
|
|
@ -27,7 +27,7 @@ void HTMLBRElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLBRElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLBRElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::BreakNode>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class HTMLBRElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLBRElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -175,7 +175,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::set_height(WebIDL::UnsignedLong val
|
|||
return {};
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLCanvasElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLCanvasElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::CanvasBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
|
||||
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
template<typename ContextType>
|
||||
|
|
|
@ -83,7 +83,7 @@ Layout::FieldSetBox* HTMLFieldSetElement::layout_node()
|
|||
return static_cast<Layout::FieldSetBox*>(Node::layout_node());
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLFieldSetElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLFieldSetElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::FieldSetBox>(document(), *this, style);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::group; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
Layout::FieldSetBox* layout_node();
|
||||
Layout::FieldSetBox const* layout_node() const;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void HTMLIFrameElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLIFrameElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLIFrameElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLIFrameElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::NavigableContainerViewport>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class HTMLIFrameElement final
|
|||
public:
|
||||
virtual ~HTMLIFrameElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
void set_current_navigation_was_lazy_loaded(bool value);
|
||||
|
|
|
@ -134,7 +134,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const
|
|||
}
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLImageElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLImageElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::ImageBox>(document(), *this, move(style), *this);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return true; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void did_set_viewport_rect(CSSPixelRect const&) override;
|
||||
|
|
|
@ -99,7 +99,7 @@ GC::Ref<ValidityState const> HTMLInputElement::validity() const
|
|||
return realm.create<ValidityState>(realm);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
if (type_state() == TypeAttributeState::Hidden)
|
||||
return nullptr;
|
||||
|
@ -114,8 +114,8 @@ GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperti
|
|||
// This specification introduces the appearance property to provide some control over this behavior.
|
||||
// In particular, using appearance: none allows authors to suppress the native appearance of widgets,
|
||||
// giving them a primitive appearance where CSS can be used to restyle them.
|
||||
if (style.appearance() == CSS::Appearance::None) {
|
||||
return Element::create_layout_node_for_display_type(document(), style.display(), style, this);
|
||||
if (style->appearance() == CSS::Appearance::None) {
|
||||
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
|
||||
}
|
||||
|
||||
if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton)
|
||||
|
@ -127,7 +127,7 @@ GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperti
|
|||
if (type_state() == TypeAttributeState::RadioButton)
|
||||
return heap().allocate<Layout::RadioButton>(document(), *this, move(style));
|
||||
|
||||
return Element::create_layout_node_for_display_type(document(), style.display(), style, this);
|
||||
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
|
||||
}
|
||||
|
||||
void HTMLInputElement::adjust_computed_style(CSS::ComputedProperties& style)
|
||||
|
@ -1123,16 +1123,16 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback));
|
||||
}
|
||||
|
||||
void HTMLInputElement::computed_css_values_changed()
|
||||
void HTMLInputElement::computed_properties_changed()
|
||||
{
|
||||
auto appearance = computed_css_values()->appearance();
|
||||
auto appearance = computed_properties()->appearance();
|
||||
if (!appearance.has_value() || *appearance == CSS::Appearance::None)
|
||||
return;
|
||||
|
||||
auto palette = document().page().palette();
|
||||
auto accent_color = palette.color(ColorRole::Accent).to_string();
|
||||
|
||||
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
|
||||
auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor);
|
||||
if (accent_color_property.has_color())
|
||||
accent_color = accent_color_property.to_string(CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class HTMLInputElement final
|
|||
public:
|
||||
virtual ~HTMLInputElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
enum class TypeAttributeState {
|
||||
|
@ -241,7 +241,7 @@ private:
|
|||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return type_state() == TypeAttributeState::ImageButton; }
|
||||
|
|
|
@ -27,7 +27,7 @@ void HTMLLabelElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLabelElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLLabelElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLLabelElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::Label>(document(), this, move(style));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class HTMLLabelElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLLabelElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
|
||||
Optional<String> for_() const { return attribute(HTML::AttributeNames::for_); }
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ HTMLFormElement* HTMLLegendElement::form()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLLegendElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLLegendElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::LegendBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
HTMLFormElement* form();
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
Layout::LegendBox* layout_node();
|
||||
Layout::LegendBox const* layout_node() const;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ String HTMLObjectElement::data() const
|
|||
return document().encoding_parse_url(*data).to_string();
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLObjectElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLObjectElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
switch (m_representation) {
|
||||
case Representation::Children:
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
|
||||
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const;
|
||||
|
|
|
@ -130,12 +130,12 @@ void HTMLProgressElement::update_progress_value_element()
|
|||
MUST(m_progress_value_element->style_for_bindings()->set_property(CSS::PropertyID::Width, MUST(String::formatted("{}%", position() * 100))));
|
||||
}
|
||||
|
||||
void HTMLProgressElement::computed_css_values_changed()
|
||||
void HTMLProgressElement::computed_properties_changed()
|
||||
{
|
||||
auto palette = document().page().palette();
|
||||
auto accent_color = palette.color(ColorRole::Accent).to_string();
|
||||
|
||||
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
|
||||
auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor);
|
||||
if (accent_color_property.has_color())
|
||||
accent_color = accent_color_property.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
|
||||
// ^DOM::Node
|
||||
virtual bool is_html_progress_element() const final { return true; }
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -516,11 +516,11 @@ void HTMLSelectElement::form_associated_element_was_removed(DOM::Node*)
|
|||
set_shadow_root(nullptr);
|
||||
}
|
||||
|
||||
void HTMLSelectElement::computed_css_values_changed()
|
||||
void HTMLSelectElement::computed_properties_changed()
|
||||
{
|
||||
// Hide chevron icon when appearance is none
|
||||
if (m_chevron_icon_element) {
|
||||
auto appearance = computed_css_values()->appearance();
|
||||
auto appearance = computed_properties()->appearance();
|
||||
if (appearance.has_value() && *appearance == CSS::Appearance::None) {
|
||||
MUST(m_chevron_icon_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "none"_string));
|
||||
} else {
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
virtual void children_changed() override;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Ref<CSS::CascadedPrope
|
|||
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
|
||||
cascaded_properties->set_property_from_presentational_hint(style_property, CSS::CSSKeywordValue::create(CSS::Keyword::Inset));
|
||||
cascaded_properties->set_property_from_presentational_hint(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1)));
|
||||
cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_css_values()->property(color_property));
|
||||
cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_properties()->property(color_property));
|
||||
};
|
||||
apply_border_style(CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor);
|
||||
apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor);
|
||||
|
|
|
@ -63,7 +63,7 @@ void HTMLVideoElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
}
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLVideoElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLVideoElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::VideoBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/media.html#the-video-element:dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return true; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void on_playing() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue