mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec. https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue No behaviour changes.
This commit is contained in:
parent
2e1f62681c
commit
0e3487b9ab
Notes:
github-actions[bot]
2024-08-15 12:59:46 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/0e3487b9ab4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1076
100 changed files with 576 additions and 575 deletions
|
@ -80,7 +80,7 @@ The cascade origin determines the processing order for rules. The "user-agent" s
|
||||||
|
|
||||||
Note: the user-agent style is a built-in CSS style sheet that lives in the LibWeb source code [here](https://github.com/LadybirdBrowser/ladybird/blob/master/Userland/Libraries/LibWeb/CSS/Default.css).
|
Note: the user-agent style is a built-in CSS style sheet that lives in the LibWeb source code [here](https://github.com/LadybirdBrowser/ladybird/blob/master/Userland/Libraries/LibWeb/CSS/Default.css).
|
||||||
|
|
||||||
The end product of style computation is a fully populated StyleProperties object. It has a StyleValue for each CSS::PropertyID. In spec parlance, these are the *computed* values. (Note that these are not the same as you get from `getComputedStyle()`, that API returns the *resolved* values.)
|
The end product of style computation is a fully populated StyleProperties object. It has a CSSStyleValue for each CSS::PropertyID. In spec parlance, these are the *computed* values. (Note that these are not the same as you get from `getComputedStyle()`, that API returns the *resolved* values.)
|
||||||
|
|
||||||
#### Resolving CSS custom properties ("variables")
|
#### Resolving CSS custom properties ("variables")
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ Optional<PropertyID> property_id_from_string(StringView);
|
||||||
[[nodiscard]] FlyString const& string_from_property_id(PropertyID);
|
[[nodiscard]] FlyString const& string_from_property_id(PropertyID);
|
||||||
[[nodiscard]] FlyString const& camel_case_string_from_property_id(PropertyID);
|
[[nodiscard]] FlyString const& camel_case_string_from_property_id(PropertyID);
|
||||||
bool is_inherited_property(PropertyID);
|
bool is_inherited_property(PropertyID);
|
||||||
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
|
NonnullRefPtr<CSSStyleValue> property_initial_value(JS::Realm&, PropertyID);
|
||||||
|
|
||||||
enum class ValueType {
|
enum class ValueType {
|
||||||
Angle,
|
Angle,
|
||||||
|
@ -373,7 +373,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& f
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||||
#include <LibWeb/Infra/Strings.h>
|
#include <LibWeb/Infra/Strings.h>
|
||||||
|
@ -628,9 +628,9 @@ bool property_affects_stacking_context(PropertyID property_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
|
NonnullRefPtr<CSSStyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
|
||||||
{
|
{
|
||||||
static Array<RefPtr<StyleValue>, to_underlying(last_property_id) + 1> initial_values;
|
static Array<RefPtr<CSSStyleValue>, to_underlying(last_property_id) + 1> initial_values;
|
||||||
if (auto initial_value = initial_values[to_underlying(property_id)])
|
if (auto initial_value = initial_values[to_underlying(property_id)])
|
||||||
return initial_value.release_nonnull();
|
return initial_value.release_nonnull();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ source_set("CSS") {
|
||||||
"CSSStyleDeclaration.cpp",
|
"CSSStyleDeclaration.cpp",
|
||||||
"CSSStyleRule.cpp",
|
"CSSStyleRule.cpp",
|
||||||
"CSSStyleSheet.cpp",
|
"CSSStyleSheet.cpp",
|
||||||
|
"CSSStyleValue.cpp",
|
||||||
"CSSSupportsRule.cpp",
|
"CSSSupportsRule.cpp",
|
||||||
"CSSTransition.cpp",
|
"CSSTransition.cpp",
|
||||||
"CalculatedOr.cpp",
|
"CalculatedOr.cpp",
|
||||||
|
@ -63,7 +64,6 @@ source_set("CSS") {
|
||||||
"StyleProperty.cpp",
|
"StyleProperty.cpp",
|
||||||
"StyleSheet.cpp",
|
"StyleSheet.cpp",
|
||||||
"StyleSheetList.cpp",
|
"StyleSheetList.cpp",
|
||||||
"StyleValue.cpp",
|
|
||||||
"Supports.cpp",
|
"Supports.cpp",
|
||||||
"SystemColor.cpp",
|
"SystemColor.cpp",
|
||||||
"Time.cpp",
|
"Time.cpp",
|
||||||
|
|
|
@ -154,7 +154,7 @@ WebIDL::ExceptionOr<void> AnimationEffect::update_timing(OptionalEffectTiming ti
|
||||||
|
|
||||||
// 4. If the easing member of input exists but cannot be parsed using the <easing-function> production
|
// 4. If the easing member of input exists but cannot be parsed using the <easing-function> production
|
||||||
// [CSS-EASING-1], throw a TypeError and abort this procedure.
|
// [CSS-EASING-1], throw a TypeError and abort this procedure.
|
||||||
RefPtr<CSS::StyleValue const> easing_value;
|
RefPtr<CSS::CSSStyleValue const> easing_value;
|
||||||
if (timing.easing.has_value()) {
|
if (timing.easing.has_value()) {
|
||||||
easing_value = parse_easing_string(realm(), timing.easing.value());
|
easing_value = parse_easing_string(realm(), timing.easing.value());
|
||||||
if (!easing_value)
|
if (!easing_value)
|
||||||
|
@ -592,7 +592,7 @@ Optional<double> AnimationEffect::transformed_progress() const
|
||||||
return m_timing_function.evaluate_at(directed_progress.value(), before_flag);
|
return m_timing_function.evaluate_at(directed_progress.value(), before_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<CSS::StyleValue const> AnimationEffect::parse_easing_string(JS::Realm& realm, StringView value)
|
RefPtr<CSS::CSSStyleValue const> AnimationEffect::parse_easing_string(JS::Realm& realm, StringView value)
|
||||||
{
|
{
|
||||||
auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), value);
|
auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), value);
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class AnimationEffect : public Bindings::PlatformObject {
|
||||||
JS_DECLARE_ALLOCATOR(AnimationEffect);
|
JS_DECLARE_ALLOCATOR(AnimationEffect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static RefPtr<CSS::StyleValue const> parse_easing_string(JS::Realm& realm, StringView value);
|
static RefPtr<CSS::CSSStyleValue const> parse_easing_string(JS::Realm& realm, StringView value);
|
||||||
|
|
||||||
EffectTiming get_timing() const;
|
EffectTiming get_timing() const;
|
||||||
ComputedEffectTiming get_computed_timing() const;
|
ComputedEffectTiming get_computed_timing() const;
|
||||||
|
|
|
@ -561,7 +561,7 @@ static WebIDL::ExceptionOr<Vector<BaseKeyframe>> process_a_keyframes_argument(JS
|
||||||
if (!easing_value)
|
if (!easing_value)
|
||||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Invalid animation easing value: \"{}\"", easing_string)) };
|
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Invalid animation easing value: \"{}\"", easing_string)) };
|
||||||
|
|
||||||
keyframe.easing.set(NonnullRefPtr<CSS::StyleValue const> { *easing_value });
|
keyframe.easing.set(NonnullRefPtr<CSS::CSSStyleValue const> { *easing_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. Parse each of the values in unused easings using the CSS syntax defined for easing member of the EffectTiming
|
// 9. Parse each of the values in unused easings using the CSS syntax defined for easing member of the EffectTiming
|
||||||
|
@ -843,7 +843,7 @@ WebIDL::ExceptionOr<JS::MarkedVector<JS::Object*>> KeyframeEffect::get_keyframes
|
||||||
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
TRY(object->set(vm.names.offset, keyframe.offset.has_value() ? JS::Value(keyframe.offset.value()) : JS::js_null(), ShouldThrowExceptions::Yes));
|
TRY(object->set(vm.names.offset, keyframe.offset.has_value() ? JS::Value(keyframe.offset.value()) : JS::js_null(), ShouldThrowExceptions::Yes));
|
||||||
TRY(object->set(vm.names.computedOffset, JS::Value(keyframe.computed_offset.value()), ShouldThrowExceptions::Yes));
|
TRY(object->set(vm.names.computedOffset, JS::Value(keyframe.computed_offset.value()), ShouldThrowExceptions::Yes));
|
||||||
auto easing_value = keyframe.easing.get<NonnullRefPtr<CSS::StyleValue const>>();
|
auto easing_value = keyframe.easing.get<NonnullRefPtr<CSS::CSSStyleValue const>>();
|
||||||
TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string()), ShouldThrowExceptions::Yes));
|
TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string()), ShouldThrowExceptions::Yes));
|
||||||
|
|
||||||
if (keyframe.composite == Bindings::CompositeOperationOrAuto::Replace) {
|
if (keyframe.composite == Bindings::CompositeOperationOrAuto::Replace) {
|
||||||
|
@ -894,9 +894,9 @@ WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes(Optional<JS::Handle<JS::
|
||||||
for (auto [property_id, property_value] : keyframe.parsed_properties()) {
|
for (auto [property_id, property_value] : keyframe.parsed_properties()) {
|
||||||
if (property_value->is_unresolved() && target)
|
if (property_value->is_unresolved() && target)
|
||||||
property_value = CSS::Parser::Parser::resolve_unresolved_style_value(CSS::Parser::ParsingContext { target->document() }, *target, pseudo_element_type(), property_id, property_value->as_unresolved());
|
property_value = CSS::Parser::Parser::resolve_unresolved_style_value(CSS::Parser::ParsingContext { target->document() }, *target, pseudo_element_type(), property_id, property_value->as_unresolved());
|
||||||
CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, CSS::StyleComputer::AllowUnresolved::Yes, [&](CSS::PropertyID shorthand_id, CSS::StyleValue const& shorthand_value) {
|
CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, CSS::StyleComputer::AllowUnresolved::Yes, [&](CSS::PropertyID shorthand_id, CSS::CSSStyleValue const& shorthand_value) {
|
||||||
m_target_properties.set(shorthand_id);
|
m_target_properties.set(shorthand_id);
|
||||||
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<CSS::StyleValue const> { shorthand_value });
|
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<CSS::CSSStyleValue const> { shorthand_value });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +927,7 @@ void KeyframeEffect::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_keyframe_objects);
|
visitor.visit(m_keyframe_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>> const& old_properties, HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>> const& new_properties)
|
static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>> const& old_properties, HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>> const& new_properties)
|
||||||
{
|
{
|
||||||
CSS::RequiredInvalidationAfterStyleChange invalidation;
|
CSS::RequiredInvalidationAfterStyleChange invalidation;
|
||||||
auto old_and_new_properties = MUST(Bitmap::create(to_underlying(CSS::last_property_id) + 1, 0));
|
auto old_and_new_properties = MUST(Bitmap::create(to_underlying(CSS::last_property_id) + 1, 0));
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
#include <LibWeb/Animations/AnimationEffect.h>
|
#include <LibWeb/Animations/AnimationEffect.h>
|
||||||
#include <LibWeb/Bindings/KeyframeEffectPrototype.h>
|
#include <LibWeb/Bindings/KeyframeEffectPrototype.h>
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/Selector.h>
|
#include <LibWeb/CSS/Selector.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::Animations {
|
namespace Web::Animations {
|
||||||
|
|
||||||
using EasingValue = Variant<String, NonnullRefPtr<CSS::StyleValue const>>;
|
using EasingValue = Variant<String, NonnullRefPtr<CSS::CSSStyleValue const>>;
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffectoptions-dictionary
|
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffectoptions-dictionary
|
||||||
struct KeyframeEffectOptions : public EffectTiming {
|
struct KeyframeEffectOptions : public EffectTiming {
|
||||||
|
@ -39,7 +39,7 @@ struct BasePropertyIndexedKeyframe {
|
||||||
// https://www.w3.org/TR/web-animations-1/#dictdef-basekeyframe
|
// https://www.w3.org/TR/web-animations-1/#dictdef-basekeyframe
|
||||||
struct BaseKeyframe {
|
struct BaseKeyframe {
|
||||||
using UnparsedProperties = HashMap<String, String>;
|
using UnparsedProperties = HashMap<String, String>;
|
||||||
using ParsedProperties = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>>;
|
using ParsedProperties = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>>;
|
||||||
|
|
||||||
Optional<double> offset {};
|
Optional<double> offset {};
|
||||||
EasingValue easing { "linear"_string };
|
EasingValue easing { "linear"_string };
|
||||||
|
@ -64,9 +64,9 @@ public:
|
||||||
struct KeyFrameSet : public RefCounted<KeyFrameSet> {
|
struct KeyFrameSet : public RefCounted<KeyFrameSet> {
|
||||||
struct UseInitial { };
|
struct UseInitial { };
|
||||||
struct ResolvedKeyFrame {
|
struct ResolvedKeyFrame {
|
||||||
// These StyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well
|
// These CSSStyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well
|
||||||
// before they are applied to an element
|
// before they are applied to an element
|
||||||
HashMap<CSS::PropertyID, Variant<UseInitial, NonnullRefPtr<CSS::StyleValue const>>> properties {};
|
HashMap<CSS::PropertyID, Variant<UseInitial, NonnullRefPtr<CSS::CSSStyleValue const>>> properties {};
|
||||||
};
|
};
|
||||||
RedBlackTree<u64, ResolvedKeyFrame> keyframes_by_key;
|
RedBlackTree<u64, ResolvedKeyFrame> keyframes_by_key;
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,7 @@ set(SOURCES
|
||||||
CSS/CSSStyleDeclaration.cpp
|
CSS/CSSStyleDeclaration.cpp
|
||||||
CSS/CSSStyleRule.cpp
|
CSS/CSSStyleRule.cpp
|
||||||
CSS/CSSStyleSheet.cpp
|
CSS/CSSStyleSheet.cpp
|
||||||
|
CSS/CSSStyleValue.cpp
|
||||||
CSS/CSSSupportsRule.cpp
|
CSS/CSSSupportsRule.cpp
|
||||||
CSS/CSSTransition.cpp
|
CSS/CSSTransition.cpp
|
||||||
CSS/Display.cpp
|
CSS/Display.cpp
|
||||||
|
@ -101,7 +102,6 @@ set(SOURCES
|
||||||
CSS/StyleProperty.cpp
|
CSS/StyleProperty.cpp
|
||||||
CSS/StyleSheet.cpp
|
CSS/StyleSheet.cpp
|
||||||
CSS/StyleSheetList.cpp
|
CSS/StyleSheetList.cpp
|
||||||
CSS/StyleValue.cpp
|
|
||||||
CSS/StyleValues/AngleStyleValue.cpp
|
CSS/StyleValues/AngleStyleValue.cpp
|
||||||
CSS/StyleValues/BackgroundRepeatStyleValue.cpp
|
CSS/StyleValues/BackgroundRepeatStyleValue.cpp
|
||||||
CSS/StyleValues/BackgroundSizeStyleValue.cpp
|
CSS/StyleValues/BackgroundSizeStyleValue.cpp
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Animations/Animation.h>
|
#include <LibWeb/Animations/Animation.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ void ElementInlineCSSStyleDeclaration::update_style_attribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#set-a-css-declaration
|
// https://drafts.csswg.org/cssom/#set-a-css-declaration
|
||||||
bool PropertyOwningCSSStyleDeclaration::set_a_css_declaration(PropertyID property_id, NonnullRefPtr<StyleValue const> value, Important important)
|
bool PropertyOwningCSSStyleDeclaration::set_a_css_declaration(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value, Important important)
|
||||||
{
|
{
|
||||||
// FIXME: Handle logical property groups.
|
// FIXME: Handle logical property groups.
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleProperty.h>
|
#include <LibWeb/CSS/StyleProperty.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ protected:
|
||||||
void set_the_declarations(Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties);
|
void set_the_declarations(Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool set_a_css_declaration(PropertyID, NonnullRefPtr<StyleValue const>, Important);
|
bool set_a_css_declaration(PropertyID, NonnullRefPtr<CSSStyleValue const>, Important);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <LibGfx/Font/FontStyleMapping.h>
|
#include <LibGfx/Font/FontStyleMapping.h>
|
||||||
#include <LibGfx/Font/FontWeight.h>
|
#include <LibGfx/Font/FontWeight.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||||
|
@ -63,329 +63,329 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
StyleValue::StyleValue(Type type)
|
CSSStyleValue::CSSStyleValue(Type type)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractImageStyleValue const& StyleValue::as_abstract_image() const
|
AbstractImageStyleValue const& CSSStyleValue::as_abstract_image() const
|
||||||
{
|
{
|
||||||
VERIFY(is_abstract_image());
|
VERIFY(is_abstract_image());
|
||||||
return static_cast<AbstractImageStyleValue const&>(*this);
|
return static_cast<AbstractImageStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AngleStyleValue const& StyleValue::as_angle() const
|
AngleStyleValue const& CSSStyleValue::as_angle() const
|
||||||
{
|
{
|
||||||
VERIFY(is_angle());
|
VERIFY(is_angle());
|
||||||
return static_cast<AngleStyleValue const&>(*this);
|
return static_cast<AngleStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundRepeatStyleValue const& StyleValue::as_background_repeat() const
|
BackgroundRepeatStyleValue const& CSSStyleValue::as_background_repeat() const
|
||||||
{
|
{
|
||||||
VERIFY(is_background_repeat());
|
VERIFY(is_background_repeat());
|
||||||
return static_cast<BackgroundRepeatStyleValue const&>(*this);
|
return static_cast<BackgroundRepeatStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundSizeStyleValue const& StyleValue::as_background_size() const
|
BackgroundSizeStyleValue const& CSSStyleValue::as_background_size() const
|
||||||
{
|
{
|
||||||
VERIFY(is_background_size());
|
VERIFY(is_background_size());
|
||||||
return static_cast<BackgroundSizeStyleValue const&>(*this);
|
return static_cast<BackgroundSizeStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicShapeStyleValue const& StyleValue::as_basic_shape() const
|
BasicShapeStyleValue const& CSSStyleValue::as_basic_shape() const
|
||||||
{
|
{
|
||||||
VERIFY(is_basic_shape());
|
VERIFY(is_basic_shape());
|
||||||
return static_cast<BasicShapeStyleValue const&>(*this);
|
return static_cast<BasicShapeStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BorderRadiusStyleValue const& StyleValue::as_border_radius() const
|
BorderRadiusStyleValue const& CSSStyleValue::as_border_radius() const
|
||||||
{
|
{
|
||||||
VERIFY(is_border_radius());
|
VERIFY(is_border_radius());
|
||||||
return static_cast<BorderRadiusStyleValue const&>(*this);
|
return static_cast<BorderRadiusStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculatedStyleValue const& StyleValue::as_calculated() const
|
CalculatedStyleValue const& CSSStyleValue::as_calculated() const
|
||||||
{
|
{
|
||||||
VERIFY(is_calculated());
|
VERIFY(is_calculated());
|
||||||
return static_cast<CalculatedStyleValue const&>(*this);
|
return static_cast<CalculatedStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorStyleValue const& StyleValue::as_color() const
|
ColorStyleValue const& CSSStyleValue::as_color() const
|
||||||
{
|
{
|
||||||
VERIFY(is_color());
|
VERIFY(is_color());
|
||||||
return static_cast<ColorStyleValue const&>(*this);
|
return static_cast<ColorStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConicGradientStyleValue const& StyleValue::as_conic_gradient() const
|
ConicGradientStyleValue const& CSSStyleValue::as_conic_gradient() const
|
||||||
{
|
{
|
||||||
VERIFY(is_conic_gradient());
|
VERIFY(is_conic_gradient());
|
||||||
return static_cast<ConicGradientStyleValue const&>(*this);
|
return static_cast<ConicGradientStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentStyleValue const& StyleValue::as_content() const
|
ContentStyleValue const& CSSStyleValue::as_content() const
|
||||||
{
|
{
|
||||||
VERIFY(is_content());
|
VERIFY(is_content());
|
||||||
return static_cast<ContentStyleValue const&>(*this);
|
return static_cast<ContentStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CounterStyleValue const& StyleValue::as_counter() const
|
CounterStyleValue const& CSSStyleValue::as_counter() const
|
||||||
{
|
{
|
||||||
VERIFY(is_counter());
|
VERIFY(is_counter());
|
||||||
return static_cast<CounterStyleValue const&>(*this);
|
return static_cast<CounterStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CounterDefinitionsStyleValue const& StyleValue::as_counter_definitions() const
|
CounterDefinitionsStyleValue const& CSSStyleValue::as_counter_definitions() const
|
||||||
{
|
{
|
||||||
VERIFY(is_counter_definitions());
|
VERIFY(is_counter_definitions());
|
||||||
return static_cast<CounterDefinitionsStyleValue const&>(*this);
|
return static_cast<CounterDefinitionsStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomIdentStyleValue const& StyleValue::as_custom_ident() const
|
CustomIdentStyleValue const& CSSStyleValue::as_custom_ident() const
|
||||||
{
|
{
|
||||||
VERIFY(is_custom_ident());
|
VERIFY(is_custom_ident());
|
||||||
return static_cast<CustomIdentStyleValue const&>(*this);
|
return static_cast<CustomIdentStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayStyleValue const& StyleValue::as_display() const
|
DisplayStyleValue const& CSSStyleValue::as_display() const
|
||||||
{
|
{
|
||||||
VERIFY(is_display());
|
VERIFY(is_display());
|
||||||
return static_cast<DisplayStyleValue const&>(*this);
|
return static_cast<DisplayStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
EasingStyleValue const& StyleValue::as_easing() const
|
EasingStyleValue const& CSSStyleValue::as_easing() const
|
||||||
{
|
{
|
||||||
VERIFY(is_easing());
|
VERIFY(is_easing());
|
||||||
return static_cast<EasingStyleValue const&>(*this);
|
return static_cast<EasingStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeStyleValue const& StyleValue::as_edge() const
|
EdgeStyleValue const& CSSStyleValue::as_edge() const
|
||||||
{
|
{
|
||||||
VERIFY(is_edge());
|
VERIFY(is_edge());
|
||||||
return static_cast<EdgeStyleValue const&>(*this);
|
return static_cast<EdgeStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterValueListStyleValue const& StyleValue::as_filter_value_list() const
|
FilterValueListStyleValue const& CSSStyleValue::as_filter_value_list() const
|
||||||
{
|
{
|
||||||
VERIFY(is_filter_value_list());
|
VERIFY(is_filter_value_list());
|
||||||
return static_cast<FilterValueListStyleValue const&>(*this);
|
return static_cast<FilterValueListStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexStyleValue const& StyleValue::as_flex() const
|
FlexStyleValue const& CSSStyleValue::as_flex() const
|
||||||
{
|
{
|
||||||
VERIFY(is_flex());
|
VERIFY(is_flex());
|
||||||
return static_cast<FlexStyleValue const&>(*this);
|
return static_cast<FlexStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrequencyStyleValue const& StyleValue::as_frequency() const
|
FrequencyStyleValue const& CSSStyleValue::as_frequency() const
|
||||||
{
|
{
|
||||||
VERIFY(is_frequency());
|
VERIFY(is_frequency());
|
||||||
return static_cast<FrequencyStyleValue const&>(*this);
|
return static_cast<FrequencyStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridAutoFlowStyleValue const& StyleValue::as_grid_auto_flow() const
|
GridAutoFlowStyleValue const& CSSStyleValue::as_grid_auto_flow() const
|
||||||
{
|
{
|
||||||
VERIFY(is_grid_auto_flow());
|
VERIFY(is_grid_auto_flow());
|
||||||
return static_cast<GridAutoFlowStyleValue const&>(*this);
|
return static_cast<GridAutoFlowStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridTemplateAreaStyleValue const& StyleValue::as_grid_template_area() const
|
GridTemplateAreaStyleValue const& CSSStyleValue::as_grid_template_area() const
|
||||||
{
|
{
|
||||||
VERIFY(is_grid_template_area());
|
VERIFY(is_grid_template_area());
|
||||||
return static_cast<GridTemplateAreaStyleValue const&>(*this);
|
return static_cast<GridTemplateAreaStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridTrackPlacementStyleValue const& StyleValue::as_grid_track_placement() const
|
GridTrackPlacementStyleValue const& CSSStyleValue::as_grid_track_placement() const
|
||||||
{
|
{
|
||||||
VERIFY(is_grid_track_placement());
|
VERIFY(is_grid_track_placement());
|
||||||
return static_cast<GridTrackPlacementStyleValue const&>(*this);
|
return static_cast<GridTrackPlacementStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridTrackSizeListStyleValue const& StyleValue::as_grid_track_size_list() const
|
GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() const
|
||||||
{
|
{
|
||||||
VERIFY(is_grid_track_size_list());
|
VERIFY(is_grid_track_size_list());
|
||||||
return static_cast<GridTrackSizeListStyleValue const&>(*this);
|
return static_cast<GridTrackSizeListStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierStyleValue const& StyleValue::as_identifier() const
|
IdentifierStyleValue const& CSSStyleValue::as_identifier() const
|
||||||
{
|
{
|
||||||
VERIFY(is_identifier());
|
VERIFY(is_identifier());
|
||||||
return static_cast<IdentifierStyleValue const&>(*this);
|
return static_cast<IdentifierStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageStyleValue const& StyleValue::as_image() const
|
ImageStyleValue const& CSSStyleValue::as_image() const
|
||||||
{
|
{
|
||||||
VERIFY(is_image());
|
VERIFY(is_image());
|
||||||
return static_cast<ImageStyleValue const&>(*this);
|
return static_cast<ImageStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
InheritStyleValue const& StyleValue::as_inherit() const
|
InheritStyleValue const& CSSStyleValue::as_inherit() const
|
||||||
{
|
{
|
||||||
VERIFY(is_inherit());
|
VERIFY(is_inherit());
|
||||||
return static_cast<InheritStyleValue const&>(*this);
|
return static_cast<InheritStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitialStyleValue const& StyleValue::as_initial() const
|
InitialStyleValue const& CSSStyleValue::as_initial() const
|
||||||
{
|
{
|
||||||
VERIFY(is_initial());
|
VERIFY(is_initial());
|
||||||
return static_cast<InitialStyleValue const&>(*this);
|
return static_cast<InitialStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegerStyleValue const& StyleValue::as_integer() const
|
IntegerStyleValue const& CSSStyleValue::as_integer() const
|
||||||
{
|
{
|
||||||
VERIFY(is_integer());
|
VERIFY(is_integer());
|
||||||
return static_cast<IntegerStyleValue const&>(*this);
|
return static_cast<IntegerStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LengthStyleValue const& StyleValue::as_length() const
|
LengthStyleValue const& CSSStyleValue::as_length() const
|
||||||
{
|
{
|
||||||
VERIFY(is_length());
|
VERIFY(is_length());
|
||||||
return static_cast<LengthStyleValue const&>(*this);
|
return static_cast<LengthStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearGradientStyleValue const& StyleValue::as_linear_gradient() const
|
LinearGradientStyleValue const& CSSStyleValue::as_linear_gradient() const
|
||||||
{
|
{
|
||||||
VERIFY(is_linear_gradient());
|
VERIFY(is_linear_gradient());
|
||||||
return static_cast<LinearGradientStyleValue const&>(*this);
|
return static_cast<LinearGradientStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MathDepthStyleValue const& StyleValue::as_math_depth() const
|
MathDepthStyleValue const& CSSStyleValue::as_math_depth() const
|
||||||
{
|
{
|
||||||
VERIFY(is_math_depth());
|
VERIFY(is_math_depth());
|
||||||
return static_cast<MathDepthStyleValue const&>(*this);
|
return static_cast<MathDepthStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberStyleValue const& StyleValue::as_number() const
|
NumberStyleValue const& CSSStyleValue::as_number() const
|
||||||
{
|
{
|
||||||
VERIFY(is_number());
|
VERIFY(is_number());
|
||||||
return static_cast<NumberStyleValue const&>(*this);
|
return static_cast<NumberStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentageStyleValue const& StyleValue::as_percentage() const
|
PercentageStyleValue const& CSSStyleValue::as_percentage() const
|
||||||
{
|
{
|
||||||
VERIFY(is_percentage());
|
VERIFY(is_percentage());
|
||||||
return static_cast<PercentageStyleValue const&>(*this);
|
return static_cast<PercentageStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PositionStyleValue const& StyleValue::as_position() const
|
PositionStyleValue const& CSSStyleValue::as_position() const
|
||||||
{
|
{
|
||||||
VERIFY(is_position());
|
VERIFY(is_position());
|
||||||
return static_cast<PositionStyleValue const&>(*this);
|
return static_cast<PositionStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RadialGradientStyleValue const& StyleValue::as_radial_gradient() const
|
RadialGradientStyleValue const& CSSStyleValue::as_radial_gradient() const
|
||||||
{
|
{
|
||||||
VERIFY(is_radial_gradient());
|
VERIFY(is_radial_gradient());
|
||||||
return static_cast<RadialGradientStyleValue const&>(*this);
|
return static_cast<RadialGradientStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RatioStyleValue const& StyleValue::as_ratio() const
|
RatioStyleValue const& CSSStyleValue::as_ratio() const
|
||||||
{
|
{
|
||||||
VERIFY(is_ratio());
|
VERIFY(is_ratio());
|
||||||
return static_cast<RatioStyleValue const&>(*this);
|
return static_cast<RatioStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RectStyleValue const& StyleValue::as_rect() const
|
RectStyleValue const& CSSStyleValue::as_rect() const
|
||||||
{
|
{
|
||||||
VERIFY(is_rect());
|
VERIFY(is_rect());
|
||||||
return static_cast<RectStyleValue const&>(*this);
|
return static_cast<RectStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolutionStyleValue const& StyleValue::as_resolution() const
|
ResolutionStyleValue const& CSSStyleValue::as_resolution() const
|
||||||
{
|
{
|
||||||
VERIFY(is_resolution());
|
VERIFY(is_resolution());
|
||||||
return static_cast<ResolutionStyleValue const&>(*this);
|
return static_cast<ResolutionStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RevertStyleValue const& StyleValue::as_revert() const
|
RevertStyleValue const& CSSStyleValue::as_revert() const
|
||||||
{
|
{
|
||||||
VERIFY(is_revert());
|
VERIFY(is_revert());
|
||||||
return static_cast<RevertStyleValue const&>(*this);
|
return static_cast<RevertStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollbarGutterStyleValue const& StyleValue::as_scrollbar_gutter() const
|
ScrollbarGutterStyleValue const& CSSStyleValue::as_scrollbar_gutter() const
|
||||||
{
|
{
|
||||||
VERIFY(is_scrollbar_gutter());
|
VERIFY(is_scrollbar_gutter());
|
||||||
return static_cast<ScrollbarGutterStyleValue const&>(*this);
|
return static_cast<ScrollbarGutterStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowStyleValue const& StyleValue::as_shadow() const
|
ShadowStyleValue const& CSSStyleValue::as_shadow() const
|
||||||
{
|
{
|
||||||
VERIFY(is_shadow());
|
VERIFY(is_shadow());
|
||||||
return static_cast<ShadowStyleValue const&>(*this);
|
return static_cast<ShadowStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShorthandStyleValue const& StyleValue::as_shorthand() const
|
ShorthandStyleValue const& CSSStyleValue::as_shorthand() const
|
||||||
{
|
{
|
||||||
VERIFY(is_shorthand());
|
VERIFY(is_shorthand());
|
||||||
return static_cast<ShorthandStyleValue const&>(*this);
|
return static_cast<ShorthandStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringStyleValue const& StyleValue::as_string() const
|
StringStyleValue const& CSSStyleValue::as_string() const
|
||||||
{
|
{
|
||||||
VERIFY(is_string());
|
VERIFY(is_string());
|
||||||
return static_cast<StringStyleValue const&>(*this);
|
return static_cast<StringStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStyleValue const& StyleValue::as_time() const
|
TimeStyleValue const& CSSStyleValue::as_time() const
|
||||||
{
|
{
|
||||||
VERIFY(is_time());
|
VERIFY(is_time());
|
||||||
return static_cast<TimeStyleValue const&>(*this);
|
return static_cast<TimeStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransformationStyleValue const& StyleValue::as_transformation() const
|
TransformationStyleValue const& CSSStyleValue::as_transformation() const
|
||||||
{
|
{
|
||||||
VERIFY(is_transformation());
|
VERIFY(is_transformation());
|
||||||
return static_cast<TransformationStyleValue const&>(*this);
|
return static_cast<TransformationStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionStyleValue const& StyleValue::as_transition() const
|
TransitionStyleValue const& CSSStyleValue::as_transition() const
|
||||||
{
|
{
|
||||||
VERIFY(is_transition());
|
VERIFY(is_transition());
|
||||||
return static_cast<TransitionStyleValue const&>(*this);
|
return static_cast<TransitionStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnresolvedStyleValue const& StyleValue::as_unresolved() const
|
UnresolvedStyleValue const& CSSStyleValue::as_unresolved() const
|
||||||
{
|
{
|
||||||
VERIFY(is_unresolved());
|
VERIFY(is_unresolved());
|
||||||
return static_cast<UnresolvedStyleValue const&>(*this);
|
return static_cast<UnresolvedStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnsetStyleValue const& StyleValue::as_unset() const
|
UnsetStyleValue const& CSSStyleValue::as_unset() const
|
||||||
{
|
{
|
||||||
VERIFY(is_unset());
|
VERIFY(is_unset());
|
||||||
return static_cast<UnsetStyleValue const&>(*this);
|
return static_cast<UnsetStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
URLStyleValue const& StyleValue::as_url() const
|
URLStyleValue const& CSSStyleValue::as_url() const
|
||||||
{
|
{
|
||||||
VERIFY(is_url());
|
VERIFY(is_url());
|
||||||
return static_cast<URLStyleValue const&>(*this);
|
return static_cast<URLStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleValueList const& StyleValue::as_value_list() const
|
StyleValueList const& CSSStyleValue::as_value_list() const
|
||||||
{
|
{
|
||||||
VERIFY(is_value_list());
|
VERIFY(is_value_list());
|
||||||
return static_cast<StyleValueList const&>(*this);
|
return static_cast<StyleValueList const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> StyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const
|
ValueComparingNonnullRefPtr<CSSStyleValue const> CSSStyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StyleValue::has_auto() const
|
bool CSSStyleValue::has_auto() const
|
||||||
{
|
{
|
||||||
return is_identifier() && as_identifier().id() == ValueID::Auto;
|
return is_identifier() && as_identifier().id() == ValueID::Auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueID StyleValue::to_identifier() const
|
ValueID CSSStyleValue::to_identifier() const
|
||||||
{
|
{
|
||||||
if (is_identifier())
|
if (is_identifier())
|
||||||
return as_identifier().id();
|
return as_identifier().id();
|
||||||
return ValueID::Invalid;
|
return ValueID::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StyleValue::to_font_weight() const
|
int CSSStyleValue::to_font_weight() const
|
||||||
{
|
{
|
||||||
if (is_identifier()) {
|
if (is_identifier()) {
|
||||||
switch (static_cast<IdentifierStyleValue const&>(*this).id()) {
|
switch (static_cast<IdentifierStyleValue const&>(*this).id()) {
|
||||||
|
@ -414,7 +414,7 @@ int StyleValue::to_font_weight() const
|
||||||
return Gfx::FontWeight::Regular;
|
return Gfx::FontWeight::Regular;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StyleValue::to_font_slope() const
|
int CSSStyleValue::to_font_slope() const
|
||||||
{
|
{
|
||||||
// FIXME: Implement oblique <angle>
|
// FIXME: Implement oblique <angle>
|
||||||
if (is_identifier()) {
|
if (is_identifier()) {
|
||||||
|
@ -435,7 +435,7 @@ int StyleValue::to_font_slope() const
|
||||||
return normal_slope;
|
return normal_slope;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StyleValue::to_font_stretch_width() const
|
int CSSStyleValue::to_font_stretch_width() const
|
||||||
{
|
{
|
||||||
int width = Gfx::FontWidth::Normal;
|
int width = Gfx::FontWidth::Normal;
|
||||||
if (is_identifier()) {
|
if (is_identifier()) {
|
|
@ -80,11 +80,12 @@ private:
|
||||||
using RefPtr<T>::operator==;
|
using RefPtr<T>::operator==;
|
||||||
};
|
};
|
||||||
|
|
||||||
using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
|
using StyleValueVector = Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>>;
|
||||||
|
|
||||||
class StyleValue : public RefCounted<StyleValue> {
|
// https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue
|
||||||
|
class CSSStyleValue : public RefCounted<CSSStyleValue> {
|
||||||
public:
|
public:
|
||||||
virtual ~StyleValue() = default;
|
virtual ~CSSStyleValue() = default;
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Angle,
|
Angle,
|
||||||
|
@ -145,203 +146,203 @@ public:
|
||||||
return AK::first_is_one_of(type(), Type::Image, Type::LinearGradient, Type::ConicGradient, Type::RadialGradient);
|
return AK::first_is_one_of(type(), Type::Image, Type::LinearGradient, Type::ConicGradient, Type::RadialGradient);
|
||||||
}
|
}
|
||||||
AbstractImageStyleValue const& as_abstract_image() const;
|
AbstractImageStyleValue const& as_abstract_image() const;
|
||||||
AbstractImageStyleValue& as_abstract_image() { return const_cast<AbstractImageStyleValue&>(const_cast<StyleValue const&>(*this).as_abstract_image()); }
|
AbstractImageStyleValue& as_abstract_image() { return const_cast<AbstractImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_abstract_image()); }
|
||||||
|
|
||||||
bool is_angle() const { return type() == Type::Angle; }
|
bool is_angle() const { return type() == Type::Angle; }
|
||||||
AngleStyleValue const& as_angle() const;
|
AngleStyleValue const& as_angle() const;
|
||||||
AngleStyleValue& as_angle() { return const_cast<AngleStyleValue&>(const_cast<StyleValue const&>(*this).as_angle()); }
|
AngleStyleValue& as_angle() { return const_cast<AngleStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_angle()); }
|
||||||
|
|
||||||
bool is_background_repeat() const { return type() == Type::BackgroundRepeat; }
|
bool is_background_repeat() const { return type() == Type::BackgroundRepeat; }
|
||||||
BackgroundRepeatStyleValue const& as_background_repeat() const;
|
BackgroundRepeatStyleValue const& as_background_repeat() const;
|
||||||
BackgroundRepeatStyleValue& as_background_repeat() { return const_cast<BackgroundRepeatStyleValue&>(const_cast<StyleValue const&>(*this).as_background_repeat()); }
|
BackgroundRepeatStyleValue& as_background_repeat() { return const_cast<BackgroundRepeatStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_background_repeat()); }
|
||||||
|
|
||||||
bool is_background_size() const { return type() == Type::BackgroundSize; }
|
bool is_background_size() const { return type() == Type::BackgroundSize; }
|
||||||
BackgroundSizeStyleValue const& as_background_size() const;
|
BackgroundSizeStyleValue const& as_background_size() const;
|
||||||
BackgroundSizeStyleValue& as_background_size() { return const_cast<BackgroundSizeStyleValue&>(const_cast<StyleValue const&>(*this).as_background_size()); }
|
BackgroundSizeStyleValue& as_background_size() { return const_cast<BackgroundSizeStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_background_size()); }
|
||||||
|
|
||||||
bool is_basic_shape() const { return type() == Type::BasicShape; }
|
bool is_basic_shape() const { return type() == Type::BasicShape; }
|
||||||
BasicShapeStyleValue const& as_basic_shape() const;
|
BasicShapeStyleValue const& as_basic_shape() const;
|
||||||
BasicShapeStyleValue& as_basic_shape() { return const_cast<BasicShapeStyleValue&>(const_cast<StyleValue const&>(*this).as_basic_shape()); }
|
BasicShapeStyleValue& as_basic_shape() { return const_cast<BasicShapeStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_basic_shape()); }
|
||||||
|
|
||||||
bool is_border_radius() const { return type() == Type::BorderRadius; }
|
bool is_border_radius() const { return type() == Type::BorderRadius; }
|
||||||
BorderRadiusStyleValue const& as_border_radius() const;
|
BorderRadiusStyleValue const& as_border_radius() const;
|
||||||
BorderRadiusStyleValue& as_border_radius() { return const_cast<BorderRadiusStyleValue&>(const_cast<StyleValue const&>(*this).as_border_radius()); }
|
BorderRadiusStyleValue& as_border_radius() { return const_cast<BorderRadiusStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_border_radius()); }
|
||||||
|
|
||||||
bool is_calculated() const { return type() == Type::Calculated; }
|
bool is_calculated() const { return type() == Type::Calculated; }
|
||||||
CalculatedStyleValue const& as_calculated() const;
|
CalculatedStyleValue const& as_calculated() const;
|
||||||
CalculatedStyleValue& as_calculated() { return const_cast<CalculatedStyleValue&>(const_cast<StyleValue const&>(*this).as_calculated()); }
|
CalculatedStyleValue& as_calculated() { return const_cast<CalculatedStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_calculated()); }
|
||||||
|
|
||||||
bool is_color() const { return type() == Type::Color; }
|
bool is_color() const { return type() == Type::Color; }
|
||||||
ColorStyleValue const& as_color() const;
|
ColorStyleValue const& as_color() const;
|
||||||
ColorStyleValue& as_color() { return const_cast<ColorStyleValue&>(const_cast<StyleValue const&>(*this).as_color()); }
|
ColorStyleValue& as_color() { return const_cast<ColorStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_color()); }
|
||||||
|
|
||||||
bool is_conic_gradient() const { return type() == Type::ConicGradient; }
|
bool is_conic_gradient() const { return type() == Type::ConicGradient; }
|
||||||
ConicGradientStyleValue const& as_conic_gradient() const;
|
ConicGradientStyleValue const& as_conic_gradient() const;
|
||||||
ConicGradientStyleValue& as_conic_gradient() { return const_cast<ConicGradientStyleValue&>(const_cast<StyleValue const&>(*this).as_conic_gradient()); }
|
ConicGradientStyleValue& as_conic_gradient() { return const_cast<ConicGradientStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_conic_gradient()); }
|
||||||
|
|
||||||
bool is_content() const { return type() == Type::Content; }
|
bool is_content() const { return type() == Type::Content; }
|
||||||
ContentStyleValue const& as_content() const;
|
ContentStyleValue const& as_content() const;
|
||||||
ContentStyleValue& as_content() { return const_cast<ContentStyleValue&>(const_cast<StyleValue const&>(*this).as_content()); }
|
ContentStyleValue& as_content() { return const_cast<ContentStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_content()); }
|
||||||
|
|
||||||
bool is_counter() const { return type() == Type::Counter; }
|
bool is_counter() const { return type() == Type::Counter; }
|
||||||
CounterStyleValue const& as_counter() const;
|
CounterStyleValue const& as_counter() const;
|
||||||
CounterStyleValue& as_counter() { return const_cast<CounterStyleValue&>(const_cast<StyleValue const&>(*this).as_counter()); }
|
CounterStyleValue& as_counter() { return const_cast<CounterStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_counter()); }
|
||||||
|
|
||||||
bool is_counter_definitions() const { return type() == Type::CounterDefinitions; }
|
bool is_counter_definitions() const { return type() == Type::CounterDefinitions; }
|
||||||
CounterDefinitionsStyleValue const& as_counter_definitions() const;
|
CounterDefinitionsStyleValue const& as_counter_definitions() const;
|
||||||
CounterDefinitionsStyleValue& as_counter_definitions() { return const_cast<CounterDefinitionsStyleValue&>(const_cast<StyleValue const&>(*this).as_counter_definitions()); }
|
CounterDefinitionsStyleValue& as_counter_definitions() { return const_cast<CounterDefinitionsStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_counter_definitions()); }
|
||||||
|
|
||||||
bool is_custom_ident() const { return type() == Type::CustomIdent; }
|
bool is_custom_ident() const { return type() == Type::CustomIdent; }
|
||||||
CustomIdentStyleValue const& as_custom_ident() const;
|
CustomIdentStyleValue const& as_custom_ident() const;
|
||||||
CustomIdentStyleValue& as_custom_ident() { return const_cast<CustomIdentStyleValue&>(const_cast<StyleValue const&>(*this).as_custom_ident()); }
|
CustomIdentStyleValue& as_custom_ident() { return const_cast<CustomIdentStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_custom_ident()); }
|
||||||
|
|
||||||
bool is_display() const { return type() == Type::Display; }
|
bool is_display() const { return type() == Type::Display; }
|
||||||
DisplayStyleValue const& as_display() const;
|
DisplayStyleValue const& as_display() const;
|
||||||
DisplayStyleValue& as_display() { return const_cast<DisplayStyleValue&>(const_cast<StyleValue const&>(*this).as_display()); }
|
DisplayStyleValue& as_display() { return const_cast<DisplayStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_display()); }
|
||||||
|
|
||||||
bool is_easing() const { return type() == Type::Easing; }
|
bool is_easing() const { return type() == Type::Easing; }
|
||||||
EasingStyleValue const& as_easing() const;
|
EasingStyleValue const& as_easing() const;
|
||||||
EasingStyleValue& as_easing() { return const_cast<EasingStyleValue&>(const_cast<StyleValue const&>(*this).as_easing()); }
|
EasingStyleValue& as_easing() { return const_cast<EasingStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_easing()); }
|
||||||
|
|
||||||
bool is_edge() const { return type() == Type::Edge; }
|
bool is_edge() const { return type() == Type::Edge; }
|
||||||
EdgeStyleValue const& as_edge() const;
|
EdgeStyleValue const& as_edge() const;
|
||||||
EdgeStyleValue& as_edge() { return const_cast<EdgeStyleValue&>(const_cast<StyleValue const&>(*this).as_edge()); }
|
EdgeStyleValue& as_edge() { return const_cast<EdgeStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_edge()); }
|
||||||
|
|
||||||
bool is_filter_value_list() const { return type() == Type::FilterValueList; }
|
bool is_filter_value_list() const { return type() == Type::FilterValueList; }
|
||||||
FilterValueListStyleValue const& as_filter_value_list() const;
|
FilterValueListStyleValue const& as_filter_value_list() const;
|
||||||
FilterValueListStyleValue& as_filter_value_list() { return const_cast<FilterValueListStyleValue&>(const_cast<StyleValue const&>(*this).as_filter_value_list()); }
|
FilterValueListStyleValue& as_filter_value_list() { return const_cast<FilterValueListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_filter_value_list()); }
|
||||||
|
|
||||||
bool is_flex() const { return type() == Type::Flex; }
|
bool is_flex() const { return type() == Type::Flex; }
|
||||||
FlexStyleValue const& as_flex() const;
|
FlexStyleValue const& as_flex() const;
|
||||||
FlexStyleValue& as_flex() { return const_cast<FlexStyleValue&>(const_cast<StyleValue const&>(*this).as_flex()); }
|
FlexStyleValue& as_flex() { return const_cast<FlexStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_flex()); }
|
||||||
|
|
||||||
bool is_frequency() const { return type() == Type::Frequency; }
|
bool is_frequency() const { return type() == Type::Frequency; }
|
||||||
FrequencyStyleValue const& as_frequency() const;
|
FrequencyStyleValue const& as_frequency() const;
|
||||||
FrequencyStyleValue& as_frequency() { return const_cast<FrequencyStyleValue&>(const_cast<StyleValue const&>(*this).as_frequency()); }
|
FrequencyStyleValue& as_frequency() { return const_cast<FrequencyStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_frequency()); }
|
||||||
|
|
||||||
bool is_grid_auto_flow() const { return type() == Type::GridAutoFlow; }
|
bool is_grid_auto_flow() const { return type() == Type::GridAutoFlow; }
|
||||||
GridAutoFlowStyleValue const& as_grid_auto_flow() const;
|
GridAutoFlowStyleValue const& as_grid_auto_flow() const;
|
||||||
GridAutoFlowStyleValue& as_grid_auto_flow() { return const_cast<GridAutoFlowStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_auto_flow()); }
|
GridAutoFlowStyleValue& as_grid_auto_flow() { return const_cast<GridAutoFlowStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_auto_flow()); }
|
||||||
|
|
||||||
bool is_grid_template_area() const { return type() == Type::GridTemplateArea; }
|
bool is_grid_template_area() const { return type() == Type::GridTemplateArea; }
|
||||||
GridTemplateAreaStyleValue const& as_grid_template_area() const;
|
GridTemplateAreaStyleValue const& as_grid_template_area() const;
|
||||||
GridTemplateAreaStyleValue& as_grid_template_area() { return const_cast<GridTemplateAreaStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_template_area()); }
|
GridTemplateAreaStyleValue& as_grid_template_area() { return const_cast<GridTemplateAreaStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_template_area()); }
|
||||||
|
|
||||||
bool is_grid_track_placement() const { return type() == Type::GridTrackPlacement; }
|
bool is_grid_track_placement() const { return type() == Type::GridTrackPlacement; }
|
||||||
GridTrackPlacementStyleValue const& as_grid_track_placement() const;
|
GridTrackPlacementStyleValue const& as_grid_track_placement() const;
|
||||||
GridTrackPlacementStyleValue& as_grid_track_placement() { return const_cast<GridTrackPlacementStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_track_placement()); }
|
GridTrackPlacementStyleValue& as_grid_track_placement() { return const_cast<GridTrackPlacementStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_placement()); }
|
||||||
|
|
||||||
bool is_grid_track_size_list() const { return type() == Type::GridTrackSizeList; }
|
bool is_grid_track_size_list() const { return type() == Type::GridTrackSizeList; }
|
||||||
GridTrackSizeListStyleValue const& as_grid_track_size_list() const;
|
GridTrackSizeListStyleValue const& as_grid_track_size_list() const;
|
||||||
GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_track_size_list()); }
|
GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_size_list()); }
|
||||||
|
|
||||||
bool is_identifier() const { return type() == Type::Identifier; }
|
bool is_identifier() const { return type() == Type::Identifier; }
|
||||||
IdentifierStyleValue const& as_identifier() const;
|
IdentifierStyleValue const& as_identifier() const;
|
||||||
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<StyleValue const&>(*this).as_identifier()); }
|
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_identifier()); }
|
||||||
|
|
||||||
bool is_image() const { return type() == Type::Image; }
|
bool is_image() const { return type() == Type::Image; }
|
||||||
ImageStyleValue const& as_image() const;
|
ImageStyleValue const& as_image() const;
|
||||||
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<StyleValue const&>(*this).as_image()); }
|
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_image()); }
|
||||||
|
|
||||||
bool is_inherit() const { return type() == Type::Inherit; }
|
bool is_inherit() const { return type() == Type::Inherit; }
|
||||||
InheritStyleValue const& as_inherit() const;
|
InheritStyleValue const& as_inherit() const;
|
||||||
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<StyleValue const&>(*this).as_inherit()); }
|
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_inherit()); }
|
||||||
|
|
||||||
bool is_initial() const { return type() == Type::Initial; }
|
bool is_initial() const { return type() == Type::Initial; }
|
||||||
InitialStyleValue const& as_initial() const;
|
InitialStyleValue const& as_initial() const;
|
||||||
InitialStyleValue& as_initial() { return const_cast<InitialStyleValue&>(const_cast<StyleValue const&>(*this).as_initial()); }
|
InitialStyleValue& as_initial() { return const_cast<InitialStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_initial()); }
|
||||||
|
|
||||||
bool is_integer() const { return type() == Type::Integer; }
|
bool is_integer() const { return type() == Type::Integer; }
|
||||||
IntegerStyleValue const& as_integer() const;
|
IntegerStyleValue const& as_integer() const;
|
||||||
IntegerStyleValue& as_integer() { return const_cast<IntegerStyleValue&>(const_cast<StyleValue const&>(*this).as_integer()); }
|
IntegerStyleValue& as_integer() { return const_cast<IntegerStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_integer()); }
|
||||||
|
|
||||||
bool is_length() const { return type() == Type::Length; }
|
bool is_length() const { return type() == Type::Length; }
|
||||||
LengthStyleValue const& as_length() const;
|
LengthStyleValue const& as_length() const;
|
||||||
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<StyleValue const&>(*this).as_length()); }
|
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_length()); }
|
||||||
|
|
||||||
bool is_linear_gradient() const { return type() == Type::LinearGradient; }
|
bool is_linear_gradient() const { return type() == Type::LinearGradient; }
|
||||||
LinearGradientStyleValue const& as_linear_gradient() const;
|
LinearGradientStyleValue const& as_linear_gradient() const;
|
||||||
LinearGradientStyleValue& as_linear_gradient() { return const_cast<LinearGradientStyleValue&>(const_cast<StyleValue const&>(*this).as_linear_gradient()); }
|
LinearGradientStyleValue& as_linear_gradient() { return const_cast<LinearGradientStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_linear_gradient()); }
|
||||||
|
|
||||||
bool is_math_depth() const { return type() == Type::MathDepth; }
|
bool is_math_depth() const { return type() == Type::MathDepth; }
|
||||||
MathDepthStyleValue const& as_math_depth() const;
|
MathDepthStyleValue const& as_math_depth() const;
|
||||||
MathDepthStyleValue& as_math_depth() { return const_cast<MathDepthStyleValue&>(const_cast<StyleValue const&>(*this).as_math_depth()); }
|
MathDepthStyleValue& as_math_depth() { return const_cast<MathDepthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_math_depth()); }
|
||||||
|
|
||||||
bool is_number() const { return type() == Type::Number; }
|
bool is_number() const { return type() == Type::Number; }
|
||||||
NumberStyleValue const& as_number() const;
|
NumberStyleValue const& as_number() const;
|
||||||
NumberStyleValue& as_number() { return const_cast<NumberStyleValue&>(const_cast<StyleValue const&>(*this).as_number()); }
|
NumberStyleValue& as_number() { return const_cast<NumberStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_number()); }
|
||||||
|
|
||||||
bool is_percentage() const { return type() == Type::Percentage; }
|
bool is_percentage() const { return type() == Type::Percentage; }
|
||||||
PercentageStyleValue const& as_percentage() const;
|
PercentageStyleValue const& as_percentage() const;
|
||||||
PercentageStyleValue& as_percentage() { return const_cast<PercentageStyleValue&>(const_cast<StyleValue const&>(*this).as_percentage()); }
|
PercentageStyleValue& as_percentage() { return const_cast<PercentageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_percentage()); }
|
||||||
|
|
||||||
bool is_position() const { return type() == Type::Position; }
|
bool is_position() const { return type() == Type::Position; }
|
||||||
PositionStyleValue const& as_position() const;
|
PositionStyleValue const& as_position() const;
|
||||||
|
|
||||||
PositionStyleValue& as_position() { return const_cast<PositionStyleValue&>(const_cast<StyleValue const&>(*this).as_position()); }
|
PositionStyleValue& as_position() { return const_cast<PositionStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_position()); }
|
||||||
bool is_radial_gradient() const { return type() == Type::RadialGradient; }
|
bool is_radial_gradient() const { return type() == Type::RadialGradient; }
|
||||||
RadialGradientStyleValue const& as_radial_gradient() const;
|
RadialGradientStyleValue const& as_radial_gradient() const;
|
||||||
RadialGradientStyleValue& as_radial_gradient() { return const_cast<RadialGradientStyleValue&>(const_cast<StyleValue const&>(*this).as_radial_gradient()); }
|
RadialGradientStyleValue& as_radial_gradient() { return const_cast<RadialGradientStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_radial_gradient()); }
|
||||||
|
|
||||||
bool is_ratio() const { return type() == Type::Ratio; }
|
bool is_ratio() const { return type() == Type::Ratio; }
|
||||||
RatioStyleValue const& as_ratio() const;
|
RatioStyleValue const& as_ratio() const;
|
||||||
RatioStyleValue& as_ratio() { return const_cast<RatioStyleValue&>(const_cast<StyleValue const&>(*this).as_ratio()); }
|
RatioStyleValue& as_ratio() { return const_cast<RatioStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_ratio()); }
|
||||||
|
|
||||||
bool is_rect() const { return type() == Type::Rect; }
|
bool is_rect() const { return type() == Type::Rect; }
|
||||||
RectStyleValue const& as_rect() const;
|
RectStyleValue const& as_rect() const;
|
||||||
RectStyleValue& as_rect() { return const_cast<RectStyleValue&>(const_cast<StyleValue const&>(*this).as_rect()); }
|
RectStyleValue& as_rect() { return const_cast<RectStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_rect()); }
|
||||||
|
|
||||||
bool is_resolution() const { return type() == Type::Resolution; }
|
bool is_resolution() const { return type() == Type::Resolution; }
|
||||||
ResolutionStyleValue const& as_resolution() const;
|
ResolutionStyleValue const& as_resolution() const;
|
||||||
ResolutionStyleValue& as_resolution() { return const_cast<ResolutionStyleValue&>(const_cast<StyleValue const&>(*this).as_resolution()); }
|
ResolutionStyleValue& as_resolution() { return const_cast<ResolutionStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_resolution()); }
|
||||||
|
|
||||||
bool is_revert() const { return type() == Type::Revert; }
|
bool is_revert() const { return type() == Type::Revert; }
|
||||||
RevertStyleValue const& as_revert() const;
|
RevertStyleValue const& as_revert() const;
|
||||||
RevertStyleValue& as_revert() { return const_cast<RevertStyleValue&>(const_cast<StyleValue const&>(*this).as_revert()); }
|
RevertStyleValue& as_revert() { return const_cast<RevertStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_revert()); }
|
||||||
|
|
||||||
bool is_scrollbar_gutter() const { return type() == Type::ScrollbarGutter; }
|
bool is_scrollbar_gutter() const { return type() == Type::ScrollbarGutter; }
|
||||||
ScrollbarGutterStyleValue const& as_scrollbar_gutter() const;
|
ScrollbarGutterStyleValue const& as_scrollbar_gutter() const;
|
||||||
ScrollbarGutterStyleValue& as_scrollbar_gutter() { return const_cast<ScrollbarGutterStyleValue&>(const_cast<StyleValue const&>(*this).as_scrollbar_gutter()); }
|
ScrollbarGutterStyleValue& as_scrollbar_gutter() { return const_cast<ScrollbarGutterStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_scrollbar_gutter()); }
|
||||||
|
|
||||||
bool is_shadow() const { return type() == Type::Shadow; }
|
bool is_shadow() const { return type() == Type::Shadow; }
|
||||||
ShadowStyleValue const& as_shadow() const;
|
ShadowStyleValue const& as_shadow() const;
|
||||||
ShadowStyleValue& as_shadow() { return const_cast<ShadowStyleValue&>(const_cast<StyleValue const&>(*this).as_shadow()); }
|
ShadowStyleValue& as_shadow() { return const_cast<ShadowStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_shadow()); }
|
||||||
|
|
||||||
bool is_shorthand() const { return type() == Type::Shorthand; }
|
bool is_shorthand() const { return type() == Type::Shorthand; }
|
||||||
ShorthandStyleValue const& as_shorthand() const;
|
ShorthandStyleValue const& as_shorthand() const;
|
||||||
ShorthandStyleValue& as_shorthand() { return const_cast<ShorthandStyleValue&>(const_cast<StyleValue const&>(*this).as_shorthand()); }
|
ShorthandStyleValue& as_shorthand() { return const_cast<ShorthandStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_shorthand()); }
|
||||||
|
|
||||||
bool is_string() const { return type() == Type::String; }
|
bool is_string() const { return type() == Type::String; }
|
||||||
StringStyleValue const& as_string() const;
|
StringStyleValue const& as_string() const;
|
||||||
StringStyleValue& as_string() { return const_cast<StringStyleValue&>(const_cast<StyleValue const&>(*this).as_string()); }
|
StringStyleValue& as_string() { return const_cast<StringStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_string()); }
|
||||||
|
|
||||||
bool is_time() const { return type() == Type::Time; }
|
bool is_time() const { return type() == Type::Time; }
|
||||||
TimeStyleValue const& as_time() const;
|
TimeStyleValue const& as_time() const;
|
||||||
TimeStyleValue& as_time() { return const_cast<TimeStyleValue&>(const_cast<StyleValue const&>(*this).as_time()); }
|
TimeStyleValue& as_time() { return const_cast<TimeStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_time()); }
|
||||||
|
|
||||||
bool is_transformation() const { return type() == Type::Transformation; }
|
bool is_transformation() const { return type() == Type::Transformation; }
|
||||||
TransformationStyleValue const& as_transformation() const;
|
TransformationStyleValue const& as_transformation() const;
|
||||||
TransformationStyleValue& as_transformation() { return const_cast<TransformationStyleValue&>(const_cast<StyleValue const&>(*this).as_transformation()); }
|
TransformationStyleValue& as_transformation() { return const_cast<TransformationStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_transformation()); }
|
||||||
|
|
||||||
bool is_transition() const { return type() == Type::Transition; }
|
bool is_transition() const { return type() == Type::Transition; }
|
||||||
TransitionStyleValue const& as_transition() const;
|
TransitionStyleValue const& as_transition() const;
|
||||||
TransitionStyleValue& as_transition() { return const_cast<TransitionStyleValue&>(const_cast<StyleValue const&>(*this).as_transition()); }
|
TransitionStyleValue& as_transition() { return const_cast<TransitionStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_transition()); }
|
||||||
|
|
||||||
bool is_unresolved() const { return type() == Type::Unresolved; }
|
bool is_unresolved() const { return type() == Type::Unresolved; }
|
||||||
UnresolvedStyleValue const& as_unresolved() const;
|
UnresolvedStyleValue const& as_unresolved() const;
|
||||||
UnresolvedStyleValue& as_unresolved() { return const_cast<UnresolvedStyleValue&>(const_cast<StyleValue const&>(*this).as_unresolved()); }
|
UnresolvedStyleValue& as_unresolved() { return const_cast<UnresolvedStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_unresolved()); }
|
||||||
|
|
||||||
bool is_unset() const { return type() == Type::Unset; }
|
bool is_unset() const { return type() == Type::Unset; }
|
||||||
UnsetStyleValue const& as_unset() const;
|
UnsetStyleValue const& as_unset() const;
|
||||||
UnsetStyleValue& as_unset() { return const_cast<UnsetStyleValue&>(const_cast<StyleValue const&>(*this).as_unset()); }
|
UnsetStyleValue& as_unset() { return const_cast<UnsetStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_unset()); }
|
||||||
|
|
||||||
bool is_url() const { return type() == Type::URL; }
|
bool is_url() const { return type() == Type::URL; }
|
||||||
URLStyleValue const& as_url() const;
|
URLStyleValue const& as_url() const;
|
||||||
URLStyleValue& as_url() { return const_cast<URLStyleValue&>(const_cast<StyleValue const&>(*this).as_url()); }
|
URLStyleValue& as_url() { return const_cast<URLStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_url()); }
|
||||||
|
|
||||||
bool is_value_list() const { return type() == Type::ValueList; }
|
bool is_value_list() const { return type() == Type::ValueList; }
|
||||||
StyleValueList const& as_value_list() const;
|
StyleValueList const& as_value_list() const;
|
||||||
StyleValueList& as_value_list() { return const_cast<StyleValueList&>(const_cast<StyleValue const&>(*this).as_value_list()); }
|
StyleValueList& as_value_list() { return const_cast<StyleValueList&>(const_cast<CSSStyleValue const&>(*this).as_value_list()); }
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-values-4/#common-keywords
|
// https://www.w3.org/TR/css-values-4/#common-keywords
|
||||||
// https://drafts.csswg.org/css-cascade-4/#valdef-all-revert
|
// https://drafts.csswg.org/css-cascade-4/#valdef-all-revert
|
||||||
|
@ -350,7 +351,7 @@ public:
|
||||||
bool has_auto() const;
|
bool has_auto() const;
|
||||||
virtual bool has_color() const { return false; }
|
virtual bool has_color() const { return false; }
|
||||||
|
|
||||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const;
|
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const;
|
||||||
|
|
||||||
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const { return {}; }
|
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const { return {}; }
|
||||||
ValueID to_identifier() const;
|
ValueID to_identifier() const;
|
||||||
|
@ -360,25 +361,25 @@ public:
|
||||||
[[nodiscard]] int to_font_slope() const;
|
[[nodiscard]] int to_font_slope() const;
|
||||||
[[nodiscard]] int to_font_stretch_width() const;
|
[[nodiscard]] int to_font_stretch_width() const;
|
||||||
|
|
||||||
virtual bool equals(StyleValue const& other) const = 0;
|
virtual bool equals(CSSStyleValue const& other) const = 0;
|
||||||
|
|
||||||
bool operator==(StyleValue const& other) const
|
bool operator==(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
return this->equals(other);
|
return this->equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit StyleValue(Type);
|
explicit CSSStyleValue(Type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type;
|
Type m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct StyleValueWithDefaultOperators : public StyleValue {
|
struct StyleValueWithDefaultOperators : public CSSStyleValue {
|
||||||
using StyleValue::StyleValue;
|
using CSSStyleValue::CSSStyleValue;
|
||||||
|
|
||||||
virtual bool equals(StyleValue const& other) const override
|
virtual bool equals(CSSStyleValue const& other) const override
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
@ -390,8 +391,8 @@ struct StyleValueWithDefaultOperators : public StyleValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct AK::Formatter<Web::CSS::StyleValue> : Formatter<StringView> {
|
struct AK::Formatter<Web::CSS::CSSStyleValue> : Formatter<StringView> {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::StyleValue const& style_value)
|
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::CSSStyleValue const& style_value)
|
||||||
{
|
{
|
||||||
return Formatter<StringView>::format(builder, style_value.to_string());
|
return Formatter<StringView>::format(builder, style_value.to_string());
|
||||||
}
|
}
|
|
@ -7,8 +7,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Animations/Animation.h>
|
#include <LibWeb/Animations/Animation.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/Time.h>
|
#include <LibWeb/CSS/Time.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -22,7 +22,7 @@ Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue>
|
||||||
return calculated->resolve_angle().value();
|
return calculated->resolve_angle().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> AngleOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> AngleOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return AngleStyleValue::create(value());
|
return AngleStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> co
|
||||||
return calculated->resolve_flex().value();
|
return calculated->resolve_flex().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> FlexOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> FlexOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return FlexStyleValue::create(value());
|
return FlexStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyl
|
||||||
return calculated->resolve_frequency().value();
|
return calculated->resolve_frequency().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> FrequencyOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> FrequencyOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return FrequencyStyleValue::create(value());
|
return FrequencyStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue>
|
||||||
return calculated->resolve_integer().value();
|
return calculated->resolve_integer().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> IntegerOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return IntegerStyleValue::create(value());
|
return IntegerStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ Length LengthOrCalculated::resolved(Length::ResolutionContext const& context) co
|
||||||
return value();
|
return value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> LengthOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return LengthStyleValue::create(value());
|
return LengthStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue
|
||||||
return calculated->resolve_number().value();
|
return calculated->resolve_number().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> NumberOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return NumberStyleValue::create(value());
|
return NumberStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedSt
|
||||||
return calculated->resolve_percentage().value();
|
return calculated->resolve_percentage().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> PercentageOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return PercentageStyleValue::create(value());
|
return PercentageStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedSt
|
||||||
return calculated->resolve_resolution().value();
|
return calculated->resolve_resolution().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> ResolutionOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return ResolutionStyleValue::create(value());
|
return ResolutionStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> co
|
||||||
return calculated->resolve_time().value();
|
return calculated->resolve_time().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> TimeOrCalculated::create_style_value() const
|
NonnullRefPtr<CSSStyleValue> TimeOrCalculated::create_style_value() const
|
||||||
{
|
{
|
||||||
return TimeStyleValue::create(value());
|
return TimeStyleValue::create(value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
return m_value.template get<T>();
|
return m_value.template get<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> as_style_value() const
|
NonnullRefPtr<CSSStyleValue> as_style_value() const
|
||||||
{
|
{
|
||||||
if (is_calculated())
|
if (is_calculated())
|
||||||
return calculated();
|
return calculated();
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual T resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const = 0;
|
virtual T resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const = 0;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const = 0;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Variant<T, NonnullRefPtr<CalculatedStyleValue>> m_value;
|
Variant<T, NonnullRefPtr<CalculatedStyleValue>> m_value;
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlexOrCalculated : public CalculatedOr<Flex> {
|
class FlexOrCalculated : public CalculatedOr<Flex> {
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Flex resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Flex resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FrequencyOrCalculated : public CalculatedOr<Frequency> {
|
class FrequencyOrCalculated : public CalculatedOr<Frequency> {
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntegerOrCalculated : public CalculatedOr<i64> {
|
class IntegerOrCalculated : public CalculatedOr<i64> {
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual i64 resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual i64 resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LengthOrCalculated : public CalculatedOr<Length> {
|
class LengthOrCalculated : public CalculatedOr<Length> {
|
||||||
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NumberOrCalculated : public CalculatedOr<double> {
|
class NumberOrCalculated : public CalculatedOr<double> {
|
||||||
|
@ -141,7 +141,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual double resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual double resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PercentageOrCalculated : public CalculatedOr<Percentage> {
|
class PercentageOrCalculated : public CalculatedOr<Percentage> {
|
||||||
|
@ -150,7 +150,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Percentage resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Percentage resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResolutionOrCalculated : public CalculatedOr<Resolution> {
|
class ResolutionOrCalculated : public CalculatedOr<Resolution> {
|
||||||
|
@ -159,7 +159,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Resolution resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Resolution resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TimeOrCalculated : public CalculatedOr<Time> {
|
class TimeOrCalculated : public CalculatedOr<Time> {
|
||||||
|
@ -168,7 +168,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
virtual Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||||
virtual NonnullRefPtr<StyleValue> create_style_value() const override;
|
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> load_vector_fo
|
||||||
JS_DEFINE_ALLOCATOR(FontFace);
|
JS_DEFINE_ALLOCATOR(FontFace);
|
||||||
|
|
||||||
template<CSS::PropertyID PropertyID>
|
template<CSS::PropertyID PropertyID>
|
||||||
RefPtr<CSS::StyleValue const> parse_property_string(JS::Realm& realm, StringView value)
|
RefPtr<CSSStyleValue const> parse_property_string(JS::Realm& realm, StringView value)
|
||||||
{
|
{
|
||||||
auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), value);
|
auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), value);
|
||||||
return parser.parse_as_css_value(PropertyID);
|
return parser.parse_as_css_value(PropertyID);
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
|
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
|
||||||
~LengthBox();
|
~LengthBox();
|
||||||
|
|
||||||
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue> member, but we can't include the header StyleValue.h as it includes
|
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue> member, but we can't include the header CSSStyleValue.h as it includes
|
||||||
// this file already. To break the cyclic dependency, we must initialize these members in the constructor.
|
// this file already. To break the cyclic dependency, we must initialize these members in the constructor.
|
||||||
LengthPercentage& top() { return m_top; }
|
LengthPercentage& top() { return m_top; }
|
||||||
LengthPercentage& right() { return m_right; }
|
LengthPercentage& right() { return m_right; }
|
||||||
|
|
|
@ -31,7 +31,7 @@ Optional<Vector<TElement>> Parser::parse_color_stop_list(TokenStream<ComponentVa
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return ElementType::Garbage;
|
return ElementType::Garbage;
|
||||||
|
|
||||||
RefPtr<StyleValue> color;
|
RefPtr<CSSStyleValue> color;
|
||||||
Optional<typename TElement::PositionType> position;
|
Optional<typename TElement::PositionType> position;
|
||||||
Optional<typename TElement::PositionType> second_position;
|
Optional<typename TElement::PositionType> second_position;
|
||||||
if (auto dimension = parse_dimension(tokens.peek_token()); dimension.has_value() && is_position(*dimension)) {
|
if (auto dimension = parse_dimension(tokens.peek_token()); dimension.has_value() && is_position(*dimension)) {
|
||||||
|
@ -135,7 +135,7 @@ Optional<Vector<AngularColorStopListElement>> Parser::parse_angular_color_stop_l
|
||||||
[](Dimension& dimension) { return dimension.angle_percentage(); });
|
[](Dimension& dimension) { return dimension.angle_percentage(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_linear_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
RefPtr<CSSStyleValue> Parser::parse_linear_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||||
{
|
{
|
||||||
using GradientType = LinearGradientStyleValue::GradientType;
|
using GradientType = LinearGradientStyleValue::GradientType;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ RefPtr<StyleValue> Parser::parse_linear_gradient_function(TokenStream<ComponentV
|
||||||
return LinearGradientStyleValue::create(gradient_direction, move(*color_stops), gradient_type, repeating_gradient);
|
return LinearGradientStyleValue::create(gradient_direction, move(*color_stops), gradient_type, repeating_gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_conic_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
RefPtr<CSSStyleValue> Parser::parse_conic_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||||
{
|
{
|
||||||
auto transaction = outer_tokens.begin_transaction();
|
auto transaction = outer_tokens.begin_transaction();
|
||||||
auto& component_value = outer_tokens.next_token();
|
auto& component_value = outer_tokens.next_token();
|
||||||
|
@ -371,7 +371,7 @@ RefPtr<StyleValue> Parser::parse_conic_gradient_function(TokenStream<ComponentVa
|
||||||
return ConicGradientStyleValue::create(from_angle, at_position.release_nonnull(), move(*color_stops), repeating_gradient);
|
return ConicGradientStyleValue::create(from_angle, at_position.release_nonnull(), move(*color_stops), repeating_gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_radial_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
RefPtr<CSSStyleValue> Parser::parse_radial_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||||
{
|
{
|
||||||
using EndingShape = RadialGradientStyleValue::EndingShape;
|
using EndingShape = RadialGradientStyleValue::EndingShape;
|
||||||
using Extent = RadialGradientStyleValue::Extent;
|
using Extent = RadialGradientStyleValue::Extent;
|
||||||
|
|
|
@ -32,7 +32,7 @@ CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::Pa
|
||||||
return CSS::Parser::Parser::create(context, css).parse_as_style_attribute(element);
|
return CSS::Parser::Parser::create(context, css).parse_as_style_attribute(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
|
RefPtr<CSS::CSSStyleValue> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
|
||||||
{
|
{
|
||||||
if (string.is_empty())
|
if (string.is_empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||||
#include <LibWeb/CSS/CalculatedOr.h>
|
#include <LibWeb/CSS/CalculatedOr.h>
|
||||||
#include <LibWeb/CSS/EdgeRect.h>
|
#include <LibWeb/CSS/EdgeRect.h>
|
||||||
|
@ -36,7 +37,6 @@
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/Parser/Rule.h>
|
#include <LibWeb/CSS/Parser/Rule.h>
|
||||||
#include <LibWeb/CSS/Selector.h>
|
#include <LibWeb/CSS/Selector.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||||
|
@ -1193,7 +1193,7 @@ Optional<URL::URL> Parser::parse_url_function(TokenStream<ComponentValue>& token
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_url_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_url_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto url = parse_url_function(tokens);
|
auto url = parse_url_function(tokens);
|
||||||
if (!url.has_value())
|
if (!url.has_value())
|
||||||
|
@ -1201,7 +1201,7 @@ RefPtr<StyleValue> Parser::parse_url_value(TokenStream<ComponentValue>& tokens)
|
||||||
return URLStyleValue::create(*url);
|
return URLStyleValue::create(*url);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto& component_value = tokens.next_token();
|
auto& component_value = tokens.next_token();
|
||||||
|
@ -1618,7 +1618,7 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
|
||||||
return StyleProperty { declaration.importance(), property_id.value(), value.release_value(), {} };
|
return StyleProperty { declaration.importance(), property_id.value(), value.release_value(), {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto& component_value = tokens.next_token();
|
auto& component_value = tokens.next_token();
|
||||||
|
@ -2312,7 +2312,7 @@ Vector<Gfx::UnicodeRange> Parser::parse_unicode_ranges(TokenStream<ComponentValu
|
||||||
return unicode_ranges;
|
return unicode_ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_dimension_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_dimension_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto dimension = parse_dimension(tokens.peek_token());
|
auto dimension = parse_dimension(tokens.peek_token());
|
||||||
if (!dimension.has_value())
|
if (!dimension.has_value())
|
||||||
|
@ -2334,7 +2334,7 @@ RefPtr<StyleValue> Parser::parse_dimension_value(TokenStream<ComponentValue>& to
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto peek_token = tokens.peek_token();
|
auto peek_token = tokens.peek_token();
|
||||||
if (peek_token.is(Token::Type::Number) && peek_token.token().number().is_integer()) {
|
if (peek_token.is(Token::Type::Number) && peek_token.token().number().is_integer()) {
|
||||||
|
@ -2345,7 +2345,7 @@ RefPtr<StyleValue> Parser::parse_integer_value(TokenStream<ComponentValue>& toke
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_number_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_number_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto peek_token = tokens.peek_token();
|
auto peek_token = tokens.peek_token();
|
||||||
if (peek_token.is(Token::Type::Number)) {
|
if (peek_token.is(Token::Type::Number)) {
|
||||||
|
@ -2356,7 +2356,7 @@ RefPtr<StyleValue> Parser::parse_number_value(TokenStream<ComponentValue>& token
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_number_or_percentage_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_number_or_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto peek_token = tokens.peek_token();
|
auto peek_token = tokens.peek_token();
|
||||||
if (peek_token.is(Token::Type::Number)) {
|
if (peek_token.is(Token::Type::Number)) {
|
||||||
|
@ -2371,7 +2371,7 @@ RefPtr<StyleValue> Parser::parse_number_or_percentage_value(TokenStream<Componen
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_identifier_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_identifier_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto peek_token = tokens.peek_token();
|
auto peek_token = tokens.peek_token();
|
||||||
if (peek_token.is(Token::Type::Ident)) {
|
if (peek_token.is(Token::Type::Ident)) {
|
||||||
|
@ -2386,7 +2386,7 @@ RefPtr<StyleValue> Parser::parse_identifier_value(TokenStream<ComponentValue>& t
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/CSS2/visufx.html#value-def-shape
|
// https://www.w3.org/TR/CSS2/visufx.html#value-def-shape
|
||||||
RefPtr<StyleValue> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto function_token = tokens.next_token();
|
auto function_token = tokens.next_token();
|
||||||
|
@ -2996,7 +2996,7 @@ Optional<Color> Parser::parse_color(TokenStream<ComponentValue>& tokens)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (auto color = parse_color(tokens); color.has_value())
|
if (auto color = parse_color(tokens); color.has_value())
|
||||||
return ColorStyleValue::create(color.value());
|
return ColorStyleValue::create(color.value());
|
||||||
|
@ -3011,7 +3011,7 @@ RefPtr<StyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-lists-3/#counter-functions
|
// https://drafts.csswg.org/css-lists-3/#counter-functions
|
||||||
RefPtr<StyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto parse_counter_name = [this](TokenStream<ComponentValue>& tokens) -> Optional<FlyString> {
|
auto parse_counter_name = [this](TokenStream<ComponentValue>& tokens) -> Optional<FlyString> {
|
||||||
// https://drafts.csswg.org/css-lists-3/#typedef-counter-name
|
// https://drafts.csswg.org/css-lists-3/#typedef-counter-name
|
||||||
|
@ -3033,7 +3033,7 @@ RefPtr<StyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& toke
|
||||||
return counter_name->custom_ident();
|
return counter_name->custom_ident();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<StyleValue> {
|
auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<CSSStyleValue> {
|
||||||
// https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style
|
// https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style
|
||||||
// <counter-style> = <counter-style-name> | <symbols()>
|
// <counter-style> = <counter-style-name> | <symbols()>
|
||||||
// For now we just support <counter-style-name>, found here:
|
// For now we just support <counter-style-name>, found here:
|
||||||
|
@ -3069,7 +3069,7 @@ RefPtr<StyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& toke
|
||||||
if (!counter_name.has_value())
|
if (!counter_name.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
RefPtr<StyleValue> counter_style;
|
RefPtr<CSSStyleValue> counter_style;
|
||||||
if (function_values.size() > 1) {
|
if (function_values.size() > 1) {
|
||||||
TokenStream counter_style_tokens { function_values[1] };
|
TokenStream counter_style_tokens { function_values[1] };
|
||||||
counter_style = parse_counter_style(counter_style_tokens);
|
counter_style = parse_counter_style(counter_style_tokens);
|
||||||
|
@ -3099,12 +3099,12 @@ RefPtr<StyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& toke
|
||||||
|
|
||||||
TokenStream string_tokens { function_values[1] };
|
TokenStream string_tokens { function_values[1] };
|
||||||
string_tokens.skip_whitespace();
|
string_tokens.skip_whitespace();
|
||||||
RefPtr<StyleValue> join_string = parse_string_value(string_tokens);
|
RefPtr<CSSStyleValue> join_string = parse_string_value(string_tokens);
|
||||||
string_tokens.skip_whitespace();
|
string_tokens.skip_whitespace();
|
||||||
if (!join_string || string_tokens.has_next_token())
|
if (!join_string || string_tokens.has_next_token())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
RefPtr<StyleValue> counter_style;
|
RefPtr<CSSStyleValue> counter_style;
|
||||||
if (function_values.size() > 2) {
|
if (function_values.size() > 2) {
|
||||||
TokenStream counter_style_tokens { function_values[2] };
|
TokenStream counter_style_tokens { function_values[2] };
|
||||||
counter_style = parse_counter_style(counter_style_tokens);
|
counter_style = parse_counter_style(counter_style_tokens);
|
||||||
|
@ -3122,7 +3122,7 @@ RefPtr<StyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& toke
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_counter_definitions_value(TokenStream<ComponentValue>& tokens, AllowReversed allow_reversed, i32 default_value_if_not_reversed)
|
RefPtr<CSSStyleValue> Parser::parse_counter_definitions_value(TokenStream<ComponentValue>& tokens, AllowReversed allow_reversed, i32 default_value_if_not_reversed)
|
||||||
{
|
{
|
||||||
// If AllowReversed is Yes, parses:
|
// If AllowReversed is Yes, parses:
|
||||||
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+
|
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+
|
||||||
|
@ -3179,14 +3179,14 @@ RefPtr<StyleValue> Parser::parse_counter_definitions_value(TokenStream<Component
|
||||||
return CounterDefinitionsStyleValue::create(move(counter_definitions));
|
return CounterDefinitionsStyleValue::create(move(counter_definitions));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (auto ratio = parse_ratio(tokens); ratio.has_value())
|
if (auto ratio = parse_ratio(tokens); ratio.has_value())
|
||||||
return RatioStyleValue::create(ratio.release_value());
|
return RatioStyleValue::create(ratio.release_value());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_string_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_string_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto peek = tokens.peek_token();
|
auto peek = tokens.peek_token();
|
||||||
if (peek.is(Token::Type::String)) {
|
if (peek.is(Token::Type::String)) {
|
||||||
|
@ -3197,7 +3197,7 @@ RefPtr<StyleValue> Parser::parse_string_value(TokenStream<ComponentValue>& token
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_image_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_image_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (auto url = parse_url_function(tokens); url.has_value())
|
if (auto url = parse_url_function(tokens); url.has_value())
|
||||||
return ImageStyleValue::create(url.value());
|
return ImageStyleValue::create(url.value());
|
||||||
|
@ -3215,11 +3215,11 @@ RefPtr<StyleValue> Parser::parse_image_value(TokenStream<ComponentValue>& tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
|
// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
|
||||||
RefPtr<StyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
|
// `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
|
||||||
|
|
||||||
auto parse_color_or_none = [&]() -> Optional<RefPtr<StyleValue>> {
|
auto parse_color_or_none = [&]() -> Optional<RefPtr<CSSStyleValue>> {
|
||||||
if (auto color = parse_color_value(tokens))
|
if (auto color = parse_color_value(tokens))
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
|
@ -3582,7 +3582,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ParseFunction>
|
template<typename ParseFunction>
|
||||||
RefPtr<StyleValue> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
|
RefPtr<CSSStyleValue> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
|
||||||
{
|
{
|
||||||
auto first = parse_one_value(tokens);
|
auto first = parse_one_value(tokens);
|
||||||
if (!first || !tokens.has_next_token())
|
if (!first || !tokens.has_next_token())
|
||||||
|
@ -3605,9 +3605,9 @@ RefPtr<StyleValue> Parser::parse_comma_separated_value_list(TokenStream<Componen
|
||||||
return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
|
return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
return parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) -> RefPtr<StyleValue> {
|
return parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) -> RefPtr<CSSStyleValue> {
|
||||||
if (auto value = parse_css_value_for_property(property_id, tokens))
|
if (auto value = parse_css_value_for_property(property_id, tokens))
|
||||||
return value;
|
return value;
|
||||||
tokens.reconsume_current_input_token();
|
tokens.reconsume_current_input_token();
|
||||||
|
@ -3615,7 +3615,7 @@ RefPtr<StyleValue> Parser::parse_simple_comma_separated_value_list(PropertyID pr
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_all_as_single_none_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_all_as_single_none_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
tokens.skip_whitespace();
|
tokens.skip_whitespace();
|
||||||
|
@ -3635,11 +3635,11 @@ static void remove_property(Vector<PropertyID>& properties, PropertyID property_
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-sizing-4/#aspect-ratio
|
// https://www.w3.org/TR/css-sizing-4/#aspect-ratio
|
||||||
RefPtr<StyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// `auto || <ratio>`
|
// `auto || <ratio>`
|
||||||
RefPtr<StyleValue> auto_value;
|
RefPtr<CSSStyleValue> auto_value;
|
||||||
RefPtr<StyleValue> ratio_value;
|
RefPtr<CSSStyleValue> ratio_value;
|
||||||
|
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
while (tokens.has_next_token()) {
|
while (tokens.has_next_token()) {
|
||||||
|
@ -3684,7 +3684,7 @@ RefPtr<StyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValue>&
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_background_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_background_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
|
@ -3701,7 +3701,7 @@ RefPtr<StyleValue> Parser::parse_background_value(TokenStream<ComponentValue>& t
|
||||||
StyleValueVector background_attachments;
|
StyleValueVector background_attachments;
|
||||||
StyleValueVector background_clips;
|
StyleValueVector background_clips;
|
||||||
StyleValueVector background_origins;
|
StyleValueVector background_origins;
|
||||||
RefPtr<StyleValue> background_color;
|
RefPtr<CSSStyleValue> background_color;
|
||||||
|
|
||||||
auto initial_background_image = property_initial_value(m_context.realm(), PropertyID::BackgroundImage);
|
auto initial_background_image = property_initial_value(m_context.realm(), PropertyID::BackgroundImage);
|
||||||
auto initial_background_position = property_initial_value(m_context.realm(), PropertyID::BackgroundPosition);
|
auto initial_background_position = property_initial_value(m_context.realm(), PropertyID::BackgroundPosition);
|
||||||
|
@ -3713,13 +3713,13 @@ RefPtr<StyleValue> Parser::parse_background_value(TokenStream<ComponentValue>& t
|
||||||
auto initial_background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
|
auto initial_background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
|
||||||
|
|
||||||
// Per-layer values
|
// Per-layer values
|
||||||
RefPtr<StyleValue> background_image;
|
RefPtr<CSSStyleValue> background_image;
|
||||||
RefPtr<StyleValue> background_position;
|
RefPtr<CSSStyleValue> background_position;
|
||||||
RefPtr<StyleValue> background_size;
|
RefPtr<CSSStyleValue> background_size;
|
||||||
RefPtr<StyleValue> background_repeat;
|
RefPtr<CSSStyleValue> background_repeat;
|
||||||
RefPtr<StyleValue> background_attachment;
|
RefPtr<CSSStyleValue> background_attachment;
|
||||||
RefPtr<StyleValue> background_clip;
|
RefPtr<CSSStyleValue> background_clip;
|
||||||
RefPtr<StyleValue> background_origin;
|
RefPtr<CSSStyleValue> background_origin;
|
||||||
|
|
||||||
bool has_multiple_layers = false;
|
bool has_multiple_layers = false;
|
||||||
// BackgroundSize is always parsed as part of BackgroundPosition, so we don't include it here.
|
// BackgroundSize is always parsed as part of BackgroundPosition, so we don't include it here.
|
||||||
|
@ -3922,7 +3922,7 @@ static Optional<LengthPercentage> style_value_to_length_percentage(auto value)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property)
|
RefPtr<CSSStyleValue> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property)
|
||||||
{
|
{
|
||||||
PositionEdge relative_edge {};
|
PositionEdge relative_edge {};
|
||||||
if (property == PropertyID::BackgroundPositionX) {
|
if (property == PropertyID::BackgroundPositionX) {
|
||||||
|
@ -3974,11 +3974,11 @@ RefPtr<StyleValue> Parser::parse_single_background_position_x_or_y_value(TokenSt
|
||||||
return EdgeStyleValue::create(relative_edge, Length::make_px(0));
|
return EdgeStyleValue::create(relative_edge, Length::make_px(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_single_background_repeat_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_single_background_repeat_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
auto is_directional_repeat = [](StyleValue const& value) -> bool {
|
auto is_directional_repeat = [](CSSStyleValue const& value) -> bool {
|
||||||
auto value_id = value.to_identifier();
|
auto value_id = value.to_identifier();
|
||||||
return value_id == ValueID::RepeatX || value_id == ValueID::RepeatY;
|
return value_id == ValueID::RepeatX || value_id == ValueID::RepeatY;
|
||||||
};
|
};
|
||||||
|
@ -4034,11 +4034,11 @@ RefPtr<StyleValue> Parser::parse_single_background_repeat_value(TokenStream<Comp
|
||||||
return BackgroundRepeatStyleValue::create(x_repeat.value(), y_repeat.value());
|
return BackgroundRepeatStyleValue::create(x_repeat.value(), y_repeat.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_single_background_size_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_single_background_size_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
auto get_length_percentage = [](StyleValue& style_value) -> Optional<LengthPercentage> {
|
auto get_length_percentage = [](CSSStyleValue& style_value) -> Optional<LengthPercentage> {
|
||||||
if (style_value.has_auto())
|
if (style_value.has_auto())
|
||||||
return LengthPercentage { Length::make_auto() };
|
return LengthPercentage { Length::make_auto() };
|
||||||
if (style_value.is_percentage())
|
if (style_value.is_percentage())
|
||||||
|
@ -4082,11 +4082,11 @@ RefPtr<StyleValue> Parser::parse_single_background_size_value(TokenStream<Compon
|
||||||
return BackgroundSizeStyleValue::create(x_size.release_value(), y_size.release_value());
|
return BackgroundSizeStyleValue::create(x_size.release_value(), y_size.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_border_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_border_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> border_width;
|
RefPtr<CSSStyleValue> border_width;
|
||||||
RefPtr<StyleValue> border_color;
|
RefPtr<CSSStyleValue> border_color;
|
||||||
RefPtr<StyleValue> border_style;
|
RefPtr<CSSStyleValue> border_style;
|
||||||
|
|
||||||
auto color_property = PropertyID::Invalid;
|
auto color_property = PropertyID::Invalid;
|
||||||
auto style_property = PropertyID::Invalid;
|
auto style_property = PropertyID::Invalid;
|
||||||
|
@ -4159,7 +4159,7 @@ RefPtr<StyleValue> Parser::parse_border_value(PropertyID property_id, TokenStrea
|
||||||
{ border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull() });
|
{ border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_border_radius_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_border_radius_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (tokens.remaining_token_count() == 2) {
|
if (tokens.remaining_token_count() == 2) {
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
@ -4183,7 +4183,7 @@ RefPtr<StyleValue> Parser::parse_border_radius_value(TokenStream<ComponentValue>
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto top_left = [&](Vector<LengthPercentage>& radii) { return radii[0]; };
|
auto top_left = [&](Vector<LengthPercentage>& radii) { return radii[0]; };
|
||||||
auto top_right = [&](Vector<LengthPercentage>& radii) {
|
auto top_right = [&](Vector<LengthPercentage>& radii) {
|
||||||
|
@ -4269,7 +4269,7 @@ RefPtr<StyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<Compo
|
||||||
{ move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius) });
|
{ move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius) });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
|
RefPtr<CSSStyleValue> Parser::parse_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
|
||||||
{
|
{
|
||||||
// "none"
|
// "none"
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
|
@ -4280,18 +4280,18 @@ RefPtr<StyleValue> Parser::parse_shadow_value(TokenStream<ComponentValue>& token
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
|
RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
Optional<Color> color;
|
Optional<Color> color;
|
||||||
RefPtr<StyleValue> offset_x;
|
RefPtr<CSSStyleValue> offset_x;
|
||||||
RefPtr<StyleValue> offset_y;
|
RefPtr<CSSStyleValue> offset_y;
|
||||||
RefPtr<StyleValue> blur_radius;
|
RefPtr<CSSStyleValue> blur_radius;
|
||||||
RefPtr<StyleValue> spread_distance;
|
RefPtr<CSSStyleValue> spread_distance;
|
||||||
Optional<ShadowPlacement> placement;
|
Optional<ShadowPlacement> placement;
|
||||||
|
|
||||||
auto possibly_dynamic_length = [&](ComponentValue const& token) -> RefPtr<StyleValue> {
|
auto possibly_dynamic_length = [&](ComponentValue const& token) -> RefPtr<CSSStyleValue> {
|
||||||
auto tokens = TokenStream<ComponentValue>::of_single_token(token);
|
auto tokens = TokenStream<ComponentValue>::of_single_token(token);
|
||||||
auto maybe_length = parse_length(tokens);
|
auto maybe_length = parse_length(tokens);
|
||||||
if (!maybe_length.has_value())
|
if (!maybe_length.has_value())
|
||||||
|
@ -4381,7 +4381,7 @@ RefPtr<StyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentValue>
|
||||||
return ShadowStyleValue::create(color.release_value(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value());
|
return ShadowStyleValue::create(color.release_value(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// FIXME: `content` accepts several kinds of function() type, which we don't handle in property_accepts_value() yet.
|
// FIXME: `content` accepts several kinds of function() type, which we don't handle in property_accepts_value() yet.
|
||||||
|
|
||||||
|
@ -4450,7 +4450,7 @@ RefPtr<StyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& toke
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-lists-3/#propdef-counter-increment
|
// https://drafts.csswg.org/css-lists-3/#propdef-counter-increment
|
||||||
RefPtr<StyleValue> Parser::parse_counter_increment_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_counter_increment_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// [ <counter-name> <integer>? ]+ | none
|
// [ <counter-name> <integer>? ]+ | none
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
|
@ -4460,7 +4460,7 @@ RefPtr<StyleValue> Parser::parse_counter_increment_value(TokenStream<ComponentVa
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-lists-3/#propdef-counter-reset
|
// https://drafts.csswg.org/css-lists-3/#propdef-counter-reset
|
||||||
RefPtr<StyleValue> Parser::parse_counter_reset_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_counter_reset_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ | none
|
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ | none
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
|
@ -4470,7 +4470,7 @@ RefPtr<StyleValue> Parser::parse_counter_reset_value(TokenStream<ComponentValue>
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-lists-3/#propdef-counter-set
|
// https://drafts.csswg.org/css-lists-3/#propdef-counter-set
|
||||||
RefPtr<StyleValue> Parser::parse_counter_set_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_counter_set_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// [ <counter-name> <integer>? ]+ | none
|
// [ <counter-name> <integer>? ]+ | none
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
|
@ -4480,7 +4480,7 @@ RefPtr<StyleValue> Parser::parse_counter_set_value(TokenStream<ComponentValue>&
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-display-3/#the-display-properties
|
// https://www.w3.org/TR/css-display-3/#the-display-properties
|
||||||
RefPtr<StyleValue> Parser::parse_display_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_display_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto parse_single_component_display = [this](TokenStream<ComponentValue>& tokens) -> Optional<Display> {
|
auto parse_single_component_display = [this](TokenStream<ComponentValue>& tokens) -> Optional<Display> {
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
@ -4610,7 +4610,7 @@ RefPtr<StyleValue> Parser::parse_display_value(TokenStream<ComponentValue>& toke
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
return none;
|
return none;
|
||||||
|
@ -4787,11 +4787,11 @@ RefPtr<StyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentVa
|
||||||
return FilterValueListStyleValue::create(move(filter_value_list));
|
return FilterValueListStyleValue::create(move(filter_value_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
auto make_flex_shorthand = [&](NonnullRefPtr<StyleValue> flex_grow, NonnullRefPtr<StyleValue> flex_shrink, NonnullRefPtr<StyleValue> flex_basis) {
|
auto make_flex_shorthand = [&](NonnullRefPtr<CSSStyleValue> flex_grow, NonnullRefPtr<CSSStyleValue> flex_shrink, NonnullRefPtr<CSSStyleValue> flex_basis) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::Flex,
|
return ShorthandStyleValue::create(PropertyID::Flex,
|
||||||
{ PropertyID::FlexGrow, PropertyID::FlexShrink, PropertyID::FlexBasis },
|
{ PropertyID::FlexGrow, PropertyID::FlexShrink, PropertyID::FlexBasis },
|
||||||
|
@ -4832,9 +4832,9 @@ RefPtr<StyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> flex_grow;
|
RefPtr<CSSStyleValue> flex_grow;
|
||||||
RefPtr<StyleValue> flex_shrink;
|
RefPtr<CSSStyleValue> flex_shrink;
|
||||||
RefPtr<StyleValue> flex_basis;
|
RefPtr<CSSStyleValue> flex_basis;
|
||||||
|
|
||||||
// NOTE: FlexGrow has to be before FlexBasis. `0` is a valid FlexBasis, but only
|
// NOTE: FlexGrow has to be before FlexBasis. `0` is a valid FlexBasis, but only
|
||||||
// if FlexGrow (along with optional FlexShrink) have already been specified.
|
// if FlexGrow (along with optional FlexShrink) have already been specified.
|
||||||
|
@ -4881,10 +4881,10 @@ RefPtr<StyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
||||||
return make_flex_shorthand(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
|
return make_flex_shorthand(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_flex_flow_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_flex_flow_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> flex_direction;
|
RefPtr<CSSStyleValue> flex_direction;
|
||||||
RefPtr<StyleValue> flex_wrap;
|
RefPtr<CSSStyleValue> flex_wrap;
|
||||||
|
|
||||||
auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap };
|
auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap };
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
@ -4939,15 +4939,15 @@ static bool is_generic_font_family(ValueID identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> font_stretch;
|
RefPtr<CSSStyleValue> font_stretch;
|
||||||
RefPtr<StyleValue> font_style;
|
RefPtr<CSSStyleValue> font_style;
|
||||||
RefPtr<StyleValue> font_weight;
|
RefPtr<CSSStyleValue> font_weight;
|
||||||
RefPtr<StyleValue> font_size;
|
RefPtr<CSSStyleValue> font_size;
|
||||||
RefPtr<StyleValue> line_height;
|
RefPtr<CSSStyleValue> line_height;
|
||||||
RefPtr<StyleValue> font_families;
|
RefPtr<CSSStyleValue> font_families;
|
||||||
RefPtr<StyleValue> font_variant;
|
RefPtr<CSSStyleValue> font_variant;
|
||||||
|
|
||||||
// FIXME: Handle system fonts. (caption, icon, menu, message-box, small-caption, status-bar)
|
// FIXME: Handle system fonts. (caption, icon, menu, message-box, small-caption, status-bar)
|
||||||
|
|
||||||
|
@ -5049,7 +5049,7 @@ RefPtr<StyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& tokens)
|
||||||
{ font_style.release_nonnull(), font_variant.release_nonnull(), font_weight.release_nonnull(), font_stretch.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull() });
|
{ font_style.release_nonnull(), font_variant.release_nonnull(), font_weight.release_nonnull(), font_stretch.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto next_is_comma_or_eof = [&]() -> bool {
|
auto next_is_comma_or_eof = [&]() -> bool {
|
||||||
return !tokens.has_next_token() || tokens.peek_token().is(Token::Type::Comma);
|
return !tokens.has_next_token() || tokens.peek_token().is(Token::Type::Comma);
|
||||||
|
@ -5331,11 +5331,11 @@ Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<T>& compo
|
||||||
return supported_sources;
|
return supported_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> list_position;
|
RefPtr<CSSStyleValue> list_position;
|
||||||
RefPtr<StyleValue> list_image;
|
RefPtr<CSSStyleValue> list_image;
|
||||||
RefPtr<StyleValue> list_type;
|
RefPtr<CSSStyleValue> list_type;
|
||||||
int found_nones = 0;
|
int found_nones = 0;
|
||||||
|
|
||||||
Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
|
Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
|
||||||
|
@ -5408,7 +5408,7 @@ RefPtr<StyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>& t
|
||||||
{ list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull() });
|
{ list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// https://w3c.github.io/mathml-core/#propdef-math-depth
|
// https://w3c.github.io/mathml-core/#propdef-math-depth
|
||||||
// auto-add | add(<integer>) | <integer>
|
// auto-add | add(<integer>) | <integer>
|
||||||
|
@ -5425,7 +5425,7 @@ RefPtr<StyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>& t
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Make it easier to parse "thing that might be <bar> or literally anything that resolves to it" and get rid of this
|
// FIXME: Make it easier to parse "thing that might be <bar> or literally anything that resolves to it" and get rid of this
|
||||||
auto parse_something_that_resolves_to_integer = [this](ComponentValue& token) -> RefPtr<StyleValue> {
|
auto parse_something_that_resolves_to_integer = [this](ComponentValue& token) -> RefPtr<CSSStyleValue> {
|
||||||
if (token.is(Token::Type::Number) && token.token().number().is_integer())
|
if (token.is(Token::Type::Number) && token.token().number().is_integer())
|
||||||
return IntegerStyleValue::create(token.token().to_integer());
|
return IntegerStyleValue::create(token.token().to_integer());
|
||||||
if (auto value = parse_calculated_value(token); value && value->resolves_to_number())
|
if (auto value = parse_calculated_value(token); value && value->resolves_to_number())
|
||||||
|
@ -5457,7 +5457,7 @@ RefPtr<StyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>& t
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_x_value = parse_css_value_for_property(PropertyID::OverflowX, tokens);
|
auto maybe_x_value = parse_css_value_for_property(PropertyID::OverflowX, tokens);
|
||||||
|
@ -5475,7 +5475,7 @@ RefPtr<StyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>& tok
|
||||||
{ *maybe_x_value, *maybe_x_value });
|
{ *maybe_x_value, *maybe_x_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens);
|
auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens);
|
||||||
|
@ -5500,7 +5500,7 @@ RefPtr<StyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>
|
||||||
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens);
|
auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens);
|
||||||
|
@ -5525,7 +5525,7 @@ RefPtr<StyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>&
|
||||||
{ *maybe_align_items_value, *maybe_justify_items_value });
|
{ *maybe_align_items_value, *maybe_justify_items_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens);
|
auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens);
|
||||||
|
@ -5550,7 +5550,7 @@ RefPtr<StyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>& t
|
||||||
{ *maybe_align_self_value, *maybe_justify_self_value });
|
{ *maybe_align_self_value, *maybe_justify_self_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_quotes_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_quotes_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// https://www.w3.org/TR/css-content-3/#quotes-property
|
// https://www.w3.org/TR/css-content-3/#quotes-property
|
||||||
// auto | none | [ <string> <string> ]+
|
// auto | none | [ <string> <string> ]+
|
||||||
|
@ -5582,12 +5582,12 @@ RefPtr<StyleValue> Parser::parse_quotes_value(TokenStream<ComponentValue>& token
|
||||||
return StyleValueList::create(move(string_values), StyleValueList::Separator::Space);
|
return StyleValueList::create(move(string_values), StyleValueList::Separator::Space);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_text_decoration_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_text_decoration_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> decoration_line;
|
RefPtr<CSSStyleValue> decoration_line;
|
||||||
RefPtr<StyleValue> decoration_thickness;
|
RefPtr<CSSStyleValue> decoration_thickness;
|
||||||
RefPtr<StyleValue> decoration_style;
|
RefPtr<CSSStyleValue> decoration_style;
|
||||||
RefPtr<StyleValue> decoration_color;
|
RefPtr<CSSStyleValue> decoration_color;
|
||||||
|
|
||||||
auto remaining_longhands = Vector { PropertyID::TextDecorationColor, PropertyID::TextDecorationLine, PropertyID::TextDecorationStyle, PropertyID::TextDecorationThickness };
|
auto remaining_longhands = Vector { PropertyID::TextDecorationColor, PropertyID::TextDecorationLine, PropertyID::TextDecorationStyle, PropertyID::TextDecorationThickness };
|
||||||
|
|
||||||
|
@ -5644,7 +5644,7 @@ RefPtr<StyleValue> Parser::parse_text_decoration_value(TokenStream<ComponentValu
|
||||||
{ decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull() });
|
{ decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_text_decoration_line_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
StyleValueVector style_values;
|
StyleValueVector style_values;
|
||||||
|
|
||||||
|
@ -5674,7 +5674,7 @@ RefPtr<StyleValue> Parser::parse_text_decoration_line_value(TokenStream<Componen
|
||||||
return StyleValueList::create(move(style_values), StyleValueList::Separator::Space);
|
return StyleValueList::create(move(style_values), StyleValueList::Separator::Space);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
|
@ -5848,7 +5848,7 @@ RefPtr<StyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& token
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-transforms-1/#transform-property
|
// https://www.w3.org/TR/css-transforms-1/#transform-property
|
||||||
RefPtr<StyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// <transform> = none | <transform-list>
|
// <transform> = none | <transform-list>
|
||||||
// <transform-list> = <transform-function>+
|
// <transform-list> = <transform-function>+
|
||||||
|
@ -5991,7 +5991,7 @@ RefPtr<StyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>& to
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-transforms-1/#propdef-transform-origin
|
// https://www.w3.org/TR/css-transforms-1/#propdef-transform-origin
|
||||||
// FIXME: This only supports a 2D position
|
// FIXME: This only supports a 2D position
|
||||||
RefPtr<StyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
enum class Axis {
|
enum class Axis {
|
||||||
None,
|
None,
|
||||||
|
@ -6001,10 +6001,10 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentVal
|
||||||
|
|
||||||
struct AxisOffset {
|
struct AxisOffset {
|
||||||
Axis axis;
|
Axis axis;
|
||||||
NonnullRefPtr<StyleValue> offset;
|
NonnullRefPtr<CSSStyleValue> offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto to_axis_offset = [](RefPtr<StyleValue> value) -> Optional<AxisOffset> {
|
auto to_axis_offset = [](RefPtr<CSSStyleValue> value) -> Optional<AxisOffset> {
|
||||||
if (!value)
|
if (!value)
|
||||||
return OptionalNone {};
|
return OptionalNone {};
|
||||||
if (value->is_percentage())
|
if (value->is_percentage())
|
||||||
|
@ -6032,7 +6032,7 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentVal
|
||||||
|
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
auto make_list = [&transaction](NonnullRefPtr<StyleValue> const& x_value, NonnullRefPtr<StyleValue> const& y_value) -> NonnullRefPtr<StyleValueList> {
|
auto make_list = [&transaction](NonnullRefPtr<CSSStyleValue> const& x_value, NonnullRefPtr<CSSStyleValue> const& y_value) -> NonnullRefPtr<StyleValueList> {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
return StyleValueList::create(StyleValueVector { x_value, y_value }, StyleValueList::Separator::Space);
|
return StyleValueList::create(StyleValueVector { x_value, y_value }, StyleValueList::Separator::Space);
|
||||||
};
|
};
|
||||||
|
@ -6059,8 +6059,8 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentVal
|
||||||
if (!first_value.has_value() || !second_value.has_value())
|
if (!first_value.has_value() || !second_value.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
RefPtr<StyleValue> x_value;
|
RefPtr<CSSStyleValue> x_value;
|
||||||
RefPtr<StyleValue> y_value;
|
RefPtr<CSSStyleValue> y_value;
|
||||||
|
|
||||||
if (first_value->axis == Axis::X) {
|
if (first_value->axis == Axis::X) {
|
||||||
x_value = first_value->offset;
|
x_value = first_value->offset;
|
||||||
|
@ -6103,7 +6103,7 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentVal
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_transition_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_transition_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
return none;
|
return none;
|
||||||
|
@ -6177,7 +6177,7 @@ RefPtr<StyleValue> Parser::parse_transition_value(TokenStream<ComponentValue>& t
|
||||||
return TransitionStyleValue::create(move(transitions));
|
return TransitionStyleValue::create(move(transitions));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
|
RefPtr<CSSStyleValue> Parser::parse_as_css_value(PropertyID property_id)
|
||||||
{
|
{
|
||||||
auto component_values = parse_a_list_of_component_values(m_token_stream);
|
auto component_values = parse_a_list_of_component_values(m_token_stream);
|
||||||
auto tokens = TokenStream(component_values);
|
auto tokens = TokenStream(component_values);
|
||||||
|
@ -6409,7 +6409,7 @@ Optional<CSS::ExplicitGridTrack> Parser::parse_track_sizing_function(ComponentVa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_track_size_list(TokenStream<ComponentValue>& tokens, bool allow_separate_line_name_blocks)
|
RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list(TokenStream<ComponentValue>& tokens, bool allow_separate_line_name_blocks)
|
||||||
{
|
{
|
||||||
if (auto none = parse_all_as_single_none_value(tokens))
|
if (auto none = parse_all_as_single_none_value(tokens))
|
||||||
return GridTrackSizeListStyleValue::make_none();
|
return GridTrackSizeListStyleValue::make_none();
|
||||||
|
@ -6510,7 +6510,7 @@ RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(TokenStream<Co
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-overflow/#propdef-scrollbar-gutter
|
// https://drafts.csswg.org/css-overflow/#propdef-scrollbar-gutter
|
||||||
RefPtr<StyleValue> Parser::parse_scrollbar_gutter_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_scrollbar_gutter_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// auto | stable && both-edges?
|
// auto | stable && both-edges?
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
|
@ -6573,7 +6573,7 @@ RefPtr<StyleValue> Parser::parse_scrollbar_gutter_value(TokenStream<ComponentVal
|
||||||
return ScrollbarGutterStyleValue::create(gutter_value);
|
return ScrollbarGutterStyleValue::create(gutter_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// https://www.w3.org/TR/css-grid-2/#auto-tracks
|
// https://www.w3.org/TR/css-grid-2/#auto-tracks
|
||||||
// <track-size>+
|
// <track-size>+
|
||||||
|
@ -6594,9 +6594,9 @@ RefPtr<StyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValu
|
||||||
return GridTrackSizeListStyleValue::create(GridTrackSizeList(move(track_list)));
|
return GridTrackSizeListStyleValue::create(GridTrackSizeList(move(track_list)));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_track_placement(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_track_placement(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// FIXME: This shouldn't be needed. Right now, the below code returns a StyleValue even if no tokens are consumed!
|
// FIXME: This shouldn't be needed. Right now, the below code returns a CSSStyleValue even if no tokens are consumed!
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -6690,7 +6690,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement(TokenStream<ComponentValue
|
||||||
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value));
|
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart;
|
auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart;
|
||||||
auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd;
|
auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd;
|
||||||
|
@ -6742,7 +6742,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-grid-2/#explicit-grid-shorthand
|
// https://www.w3.org/TR/css-grid-2/#explicit-grid-shorthand
|
||||||
// 7.4. Explicit Grid Shorthand: the grid-template property
|
// 7.4. Explicit Grid Shorthand: the grid-template property
|
||||||
RefPtr<StyleValue> Parser::parse_grid_track_size_list_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// The grid-template property is a shorthand for setting grid-template-columns, grid-template-rows,
|
// The grid-template property is a shorthand for setting grid-template-columns, grid-template-rows,
|
||||||
// and grid-template-areas in a single declaration. It has several distinct syntax forms:
|
// and grid-template-areas in a single declaration. It has several distinct syntax forms:
|
||||||
|
@ -6800,7 +6800,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_size_list_shorthand_value(PropertyID
|
||||||
{ parsed_template_areas_values.release_nonnull(), parsed_template_rows_values.release_nonnull(), parsed_template_columns_values.release_nonnull() });
|
{ parsed_template_areas_values.release_nonnull(), parsed_template_rows_values.release_nonnull(), parsed_template_columns_values.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_area_shorthand_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_area_shorthand_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
|
@ -6889,7 +6889,7 @@ RefPtr<StyleValue> Parser::parse_grid_area_shorthand_value(TokenStream<Component
|
||||||
{ GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end) });
|
{ GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end) });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_shorthand_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_shorthand_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// <'grid-template'> |
|
// <'grid-template'> |
|
||||||
// FIXME: <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? |
|
// FIXME: <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? |
|
||||||
|
@ -6898,7 +6898,7 @@ RefPtr<StyleValue> Parser::parse_grid_shorthand_value(TokenStream<ComponentValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-grid-1/#grid-template-areas-property
|
// https://www.w3.org/TR/css-grid-1/#grid-template-areas-property
|
||||||
RefPtr<StyleValue> Parser::parse_grid_template_areas_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_grid_template_areas_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// none | <string>+
|
// none | <string>+
|
||||||
Vector<Vector<String>> grid_area_rows;
|
Vector<Vector<String>> grid_area_rows;
|
||||||
|
@ -6945,7 +6945,7 @@ bool block_contains_var_or_attr(Block const& block)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& unprocessed_tokens)
|
Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& unprocessed_tokens)
|
||||||
{
|
{
|
||||||
m_context.set_current_property_id(property_id);
|
m_context.set_current_property_id(property_id);
|
||||||
Vector<ComponentValue> component_values;
|
Vector<ComponentValue> component_values;
|
||||||
|
@ -7221,7 +7221,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's only 1 ComponentValue, we can only produce a single StyleValue.
|
// If there's only 1 ComponentValue, we can only produce a single CSSStyleValue.
|
||||||
if (component_values.size() == 1) {
|
if (component_values.size() == 1) {
|
||||||
auto stream = TokenStream { component_values };
|
auto stream = TokenStream { component_values };
|
||||||
if (auto parsed_value = parse_css_value_for_property(property_id, stream))
|
if (auto parsed_value = parse_css_value_for_property(property_id, stream))
|
||||||
|
@ -7235,7 +7235,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some types (such as <ratio>) can be made from multiple ComponentValues, so if we only made 1 StyleValue, return it directly.
|
// Some types (such as <ratio>) can be made from multiple ComponentValues, so if we only made 1 CSSStyleValue, return it directly.
|
||||||
if (parsed_values.size() == 1)
|
if (parsed_values.size() == 1)
|
||||||
return *parsed_values.take_first();
|
return *parsed_values.take_first();
|
||||||
|
|
||||||
|
@ -7250,7 +7250,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
|
|
||||||
auto stream = TokenStream { component_values };
|
auto stream = TokenStream { component_values };
|
||||||
|
|
||||||
HashMap<UnderlyingType<PropertyID>, Vector<ValueComparingNonnullRefPtr<StyleValue const>>> assigned_values;
|
HashMap<UnderlyingType<PropertyID>, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>>> assigned_values;
|
||||||
|
|
||||||
while (stream.has_next_token() && !unassigned_properties.is_empty()) {
|
while (stream.has_next_token() && !unassigned_properties.is_empty()) {
|
||||||
auto property_and_value = parse_css_value_for_properties(unassigned_properties, stream);
|
auto property_and_value = parse_css_value_for_properties(unassigned_properties, stream);
|
||||||
|
@ -7298,7 +7298,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
return { ShorthandStyleValue::create(property_id, move(longhand_properties), move(longhand_values)) };
|
return { ShorthandStyleValue::create(property_id, move(longhand_properties), move(longhand_values)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_css_value_for_property(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue> Parser::parse_css_value_for_property(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
return parse_css_value_for_properties({ &property_id, 1 }, tokens)
|
return parse_css_value_for_properties({ &property_id, 1 }, tokens)
|
||||||
.map([](auto& it) { return it.style_value; })
|
.map([](auto& it) { return it.style_value; })
|
||||||
|
@ -7885,10 +7885,10 @@ bool Parser::has_ignored_vendor_prefix(StringView string)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> Parser::resolve_unresolved_style_value(ParsingContext const& context, DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
|
NonnullRefPtr<CSSStyleValue> Parser::resolve_unresolved_style_value(ParsingContext const& context, DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
|
||||||
{
|
{
|
||||||
// Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying
|
// Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying
|
||||||
// to produce a different StyleValue from it.
|
// to produce a different CSSStyleValue from it.
|
||||||
VERIFY(unresolved.contains_var_or_attr());
|
VERIFY(unresolved.contains_var_or_attr());
|
||||||
|
|
||||||
// If the value is invalid, we fall back to `unset`: https://www.w3.org/TR/css-variables-1/#invalid-at-computed-value-time
|
// If the value is invalid, we fall back to `unset`: https://www.w3.org/TR/css-variables-1/#invalid-at-computed-value-time
|
||||||
|
@ -7940,7 +7940,7 @@ private:
|
||||||
bool m_marked { false };
|
bool m_marked { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> Parser::resolve_unresolved_style_value(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
|
NonnullRefPtr<CSSStyleValue> Parser::resolve_unresolved_style_value(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
|
||||||
{
|
{
|
||||||
TokenStream unresolved_values_without_variables_expanded { unresolved.values() };
|
TokenStream unresolved_values_without_variables_expanded { unresolved.values() };
|
||||||
Vector<ComponentValue> values_with_variables_expanded;
|
Vector<ComponentValue> values_with_variables_expanded;
|
||||||
|
@ -7961,7 +7961,7 @@ NonnullRefPtr<StyleValue> Parser::resolve_unresolved_style_value(DOM::Element& e
|
||||||
return UnsetStyleValue::the();
|
return UnsetStyleValue::the();
|
||||||
}
|
}
|
||||||
|
|
||||||
static RefPtr<StyleValue const> get_custom_property(DOM::Element const& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, FlyString const& custom_property_name)
|
static RefPtr<CSSStyleValue const> get_custom_property(DOM::Element const& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, FlyString const& custom_property_name)
|
||||||
{
|
{
|
||||||
if (pseudo_element.has_value()) {
|
if (pseudo_element.has_value()) {
|
||||||
if (auto it = element.custom_properties(pseudo_element).find(custom_property_name); it != element.custom_properties(pseudo_element).end())
|
if (auto it = element.custom_properties(pseudo_element).find(custom_property_name); it != element.custom_properties(pseudo_element).end())
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/Font/UnicodeRange.h>
|
#include <LibGfx/Font/UnicodeRange.h>
|
||||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/GeneralEnclosed.h>
|
#include <LibWeb/CSS/GeneralEnclosed.h>
|
||||||
#include <LibWeb/CSS/MediaQuery.h>
|
#include <LibWeb/CSS/MediaQuery.h>
|
||||||
#include <LibWeb/CSS/ParsedFontFace.h>
|
#include <LibWeb/CSS/ParsedFontFace.h>
|
||||||
|
@ -28,7 +29,6 @@
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/Ratio.h>
|
#include <LibWeb/CSS/Ratio.h>
|
||||||
#include <LibWeb/CSS/Selector.h>
|
#include <LibWeb/CSS/Selector.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||||
#include <LibWeb/CSS/Supports.h>
|
#include <LibWeb/CSS/Supports.h>
|
||||||
|
@ -67,13 +67,13 @@ public:
|
||||||
|
|
||||||
RefPtr<Supports> parse_as_supports();
|
RefPtr<Supports> parse_as_supports();
|
||||||
|
|
||||||
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
RefPtr<CSSStyleValue> parse_as_css_value(PropertyID);
|
||||||
|
|
||||||
Optional<ComponentValue> parse_as_component_value();
|
Optional<ComponentValue> parse_as_component_value();
|
||||||
|
|
||||||
Vector<ParsedFontFace::Source> parse_as_font_face_src();
|
Vector<ParsedFontFace::Source> parse_as_font_face_src();
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue> resolve_unresolved_style_value(ParsingContext const&, DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, PropertyID, UnresolvedStyleValue const&);
|
static NonnullRefPtr<CSSStyleValue> resolve_unresolved_style_value(ParsingContext const&, DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, PropertyID, UnresolvedStyleValue const&);
|
||||||
|
|
||||||
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute();
|
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute();
|
||||||
|
|
||||||
|
@ -262,107 +262,107 @@ private:
|
||||||
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
|
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
|
||||||
|
|
||||||
Optional<URL::URL> parse_url_function(TokenStream<ComponentValue>&);
|
Optional<URL::URL> parse_url_function(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_url_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_url_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
RefPtr<StyleValue> parse_basic_shape_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_basic_shape_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
template<typename TElement>
|
template<typename TElement>
|
||||||
Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto is_position, auto get_position);
|
Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto is_position, auto get_position);
|
||||||
Optional<Vector<LinearColorStopListElement>> parse_linear_color_stop_list(TokenStream<ComponentValue>&);
|
Optional<Vector<LinearColorStopListElement>> parse_linear_color_stop_list(TokenStream<ComponentValue>&);
|
||||||
Optional<Vector<AngularColorStopListElement>> parse_angular_color_stop_list(TokenStream<ComponentValue>&);
|
Optional<Vector<AngularColorStopListElement>> parse_angular_color_stop_list(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
RefPtr<StyleValue> parse_linear_gradient_function(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_linear_gradient_function(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_conic_gradient_function(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_conic_gradient_function(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_radial_gradient_function(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_radial_gradient_function(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
ParseErrorOr<NonnullRefPtr<StyleValue>> parse_css_value(PropertyID, TokenStream<ComponentValue>&);
|
ParseErrorOr<NonnullRefPtr<CSSStyleValue>> parse_css_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&);
|
||||||
struct PropertyAndValue {
|
struct PropertyAndValue {
|
||||||
PropertyID property;
|
PropertyID property;
|
||||||
RefPtr<StyleValue> style_value;
|
RefPtr<CSSStyleValue> style_value;
|
||||||
};
|
};
|
||||||
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
|
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_builtin_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_builtin_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<CalculatedStyleValue> parse_calculated_value(ComponentValue const&);
|
RefPtr<CalculatedStyleValue> parse_calculated_value(ComponentValue const&);
|
||||||
RefPtr<CustomIdentStyleValue> parse_custom_ident_value(TokenStream<ComponentValue>&, std::initializer_list<StringView> blacklist);
|
RefPtr<CustomIdentStyleValue> parse_custom_ident_value(TokenStream<ComponentValue>&, std::initializer_list<StringView> blacklist);
|
||||||
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
|
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
|
||||||
OwnPtr<CalculationNode> parse_math_function(PropertyID, Function const&);
|
OwnPtr<CalculationNode> parse_math_function(PropertyID, Function const&);
|
||||||
OwnPtr<CalculationNode> parse_a_calc_function_node(Function const&);
|
OwnPtr<CalculationNode> parse_a_calc_function_node(Function const&);
|
||||||
RefPtr<StyleValue> parse_dimension_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_dimension_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_integer_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_integer_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_number_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_number_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_number_or_percentage_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_number_or_percentage_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_identifier_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_identifier_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_color_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_color_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_counter_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_counter_value(TokenStream<ComponentValue>&);
|
||||||
enum class AllowReversed {
|
enum class AllowReversed {
|
||||||
No,
|
No,
|
||||||
Yes,
|
Yes,
|
||||||
};
|
};
|
||||||
RefPtr<StyleValue> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed);
|
RefPtr<CSSStyleValue> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed);
|
||||||
RefPtr<StyleValue> parse_rect_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_rect_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_ratio_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_ratio_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_string_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_string_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_image_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_image_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_paint_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_paint_value(TokenStream<ComponentValue>&);
|
||||||
enum class PositionParsingMode {
|
enum class PositionParsingMode {
|
||||||
Normal,
|
Normal,
|
||||||
BackgroundPosition,
|
BackgroundPosition,
|
||||||
};
|
};
|
||||||
RefPtr<PositionStyleValue> parse_position_value(TokenStream<ComponentValue>&, PositionParsingMode = PositionParsingMode::Normal);
|
RefPtr<PositionStyleValue> parse_position_value(TokenStream<ComponentValue>&, PositionParsingMode = PositionParsingMode::Normal);
|
||||||
RefPtr<StyleValue> parse_filter_value_list_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_filter_value_list_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
template<typename ParseFunction>
|
template<typename ParseFunction>
|
||||||
RefPtr<StyleValue> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
|
RefPtr<CSSStyleValue> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
|
||||||
RefPtr<StyleValue> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_all_as_single_none_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_all_as_single_none_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
RefPtr<StyleValue> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_background_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_background_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID);
|
RefPtr<CSSStyleValue> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID);
|
||||||
RefPtr<StyleValue> parse_single_background_repeat_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_single_background_repeat_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_single_background_size_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_single_background_size_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_border_value(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_border_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_border_radius_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_border_radius_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_content_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_content_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_counter_increment_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_counter_increment_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_counter_reset_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_counter_reset_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_counter_set_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_counter_set_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_display_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_display_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_flex_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_flex_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_font_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_font_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_font_family_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_font_family_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_list_style_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_list_style_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_math_depth_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_math_depth_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_overflow_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_overflow_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_content_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_place_content_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_items_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_place_items_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_self_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_place_self_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&);
|
||||||
enum class AllowInsetKeyword {
|
enum class AllowInsetKeyword {
|
||||||
No,
|
No,
|
||||||
Yes,
|
Yes,
|
||||||
};
|
};
|
||||||
RefPtr<StyleValue> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
RefPtr<CSSStyleValue> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||||
RefPtr<StyleValue> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
RefPtr<CSSStyleValue> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||||
RefPtr<StyleValue> parse_text_decoration_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_text_decoration_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_text_decoration_line_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_text_decoration_line_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_easing_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_easing_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_transform_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_transform_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_transform_origin_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_transform_origin_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_transition_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_transition_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_track_size_list(TokenStream<ComponentValue>&, bool allow_separate_line_name_blocks = false);
|
RefPtr<CSSStyleValue> parse_grid_track_size_list(TokenStream<ComponentValue>&, bool allow_separate_line_name_blocks = false);
|
||||||
RefPtr<StyleValue> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
|
||||||
RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(TokenStream<ComponentValue>&);
|
RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_track_placement(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_track_placement(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_template_areas_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_template_areas_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_shorthand_value(TokenStream<ComponentValue>&);
|
RefPtr<CSSStyleValue> parse_grid_shorthand_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
OwnPtr<CalculationNode> parse_a_calculation(Vector<ComponentValue> const&);
|
OwnPtr<CalculationNode> parse_a_calculation(Vector<ComponentValue> const&);
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ private:
|
||||||
Optional<Supports::InParens> parse_supports_in_parens(TokenStream<ComponentValue>&);
|
Optional<Supports::InParens> parse_supports_in_parens(TokenStream<ComponentValue>&);
|
||||||
Optional<Supports::Feature> parse_supports_feature(TokenStream<ComponentValue>&);
|
Optional<Supports::Feature> parse_supports_feature(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> resolve_unresolved_style_value(DOM::Element&, Optional<Selector::PseudoElement::Type>, PropertyID, UnresolvedStyleValue const&);
|
NonnullRefPtr<CSSStyleValue> resolve_unresolved_style_value(DOM::Element&, Optional<Selector::PseudoElement::Type>, PropertyID, UnresolvedStyleValue const&);
|
||||||
bool expand_variables(DOM::Element&, Optional<Selector::PseudoElement::Type>, FlyString const& property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
|
bool expand_variables(DOM::Element&, Optional<Selector::PseudoElement::Type>, FlyString const& property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
|
||||||
bool expand_unresolved_values(DOM::Element&, FlyString const& property_name, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
|
bool expand_unresolved_values(DOM::Element&, FlyString const& property_name, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
|
||||||
bool substitute_attr_function(DOM::Element& element, FlyString const& property_name, Function const& attr_function, Vector<ComponentValue>& dest);
|
bool substitute_attr_function(DOM::Element& element, FlyString const& property_name, Function const& attr_function, Vector<ComponentValue>& dest);
|
||||||
|
@ -415,7 +415,7 @@ namespace Web {
|
||||||
|
|
||||||
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<URL::URL> location = {});
|
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<URL::URL> location = {});
|
||||||
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&);
|
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&);
|
||||||
RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
|
RefPtr<CSS::CSSStyleValue> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
|
||||||
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);
|
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);
|
||||||
Optional<CSS::Selector::PseudoElement> parse_pseudo_element_selector(CSS::Parser::ParsingContext const&, StringView);
|
Optional<CSS::Selector::PseudoElement> parse_pseudo_element_selector(CSS::Parser::ParsingContext const&, StringView);
|
||||||
CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const&, StringView);
|
CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const&, StringView);
|
||||||
|
|
|
@ -83,7 +83,7 @@ String ResolvedCSSStyleDeclaration::item(size_t index) const
|
||||||
return string_from_property_id(property_id).to_string();
|
return string_from_property_id(property_id).to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> style_value_for_background_property(Layout::NodeWithStyle const& layout_node, Function<NonnullRefPtr<StyleValue const>(BackgroundLayerData const&)> callback, Function<NonnullRefPtr<StyleValue const>()> default_value)
|
static NonnullRefPtr<CSSStyleValue const> style_value_for_background_property(Layout::NodeWithStyle const& layout_node, Function<NonnullRefPtr<CSSStyleValue const>(BackgroundLayerData const&)> callback, Function<NonnullRefPtr<CSSStyleValue const>()> default_value)
|
||||||
{
|
{
|
||||||
auto const& background_layers = layout_node.background_layers();
|
auto const& background_layers = layout_node.background_layers();
|
||||||
if (background_layers.is_empty())
|
if (background_layers.is_empty())
|
||||||
|
@ -97,7 +97,7 @@ static NonnullRefPtr<StyleValue const> style_value_for_background_property(Layou
|
||||||
return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
|
return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
|
static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
|
||||||
{
|
{
|
||||||
if (length_percentage.is_auto())
|
if (length_percentage.is_auto())
|
||||||
return IdentifierStyleValue::create(ValueID::Auto);
|
return IdentifierStyleValue::create(ValueID::Auto);
|
||||||
|
@ -108,7 +108,7 @@ static NonnullRefPtr<StyleValue const> style_value_for_length_percentage(LengthP
|
||||||
return length_percentage.calculated();
|
return length_percentage.calculated();
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> style_value_for_size(Size const& size)
|
static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size)
|
||||||
{
|
{
|
||||||
if (size.is_none())
|
if (size.is_none())
|
||||||
return IdentifierStyleValue::create(ValueID::None);
|
return IdentifierStyleValue::create(ValueID::None);
|
||||||
|
@ -130,7 +130,7 @@ static NonnullRefPtr<StyleValue const> style_value_for_size(Size const& size)
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> style_value_for_sided_shorthand(ValueComparingNonnullRefPtr<StyleValue const> top, ValueComparingNonnullRefPtr<StyleValue const> right, ValueComparingNonnullRefPtr<StyleValue const> bottom, ValueComparingNonnullRefPtr<StyleValue const> left)
|
static NonnullRefPtr<CSSStyleValue const> style_value_for_sided_shorthand(ValueComparingNonnullRefPtr<CSSStyleValue const> top, ValueComparingNonnullRefPtr<CSSStyleValue const> right, ValueComparingNonnullRefPtr<CSSStyleValue const> bottom, ValueComparingNonnullRefPtr<CSSStyleValue const> left)
|
||||||
{
|
{
|
||||||
bool top_and_bottom_same = top == bottom;
|
bool top_and_bottom_same = top == bottom;
|
||||||
bool left_and_right_same = left == right;
|
bool left_and_right_same = left == right;
|
||||||
|
@ -153,7 +153,7 @@ enum class LogicalSide {
|
||||||
InlineStart,
|
InlineStart,
|
||||||
InlineEnd,
|
InlineEnd,
|
||||||
};
|
};
|
||||||
static RefPtr<StyleValue const> style_value_for_length_box_logical_side(Layout::NodeWithStyle const&, LengthBox const& box, LogicalSide logical_side)
|
static RefPtr<CSSStyleValue const> style_value_for_length_box_logical_side(Layout::NodeWithStyle const&, LengthBox const& box, LogicalSide logical_side)
|
||||||
{
|
{
|
||||||
// FIXME: Actually determine the logical sides based on layout_node's writing-mode and direction.
|
// FIXME: Actually determine the logical sides based on layout_node's writing-mode and direction.
|
||||||
switch (logical_side) {
|
switch (logical_side) {
|
||||||
|
@ -169,7 +169,7 @@ static RefPtr<StyleValue const> style_value_for_length_box_logical_side(Layout::
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
static RefPtr<StyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
|
static RefPtr<CSSStyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
|
||||||
{
|
{
|
||||||
if (shadow_data.is_empty())
|
if (shadow_data.is_empty())
|
||||||
return IdentifierStyleValue::create(ValueID::None);
|
return IdentifierStyleValue::create(ValueID::None);
|
||||||
|
@ -195,7 +195,7 @@ static RefPtr<StyleValue const> style_value_for_shadow(Vector<ShadowData> const&
|
||||||
return StyleValueList::create(move(style_values), StyleValueList::Separator::Comma);
|
return StyleValueList::create(move(style_values), StyleValueList::Separator::Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
|
RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
|
||||||
{
|
{
|
||||||
auto used_value_for_property = [&layout_node, property_id](Function<CSSPixels(Painting::PaintableBox const&)>&& used_value_getter) -> Optional<CSSPixels> {
|
auto used_value_for_property = [&layout_node, property_id](Function<CSSPixels(Painting::PaintableBox const&)>&& used_value_getter) -> Optional<CSSPixels> {
|
||||||
auto const& display = layout_node.computed_values().display();
|
auto const& display = layout_node.computed_values().display();
|
||||||
|
@ -457,12 +457,12 @@ RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(L
|
||||||
case PropertyID::BackgroundPosition:
|
case PropertyID::BackgroundPosition:
|
||||||
return style_value_for_background_property(
|
return style_value_for_background_property(
|
||||||
layout_node,
|
layout_node,
|
||||||
[](auto& layer) -> NonnullRefPtr<StyleValue> {
|
[](auto& layer) -> NonnullRefPtr<CSSStyleValue> {
|
||||||
return PositionStyleValue::create(
|
return PositionStyleValue::create(
|
||||||
EdgeStyleValue::create(layer.position_edge_x, layer.position_offset_x),
|
EdgeStyleValue::create(layer.position_edge_x, layer.position_offset_x),
|
||||||
EdgeStyleValue::create(layer.position_edge_y, layer.position_offset_y));
|
EdgeStyleValue::create(layer.position_edge_y, layer.position_offset_y));
|
||||||
},
|
},
|
||||||
[]() -> NonnullRefPtr<StyleValue> {
|
[]() -> NonnullRefPtr<CSSStyleValue> {
|
||||||
return PositionStyleValue::create(
|
return PositionStyleValue::create(
|
||||||
EdgeStyleValue::create(PositionEdge::Left, Percentage(0)),
|
EdgeStyleValue::create(PositionEdge::Left, Percentage(0)),
|
||||||
EdgeStyleValue::create(PositionEdge::Top, Percentage(0)));
|
EdgeStyleValue::create(PositionEdge::Top, Percentage(0)));
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
RefPtr<StyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||||
|
|
||||||
JS::NonnullGCPtr<DOM::Element> m_element;
|
JS::NonnullGCPtr<DOM::Element> m_element;
|
||||||
Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
|
Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
|
||||||
|
|
|
@ -429,7 +429,7 @@ static void sort_matching_rules(Vector<MatchingRule>& matching_rules)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_id, StyleValue const& value, AllowUnresolved allow_unresolved, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property)
|
void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_id, CSSStyleValue const& value, AllowUnresolved allow_unresolved, Function<void(PropertyID, CSSStyleValue const&)> const& set_longhand_property)
|
||||||
{
|
{
|
||||||
auto map_logical_property_to_real_property = [](PropertyID property_id) -> Optional<PropertyID> {
|
auto map_logical_property_to_real_property = [](PropertyID property_id) -> Optional<PropertyID> {
|
||||||
// FIXME: Honor writing-mode, direction and text-orientation.
|
// FIXME: Honor writing-mode, direction and text-orientation.
|
||||||
|
@ -791,7 +791,7 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto const& transitions = value.as_transition().transitions();
|
auto const& transitions = value.as_transition().transitions();
|
||||||
Array<Vector<ValueComparingNonnullRefPtr<StyleValue const>>, 4> transition_values;
|
Array<Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>>, 4> transition_values;
|
||||||
for (auto const& transition : transitions) {
|
for (auto const& transition : transitions) {
|
||||||
transition_values[0].append(*transition.property_name);
|
transition_values[0].append(*transition.property_name);
|
||||||
transition_values[1].append(transition.duration.as_style_value());
|
transition_values[1].append(transition.duration.as_style_value());
|
||||||
|
@ -835,9 +835,9 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
||||||
set_longhand_property(property_id, value);
|
set_longhand_property(property_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleComputer::set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, StyleValue const& value, CSS::CSSStyleDeclaration const* declaration, StyleProperties const& style_for_revert, Important important)
|
void StyleComputer::set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, CSSStyleValue const& value, CSS::CSSStyleDeclaration const* declaration, StyleProperties const& style_for_revert, Important important)
|
||||||
{
|
{
|
||||||
for_each_property_expanding_shorthands(property_id, value, AllowUnresolved::No, [&](PropertyID shorthand_id, StyleValue const& shorthand_value) {
|
for_each_property_expanding_shorthands(property_id, value, AllowUnresolved::No, [&](PropertyID shorthand_id, CSSStyleValue const& shorthand_value) {
|
||||||
if (shorthand_value.is_revert()) {
|
if (shorthand_value.is_revert()) {
|
||||||
auto const& property_in_previous_cascade_origin = style_for_revert.m_property_values[to_underlying(shorthand_id)];
|
auto const& property_in_previous_cascade_origin = style_for_revert.m_property_values[to_underlying(shorthand_id)];
|
||||||
if (property_in_previous_cascade_origin) {
|
if (property_in_previous_cascade_origin) {
|
||||||
|
@ -853,7 +853,7 @@ void StyleComputer::set_property_expanding_shorthands(StyleProperties& style, CS
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleComputer::set_all_properties(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, StyleProperties& style, StyleValue const& value, DOM::Document& document, CSS::CSSStyleDeclaration const* declaration, StyleProperties const& style_for_revert, Important important) const
|
void StyleComputer::set_all_properties(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, StyleProperties& style, CSSStyleValue const& value, DOM::Document& document, CSS::CSSStyleDeclaration const* declaration, StyleProperties const& style_for_revert, Important important) const
|
||||||
{
|
{
|
||||||
for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) {
|
for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) {
|
||||||
auto property_id = (CSS::PropertyID)i;
|
auto property_id = (CSS::PropertyID)i;
|
||||||
|
@ -880,7 +880,7 @@ void StyleComputer::set_all_properties(DOM::Element& element, Optional<CSS::Sele
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue> property_value = value;
|
NonnullRefPtr<CSSStyleValue> property_value = value;
|
||||||
if (property_value->is_unresolved())
|
if (property_value->is_unresolved())
|
||||||
property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingContext { document }, element, pseudo_element, property_id, property_value->as_unresolved());
|
property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingContext { document }, element, pseudo_element, property_id, property_value->as_unresolved());
|
||||||
if (!property_value->is_unresolved())
|
if (!property_value->is_unresolved())
|
||||||
|
@ -964,7 +964,7 @@ static void cascade_custom_properties(DOM::Element& element, Optional<CSS::Selec
|
||||||
element.set_custom_properties(pseudo_element, move(custom_properties));
|
element.set_custom_properties(pseudo_element, move(custom_properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element, StyleValue const& from, StyleValue const& to, float delta);
|
static NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, CSSStyleValue const& from, CSSStyleValue const& to, float delta);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T interpolate_raw(T from, T to, float delta)
|
static T interpolate_raw(T from, T to, float delta)
|
||||||
|
@ -977,7 +977,7 @@ static T interpolate_raw(T from, T to, float delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A null return value means the interpolated matrix was not invertible or otherwise invalid
|
// A null return value means the interpolated matrix was not invertible or otherwise invalid
|
||||||
static RefPtr<StyleValue const> interpolate_transform(DOM::Element& element, StyleValue const& from, StyleValue const& to, float delta)
|
static RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyleValue const& from, CSSStyleValue const& to, float delta)
|
||||||
{
|
{
|
||||||
// Note that the spec uses column-major notation, so all the matrix indexing is reversed.
|
// Note that the spec uses column-major notation, so all the matrix indexing is reversed.
|
||||||
|
|
||||||
|
@ -986,19 +986,19 @@ static RefPtr<StyleValue const> interpolate_transform(DOM::Element& element, Sty
|
||||||
|
|
||||||
for (auto const& value : transformation.values()) {
|
for (auto const& value : transformation.values()) {
|
||||||
switch (value->type()) {
|
switch (value->type()) {
|
||||||
case StyleValue::Type::Angle:
|
case CSSStyleValue::Type::Angle:
|
||||||
values.append(AngleOrCalculated { value->as_angle().angle() });
|
values.append(AngleOrCalculated { value->as_angle().angle() });
|
||||||
break;
|
break;
|
||||||
case StyleValue::Type::Calculated:
|
case CSSStyleValue::Type::Calculated:
|
||||||
values.append(LengthPercentage { value->as_calculated() });
|
values.append(LengthPercentage { value->as_calculated() });
|
||||||
break;
|
break;
|
||||||
case StyleValue::Type::Length:
|
case CSSStyleValue::Type::Length:
|
||||||
values.append(LengthPercentage { value->as_length().length() });
|
values.append(LengthPercentage { value->as_length().length() });
|
||||||
break;
|
break;
|
||||||
case StyleValue::Type::Percentage:
|
case CSSStyleValue::Type::Percentage:
|
||||||
values.append(LengthPercentage { value->as_percentage().percentage() });
|
values.append(LengthPercentage { value->as_percentage().percentage() });
|
||||||
break;
|
break;
|
||||||
case StyleValue::Type::Number:
|
case CSSStyleValue::Type::Number:
|
||||||
values.append(NumberPercentage { Number(Number::Type::Number, value->as_number().number()) });
|
values.append(NumberPercentage { Number(Number::Type::Number, value->as_number().number()) });
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1023,7 +1023,7 @@ static RefPtr<StyleValue const> interpolate_transform(DOM::Element& element, Sty
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto style_value_to_matrix = [](DOM::Element& element, StyleValue const& value) -> FloatMatrix4x4 {
|
static constexpr auto style_value_to_matrix = [](DOM::Element& element, CSSStyleValue const& value) -> FloatMatrix4x4 {
|
||||||
if (value.is_transformation())
|
if (value.is_transformation())
|
||||||
return transformation_style_value_to_matrix(element, value.as_transformation()).value_or(FloatMatrix4x4::identity());
|
return transformation_style_value_to_matrix(element, value.as_transformation()).value_or(FloatMatrix4x4::identity());
|
||||||
|
|
||||||
|
@ -1291,14 +1291,14 @@ static Color interpolate_color(Color from, Color to, float delta)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, StyleValue const& from, StyleValue const& to, float delta)
|
static NonnullRefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& element, CSSStyleValue const& from, CSSStyleValue const& to, float delta)
|
||||||
{
|
{
|
||||||
// https://drafts.csswg.org/css-backgrounds/#box-shadow
|
// https://drafts.csswg.org/css-backgrounds/#box-shadow
|
||||||
// Animation type: by computed value, treating none as a zero-item list and appending blank shadows
|
// Animation type: by computed value, treating none as a zero-item list and appending blank shadows
|
||||||
// (transparent 0 0 0 0) with a corresponding inset keyword as needed to match the longer list if
|
// (transparent 0 0 0 0) with a corresponding inset keyword as needed to match the longer list if
|
||||||
// the shorter list is otherwise compatible with the longer one
|
// the shorter list is otherwise compatible with the longer one
|
||||||
|
|
||||||
static constexpr auto process_list = [](StyleValue const& value) {
|
static constexpr auto process_list = [](CSSStyleValue const& value) {
|
||||||
StyleValueVector shadows;
|
StyleValueVector shadows;
|
||||||
if (value.is_value_list()) {
|
if (value.is_value_list()) {
|
||||||
for (auto const& element : value.as_value_list().values()) {
|
for (auto const& element : value.as_value_list().values()) {
|
||||||
|
@ -1352,7 +1352,7 @@ static NonnullRefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& elem
|
||||||
return StyleValueList::create(move(result_shadows), StyleValueList::Separator::Comma);
|
return StyleValueList::create(move(result_shadows), StyleValueList::Separator::Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element, StyleValue const& from, StyleValue const& to, float delta)
|
static NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, CSSStyleValue const& from, CSSStyleValue const& to, float delta)
|
||||||
{
|
{
|
||||||
if (from.type() != to.type()) {
|
if (from.type() != to.type()) {
|
||||||
// Handle mixed percentage and dimension types
|
// Handle mixed percentage and dimension types
|
||||||
|
@ -1360,27 +1360,27 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
|
|
||||||
struct NumericBaseTypeAndDefault {
|
struct NumericBaseTypeAndDefault {
|
||||||
CSSNumericType::BaseType base_type;
|
CSSNumericType::BaseType base_type;
|
||||||
ValueComparingNonnullRefPtr<CSS::StyleValue> default_value;
|
ValueComparingNonnullRefPtr<CSSStyleValue> default_value;
|
||||||
};
|
};
|
||||||
static constexpr auto numeric_base_type_and_default = [](StyleValue const& value) -> Optional<NumericBaseTypeAndDefault> {
|
static constexpr auto numeric_base_type_and_default = [](CSSStyleValue const& value) -> Optional<NumericBaseTypeAndDefault> {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case StyleValue::Type::Angle: {
|
case CSSStyleValue::Type::Angle: {
|
||||||
static auto default_angle_value = AngleStyleValue::create(Angle::make_degrees(0));
|
static auto default_angle_value = AngleStyleValue::create(Angle::make_degrees(0));
|
||||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Angle, default_angle_value };
|
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Angle, default_angle_value };
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Frequency: {
|
case CSSStyleValue::Type::Frequency: {
|
||||||
static auto default_frequency_value = FrequencyStyleValue::create(Frequency::make_hertz(0));
|
static auto default_frequency_value = FrequencyStyleValue::create(Frequency::make_hertz(0));
|
||||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Frequency, default_frequency_value };
|
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Frequency, default_frequency_value };
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Length: {
|
case CSSStyleValue::Type::Length: {
|
||||||
static auto default_length_value = LengthStyleValue::create(Length::make_px(0));
|
static auto default_length_value = LengthStyleValue::create(Length::make_px(0));
|
||||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Length, default_length_value };
|
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Length, default_length_value };
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Percentage: {
|
case CSSStyleValue::Type::Percentage: {
|
||||||
static auto default_percentage_value = PercentageStyleValue::create(Percentage { 0.0 });
|
static auto default_percentage_value = PercentageStyleValue::create(Percentage { 0.0 });
|
||||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Percent, default_percentage_value };
|
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Percent, default_percentage_value };
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Time: {
|
case CSSStyleValue::Type::Time: {
|
||||||
static auto default_time_value = TimeStyleValue::create(Time::make_seconds(0));
|
static auto default_time_value = TimeStyleValue::create(Time::make_seconds(0));
|
||||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Time, default_time_value };
|
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Time, default_time_value };
|
||||||
}
|
}
|
||||||
|
@ -1389,17 +1389,17 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto to_calculation_node = [](StyleValue const& value) -> NonnullOwnPtr<CalculationNode> {
|
static constexpr auto to_calculation_node = [](CSSStyleValue const& value) -> NonnullOwnPtr<CalculationNode> {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case StyleValue::Type::Angle:
|
case CSSStyleValue::Type::Angle:
|
||||||
return NumericCalculationNode::create(value.as_angle().angle());
|
return NumericCalculationNode::create(value.as_angle().angle());
|
||||||
case StyleValue::Type::Frequency:
|
case CSSStyleValue::Type::Frequency:
|
||||||
return NumericCalculationNode::create(value.as_frequency().frequency());
|
return NumericCalculationNode::create(value.as_frequency().frequency());
|
||||||
case StyleValue::Type::Length:
|
case CSSStyleValue::Type::Length:
|
||||||
return NumericCalculationNode::create(value.as_length().length());
|
return NumericCalculationNode::create(value.as_length().length());
|
||||||
case StyleValue::Type::Percentage:
|
case CSSStyleValue::Type::Percentage:
|
||||||
return NumericCalculationNode::create(value.as_percentage().percentage());
|
return NumericCalculationNode::create(value.as_percentage().percentage());
|
||||||
case StyleValue::Type::Time:
|
case CSSStyleValue::Type::Time:
|
||||||
return NumericCalculationNode::create(value.as_time().time());
|
return NumericCalculationNode::create(value.as_time().time());
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -1430,22 +1430,22 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (from.type()) {
|
switch (from.type()) {
|
||||||
case StyleValue::Type::Angle:
|
case CSSStyleValue::Type::Angle:
|
||||||
return AngleStyleValue::create(Angle::make_degrees(interpolate_raw(from.as_angle().angle().to_degrees(), to.as_angle().angle().to_degrees(), delta)));
|
return AngleStyleValue::create(Angle::make_degrees(interpolate_raw(from.as_angle().angle().to_degrees(), to.as_angle().angle().to_degrees(), delta)));
|
||||||
case StyleValue::Type::Color:
|
case CSSStyleValue::Type::Color:
|
||||||
return ColorStyleValue::create(interpolate_color(from.as_color().color(), to.as_color().color(), delta));
|
return ColorStyleValue::create(interpolate_color(from.as_color().color(), to.as_color().color(), delta));
|
||||||
case StyleValue::Type::Integer:
|
case CSSStyleValue::Type::Integer:
|
||||||
return IntegerStyleValue::create(interpolate_raw(from.as_integer().integer(), to.as_integer().integer(), delta));
|
return IntegerStyleValue::create(interpolate_raw(from.as_integer().integer(), to.as_integer().integer(), delta));
|
||||||
case StyleValue::Type::Length: {
|
case CSSStyleValue::Type::Length: {
|
||||||
auto& from_length = from.as_length().length();
|
auto& from_length = from.as_length().length();
|
||||||
auto& to_length = to.as_length().length();
|
auto& to_length = to.as_length().length();
|
||||||
return LengthStyleValue::create(Length(interpolate_raw(from_length.raw_value(), to_length.raw_value(), delta), from_length.type()));
|
return LengthStyleValue::create(Length(interpolate_raw(from_length.raw_value(), to_length.raw_value(), delta), from_length.type()));
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Number:
|
case CSSStyleValue::Type::Number:
|
||||||
return NumberStyleValue::create(interpolate_raw(from.as_number().number(), to.as_number().number(), delta));
|
return NumberStyleValue::create(interpolate_raw(from.as_number().number(), to.as_number().number(), delta));
|
||||||
case StyleValue::Type::Percentage:
|
case CSSStyleValue::Type::Percentage:
|
||||||
return PercentageStyleValue::create(Percentage(interpolate_raw(from.as_percentage().percentage().value(), to.as_percentage().percentage().value(), delta)));
|
return PercentageStyleValue::create(Percentage(interpolate_raw(from.as_percentage().percentage().value(), to.as_percentage().percentage().value(), delta)));
|
||||||
case StyleValue::Type::Position: {
|
case CSSStyleValue::Type::Position: {
|
||||||
// https://www.w3.org/TR/css-values-4/#combine-positions
|
// https://www.w3.org/TR/css-values-4/#combine-positions
|
||||||
// FIXME: Interpolation of <position> is defined as the independent interpolation of each component (x, y) normalized as an offset from the top left corner as a <length-percentage>.
|
// FIXME: Interpolation of <position> is defined as the independent interpolation of each component (x, y) normalized as an offset from the top left corner as a <length-percentage>.
|
||||||
auto& from_position = from.as_position();
|
auto& from_position = from.as_position();
|
||||||
|
@ -1454,7 +1454,7 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
interpolate_value(element, from_position.edge_x(), to_position.edge_x(), delta)->as_edge(),
|
interpolate_value(element, from_position.edge_x(), to_position.edge_x(), delta)->as_edge(),
|
||||||
interpolate_value(element, from_position.edge_y(), to_position.edge_y(), delta)->as_edge());
|
interpolate_value(element, from_position.edge_y(), to_position.edge_y(), delta)->as_edge());
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Ratio: {
|
case CSSStyleValue::Type::Ratio: {
|
||||||
auto from_ratio = from.as_ratio().ratio();
|
auto from_ratio = from.as_ratio().ratio();
|
||||||
auto to_ratio = to.as_ratio().ratio();
|
auto to_ratio = to.as_ratio().ratio();
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
auto interp_number = interpolate_raw(from_number, to_number, delta);
|
auto interp_number = interpolate_raw(from_number, to_number, delta);
|
||||||
return RatioStyleValue::create(Ratio(pow(M_E, interp_number)));
|
return RatioStyleValue::create(Ratio(pow(M_E, interp_number)));
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Rect: {
|
case CSSStyleValue::Type::Rect: {
|
||||||
auto from_rect = from.as_rect().rect();
|
auto from_rect = from.as_rect().rect();
|
||||||
auto to_rect = to.as_rect().rect();
|
auto to_rect = to.as_rect().rect();
|
||||||
return RectStyleValue::create({
|
return RectStyleValue::create({
|
||||||
|
@ -1478,9 +1478,9 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
Length(interpolate_raw(from_rect.left_edge.raw_value(), to_rect.left_edge.raw_value(), delta), from_rect.left_edge.type()),
|
Length(interpolate_raw(from_rect.left_edge.raw_value(), to_rect.left_edge.raw_value(), delta), from_rect.left_edge.type()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case StyleValue::Type::Transformation:
|
case CSSStyleValue::Type::Transformation:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
case StyleValue::Type::ValueList: {
|
case CSSStyleValue::Type::ValueList: {
|
||||||
auto& from_list = from.as_value_list();
|
auto& from_list = from.as_value_list();
|
||||||
auto& to_list = to.as_value_list();
|
auto& to_list = to.as_value_list();
|
||||||
if (from_list.size() != to_list.size())
|
if (from_list.size() != to_list.size())
|
||||||
|
@ -1498,7 +1498,7 @@ static NonnullRefPtr<StyleValue const> interpolate_value(DOM::Element& element,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ValueComparingRefPtr<StyleValue const> interpolate_property(DOM::Element& element, PropertyID property_id, StyleValue const& from, StyleValue const& to, float delta)
|
static ValueComparingRefPtr<CSSStyleValue const> interpolate_property(DOM::Element& element, PropertyID property_id, CSSStyleValue const& from, CSSStyleValue const& to, float delta)
|
||||||
{
|
{
|
||||||
auto animation_type = animation_type_from_longhand_property(property_id);
|
auto animation_type = animation_type_from_longhand_property(property_id);
|
||||||
switch (animation_type) {
|
switch (animation_type) {
|
||||||
|
@ -1583,12 +1583,12 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||||
for (auto const& it : keyframe_values.properties) {
|
for (auto const& it : keyframe_values.properties) {
|
||||||
auto resolve_property = [&](auto& property) {
|
auto resolve_property = [&](auto& property) {
|
||||||
return property.visit(
|
return property.visit(
|
||||||
[&](Animations::KeyframeEffect::KeyFrameSet::UseInitial) -> RefPtr<StyleValue const> {
|
[&](Animations::KeyframeEffect::KeyFrameSet::UseInitial) -> RefPtr<CSSStyleValue const> {
|
||||||
if (refresh == AnimationRefresh::Yes)
|
if (refresh == AnimationRefresh::Yes)
|
||||||
return {};
|
return {};
|
||||||
return style_properties.maybe_null_property(it.key);
|
return style_properties.maybe_null_property(it.key);
|
||||||
},
|
},
|
||||||
[&](RefPtr<StyleValue const> value) -> RefPtr<StyleValue const> {
|
[&](RefPtr<CSSStyleValue const> value) -> RefPtr<CSSStyleValue const> {
|
||||||
if (value->is_unresolved())
|
if (value->is_unresolved())
|
||||||
return Parser::Parser::resolve_unresolved_style_value(Parser::ParsingContext { element.document() }, element, pseudo_element, it.key, value->as_unresolved());
|
return Parser::Parser::resolve_unresolved_style_value(Parser::ParsingContext { element.document() }, element, pseudo_element, it.key, value->as_unresolved());
|
||||||
return value;
|
return value;
|
||||||
|
@ -1858,7 +1858,7 @@ DOM::Element const* element_to_inherit_style_from(DOM::Element const* element, O
|
||||||
return parent_element;
|
return parent_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue const> StyleComputer::get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
|
NonnullRefPtr<CSSStyleValue const> StyleComputer::get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
|
||||||
{
|
{
|
||||||
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
||||||
|
|
||||||
|
@ -2039,7 +2039,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::font_matching_algorithm(FontFa
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, StyleValue const& font_family, StyleValue const& font_size, StyleValue const& font_style, StyleValue const& font_weight, StyleValue const& font_stretch, int math_depth) const
|
RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth) const
|
||||||
{
|
{
|
||||||
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
||||||
|
|
||||||
|
@ -2685,9 +2685,9 @@ NonnullOwnPtr<StyleComputer::RuleCache> StyleComputer::make_rule_cache_for_casca
|
||||||
auto const& keyframe_style = *keyframe.style_as_property_owning_style_declaration();
|
auto const& keyframe_style = *keyframe.style_as_property_owning_style_declaration();
|
||||||
for (auto const& it : keyframe_style.properties()) {
|
for (auto const& it : keyframe_style.properties()) {
|
||||||
// Unresolved properties will be resolved in collect_animation_into()
|
// Unresolved properties will be resolved in collect_animation_into()
|
||||||
for_each_property_expanding_shorthands(it.property_id, it.value, AllowUnresolved::Yes, [&](PropertyID shorthand_id, StyleValue const& shorthand_value) {
|
for_each_property_expanding_shorthands(it.property_id, it.value, AllowUnresolved::Yes, [&](PropertyID shorthand_id, CSSStyleValue const& shorthand_value) {
|
||||||
animated_properties.set(shorthand_id);
|
animated_properties.set(shorthand_id);
|
||||||
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<StyleValue const> { shorthand_value });
|
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<CSSStyleValue const> { shorthand_value });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2826,7 +2826,7 @@ void StyleComputer::compute_math_depth(StyleProperties& style, DOM::Element cons
|
||||||
}
|
}
|
||||||
auto& math_depth = value->as_math_depth();
|
auto& math_depth = value->as_math_depth();
|
||||||
|
|
||||||
auto resolve_integer = [&](StyleValue const& integer_value) {
|
auto resolve_integer = [&](CSSStyleValue const& integer_value) {
|
||||||
if (integer_value.is_integer())
|
if (integer_value.is_integer())
|
||||||
return integer_value.as_integer().integer();
|
return integer_value.as_integer().integer();
|
||||||
if (integer_value.is_calculated())
|
if (integer_value.is_calculated())
|
||||||
|
|
|
@ -112,9 +112,9 @@ public:
|
||||||
Yes,
|
Yes,
|
||||||
No,
|
No,
|
||||||
};
|
};
|
||||||
static void for_each_property_expanding_shorthands(PropertyID, StyleValue const&, AllowUnresolved, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property);
|
static void for_each_property_expanding_shorthands(PropertyID, CSSStyleValue const&, AllowUnresolved, Function<void(PropertyID, CSSStyleValue const&)> const& set_longhand_property);
|
||||||
static void set_property_expanding_shorthands(StyleProperties&, PropertyID, StyleValue const&, CSS::CSSStyleDeclaration const*, StyleProperties const& style_for_revert, Important = Important::No);
|
static void set_property_expanding_shorthands(StyleProperties&, PropertyID, CSSStyleValue const&, CSS::CSSStyleDeclaration const*, StyleProperties const& style_for_revert, Important = Important::No);
|
||||||
static NonnullRefPtr<StyleValue const> get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID, DOM::Element const*, Optional<CSS::Selector::PseudoElement::Type> = {});
|
static NonnullRefPtr<CSSStyleValue const> get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID, DOM::Element const*, Optional<CSS::Selector::PseudoElement::Type> = {});
|
||||||
|
|
||||||
explicit StyleComputer(DOM::Document&);
|
explicit StyleComputer(DOM::Document&);
|
||||||
~StyleComputer();
|
~StyleComputer();
|
||||||
|
@ -143,7 +143,7 @@ public:
|
||||||
|
|
||||||
void load_fonts_from_sheet(CSSStyleSheet const&);
|
void load_fonts_from_sheet(CSSStyleSheet const&);
|
||||||
|
|
||||||
RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, StyleValue const& font_family, StyleValue const& font_size, StyleValue const& font_style, StyleValue const& font_weight, StyleValue const& font_stretch, int math_depth = 0) const;
|
RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth = 0) const;
|
||||||
|
|
||||||
void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }
|
void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
|
|
||||||
void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID, Optional<CSS::Selector::PseudoElement::Type>) const;
|
void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID, Optional<CSS::Selector::PseudoElement::Type>) const;
|
||||||
|
|
||||||
void set_all_properties(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, StyleProperties&, StyleValue const&, DOM::Document&, CSS::CSSStyleDeclaration const*, StyleProperties const& style_for_revert, Important = Important::No) const;
|
void set_all_properties(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, StyleProperties&, CSSStyleValue const&, DOM::Document&, CSS::CSSStyleDeclaration const*, StyleProperties const& style_for_revert, Important = Important::No) const;
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_stylesheet(CascadeOrigin, Callback) const;
|
void for_each_stylesheet(CascadeOrigin, Callback) const;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSS::StyleValue const> const& old_value, RefPtr<CSS::StyleValue const> const& new_value)
|
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSSStyleValue const> const& old_value, RefPtr<CSSStyleValue const> const& new_value)
|
||||||
{
|
{
|
||||||
RequiredInvalidationAfterStyleChange invalidation;
|
RequiredInvalidationAfterStyleChange invalidation;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,6 @@ struct RequiredInvalidationAfterStyleChange {
|
||||||
static RequiredInvalidationAfterStyleChange full() { return { true, true, true, true }; }
|
static RequiredInvalidationAfterStyleChange full() { return { true, true, true, true }; }
|
||||||
};
|
};
|
||||||
|
|
||||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSS::StyleValue const> const& old_value, RefPtr<CSS::StyleValue const> const& new_value);
|
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSSStyleValue const> const& old_value, RefPtr<CSSStyleValue const> const& new_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ void StyleProperties::set_property_inherited(CSS::PropertyID property_id, Inheri
|
||||||
m_property_inherited[n / 8] &= ~(1 << (n % 8));
|
m_property_inherited[n / 8] &= ~(1 << (n % 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value, Inherited inherited, Important important)
|
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<CSSStyleValue const> value, Inherited inherited, Important important)
|
||||||
{
|
{
|
||||||
m_property_values[to_underlying(id)] = move(value);
|
m_property_values[to_underlying(id)] = move(value);
|
||||||
set_property_important(id, important);
|
set_property_important(id, important);
|
||||||
|
@ -95,7 +95,7 @@ void StyleProperties::revert_property(CSS::PropertyID id, StyleProperties const&
|
||||||
set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No);
|
set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value)
|
void StyleProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<CSSStyleValue const> value)
|
||||||
{
|
{
|
||||||
m_animated_property_values.set(id, move(value));
|
m_animated_property_values.set(id, move(value));
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void StyleProperties::reset_animated_properties()
|
||||||
m_animated_property_values.clear();
|
m_animated_property_values.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID property_id) const
|
NonnullRefPtr<CSSStyleValue const> StyleProperties::property(CSS::PropertyID property_id) const
|
||||||
{
|
{
|
||||||
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
||||||
return *animated_value;
|
return *animated_value;
|
||||||
|
@ -114,7 +114,7 @@ NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID proper
|
||||||
return *m_property_values[to_underlying(property_id)];
|
return *m_property_values[to_underlying(property_id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const
|
RefPtr<CSSStyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const
|
||||||
{
|
{
|
||||||
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
||||||
return *animated_value;
|
return *animated_value;
|
||||||
|
@ -275,7 +275,7 @@ Optional<int> StyleProperties::z_index() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
float StyleProperties::resolve_opacity_value(CSS::StyleValue const& value)
|
float StyleProperties::resolve_opacity_value(CSSStyleValue const& value)
|
||||||
{
|
{
|
||||||
float unclamped_opacity = 1.0f;
|
float unclamped_opacity = 1.0f;
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ Optional<CSS::JustifySelf> StyleProperties::justify_self() const
|
||||||
return value_id_to_justify_self(value->to_identifier());
|
return value_id_to_justify_self(value->to_identifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(StyleValue const& value)
|
Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(CSSStyleValue const& value)
|
||||||
{
|
{
|
||||||
if (value.is_identifier() && value.to_identifier() == CSS::ValueID::None)
|
if (value.is_identifier() && value.to_identifier() == CSS::ValueID::None)
|
||||||
return {};
|
return {};
|
||||||
|
@ -507,7 +507,7 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
||||||
return transformations_for_style_value(property(CSS::PropertyID::Transform));
|
return transformations_for_style_value(property(CSS::PropertyID::Transform));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Optional<LengthPercentage> length_percentage_for_style_value(StyleValue const& value)
|
static Optional<LengthPercentage> length_percentage_for_style_value(CSSStyleValue const& value)
|
||||||
{
|
{
|
||||||
if (value.is_length())
|
if (value.is_length())
|
||||||
return value.as_length().length();
|
return value.as_length().length();
|
||||||
|
@ -887,7 +887,7 @@ Vector<ShadowData> StyleProperties::shadow(PropertyID property_id, Layout::Node
|
||||||
{
|
{
|
||||||
auto value = property(property_id);
|
auto value = property(property_id);
|
||||||
|
|
||||||
auto resolve_to_length = [&layout_node](NonnullRefPtr<StyleValue const> const& value) -> Optional<Length> {
|
auto resolve_to_length = [&layout_node](NonnullRefPtr<CSSStyleValue const> const& value) -> Optional<Length> {
|
||||||
if (value->is_length())
|
if (value->is_length())
|
||||||
return value->as_length().length();
|
return value->as_length().length();
|
||||||
if (value->is_calculated())
|
if (value->is_calculated())
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
static constexpr size_t number_of_properties = to_underlying(CSS::last_property_id) + 1;
|
static constexpr size_t number_of_properties = to_underlying(CSS::last_property_id) + 1;
|
||||||
|
|
||||||
HashMap<CSS::PropertyID, NonnullRefPtr<StyleValue const>> const& animated_property_values() const { return m_animated_property_values; }
|
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> const& animated_property_values() const { return m_animated_property_values; }
|
||||||
void reset_animated_properties();
|
void reset_animated_properties();
|
||||||
|
|
||||||
bool is_property_important(CSS::PropertyID property_id) const;
|
bool is_property_important(CSS::PropertyID property_id) const;
|
||||||
|
@ -50,10 +50,10 @@ public:
|
||||||
void set_property_important(CSS::PropertyID, Important);
|
void set_property_important(CSS::PropertyID, Important);
|
||||||
void set_property_inherited(CSS::PropertyID, Inherited);
|
void set_property_inherited(CSS::PropertyID, Inherited);
|
||||||
|
|
||||||
void set_property(CSS::PropertyID, NonnullRefPtr<StyleValue const> value, Inherited = Inherited::No, Important = Important::No);
|
void set_property(CSS::PropertyID, NonnullRefPtr<CSSStyleValue const> value, Inherited = Inherited::No, Important = Important::No);
|
||||||
void set_animated_property(CSS::PropertyID, NonnullRefPtr<StyleValue const> value);
|
void set_animated_property(CSS::PropertyID, NonnullRefPtr<CSSStyleValue const> value);
|
||||||
NonnullRefPtr<StyleValue const> property(CSS::PropertyID) const;
|
NonnullRefPtr<CSSStyleValue const> property(CSS::PropertyID) const;
|
||||||
RefPtr<StyleValue const> maybe_null_property(CSS::PropertyID) const;
|
RefPtr<CSSStyleValue const> maybe_null_property(CSS::PropertyID) const;
|
||||||
void revert_property(CSS::PropertyID, StyleProperties const& style_for_revert);
|
void revert_property(CSS::PropertyID, StyleProperties const& style_for_revert);
|
||||||
|
|
||||||
JS::GCPtr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
JS::GCPtr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
||||||
|
@ -132,7 +132,7 @@ public:
|
||||||
Optional<CSS::TableLayout> table_layout() const;
|
Optional<CSS::TableLayout> table_layout() const;
|
||||||
Optional<CSS::Direction> direction() const;
|
Optional<CSS::Direction> direction() const;
|
||||||
|
|
||||||
static Vector<CSS::Transformation> transformations_for_style_value(StyleValue const& value);
|
static Vector<CSS::Transformation> transformations_for_style_value(CSSStyleValue const& value);
|
||||||
Vector<CSS::Transformation> transformations() const;
|
Vector<CSS::Transformation> transformations() const;
|
||||||
Optional<CSS::TransformBox> transform_box() const;
|
Optional<CSS::TransformBox> transform_box() const;
|
||||||
CSS::TransformOrigin transform_origin() const;
|
CSS::TransformOrigin transform_origin() const;
|
||||||
|
@ -178,7 +178,7 @@ public:
|
||||||
|
|
||||||
static NonnullRefPtr<Gfx::Font const> font_fallback(bool monospace, bool bold);
|
static NonnullRefPtr<Gfx::Font const> font_fallback(bool monospace, bool bold);
|
||||||
|
|
||||||
static float resolve_opacity_value(CSS::StyleValue const& value);
|
static float resolve_opacity_value(CSSStyleValue const& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class StyleComputer;
|
friend class StyleComputer;
|
||||||
|
@ -186,11 +186,11 @@ private:
|
||||||
// FIXME: This needs protection from GC!
|
// FIXME: This needs protection from GC!
|
||||||
JS::GCPtr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
JS::GCPtr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
||||||
|
|
||||||
Array<RefPtr<CSS::StyleValue const>, number_of_properties> m_property_values;
|
Array<RefPtr<CSSStyleValue const>, number_of_properties> m_property_values;
|
||||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_important {};
|
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_important {};
|
||||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_inherited {};
|
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_inherited {};
|
||||||
|
|
||||||
HashMap<CSS::PropertyID, NonnullRefPtr<StyleValue const>> m_animated_property_values;
|
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> m_animated_property_values;
|
||||||
|
|
||||||
Optional<CSS::Overflow> overflow(CSS::PropertyID) const;
|
Optional<CSS::Overflow> overflow(CSS::PropertyID) const;
|
||||||
Vector<CSS::ShadowData> shadow(CSS::PropertyID, Layout::Node const&) const;
|
Vector<CSS::ShadowData> shadow(CSS::PropertyID, Layout::Node const&) const;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleProperty.h>
|
#include <LibWeb/CSS/StyleProperty.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct StyleProperty {
|
||||||
|
|
||||||
Important important { Important::No };
|
Important important { Important::No };
|
||||||
CSS::PropertyID property_id;
|
CSS::PropertyID property_id;
|
||||||
NonnullRefPtr<StyleValue const> value;
|
NonnullRefPtr<CSSStyleValue const> value;
|
||||||
FlyString custom_name {};
|
FlyString custom_name {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/Serialize.h>
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class AbstractImageStyleValue : public StyleValue {
|
class AbstractImageStyleValue : public CSSStyleValue {
|
||||||
public:
|
public:
|
||||||
using StyleValue::StyleValue;
|
using CSSStyleValue::CSSStyleValue;
|
||||||
|
|
||||||
virtual Optional<CSSPixels> natural_width() const { return {}; }
|
virtual Optional<CSSPixels> natural_width() const { return {}; }
|
||||||
virtual Optional<CSSPixels> natural_height() const { return {}; }
|
virtual Optional<CSSPixels> natural_height() const { return {}; }
|
||||||
|
@ -58,7 +58,7 @@ struct ColorStopListElement {
|
||||||
|
|
||||||
Optional<ColorHint> transition_hint;
|
Optional<ColorHint> transition_hint;
|
||||||
struct ColorStop {
|
struct ColorStop {
|
||||||
RefPtr<StyleValue> color;
|
RefPtr<CSSStyleValue> color;
|
||||||
Optional<TPosition> position;
|
Optional<TPosition> position;
|
||||||
Optional<TPosition> second_position = {};
|
Optional<TPosition> second_position = {};
|
||||||
inline bool operator==(ColorStop const&) const = default;
|
inline bool operator==(ColorStop const&) const = default;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/Angle.h>
|
#include <LibWeb/CSS/Angle.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
#include <LibGfx/Path.h>
|
#include <LibGfx/Path.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ String BorderRadiusStyleValue::to_string() const
|
||||||
return MUST(String::formatted("{} / {}", m_properties.horizontal_radius.to_string(), m_properties.vertical_radius.to_string()));
|
return MUST(String::formatted("{} / {}", m_properties.horizontal_radius.to_string(), m_properties.vertical_radius.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
ValueComparingNonnullRefPtr<CSSStyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||||
{
|
{
|
||||||
if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage())
|
if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage())
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||||
|
|
||||||
struct Properties {
|
struct Properties {
|
||||||
bool is_elliptical;
|
bool is_elliptical;
|
||||||
|
|
|
@ -2600,7 +2600,7 @@ String CalculatedStyleValue::to_string() const
|
||||||
return MUST(String::formatted("calc({})", m_calculation->to_string()));
|
return MUST(String::formatted("calc({})", m_calculation->to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CalculatedStyleValue::equals(StyleValue const& other) const
|
bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -12,19 +12,19 @@
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <LibWeb/CSS/Angle.h>
|
#include <LibWeb/CSS/Angle.h>
|
||||||
#include <LibWeb/CSS/CSSNumericType.h>
|
#include <LibWeb/CSS/CSSNumericType.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Flex.h>
|
#include <LibWeb/CSS/Flex.h>
|
||||||
#include <LibWeb/CSS/Frequency.h>
|
#include <LibWeb/CSS/Frequency.h>
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/CSS/Percentage.h>
|
#include <LibWeb/CSS/Percentage.h>
|
||||||
#include <LibWeb/CSS/Resolution.h>
|
#include <LibWeb/CSS/Resolution.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/Time.h>
|
#include <LibWeb/CSS/Time.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class CalculationNode;
|
class CalculationNode;
|
||||||
|
|
||||||
class CalculatedStyleValue : public StyleValue {
|
class CalculatedStyleValue : public CSSStyleValue {
|
||||||
public:
|
public:
|
||||||
enum class ResolvedType {
|
enum class ResolvedType {
|
||||||
Angle,
|
Angle,
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const override;
|
String to_string() const override;
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
bool resolves_to_angle() const { return m_resolved_type.matches_angle(); }
|
bool resolves_to_angle() const { return m_resolved_type.matches_angle(); }
|
||||||
bool resolves_to_angle_percentage() const { return m_resolved_type.matches_angle_percentage(); }
|
bool resolves_to_angle_percentage() const { return m_resolved_type.matches_angle_percentage(); }
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CalculatedStyleValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
explicit CalculatedStyleValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
||||||
: StyleValue(Type::Calculated)
|
: CSSStyleValue(Type::Calculated)
|
||||||
, m_resolved_type(resolved_type)
|
, m_resolved_type(resolved_type)
|
||||||
, m_calculation(move(calculation))
|
, m_calculation(move(calculation))
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void ConicGradientStyleValue::paint(PaintContext& context, DevicePixelRect const
|
||||||
context.display_list_recorder().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position);
|
context.display_list_recorder().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConicGradientStyleValue::equals(StyleValue const& other) const
|
bool ConicGradientStyleValue::equals(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
||||||
|
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
Vector<AngularColorStopListElement> const& color_stop_list() const
|
Vector<AngularColorStopListElement> const& color_stop_list() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
struct CounterDefinition {
|
struct CounterDefinition {
|
||||||
FlyString name;
|
FlyString name;
|
||||||
bool is_reversed;
|
bool is_reversed;
|
||||||
ValueComparingRefPtr<StyleValue const> value;
|
ValueComparingRefPtr<CSSStyleValue const> value;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style, FlyString join_string)
|
CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style, FlyString join_string)
|
||||||
: StyleValueWithDefaultOperators(Type::Counter)
|
: StyleValueWithDefaultOperators(Type::Counter)
|
||||||
, m_properties {
|
, m_properties {
|
||||||
.function = function,
|
.function = function,
|
||||||
|
@ -30,7 +30,7 @@ CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter
|
||||||
CounterStyleValue::~CounterStyleValue() = default;
|
CounterStyleValue::~CounterStyleValue() = default;
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-counter-styles-3/#generate-a-counter
|
// https://drafts.csswg.org/css-counter-styles-3/#generate-a-counter
|
||||||
static String generate_a_counter_representation(StyleValue const& counter_style, i32 value)
|
static String generate_a_counter_representation(CSSStyleValue const& counter_style, i32 value)
|
||||||
{
|
{
|
||||||
// When asked to generate a counter representation using a particular counter style for a particular
|
// When asked to generate a counter representation using a particular counter style for a particular
|
||||||
// counter value, follow these steps:
|
// counter value, follow these steps:
|
||||||
|
@ -147,7 +147,7 @@ String CounterStyleValue::to_string() const
|
||||||
|
|
||||||
// 4. Let list be a list of CSS component values belonging to <counter>,
|
// 4. Let list be a list of CSS component values belonging to <counter>,
|
||||||
// omitting the last CSS component value if it is "decimal".
|
// omitting the last CSS component value if it is "decimal".
|
||||||
Vector<RefPtr<StyleValue const>> list;
|
Vector<RefPtr<CSSStyleValue const>> list;
|
||||||
list.append(CustomIdentStyleValue::create(m_properties.counter_name));
|
list.append(CustomIdentStyleValue::create(m_properties.counter_name));
|
||||||
if (m_properties.function == CounterFunction::Counters)
|
if (m_properties.function == CounterFunction::Counters)
|
||||||
list.append(StringStyleValue::create(m_properties.join_string.to_string()));
|
list.append(StringStyleValue::create(m_properties.join_string.to_string()));
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ public:
|
||||||
Counters,
|
Counters,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
|
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {}));
|
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {}));
|
||||||
}
|
}
|
||||||
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
|
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counters, move(counter_name), move(counter_style), move(join_string)));
|
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counters, move(counter_name), move(counter_style), move(join_string)));
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ public:
|
||||||
bool properties_equal(CounterStyleValue const& other) const;
|
bool properties_equal(CounterStyleValue const& other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CounterStyleValue(CounterFunction, FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style, FlyString join_string);
|
explicit CounterStyleValue(CounterFunction, FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style, FlyString join_string);
|
||||||
|
|
||||||
struct Properties {
|
struct Properties {
|
||||||
CounterFunction function;
|
CounterFunction function;
|
||||||
FlyString counter_name;
|
FlyString counter_name;
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> counter_style;
|
ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style;
|
||||||
FlyString join_string;
|
FlyString join_string;
|
||||||
bool operator==(Properties const&) const = default;
|
bool operator==(Properties const&) const = default;
|
||||||
} m_properties;
|
} m_properties;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Display.h>
|
#include <LibWeb/CSS/Display.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Flex.h>
|
#include <LibWeb/CSS/Flex.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Frequency.h>
|
#include <LibWeb/CSS/Frequency.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/GridTrackPlacement.h>
|
#include <LibWeb/CSS/GridTrackPlacement.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/GridTrackSize.h>
|
#include <LibWeb/CSS/GridTrackSize.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/ValueID.h>
|
#include <LibWeb/CSS/ValueID.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -109,7 +109,7 @@ String ImageStyleValue::to_string() const
|
||||||
return serialize_a_url(MUST(m_url.to_string()));
|
return serialize_a_url(MUST(m_url.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageStyleValue::equals(StyleValue const& other) const
|
bool ImageStyleValue::equals(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -31,12 +31,12 @@ public:
|
||||||
void visit_edges(JS::Cell::Visitor& visitor) const
|
void visit_edges(JS::Cell::Visitor& visitor) const
|
||||||
{
|
{
|
||||||
// FIXME: visit_edges in non-GC allocated classes is confusing pattern.
|
// FIXME: visit_edges in non-GC allocated classes is confusing pattern.
|
||||||
// Consider making StyleValue to be GC allocated instead.
|
// Consider making CSSStyleValue to be GC allocated instead.
|
||||||
visitor.visit(m_resource_request);
|
visitor.visit(m_resource_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual String to_string() const override;
|
virtual String to_string() const override;
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
virtual void load_any_resources(DOM::Document&) override;
|
virtual void load_any_resources(DOM::Document&) override;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ ValueComparingNonnullRefPtr<LengthStyleValue> LengthStyleValue::create(Length co
|
||||||
return adopt_ref(*new (nothrow) LengthStyleValue(length));
|
return adopt_ref(*new (nothrow) LengthStyleValue(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
ValueComparingNonnullRefPtr<CSSStyleValue const> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||||
{
|
{
|
||||||
if (auto length = m_length.absolutize(viewport_rect, font_metrics, root_font_metrics); length.has_value())
|
if (auto length = m_length.absolutize(viewport_rect, font_metrics, root_font_metrics); length.has_value())
|
||||||
return LengthStyleValue::create(length.release_value());
|
return LengthStyleValue::create(length.release_value());
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
||||||
Length const& length() const { return m_length; }
|
Length const& length() const { return m_length; }
|
||||||
|
|
||||||
virtual String to_string() const override { return m_length.to_string(); }
|
virtual String to_string() const override { return m_length.to_string(); }
|
||||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||||
|
|
||||||
bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; }
|
bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; }
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ String LinearGradientStyleValue::to_string() const
|
||||||
return MUST(builder.to_string());
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinearGradientStyleValue::equals(StyleValue const& other_) const
|
bool LinearGradientStyleValue::equals(CSSStyleValue const& other_) const
|
||||||
{
|
{
|
||||||
if (type() != other_.type())
|
if (type() != other_.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
virtual String to_string() const override;
|
virtual String to_string() const override;
|
||||||
virtual ~LinearGradientStyleValue() override = default;
|
virtual ~LinearGradientStyleValue() override = default;
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
Vector<LinearColorStopListElement> const& color_stop_list() const
|
Vector<LinearColorStopListElement> const& color_stop_list() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,17 +13,17 @@ ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_aut
|
||||||
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::AutoAdd));
|
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::AutoAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_add(ValueComparingNonnullRefPtr<StyleValue const> integer_value)
|
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Add, move(integer_value)));
|
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Add, move(integer_value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_integer(ValueComparingNonnullRefPtr<StyleValue const> integer_value)
|
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Integer, move(integer_value)));
|
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Integer, move(integer_value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MathDepthStyleValue::MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<StyleValue const> integer_value)
|
MathDepthStyleValue::MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<CSSStyleValue const> integer_value)
|
||||||
: StyleValueWithDefaultOperators(Type::MathDepth)
|
: StyleValueWithDefaultOperators(Type::MathDepth)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
, m_integer_value(move(integer_value))
|
, m_integer_value(move(integer_value))
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
|
class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_auto_add();
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_auto_add();
|
||||||
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_add(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value);
|
||||||
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_integer(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value);
|
||||||
virtual ~MathDepthStyleValue() override = default;
|
virtual ~MathDepthStyleValue() override = default;
|
||||||
|
|
||||||
bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; }
|
bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; }
|
||||||
|
@ -36,10 +36,10 @@ private:
|
||||||
Integer,
|
Integer,
|
||||||
};
|
};
|
||||||
|
|
||||||
MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<StyleValue const> integer_value = nullptr);
|
MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<CSSStyleValue const> integer_value = nullptr);
|
||||||
|
|
||||||
MathDepthType m_type;
|
MathDepthType m_type;
|
||||||
ValueComparingRefPtr<StyleValue const> m_integer_value;
|
ValueComparingRefPtr<CSSStyleValue const> m_integer_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Percentage.h>
|
#include <LibWeb/CSS/Percentage.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/PercentageOr.h>
|
#include <LibWeb/CSS/PercentageOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -199,7 +199,7 @@ void RadialGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadialGradientStyleValue::equals(StyleValue const& other) const
|
bool RadialGradientStyleValue::equals(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
||||||
|
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
Vector<LinearColorStopListElement> const& color_stop_list() const
|
Vector<LinearColorStopListElement> const& color_stop_list() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Ratio.h>
|
#include <LibWeb/CSS/Ratio.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/EdgeRect.h>
|
#include <LibWeb/CSS/EdgeRect.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Resolution.h>
|
#include <LibWeb/CSS/Resolution.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ String ShadowStyleValue::to_string() const
|
||||||
return MUST(builder.to_string());
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
ValueComparingNonnullRefPtr<CSSStyleValue const> ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||||
{
|
{
|
||||||
auto absolutized_offset_x = m_properties.offset_x->absolutized(viewport_rect, font_metrics, root_font_metrics);
|
auto absolutized_offset_x = m_properties.offset_x->absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||||
auto absolutized_offset_y = m_properties.offset_y->absolutized(viewport_rect, font_metrics, root_font_metrics);
|
auto absolutized_offset_y = m_properties.offset_y->absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ class ShadowStyleValue final : public StyleValueWithDefaultOperators<ShadowStyle
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<ShadowStyleValue> create(
|
static ValueComparingNonnullRefPtr<ShadowStyleValue> create(
|
||||||
Color color,
|
Color color,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_x,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_x,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_y,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_y,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> blur_radius,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> blur_radius,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> spread_distance,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> spread_distance,
|
||||||
ShadowPlacement placement)
|
ShadowPlacement placement)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) ShadowStyleValue(color, move(offset_x), move(offset_y), move(blur_radius), move(spread_distance), placement));
|
return adopt_ref(*new (nothrow) ShadowStyleValue(color, move(offset_x), move(offset_y), move(blur_radius), move(spread_distance), placement));
|
||||||
|
@ -35,10 +35,10 @@ public:
|
||||||
virtual ~ShadowStyleValue() override = default;
|
virtual ~ShadowStyleValue() override = default;
|
||||||
|
|
||||||
Color color() const { return m_properties.color; }
|
Color color() const { return m_properties.color; }
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> const& offset_x() const { return m_properties.offset_x; }
|
ValueComparingNonnullRefPtr<CSSStyleValue const> const& offset_x() const { return m_properties.offset_x; }
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> const& offset_y() const { return m_properties.offset_y; }
|
ValueComparingNonnullRefPtr<CSSStyleValue const> const& offset_y() const { return m_properties.offset_y; }
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> const& blur_radius() const { return m_properties.blur_radius; }
|
ValueComparingNonnullRefPtr<CSSStyleValue const> const& blur_radius() const { return m_properties.blur_radius; }
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> const& spread_distance() const { return m_properties.spread_distance; }
|
ValueComparingNonnullRefPtr<CSSStyleValue const> const& spread_distance() const { return m_properties.spread_distance; }
|
||||||
ShadowPlacement placement() const { return m_properties.placement; }
|
ShadowPlacement placement() const { return m_properties.placement; }
|
||||||
|
|
||||||
virtual String to_string() const override;
|
virtual String to_string() const override;
|
||||||
|
@ -48,10 +48,10 @@ public:
|
||||||
private:
|
private:
|
||||||
ShadowStyleValue(
|
ShadowStyleValue(
|
||||||
Color color,
|
Color color,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_x,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_x,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_y,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_y,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> blur_radius,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> blur_radius,
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> spread_distance,
|
ValueComparingNonnullRefPtr<CSSStyleValue const> spread_distance,
|
||||||
ShadowPlacement placement)
|
ShadowPlacement placement)
|
||||||
: StyleValueWithDefaultOperators(Type::Shadow)
|
: StyleValueWithDefaultOperators(Type::Shadow)
|
||||||
, m_properties {
|
, m_properties {
|
||||||
|
@ -65,14 +65,14 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||||
|
|
||||||
struct Properties {
|
struct Properties {
|
||||||
Color color;
|
Color color;
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_x;
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_x;
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> offset_y;
|
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_y;
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> blur_radius;
|
ValueComparingNonnullRefPtr<CSSStyleValue const> blur_radius;
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> spread_distance;
|
ValueComparingNonnullRefPtr<CSSStyleValue const> spread_distance;
|
||||||
ShadowPlacement placement;
|
ShadowPlacement placement;
|
||||||
bool operator==(Properties const&) const = default;
|
bool operator==(Properties const&) const = default;
|
||||||
} m_properties;
|
} m_properties;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
ShorthandStyleValue::ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
|
ShorthandStyleValue::ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values)
|
||||||
: StyleValueWithDefaultOperators(Type::Shorthand)
|
: StyleValueWithDefaultOperators(Type::Shorthand)
|
||||||
, m_properties { shorthand, move(sub_properties), move(values) }
|
, m_properties { shorthand, move(sub_properties), move(values) }
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ ShorthandStyleValue::ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID
|
||||||
|
|
||||||
ShorthandStyleValue::~ShorthandStyleValue() = default;
|
ShorthandStyleValue::~ShorthandStyleValue() = default;
|
||||||
|
|
||||||
ValueComparingRefPtr<StyleValue const> ShorthandStyleValue::longhand(PropertyID longhand) const
|
ValueComparingRefPtr<CSSStyleValue const> ShorthandStyleValue::longhand(PropertyID longhand) const
|
||||||
{
|
{
|
||||||
for (auto i = 0u; i < m_properties.sub_properties.size(); ++i) {
|
for (auto i = 0u; i < m_properties.sub_properties.size(); ++i) {
|
||||||
if (m_properties.sub_properties[i] == longhand)
|
if (m_properties.sub_properties[i] == longhand)
|
||||||
|
@ -60,7 +60,7 @@ String ShorthandStyleValue::to_string() const
|
||||||
return MUST(String::formatted("{} {} {} {} {} {} {} {}", color->to_string(), image->to_string(), position->to_string(), size->to_string(), repeat->to_string(), attachment->to_string(), origin->to_string(), clip->to_string()));
|
return MUST(String::formatted("{} {} {} {} {} {} {} {}", color->to_string(), image->to_string(), position->to_string(), size->to_string(), repeat->to_string(), attachment->to_string(), origin->to_string(), clip->to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_layer_value_string = [](ValueComparingRefPtr<StyleValue const> const& style_value, size_t index) {
|
auto get_layer_value_string = [](ValueComparingRefPtr<CSSStyleValue const> const& style_value, size_t index) {
|
||||||
if (style_value->is_value_list())
|
if (style_value->is_value_list())
|
||||||
return style_value->as_value_list().value_at(index, true)->to_string();
|
return style_value->as_value_list().value_at(index, true)->to_string();
|
||||||
return style_value->to_string();
|
return style_value->to_string();
|
||||||
|
|
|
@ -6,34 +6,34 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
|
class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
|
static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values)));
|
return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values)));
|
||||||
}
|
}
|
||||||
virtual ~ShorthandStyleValue() override;
|
virtual ~ShorthandStyleValue() override;
|
||||||
|
|
||||||
Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; }
|
Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; }
|
||||||
Vector<ValueComparingNonnullRefPtr<StyleValue const>> const& values() const { return m_properties.values; }
|
Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> const& values() const { return m_properties.values; }
|
||||||
|
|
||||||
ValueComparingRefPtr<StyleValue const> longhand(PropertyID) const;
|
ValueComparingRefPtr<CSSStyleValue const> longhand(PropertyID) const;
|
||||||
|
|
||||||
virtual String to_string() const override;
|
virtual String to_string() const override;
|
||||||
|
|
||||||
bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
|
bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
|
ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values);
|
||||||
|
|
||||||
struct Properties {
|
struct Properties {
|
||||||
PropertyID shorthand_property;
|
PropertyID shorthand_property;
|
||||||
Vector<PropertyID> sub_properties;
|
Vector<PropertyID> sub_properties;
|
||||||
Vector<ValueComparingNonnullRefPtr<StyleValue const>> values;
|
Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values;
|
||||||
bool operator==(Properties const&) const = default;
|
bool operator==(Properties const&) const = default;
|
||||||
} m_properties;
|
} m_properties;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
|
|
||||||
size_t size() const { return m_properties.values.size(); }
|
size_t size() const { return m_properties.values.size(); }
|
||||||
StyleValueVector const& values() const { return m_properties.values; }
|
StyleValueVector const& values() const { return m_properties.values; }
|
||||||
ValueComparingNonnullRefPtr<StyleValue const> value_at(size_t i, bool allow_loop) const
|
ValueComparingNonnullRefPtr<CSSStyleValue const> value_at(size_t i, bool allow_loop) const
|
||||||
{
|
{
|
||||||
if (allow_loop)
|
if (allow_loop)
|
||||||
return m_properties.values[i % size()];
|
return m_properties.values[i % size()];
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Time.h>
|
#include <LibWeb/CSS/Time.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/TransformFunctions.h>
|
#include <LibWeb/CSS/TransformFunctions.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/CalculatedOr.h>
|
#include <LibWeb/CSS/CalculatedOr.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
||||||
#include <LibWeb/CSS/Time.h>
|
#include <LibWeb/CSS/Time.h>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibURL/URL.h>
|
#include <LibURL/URL.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Serialize.h>
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ String UnresolvedStyleValue::to_string() const
|
||||||
return MUST(builder.to_string());
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnresolvedStyleValue::equals(StyleValue const& other) const
|
bool UnresolvedStyleValue::equals(CSSStyleValue const& other) const
|
||||||
{
|
{
|
||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class UnresolvedStyleValue final : public StyleValue {
|
class UnresolvedStyleValue final : public CSSStyleValue {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<UnresolvedStyleValue> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
|
static ValueComparingNonnullRefPtr<UnresolvedStyleValue> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
|
||||||
{
|
{
|
||||||
|
@ -28,11 +28,11 @@ public:
|
||||||
Vector<Parser::ComponentValue> const& values() const { return m_values; }
|
Vector<Parser::ComponentValue> const& values() const { return m_values; }
|
||||||
bool contains_var_or_attr() const { return m_contains_var_or_attr; }
|
bool contains_var_or_attr() const { return m_contains_var_or_attr; }
|
||||||
|
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(CSSStyleValue const& other) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnresolvedStyleValue(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
|
UnresolvedStyleValue(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
|
||||||
: StyleValue(Type::Unresolved)
|
: CSSStyleValue(Type::Unresolved)
|
||||||
, m_values(move(values))
|
, m_values(move(values))
|
||||||
, m_contains_var_or_attr(contains_var_or_attr)
|
, m_contains_var_or_attr(contains_var_or_attr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ class CSSStyleDeclaration;
|
||||||
class CSSStyleRule;
|
class CSSStyleRule;
|
||||||
class CSSStyleSheet;
|
class CSSStyleSheet;
|
||||||
struct CSSStyleSheetInit;
|
struct CSSStyleSheetInit;
|
||||||
|
class CSSStyleValue;
|
||||||
class CSSSupportsRule;
|
class CSSSupportsRule;
|
||||||
class CalculatedStyleValue;
|
class CalculatedStyleValue;
|
||||||
class Clip;
|
class Clip;
|
||||||
|
@ -196,7 +197,6 @@ class StyleComputer;
|
||||||
class StyleProperties;
|
class StyleProperties;
|
||||||
class StyleSheet;
|
class StyleSheet;
|
||||||
class StyleSheetList;
|
class StyleSheetList;
|
||||||
class StyleValue;
|
|
||||||
class StyleValueList;
|
class StyleValueList;
|
||||||
class Supports;
|
class Supports;
|
||||||
class SVGPaint;
|
class SVGPaint;
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
Bindings::ImageSmoothingQuality image_smoothing_quality { Bindings::ImageSmoothingQuality::Low };
|
Bindings::ImageSmoothingQuality image_smoothing_quality { Bindings::ImageSmoothingQuality::Low };
|
||||||
float global_alpha = { 1 };
|
float global_alpha = { 1 };
|
||||||
Optional<Gfx::ClipPath> clip;
|
Optional<Gfx::ClipPath> clip;
|
||||||
RefPtr<CSS::StyleValue> font_style_value { nullptr };
|
RefPtr<CSS::CSSStyleValue> font_style_value { nullptr };
|
||||||
RefPtr<Gfx::Font const> current_font { nullptr };
|
RefPtr<Gfx::Font const> current_font { nullptr };
|
||||||
Bindings::CanvasTextAlign text_align { Bindings::CanvasTextAlign::Start };
|
Bindings::CanvasTextAlign text_align { Bindings::CanvasTextAlign::Start };
|
||||||
Bindings::CanvasTextBaseline text_baseline { Bindings::CanvasTextBaseline::Alphabetic };
|
Bindings::CanvasTextBaseline text_baseline { Bindings::CanvasTextBaseline::Alphabetic };
|
||||||
|
|
|
@ -4648,7 +4648,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#current-dimension-value
|
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#current-dimension-value
|
||||||
static RefPtr<CSS::StyleValue> parse_current_dimension_value(float value, Utf8View input, Utf8View::Iterator position)
|
static RefPtr<CSS::CSSStyleValue> parse_current_dimension_value(float value, Utf8View input, Utf8View::Iterator position)
|
||||||
{
|
{
|
||||||
// 1. If position is past the end of input, then return value as a length.
|
// 1. If position is past the end of input, then return value as a length.
|
||||||
if (position == input.end())
|
if (position == input.end())
|
||||||
|
@ -4663,7 +4663,7 @@ static RefPtr<CSS::StyleValue> parse_current_dimension_value(float value, Utf8Vi
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-dimension-values
|
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-dimension-values
|
||||||
RefPtr<CSS::StyleValue> parse_dimension_value(StringView string)
|
RefPtr<CSS::CSSStyleValue> parse_dimension_value(StringView string)
|
||||||
{
|
{
|
||||||
// 1. Let input be the string being parsed.
|
// 1. Let input be the string being parsed.
|
||||||
auto input = Utf8View(string);
|
auto input = Utf8View(string);
|
||||||
|
@ -4740,7 +4740,7 @@ RefPtr<CSS::StyleValue> parse_dimension_value(StringView string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-non-zero-dimension-values
|
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-non-zero-dimension-values
|
||||||
RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView string)
|
RefPtr<CSS::CSSStyleValue> parse_nonzero_dimension_value(StringView string)
|
||||||
{
|
{
|
||||||
// 1. Let input be the string being parsed.
|
// 1. Let input be the string being parsed.
|
||||||
// 2. Let value be the result of parsing input using the rules for parsing dimension values.
|
// 2. Let value be the result of parsing input using the rules for parsing dimension values.
|
||||||
|
|
|
@ -213,8 +213,8 @@ private:
|
||||||
StringBuilder m_character_insertion_builder;
|
StringBuilder m_character_insertion_builder;
|
||||||
};
|
};
|
||||||
|
|
||||||
RefPtr<CSS::StyleValue> parse_dimension_value(StringView);
|
RefPtr<CSS::CSSStyleValue> parse_dimension_value(StringView);
|
||||||
RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView);
|
RefPtr<CSS::CSSStyleValue> parse_nonzero_dimension_value(StringView);
|
||||||
Optional<Color> parse_legacy_color_value(StringView);
|
Optional<Color> parse_legacy_color_value(StringView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto value_for_layer = [](auto& style_value, size_t layer_index) -> RefPtr<CSS::StyleValue const> {
|
auto value_for_layer = [](auto& style_value, size_t layer_index) -> RefPtr<CSS::CSSStyleValue const> {
|
||||||
if (style_value->is_value_list())
|
if (style_value->is_value_list())
|
||||||
return style_value->as_value_list().value_at(layer_index, true);
|
return style_value->as_value_list().value_at(layer_index, true);
|
||||||
return style_value;
|
return style_value;
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibJS/Runtime/JSONObject.h>
|
#include <LibJS/Runtime/JSONObject.h>
|
||||||
#include <LibJS/Runtime/Value.h>
|
#include <LibJS/Runtime/Value.h>
|
||||||
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleProperties.h>
|
#include <LibWeb/CSS/StyleProperties.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
#include <LibWeb/Cookie/Cookie.h>
|
#include <LibWeb/Cookie/Cookie.h>
|
||||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
|
Loading…
Reference in a new issue