mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb/CSS: Use FlyString for CSSStyleValue property name
This commit is contained in:
parent
a8312bf571
commit
a30afafcc9
|
|
@ -15,7 +15,7 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleValue);
|
||||
|
||||
GC::Ref<CSSStyleValue> CSSStyleValue::create(JS::Realm& realm, String associated_property, String constructed_from_string)
|
||||
GC::Ref<CSSStyleValue> CSSStyleValue::create(JS::Realm& realm, FlyString associated_property, String constructed_from_string)
|
||||
{
|
||||
return realm.create<CSSStyleValue>(realm, move(associated_property), move(constructed_from_string));
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ CSSStyleValue::CSSStyleValue(JS::Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
CSSStyleValue::CSSStyleValue(JS::Realm& realm, String associated_property, String constructed_from_string)
|
||||
CSSStyleValue::CSSStyleValue(JS::Realm& realm, FlyString associated_property, String constructed_from_string)
|
||||
: PlatformObject(realm)
|
||||
, m_associated_property(move(associated_property))
|
||||
, m_constructed_from_string(move(constructed_from_string))
|
||||
|
|
@ -39,7 +39,7 @@ void CSSStyleValue::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylevalue-parse
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSStyleValue>> CSSStyleValue::parse(JS::VM& vm, String property, String css_text)
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSStyleValue>> CSSStyleValue::parse(JS::VM& vm, FlyString const& property, String css_text)
|
||||
{
|
||||
// The parse(property, cssText) method, when invoked, must parse a CSSStyleValue with property property, cssText
|
||||
// cssText, and parseMultiple set to false, and return the result.
|
||||
|
|
@ -50,7 +50,7 @@ WebIDL::ExceptionOr<GC::Ref<CSSStyleValue>> CSSStyleValue::parse(JS::VM& vm, Str
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylevalue-parseall
|
||||
WebIDL::ExceptionOr<GC::RootVector<GC::Ref<CSSStyleValue>>> CSSStyleValue::parse_all(JS::VM& vm, String property, String css_text)
|
||||
WebIDL::ExceptionOr<GC::RootVector<GC::Ref<CSSStyleValue>>> CSSStyleValue::parse_all(JS::VM& vm, FlyString const& property, String css_text)
|
||||
{
|
||||
// The parseAll(property, cssText) method, when invoked, must parse a CSSStyleValue with property property, cssText
|
||||
// cssText, and parseMultiple set to true, and return the result.
|
||||
|
|
@ -61,7 +61,7 @@ WebIDL::ExceptionOr<GC::RootVector<GC::Ref<CSSStyleValue>>> CSSStyleValue::parse
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#parse-a-cssstylevalue
|
||||
WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, GC::RootVector<GC::Ref<CSSStyleValue>>>> CSSStyleValue::parse_a_css_style_value(JS::VM& vm, String property, String css_text, ParseMultiple parse_multiple)
|
||||
WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, GC::RootVector<GC::Ref<CSSStyleValue>>>> CSSStyleValue::parse_a_css_style_value(JS::VM& vm, FlyString property, String css_text, ParseMultiple parse_multiple)
|
||||
{
|
||||
// 1. If property is not a custom property name string, set property to property ASCII lowercased.
|
||||
if (!is_a_custom_property_name_string(property))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -16,14 +17,14 @@ class CSSStyleValue : public Bindings::PlatformObject {
|
|||
GC_DECLARE_ALLOCATOR(CSSStyleValue);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CSSStyleValue> create(JS::Realm&, String associated_property, String constructed_from_string);
|
||||
[[nodiscard]] static GC::Ref<CSSStyleValue> create(JS::Realm&, FlyString associated_property, String constructed_from_string);
|
||||
|
||||
virtual ~CSSStyleValue() override = default;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSStyleValue>> parse(JS::VM&, String property, String css_text);
|
||||
static WebIDL::ExceptionOr<GC::RootVector<GC::Ref<CSSStyleValue>>> parse_all(JS::VM&, String property, String css_text);
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSStyleValue>> parse(JS::VM&, FlyString const& property, String css_text);
|
||||
static WebIDL::ExceptionOr<GC::RootVector<GC::Ref<CSSStyleValue>>> parse_all(JS::VM&, FlyString const& property, String css_text);
|
||||
|
||||
virtual WebIDL::ExceptionOr<String> to_string() const;
|
||||
|
||||
|
|
@ -31,16 +32,16 @@ protected:
|
|||
explicit CSSStyleValue(JS::Realm&);
|
||||
|
||||
private:
|
||||
explicit CSSStyleValue(JS::Realm&, String associated_property, String constructed_from_string);
|
||||
explicit CSSStyleValue(JS::Realm&, FlyString associated_property, String constructed_from_string);
|
||||
|
||||
enum class ParseMultiple : u8 {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
static WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, GC::RootVector<GC::Ref<CSSStyleValue>>>> parse_a_css_style_value(JS::VM&, String property, String css_text, ParseMultiple);
|
||||
static WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, GC::RootVector<GC::Ref<CSSStyleValue>>>> parse_a_css_style_value(JS::VM&, FlyString property, String css_text, ParseMultiple);
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylevalue-associatedproperty-slot
|
||||
Optional<String> m_associated_property;
|
||||
Optional<FlyString> m_associated_property;
|
||||
|
||||
Optional<String> m_constructed_from_string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-stylevalue
|
||||
GC::Ref<CSSStyleValue> AbstractImageStyleValue::reify(JS::Realm& realm, String const&) const
|
||||
GC::Ref<CSSStyleValue> AbstractImageStyleValue::reify(JS::Realm& realm, FlyString const&) const
|
||||
{
|
||||
// AD-HOC: There's no spec description of how to reify as a CSSImageValue.
|
||||
return CSSImageValue::create(realm, to_string(SerializationMode::Normal));
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
virtual Optional<Gfx::Color> color_if_single_pixel_bitmap() const { return {}; }
|
||||
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
};
|
||||
|
||||
// And now, some gradient related things. Maybe these should live somewhere else.
|
||||
|
|
|
|||
|
|
@ -2772,7 +2772,7 @@ String CalculatedStyleValue::dump() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-a-math-expression
|
||||
GC::Ref<CSSStyleValue> CalculatedStyleValue::reify(JS::Realm& realm, String const& associated_property) const
|
||||
GC::Ref<CSSStyleValue> CalculatedStyleValue::reify(JS::Realm& realm, FlyString const& associated_property) const
|
||||
{
|
||||
// NB: This spec algorithm isn't really implementable here - it's incomplete, and assumes we don't already have a
|
||||
// calculation tree. So we have a per-node method instead.
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
String dump() const;
|
||||
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
private:
|
||||
explicit CalculatedStyleValue(NonnullRefPtr<CalculationNode const> calculation, NumericType resolved_type, CalculationContext context)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Vector<Parser::ComponentValue> CustomIdentStyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-ident
|
||||
GC::Ref<CSSStyleValue> CustomIdentStyleValue::reify(JS::Realm& realm, String const&) const
|
||||
GC::Ref<CSSStyleValue> CustomIdentStyleValue::reify(JS::Realm& realm, FlyString const&) const
|
||||
{
|
||||
// 1. Return a new CSSKeywordValue with its value internal slot set to the serialization of ident.
|
||||
return CSSKeywordValue::create(realm, m_custom_ident);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
virtual String to_string(SerializationMode) const override { return serialize_an_identifier(m_custom_ident.to_string()); }
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm& realm, String const&) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm& realm, FlyString const&) const override;
|
||||
|
||||
bool properties_equal(CustomIdentStyleValue const& other) const { return m_custom_ident == other.m_custom_ident; }
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Vector<Parser::ComponentValue> DimensionStyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-a-numeric-value
|
||||
GC::Ref<CSSStyleValue> DimensionStyleValue::reify(JS::Realm& realm, String const&) const
|
||||
GC::Ref<CSSStyleValue> DimensionStyleValue::reify(JS::Realm& realm, FlyString const&) const
|
||||
{
|
||||
// NB: Steps 1 and 2 don't apply here.
|
||||
// 3. Return a new CSSUnitValue with its value internal slot set to the numeric value of num, and its unit internal
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual double raw_value() const = 0;
|
||||
virtual FlyString unit_name() const = 0;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
protected:
|
||||
explicit DimensionStyleValue(Type type)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Vector<Parser::ComponentValue> IntegerStyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-a-numeric-value
|
||||
GC::Ref<CSSStyleValue> IntegerStyleValue::reify(JS::Realm& realm, String const& associated_property) const
|
||||
GC::Ref<CSSStyleValue> IntegerStyleValue::reify(JS::Realm& realm, FlyString const& associated_property) const
|
||||
{
|
||||
// NB: Step 1 doesn't apply here.
|
||||
// 2. If num is the unitless value 0 and num is a <dimension>, return a new CSSUnitValue with its value internal
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
bool equals(StyleValue const& other) const override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ Vector<Parser::ComponentValue> KeywordStyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-ident
|
||||
GC::Ref<CSSStyleValue> KeywordStyleValue::reify(JS::Realm& realm, String const&) const
|
||||
GC::Ref<CSSStyleValue> KeywordStyleValue::reify(JS::Realm& realm, FlyString const&) const
|
||||
{
|
||||
// 1. Return a new CSSKeywordValue with its value internal slot set to the serialization of ident.
|
||||
return CSSKeywordValue::create(realm, FlyString::from_utf8_without_validation(string_from_keyword(m_keyword).bytes()));
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
bool properties_equal(KeywordStyleValue const& other) const { return m_keyword == other.m_keyword; }
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Vector<Parser::ComponentValue> NumberStyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-a-numeric-value
|
||||
GC::Ref<CSSStyleValue> NumberStyleValue::reify(JS::Realm& realm, String const& associated_property) const
|
||||
GC::Ref<CSSStyleValue> NumberStyleValue::reify(JS::Realm& realm, FlyString const& associated_property) const
|
||||
{
|
||||
// NB: Step 1 doesn't apply here.
|
||||
// 2. If num is the unitless value 0 and num is a <dimension>, return a new CSSUnitValue with its value internal
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
bool equals(StyleValue const& other) const override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ Vector<Parser::ComponentValue> StyleValue::tokenize() const
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-as-a-cssstylevalue
|
||||
GC::Ref<CSSStyleValue> StyleValue::reify(JS::Realm& realm, String const& associated_property) const
|
||||
GC::Ref<CSSStyleValue> StyleValue::reify(JS::Realm& realm, FlyString const& associated_property) const
|
||||
{
|
||||
// 1. Return a new CSSStyleValue object representing value whose [[associatedProperty]] internal slot is set to property.
|
||||
return CSSStyleValue::create(realm, associated_property, to_string(SerializationMode::Normal));
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public:
|
|||
|
||||
virtual String to_string(SerializationMode) const = 0;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const;
|
||||
|
||||
virtual void set_style_sheet(GC::Ptr<CSSStyleSheet>) { }
|
||||
virtual void visit_edges(JS::Cell::Visitor&) const { }
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ static GC::Ref<CSSStyleValue> reify_a_transform_list(JS::Realm& realm, StyleValu
|
|||
return CSSTransformValue::create(realm, static_cast<Vector<GC::Ref<CSSTransformComponent>>>(move(transform_components)));
|
||||
}
|
||||
|
||||
GC::Ref<CSSStyleValue> StyleValueList::reify(JS::Realm& realm, String const& associated_property) const
|
||||
GC::Ref<CSSStyleValue> StyleValueList::reify(JS::Realm& realm, FlyString const& associated_property) const
|
||||
{
|
||||
// NB: <transform-list> is a StyleValueList that contains TransformStyleValues. If that's what we are, follow the
|
||||
// steps for reifying that.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ static GC::Ref<CSSUnparsedValue> reify_a_list_of_component_values(JS::Realm& rea
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#reify-a-list-of-component-values
|
||||
GC::Ref<CSSStyleValue> UnresolvedStyleValue::reify(JS::Realm& realm, String const&) const
|
||||
GC::Ref<CSSStyleValue> UnresolvedStyleValue::reify(JS::Realm& realm, FlyString const&) const
|
||||
{
|
||||
return reify_a_list_of_component_values(realm, m_values);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
|
||||
private:
|
||||
UnresolvedStyleValue(Vector<Parser::ComponentValue>&& values, Parser::SubstitutionFunctionsPresence, Optional<String> original_source_text);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user