mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Generate IDL attributes for all supported CSS properties
The CSSOM spec tells us to potentially add up to three different IDL attributes to CSSStyleDeclaration for every CSS property we support: - A camelCased attribute, where a dash indicates the next character should be uppercase - A camelCased attribute for every -webkit- prefixed property, with the first letter always being lowercase - A dashed-attribute for every property with a dash in it. Additionally, every attribute must have the CEReactions and LegacyNullToEmptyString extended attributes specified on it. Since we specify every property we support with Properties.json, we can use that file to generate the IDL file and it's implementation. We import it from the Build directory with the help of multiple import base paths. Then, we add it to CSSStyleDeclaration via the mixin functionality and inheriting the generated class in CSSStyleDeclaration.
This commit is contained in:
parent
d95ae629ee
commit
aacf9b08ed
Notes:
github-actions[bot]
2024-11-14 18:51:20 +00:00
Author: https://github.com/Lubrsi
Commit: aacf9b08ed
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2346
12 changed files with 909 additions and 60 deletions
|
@ -10,11 +10,14 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/GeneratedCSSStyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class CSSStyleDeclaration : public Bindings::PlatformObject {
|
||||
class CSSStyleDeclaration
|
||||
: public Bindings::PlatformObject
|
||||
, public Bindings::GeneratedCSSStyleProperties {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleDeclaration);
|
||||
|
||||
|
@ -39,16 +42,21 @@ public:
|
|||
String css_text() const;
|
||||
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) = 0;
|
||||
|
||||
virtual String serialized() const = 0;
|
||||
String css_float() const;
|
||||
WebIDL::ExceptionOr<void> set_css_float(StringView);
|
||||
|
||||
virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*) override;
|
||||
virtual String serialized() const = 0;
|
||||
|
||||
virtual JS::GCPtr<CSSRule> parent_rule() const;
|
||||
|
||||
protected:
|
||||
explicit CSSStyleDeclaration(JS::Realm&);
|
||||
|
||||
virtual CSSStyleDeclaration& generated_style_properties_to_css_style_declaration() override { return *this; }
|
||||
|
||||
private:
|
||||
// ^PlatformObject
|
||||
virtual Optional<JS::Value> item_value(size_t index) const override;
|
||||
};
|
||||
|
||||
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue