mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb/CSS: Stub out CSSStyleValue
This commit is contained in:
parent
b447dc63c4
commit
882288bf86
|
|
@ -128,6 +128,7 @@ set(SOURCES
|
|||
CSS/CSSStyleProperties.cpp
|
||||
CSS/CSSStyleRule.cpp
|
||||
CSS/CSSStyleSheet.cpp
|
||||
CSS/CSSStyleValue.cpp
|
||||
CSS/CSSSupportsRule.cpp
|
||||
CSS/CSSTransition.cpp
|
||||
CSS/Descriptor.cpp
|
||||
|
|
|
|||
53
Libraries/LibWeb/CSS/CSSStyleValue.cpp
Normal file
53
Libraries/LibWeb/CSS/CSSStyleValue.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "CSSStyleValue.h"
|
||||
#include <LibWeb/Bindings/CSSStyleValuePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleValue);
|
||||
|
||||
GC::Ref<CSSStyleValue> CSSStyleValue::create(JS::Realm& realm, Optional<String> associated_property, Optional<String> constructed_from_string)
|
||||
{
|
||||
return realm.create<CSSStyleValue>(realm, move(associated_property), move(constructed_from_string));
|
||||
}
|
||||
|
||||
CSSStyleValue::CSSStyleValue(JS::Realm& realm, Optional<String> associated_property, Optional<String> constructed_from_string)
|
||||
: PlatformObject(realm)
|
||||
, m_associated_property(move(associated_property))
|
||||
, m_constructed_from_string(move(constructed_from_string))
|
||||
{
|
||||
}
|
||||
|
||||
void CSSStyleValue::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSStyleValue);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#stylevalue-serialization
|
||||
String CSSStyleValue::to_string() const
|
||||
{
|
||||
// if the value was constructed from a USVString
|
||||
if (m_constructed_from_string.has_value()) {
|
||||
// the serialization is the USVString from which the value was constructed.
|
||||
return m_constructed_from_string.value();
|
||||
}
|
||||
// FIXME: otherwise, if the value was constructed using an IDL constructor
|
||||
{
|
||||
// the serialization is specified in the sections below.
|
||||
}
|
||||
// FIXME: otherwise, if the value was extracted from the CSSOM
|
||||
{
|
||||
// the serialization is specified in §6.7 Serialization from CSSOM Values below.
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
36
Libraries/LibWeb/CSS/CSSStyleValue.h
Normal file
36
Libraries/LibWeb/CSS/CSSStyleValue.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue
|
||||
class CSSStyleValue : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleValue, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(CSSStyleValue);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CSSStyleValue> create(JS::Realm&, Optional<String> associated_property = {}, Optional<String> constructed_from_string = {});
|
||||
|
||||
virtual ~CSSStyleValue() override = default;
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
private:
|
||||
explicit CSSStyleValue(JS::Realm&, Optional<String> associated_property = {}, Optional<String> constructed_from_string = {});
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylevalue-associatedproperty-slot
|
||||
Optional<String> m_associated_property;
|
||||
|
||||
Optional<String> m_constructed_from_string;
|
||||
};
|
||||
|
||||
}
|
||||
8
Libraries/LibWeb/CSS/CSSStyleValue.idl
Normal file
8
Libraries/LibWeb/CSS/CSSStyleValue.idl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue
|
||||
// FIXME: [Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
|
||||
[Exposed=(Window, Worker)]
|
||||
interface CSSStyleValue {
|
||||
stringifier;
|
||||
[FIXME, Exposed=Window] static CSSStyleValue parse(USVString property, USVString cssText);
|
||||
[FIXME, Exposed=Window] static sequence<CSSStyleValue> parseAll(USVString property, USVString cssText);
|
||||
};
|
||||
|
|
@ -252,6 +252,7 @@ class CSSStyleDeclaration;
|
|||
class CSSStyleProperties;
|
||||
class CSSStyleRule;
|
||||
class CSSStyleSheet;
|
||||
class CSSStyleValue;
|
||||
class CSSSupportsRule;
|
||||
class CursorStyleValue;
|
||||
class CustomIdentStyleValue;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ libweb_js_bindings(CSS/CSSStyleDeclaration)
|
|||
libweb_js_bindings(CSS/CSSStyleProperties)
|
||||
libweb_js_bindings(CSS/CSSStyleRule)
|
||||
libweb_js_bindings(CSS/CSSStyleSheet)
|
||||
libweb_js_bindings(CSS/CSSStyleValue)
|
||||
libweb_js_bindings(CSS/CSSSupportsRule)
|
||||
libweb_js_bindings(CSS/CSSTransition)
|
||||
libweb_js_bindings(CSS/FontFace)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ static bool is_platform_object(Type const& type)
|
|||
"Credential"sv,
|
||||
"CredentialsContainer"sv,
|
||||
"CryptoKey"sv,
|
||||
"CSSStyleValue"sv,
|
||||
"CustomStateSet"sv,
|
||||
"DataTransfer"sv,
|
||||
"Document"sv,
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ CSSStyleDeclaration
|
|||
CSSStyleProperties
|
||||
CSSStyleRule
|
||||
CSSStyleSheet
|
||||
CSSStyleValue
|
||||
CSSSupportsRule
|
||||
CSSTransition
|
||||
CacheStorage
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ Harness status: OK
|
|||
|
||||
Found 5 tests
|
||||
|
||||
5 Fail
|
||||
Fail CSSStyleValue.parse() with empty property name throws TypeError
|
||||
Fail CSSStyleValue.parse() with unsupported property name throws TypeError
|
||||
Fail CSSStyleValue.parse() with invalid value for valid property throws TypeError
|
||||
Fail CSSStyleValue.parse() with invalid value for shorthand property throws TypeError
|
||||
Fail CSSStyleValue.parse() with invalid value for custom property throws TypeError
|
||||
5 Pass
|
||||
Pass CSSStyleValue.parse() with empty property name throws TypeError
|
||||
Pass CSSStyleValue.parse() with unsupported property name throws TypeError
|
||||
Pass CSSStyleValue.parse() with invalid value for valid property throws TypeError
|
||||
Pass CSSStyleValue.parse() with invalid value for shorthand property throws TypeError
|
||||
Pass CSSStyleValue.parse() with invalid value for custom property throws TypeError
|
||||
|
|
@ -2,10 +2,10 @@ Harness status: OK
|
|||
|
||||
Found 6 tests
|
||||
|
||||
6 Fail
|
||||
Fail CSSStyleValue.parseAll() with empty property name throws TypeError
|
||||
Fail CSSStyleValue.parseAll() with unsupported property name throws TypeError
|
||||
Fail CSSStyleValue.parseAll() with invalid value for valid property throws TypeError
|
||||
Fail CSSStyleValue.parseAll() with invalid value for shorthand property throws TypeError
|
||||
Fail CSSStyleValue.parseAll() with invalid value for custom property throws TypeError
|
||||
Fail CSSStyleValue.parseAll() with invalid value for property throws TypeError
|
||||
6 Pass
|
||||
Pass CSSStyleValue.parseAll() with empty property name throws TypeError
|
||||
Pass CSSStyleValue.parseAll() with unsupported property name throws TypeError
|
||||
Pass CSSStyleValue.parseAll() with invalid value for valid property throws TypeError
|
||||
Pass CSSStyleValue.parseAll() with invalid value for shorthand property throws TypeError
|
||||
Pass CSSStyleValue.parseAll() with invalid value for custom property throws TypeError
|
||||
Pass CSSStyleValue.parseAll() with invalid value for property throws TypeError
|
||||
Loading…
Reference in New Issue
Block a user