mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb/CSS: Move property code from CSSStyleDeclaration to *Properties
CSSStyleDeclaration is a base class that's used by various collections of style properties or descriptors. This commit moves all style-property-related code into CSSStyleProperties, where it belongs. As noted in the previous commit, we also apply the CSSStyleProperties prototype now.
This commit is contained in:
parent
83bb92c4e0
commit
a28197669a
Notes:
github-actions[bot]
2025-03-19 13:54:14 +00:00
Author: https://github.com/AtkinsSJ
Commit: a28197669a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3983
12 changed files with 276 additions and 295 deletions
|
@ -8,11 +8,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/GeneratedCSSStyleProperties.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.csswg.org/cssom/#cssstyleproperties
|
||||
class CSSStyleProperties : public CSSStyleDeclaration {
|
||||
class CSSStyleProperties
|
||||
: public CSSStyleDeclaration
|
||||
, public Bindings::GeneratedCSSStyleProperties {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleProperties, CSSStyleDeclaration);
|
||||
GC_DECLARE_ALLOCATOR(CSSStyleProperties);
|
||||
|
||||
|
@ -28,30 +31,41 @@ public:
|
|||
virtual size_t length() const override;
|
||||
virtual String item(size_t index) const override;
|
||||
|
||||
virtual Optional<StyleProperty> property(PropertyID) const override;
|
||||
virtual Optional<StyleProperty const&> custom_property(FlyString const& custom_property_name) const override;
|
||||
Optional<StyleProperty> property(PropertyID) const;
|
||||
Optional<StyleProperty const&> custom_property(FlyString const& custom_property_name) const;
|
||||
|
||||
// Temporary for one commit.
|
||||
using Base::remove_property, Base::set_property;
|
||||
WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv);
|
||||
WebIDL::ExceptionOr<String> remove_property(PropertyID);
|
||||
|
||||
virtual WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority) override;
|
||||
virtual WebIDL::ExceptionOr<String> remove_property(StringView property_name) override;
|
||||
|
||||
virtual String get_property_value(StringView property_name) const override;
|
||||
virtual StringView get_property_priority(StringView property_name) const override;
|
||||
|
||||
Vector<StyleProperty> const& properties() const { return m_properties; }
|
||||
HashMap<FlyString, StyleProperty> const& custom_properties() const { return m_custom_properties; }
|
||||
|
||||
size_t custom_property_count() const { return m_custom_properties.size(); }
|
||||
|
||||
String css_float() const;
|
||||
WebIDL::ExceptionOr<void> set_css_float(StringView);
|
||||
|
||||
virtual String serialized() const final override;
|
||||
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;
|
||||
|
||||
void set_declarations_from_text(StringView);
|
||||
|
||||
// ^Bindings::GeneratedCSSStyleProperties
|
||||
virtual CSSStyleProperties& generated_style_properties_to_css_style_properties() override { return *this; }
|
||||
|
||||
private:
|
||||
CSSStyleProperties(JS::Realm&, Computed, Readonly, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties, Optional<DOM::ElementReference>);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
RefPtr<CSSStyleValue const> style_value_for_computed_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||
Optional<StyleProperty> get_property_internal(PropertyID) const;
|
||||
|
||||
bool set_a_css_declaration(PropertyID, NonnullRefPtr<CSSStyleValue const>, Important);
|
||||
void empty_the_declarations();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue