mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 15:19:16 +00:00
After looking into this more, the `[[declarations]]` slot does not seem to need to be a literal map of property names and values. Instead, it can just point at the source (an element or style declaration), and then direct all read or write operations to that. This means the `has()` and `delete()` methods actually work now. A few remaining failures in these tests are because of: - StylePropertyMap[ReadOnly]s not being iterable yet - We're not populating an element's custom properties map, which get fixed whenever someone gets around to producing proper computed values of them.
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/StylePropertyMapReadOnly.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
// https://drafts.css-houdini.org/css-typed-om-1/#stylepropertymap
|
|
class StylePropertyMap : public StylePropertyMapReadOnly {
|
|
WEB_PLATFORM_OBJECT(StylePropertyMap, StylePropertyMapReadOnly);
|
|
GC_DECLARE_ALLOCATOR(StylePropertyMap);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<StylePropertyMap> create(JS::Realm&, GC::Ref<CSSStyleDeclaration>);
|
|
|
|
virtual ~StylePropertyMap() override;
|
|
|
|
WebIDL::ExceptionOr<void> set(String property, Vector<Variant<GC::Root<CSSStyleValue>, String>> values);
|
|
WebIDL::ExceptionOr<void> append(String property, Vector<Variant<GC::Root<CSSStyleValue>, String>> values);
|
|
WebIDL::ExceptionOr<void> delete_(String property);
|
|
WebIDL::ExceptionOr<void> clear();
|
|
|
|
private:
|
|
explicit StylePropertyMap(JS::Realm&, GC::Ref<CSSStyleDeclaration>);
|
|
|
|
CSSStyleDeclaration& declarations();
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
};
|
|
|
|
}
|