mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibWeb/CSS: Stub out CSSNumericValue
Most of the methods on this rely on its subclasses existing, so for now it's very basic.
This commit is contained in:
parent
5bdc2981e3
commit
6cb8e92bd4
Notes:
github-actions[bot]
2025-08-22 08:49:55 +00:00
Author: https://github.com/AtkinsSJ
Commit: 6cb8e92bd4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5937
9 changed files with 233 additions and 0 deletions
59
Libraries/LibWeb/CSS/CSSNumericValue.h
Normal file
59
Libraries/LibWeb/CSS/CSSNumericValue.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/Bindings/CSSNumericValuePrototype.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/NumericType.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct CSSNumericType {
|
||||
WebIDL::Long length {};
|
||||
WebIDL::Long angle {};
|
||||
WebIDL::Long time {};
|
||||
WebIDL::Long frequency {};
|
||||
WebIDL::Long resolution {};
|
||||
WebIDL::Long flex {};
|
||||
WebIDL::Long percent {};
|
||||
Optional<Bindings::CSSNumericBaseType> percent_hint {};
|
||||
};
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue
|
||||
class CSSNumericValue : public CSSStyleValue {
|
||||
WEB_PLATFORM_OBJECT(CSSNumericValue, CSSStyleValue);
|
||||
GC_DECLARE_ALLOCATOR(CSSNumericValue);
|
||||
|
||||
public:
|
||||
struct SerializationParams {
|
||||
Optional<double> minimum {};
|
||||
Optional<double> maximum {};
|
||||
bool nested { false };
|
||||
bool parenless { false };
|
||||
};
|
||||
virtual ~CSSNumericValue() override = default;
|
||||
|
||||
CSSNumericType type_for_bindings() const;
|
||||
NumericType const& type() const { return m_type; }
|
||||
|
||||
virtual String to_string() const final override { return to_string({}); }
|
||||
String to_string(SerializationParams const&) const;
|
||||
|
||||
protected:
|
||||
explicit CSSNumericValue(JS::Realm&, NumericType);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
NumericType m_type;
|
||||
};
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#typedefdef-cssnumberish
|
||||
using CSSNumberish = Variant<double, GC::Root<CSSNumericValue>>;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue