mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.
Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.
While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
This commit is contained in:
committed by
Tim Ledbetter
parent
0d8ad0a9fe
commit
c57975c9fd
Notes:
github-actions[bot]
2025-08-08 14:20:54 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/c57975c9fdb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5775 Reviewed-by: https://github.com/tcl3 ✅
@@ -25,7 +25,7 @@ Each property will have some set of these fields on it:
|
||||
| `affects-stacking-context` | No | `false` | Boolean. Whether this property can cause a new stacking context for the element. | `bool property_affects_stacking_context(PropertyID)` |
|
||||
| `animation-type` | Yes | | String. How the property should be animated. Defined by the spec. See below. | `AnimationType animation_type_from_longhand_property(PropertyID)` |
|
||||
| `inherited` | Yes | | Boolean. Whether the property is inherited by its child elements. | `bool is_inherited_property(PropertyID)` |
|
||||
| `initial` | Yes | | String. The property's initial value if it is not specified. | `NonnullRefPtr<CSSStyleValue const> property_initial_value(PropertyID)` |
|
||||
| `initial` | Yes | | String. The property's initial value if it is not specified. | `NonnullRefPtr<StyleValue const> property_initial_value(PropertyID)` |
|
||||
| `legacy-alias-for` | No | Nothing | String. The name of a property this is an alias for. See below. | |
|
||||
| `logical-alias-for` | No | Nothing | An object. See below. | `bool property_is_logical_alias(PropertyID);`<br/>`PropertyID map_logical_alias_to_physical_property(PropertyID, LogicalAliasMappingContext const&)` |
|
||||
| `longhands` | No | `[]` | Array of strings. If this is a shorthand, these are the property names that it expands out into. | `Vector<PropertyID> longhands_for_shorthand(PropertyID)`<br/>`Vector<PropertyID> expanded_longhands_for_shorthand(PropertyID)`<br/>`Vector<PropertyID> shorthands_for_longhand(PropertyID)` |
|
||||
@@ -129,7 +129,7 @@ The generated code provides:
|
||||
it exists in that at-rule.
|
||||
- `FlyString to_string(DescriptorID)` for serializing descriptor names.
|
||||
- `bool at_rule_supports_descriptor(AtRuleID, DescriptorID)` to query if the given at-rule allows the descriptor.
|
||||
- `RefPtr<CSSStyleValue const> descriptor_initial_value(AtRuleID, DescriptorID)` for getting a descriptor's initial value.
|
||||
- `RefPtr<StyleValue const> descriptor_initial_value(AtRuleID, DescriptorID)` for getting a descriptor's initial value.
|
||||
- `DescriptorMetadata get_descriptor_metadata(AtRuleID, DescriptorID)` returns data used for parsing the descriptor.
|
||||
|
||||
### At-rule fields
|
||||
|
||||
@@ -18,7 +18,7 @@ However, there are many CSS properties with more complicated grammar and so they
|
||||
|
||||
Property-parsing code goes in `CSS/Parser/PropertyParsing.cpp`, and `CSS/Parser/Parser.h`. First,
|
||||
`Parser::parse_css_value()` is called, which has a switch for specific properties. Call your method from there. It
|
||||
should return a `RefPtr` to a `CSSStyleValue` or one of its subclasses.
|
||||
should return a `RefPtr` to a `StyleValue` or one of its subclasses.
|
||||
|
||||
For shorthands, you should normally use `ShorthandStyleValue`, which automatically expands its longhand values. You
|
||||
might need to modify `ShorthandStyleValue::to_string` if your shorthand has special serialization rules. For example,
|
||||
@@ -29,7 +29,7 @@ If you need to do this, pester @AtkinsSJ until he gets around to documenting it.
|
||||
|
||||
## Computed style
|
||||
|
||||
After parsing and style computation, longhand properties are stored as `CSSStyleValue` pointers in
|
||||
After parsing and style computation, longhand properties are stored as `StyleValue` pointers in
|
||||
`ComputedProperties`. Any shorthands have been expanded out, and so we do not need to store them directly.
|
||||
|
||||
These longhands then need to be converted to a more usable form. To do this, add a getter to `ComputedProperties` with
|
||||
|
||||
@@ -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/Libraries/LibWeb/CSS/Default.css).
|
||||
|
||||
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.)
|
||||
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.)
|
||||
|
||||
#### Resolving CSS custom properties ("variables")
|
||||
|
||||
|
||||
@@ -158,7 +158,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
|
||||
// [CSS-EASING-1], throw a TypeError and abort this procedure.
|
||||
RefPtr<CSS::CSSStyleValue const> easing_value;
|
||||
RefPtr<CSS::StyleValue const> easing_value;
|
||||
if (timing.easing.has_value()) {
|
||||
easing_value = parse_easing_string(timing.easing.value());
|
||||
if (!easing_value)
|
||||
@@ -604,7 +604,7 @@ Optional<double> AnimationEffect::transformed_progress() const
|
||||
return m_timing_function.evaluate_at(directed_progress.value(), before_flag);
|
||||
}
|
||||
|
||||
RefPtr<CSS::CSSStyleValue const> AnimationEffect::parse_easing_string(StringView value)
|
||||
RefPtr<CSS::StyleValue const> AnimationEffect::parse_easing_string(StringView value)
|
||||
{
|
||||
if (auto style_value = parse_css_value(CSS::Parser::ParsingParams(), value, CSS::PropertyID::AnimationTimingFunction)) {
|
||||
if (style_value->is_easing())
|
||||
@@ -631,7 +631,7 @@ void AnimationEffect::visit_edges(JS::Cell::Visitor& visitor)
|
||||
visitor.visit(m_associated_animation);
|
||||
}
|
||||
|
||||
static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation_for_animated_properties(HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>> const& old_properties, HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>> const& new_properties)
|
||||
static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation_for_animated_properties(HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>> const& old_properties, HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>> const& new_properties)
|
||||
{
|
||||
CSS::RequiredInvalidationAfterStyleChange invalidation;
|
||||
auto old_and_new_properties = MUST(Bitmap::create(to_underlying(CSS::last_property_id) + 1, 0));
|
||||
|
||||
@@ -62,7 +62,7 @@ Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_directi
|
||||
// This object lives for the duration of an animation update, and is used to store per-element data about animated CSS properties.
|
||||
struct AnimationUpdateContext {
|
||||
struct ElementData {
|
||||
using PropertyMap = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>>;
|
||||
using PropertyMap = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>>;
|
||||
PropertyMap animated_properties_before_update;
|
||||
GC::Ptr<CSS::ComputedProperties> target_style;
|
||||
};
|
||||
@@ -79,7 +79,7 @@ class AnimationEffect : public Bindings::PlatformObject {
|
||||
GC_DECLARE_ALLOCATOR(AnimationEffect);
|
||||
|
||||
public:
|
||||
static RefPtr<CSS::CSSStyleValue const> parse_easing_string(StringView value);
|
||||
static RefPtr<CSS::StyleValue const> parse_easing_string(StringView value);
|
||||
|
||||
EffectTiming get_timing() const;
|
||||
ComputedEffectTiming get_computed_timing() const;
|
||||
|
||||
@@ -563,7 +563,7 @@ static WebIDL::ExceptionOr<Vector<BaseKeyframe>> process_a_keyframes_argument(JS
|
||||
if (!easing_value)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Invalid animation easing value: \"{}\"", easing_string)) };
|
||||
|
||||
keyframe.easing.set(NonnullRefPtr<CSS::CSSStyleValue const> { *easing_value });
|
||||
keyframe.easing.set(NonnullRefPtr<CSS::StyleValue const> { *easing_value });
|
||||
}
|
||||
|
||||
// 9. Parse each of the values in unused easings using the CSS syntax defined for easing member of the EffectTiming
|
||||
@@ -591,7 +591,7 @@ void KeyframeEffect::generate_initial_and_final_frames(RefPtr<KeyFrameSet> keyfr
|
||||
initial_keyframe = keyframe_set->keyframes_by_key.find(0);
|
||||
}
|
||||
|
||||
auto expanded_properties = [&](HashMap<CSS::PropertyID, Variant<KeyFrameSet::UseInitial, NonnullRefPtr<CSS::CSSStyleValue const>>>& properties) {
|
||||
auto expanded_properties = [&](HashMap<CSS::PropertyID, Variant<KeyFrameSet::UseInitial, NonnullRefPtr<CSS::StyleValue const>>>& properties) {
|
||||
HashTable<CSS::PropertyID> result;
|
||||
|
||||
for (auto property : properties) {
|
||||
@@ -827,7 +827,7 @@ WebIDL::ExceptionOr<GC::RootVector<JS::Object*>> KeyframeEffect::get_keyframes()
|
||||
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.computedOffset, JS::Value(keyframe.computed_offset.value()), ShouldThrowExceptions::Yes));
|
||||
auto easing_value = keyframe.easing.get<NonnullRefPtr<CSS::CSSStyleValue const>>();
|
||||
auto easing_value = keyframe.easing.get<NonnullRefPtr<CSS::StyleValue const>>();
|
||||
TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string(CSS::SerializationMode::Normal)), ShouldThrowExceptions::Yes));
|
||||
|
||||
if (keyframe.composite == Bindings::CompositeOperationOrAuto::Replace) {
|
||||
@@ -881,7 +881,7 @@ WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes(Optional<GC::Root<JS::Ob
|
||||
property_value = CSS::Parser::Parser::resolve_unresolved_style_value(CSS::Parser::ParsingParams { target->document() }, *target, pseudo_element_type(), property_id, property_value->as_unresolved());
|
||||
|
||||
resolved_keyframe.properties.set(property_id, property_value);
|
||||
CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, [&](CSS::PropertyID longhand_id, CSS::CSSStyleValue const&) {
|
||||
CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, [&](CSS::PropertyID longhand_id, CSS::StyleValue const&) {
|
||||
m_target_properties.set(longhand_id);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#include <LibWeb/Animations/AnimationEffect.h>
|
||||
#include <LibWeb/Bindings/KeyframeEffectPrototype.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::Animations {
|
||||
|
||||
using EasingValue = Variant<String, NonnullRefPtr<CSS::CSSStyleValue const>>;
|
||||
using EasingValue = Variant<String, NonnullRefPtr<CSS::StyleValue const>>;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffectoptions-dictionary
|
||||
struct KeyframeEffectOptions : public EffectTiming {
|
||||
@@ -39,7 +39,7 @@ struct BasePropertyIndexedKeyframe {
|
||||
// https://www.w3.org/TR/web-animations-1/#dictdef-basekeyframe
|
||||
struct BaseKeyframe {
|
||||
using UnparsedProperties = HashMap<String, String>;
|
||||
using ParsedProperties = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::CSSStyleValue const>>;
|
||||
using ParsedProperties = HashMap<CSS::PropertyID, NonnullRefPtr<CSS::StyleValue const>>;
|
||||
|
||||
Optional<double> offset {};
|
||||
EasingValue easing { "linear"_string };
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
struct KeyFrameSet : public RefCounted<KeyFrameSet> {
|
||||
struct UseInitial { };
|
||||
struct ResolvedKeyFrame {
|
||||
// These CSSStyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well
|
||||
// These StyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well
|
||||
// before they are applied to an element
|
||||
HashMap<CSS::PropertyID, Variant<UseInitial, NonnullRefPtr<CSS::CSSStyleValue const>>> properties {};
|
||||
HashMap<CSS::PropertyID, Variant<UseInitial, NonnullRefPtr<CSS::StyleValue const>>> properties {};
|
||||
};
|
||||
RedBlackTree<u64, ResolvedKeyFrame> keyframes_by_key;
|
||||
};
|
||||
|
||||
@@ -125,7 +125,6 @@ set(SOURCES
|
||||
CSS/CSSStyleProperties.cpp
|
||||
CSS/CSSStyleRule.cpp
|
||||
CSS/CSSStyleSheet.cpp
|
||||
CSS/CSSStyleValue.cpp
|
||||
CSS/CSSSupportsRule.cpp
|
||||
CSS/CSSTransition.cpp
|
||||
CSS/Descriptor.cpp
|
||||
@@ -234,6 +233,7 @@ set(SOURCES
|
||||
CSS/StyleValues/ScrollbarColorStyleValue.cpp
|
||||
CSS/StyleValues/ShadowStyleValue.cpp
|
||||
CSS/StyleValues/ShorthandStyleValue.cpp
|
||||
CSS/StyleValues/StyleValue.cpp
|
||||
CSS/StyleValues/StyleValueList.cpp
|
||||
CSS/StyleValues/TransformationStyleValue.cpp
|
||||
CSS/StyleValues/TransitionStyleValue.cpp
|
||||
|
||||
@@ -89,7 +89,7 @@ WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition defin
|
||||
return WebIDL::SyntaxError::create(realm, "Invalid syntax definition"_string);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> initial_value_maybe;
|
||||
RefPtr<StyleValue const> initial_value_maybe;
|
||||
|
||||
// 4. If syntax definition is the universal syntax definition, and initialValue is not present,
|
||||
if (maybe_syntax->type() == Parser::SyntaxNode::NodeType::Universal) {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Animations/Animation.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ String CSSDescriptors::item(size_t index) const
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#set-a-css-declaration
|
||||
bool CSSDescriptors::set_a_css_declaration(DescriptorID descriptor_id, NonnullRefPtr<CSSStyleValue const> value, Important)
|
||||
bool CSSDescriptors::set_a_css_declaration(DescriptorID descriptor_id, NonnullRefPtr<StyleValue const> value, Important)
|
||||
{
|
||||
VERIFY(!is_computed());
|
||||
|
||||
@@ -89,7 +89,7 @@ WebIDL::ExceptionOr<void> CSSDescriptors::set_property(StringView property, Stri
|
||||
return {};
|
||||
|
||||
// 5. Let component value list be the result of parsing value for property property.
|
||||
RefPtr<CSSStyleValue const> component_value_list = parse_css_descriptor(Parser::ParsingParams {}, m_at_rule_id, *descriptor_id, value);
|
||||
RefPtr<StyleValue const> component_value_list = parse_css_descriptor(Parser::ParsingParams {}, m_at_rule_id, *descriptor_id, value);
|
||||
|
||||
// 6. If component value list is null, then return.
|
||||
if (!component_value_list)
|
||||
@@ -263,7 +263,7 @@ void CSSDescriptors::visit_edges(Visitor& visitor)
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> CSSDescriptors::descriptor(DescriptorID descriptor_id) const
|
||||
RefPtr<StyleValue const> CSSDescriptors::descriptor(DescriptorID descriptor_id) const
|
||||
{
|
||||
auto match = m_descriptors.first_matching([descriptor_id](Descriptor const& descriptor) {
|
||||
return descriptor.descriptor_id == descriptor_id;
|
||||
@@ -273,7 +273,7 @@ RefPtr<CSSStyleValue const> CSSDescriptors::descriptor(DescriptorID descriptor_i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> CSSDescriptors::descriptor_or_initial_value(DescriptorID descriptor_id) const
|
||||
RefPtr<StyleValue const> CSSDescriptors::descriptor_or_initial_value(DescriptorID descriptor_id) const
|
||||
{
|
||||
if (auto value = descriptor(descriptor_id))
|
||||
return value.release_nonnull();
|
||||
@@ -289,7 +289,7 @@ bool is_shorthand(AtRuleID at_rule, DescriptorID descriptor)
|
||||
return false;
|
||||
}
|
||||
|
||||
void for_each_expanded_longhand(AtRuleID at_rule, DescriptorID descriptor, RefPtr<CSSStyleValue const> value, Function<void(DescriptorID, RefPtr<CSSStyleValue const>)> callback)
|
||||
void for_each_expanded_longhand(AtRuleID at_rule, DescriptorID descriptor, RefPtr<StyleValue const> value, Function<void(DescriptorID, RefPtr<StyleValue const>)> callback)
|
||||
{
|
||||
if (at_rule == AtRuleID::Page && descriptor == DescriptorID::Margin) {
|
||||
if (!value) {
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
virtual StringView get_property_priority(StringView property) const override;
|
||||
|
||||
Vector<Descriptor> const& descriptors() const { return m_descriptors; }
|
||||
RefPtr<CSSStyleValue const> descriptor(DescriptorID) const;
|
||||
RefPtr<CSSStyleValue const> descriptor_or_initial_value(DescriptorID) const;
|
||||
RefPtr<StyleValue const> descriptor(DescriptorID) const;
|
||||
RefPtr<StyleValue const> descriptor_or_initial_value(DescriptorID) const;
|
||||
virtual String serialized() const override;
|
||||
|
||||
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;
|
||||
@@ -37,7 +37,7 @@ protected:
|
||||
CSSDescriptors(JS::Realm&, AtRuleID, Vector<Descriptor>);
|
||||
|
||||
private:
|
||||
bool set_a_css_declaration(DescriptorID, NonnullRefPtr<CSSStyleValue const>, Important);
|
||||
bool set_a_css_declaration(DescriptorID, NonnullRefPtr<StyleValue const>, Important);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
@@ -46,6 +46,6 @@ private:
|
||||
};
|
||||
|
||||
bool is_shorthand(AtRuleID, DescriptorID);
|
||||
void for_each_expanded_longhand(AtRuleID, DescriptorID, RefPtr<CSSStyleValue const>, Function<void(DescriptorID, RefPtr<CSSStyleValue const>)>);
|
||||
void for_each_expanded_longhand(AtRuleID, DescriptorID, RefPtr<StyleValue const>, Function<void(DescriptorID, RefPtr<StyleValue const>)>);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace Web::CSS {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CSSPropertyRule);
|
||||
|
||||
GC::Ref<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value)
|
||||
GC::Ref<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<StyleValue const> initial_value)
|
||||
{
|
||||
return realm.create<CSSPropertyRule>(realm, move(name), move(syntax), inherits, move(initial_value));
|
||||
}
|
||||
|
||||
CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value)
|
||||
CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<StyleValue const> initial_value)
|
||||
: CSSRule(realm, Type::Property)
|
||||
, m_name(move(name))
|
||||
, m_syntax(move(syntax))
|
||||
|
||||
@@ -21,7 +21,7 @@ class CSSPropertyRule final : public CSSRule {
|
||||
GC_DECLARE_ALLOCATOR(CSSPropertyRule);
|
||||
|
||||
public:
|
||||
static GC::Ref<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value);
|
||||
static GC::Ref<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<StyleValue const> initial_value);
|
||||
|
||||
virtual ~CSSPropertyRule() = default;
|
||||
|
||||
@@ -29,10 +29,10 @@ public:
|
||||
FlyString const& syntax() const { return m_syntax; }
|
||||
bool inherits() const { return m_inherits; }
|
||||
Optional<String> initial_value() const;
|
||||
RefPtr<CSSStyleValue const> initial_style_value() const { return m_initial_value; }
|
||||
RefPtr<StyleValue const> initial_style_value() const { return m_initial_value; }
|
||||
|
||||
private:
|
||||
CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value);
|
||||
CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<StyleValue const> initial_value);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
FlyString m_name;
|
||||
FlyString m_syntax;
|
||||
bool m_inherits;
|
||||
RefPtr<CSSStyleValue const> m_initial_value;
|
||||
RefPtr<StyleValue const> m_initial_value;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/DOM/AbstractElement.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -83,7 +83,7 @@ Vector<StyleProperty> CSSStyleProperties::convert_declarations_to_specified_orde
|
||||
Vector<StyleProperty> specified_order_declarations;
|
||||
|
||||
for (auto declaration : declarations) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(declaration.property_id, declaration.value, [&](CSS::PropertyID longhand_id, CSS::CSSStyleValue const& longhand_property_value) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(declaration.property_id, declaration.value, [&](CSS::PropertyID longhand_id, CSS::StyleValue const& longhand_property_value) {
|
||||
auto existing_entry_index = specified_order_declarations.find_first_index_if([&](StyleProperty const& existing_declaration) { return existing_declaration.property_id == longhand_id; });
|
||||
|
||||
if (existing_entry_index.has_value()) {
|
||||
@@ -282,7 +282,7 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_property(StringView property_n
|
||||
// 8. If property is a shorthand property,
|
||||
if (property_is_shorthand(property_id)) {
|
||||
// then for each longhand property longhand that property maps to, in canonical order, follow these substeps:
|
||||
StyleComputer::for_each_property_expanding_shorthands(property_id, *component_value_list, [this, &updated, priority](PropertyID longhand_property_id, CSSStyleValue const& longhand_value) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(property_id, *component_value_list, [this, &updated, priority](PropertyID longhand_property_id, StyleValue const& longhand_value) {
|
||||
// 1. Let longhand result be the result of set the CSS declaration longhand with the appropriate value(s) from component value list,
|
||||
// with the important flag set if priority is not the empty string, and unset otherwise, and with the list of declarations being the declarations.
|
||||
// 2. If longhand result is true, let updated be true.
|
||||
@@ -325,7 +325,7 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_property(PropertyID property_i
|
||||
return set_property(string_from_property_id(property_id), css_text, priority);
|
||||
}
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
|
||||
static NonnullRefPtr<StyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
|
||||
{
|
||||
if (length_percentage.is_auto())
|
||||
return CSSKeywordValue::create(Keyword::Auto);
|
||||
@@ -336,7 +336,7 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(Leng
|
||||
return length_percentage.calculated();
|
||||
}
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size)
|
||||
static NonnullRefPtr<StyleValue const> style_value_for_size(Size const& size)
|
||||
{
|
||||
if (size.is_none())
|
||||
return CSSKeywordValue::create(Keyword::None);
|
||||
@@ -357,7 +357,7 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size)
|
||||
TODO();
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
|
||||
static RefPtr<StyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
|
||||
{
|
||||
if (shadow_data.is_empty())
|
||||
return CSSKeywordValue::create(Keyword::None);
|
||||
@@ -432,7 +432,7 @@ Optional<StyleProperty> CSSStyleProperties::get_property_internal(PropertyID pro
|
||||
// 2. If property is a shorthand property, then follow these substeps:
|
||||
if (property_is_shorthand(property_id)) {
|
||||
// 1. Let list be a new empty array.
|
||||
Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> list;
|
||||
Vector<ValueComparingNonnullRefPtr<StyleValue const>> list;
|
||||
Optional<Important> last_important_flag;
|
||||
|
||||
// 2. For each longhand property longhand that property maps to, in canonical order, follow these substeps:
|
||||
@@ -469,7 +469,7 @@ Optional<StyleProperty> CSSStyleProperties::get_property_internal(PropertyID pro
|
||||
return property(property_id);
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> resolve_color_style_value(CSSStyleValue const& style_value, Color computed_color)
|
||||
static RefPtr<StyleValue const> resolve_color_style_value(StyleValue const& style_value, Color computed_color)
|
||||
{
|
||||
if (style_value.is_color_function())
|
||||
return style_value;
|
||||
@@ -482,7 +482,7 @@ static RefPtr<CSSStyleValue const> resolve_color_style_value(CSSStyleValue const
|
||||
return CSSColorValue::create_from_color(computed_color, ColorSyntax::Modern);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
|
||||
RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
|
||||
{
|
||||
if (!owner_node().has_value()) {
|
||||
dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for CSSStyleProperties without owner node was requested");
|
||||
@@ -1189,7 +1189,7 @@ String CSSStyleProperties::serialize_a_css_value(Vector<StyleProperty> list) con
|
||||
// 3. Otherwise, serialize a CSS value from a hypothetical declaration of the property shorthand with its value representing the combined values of the declarations in list.
|
||||
Function<ValueComparingNonnullRefPtr<ShorthandStyleValue const>(PropertyID)> make_shorthand_value = [&](PropertyID shorthand_id) {
|
||||
auto longhand_ids = longhands_for_shorthand(shorthand_id);
|
||||
Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> longhand_values;
|
||||
Vector<ValueComparingNonnullRefPtr<StyleValue const>> longhand_values;
|
||||
|
||||
for (auto longhand_id : longhand_ids) {
|
||||
if (property_is_shorthand(longhand_id))
|
||||
@@ -1236,7 +1236,7 @@ void CSSStyleProperties::invalidate_owners(DOM::StyleInvalidationReason reason)
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#set-a-css-declaration
|
||||
bool CSSStyleProperties::set_a_css_declaration(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value, Important important)
|
||||
bool CSSStyleProperties::set_a_css_declaration(PropertyID property_id, NonnullRefPtr<StyleValue const> value, Important important)
|
||||
{
|
||||
VERIFY(!is_computed());
|
||||
|
||||
|
||||
@@ -68,10 +68,10 @@ private:
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
RefPtr<CSSStyleValue const> style_value_for_computed_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||
RefPtr<StyleValue const> style_value_for_computed_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||
Optional<StyleProperty> get_property_internal(PropertyID) const;
|
||||
|
||||
bool set_a_css_declaration(PropertyID, NonnullRefPtr<CSSStyleValue const>, Important);
|
||||
bool set_a_css_declaration(PropertyID, NonnullRefPtr<StyleValue const>, Important);
|
||||
void empty_the_declarations();
|
||||
void set_the_declarations(Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties);
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ void CSSStyleRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
|
||||
|
||||
// This is annoying: Style values that request resources need to know their CSSStyleSheet in order to fetch them.
|
||||
for (auto const& property : m_declaration->properties()) {
|
||||
const_cast<CSSStyleValue&>(*property.value).set_style_sheet(parent_style_sheet);
|
||||
const_cast<StyleValue&>(*property.value).set_style_sheet(parent_style_sheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace Web::CSS {
|
||||
GC_DEFINE_ALLOCATOR(CSSTransition);
|
||||
|
||||
GC::Ref<CSSTransition> CSSTransition::start_a_transition(DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id,
|
||||
size_t transition_generation, double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value,
|
||||
NonnullRefPtr<CSSStyleValue const> end_value, NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
|
||||
size_t transition_generation, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value,
|
||||
NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return realm.create<CSSTransition>(realm, element, pseudo_element, property_id, transition_generation, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor);
|
||||
@@ -76,8 +76,8 @@ Optional<int> CSSTransition::class_specific_composite_order(GC::Ref<Animations::
|
||||
}
|
||||
|
||||
CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, size_t transition_generation,
|
||||
double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value, NonnullRefPtr<CSSStyleValue const> end_value,
|
||||
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
|
||||
double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value,
|
||||
NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
|
||||
: Animations::Animation(realm)
|
||||
, m_transition_property(property_id)
|
||||
, m_transition_generation(transition_generation)
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Animations/Animation.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Interpolation.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/PseudoElement.h>
|
||||
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
@@ -23,8 +23,8 @@ class CSSTransition : public Animations::Animation {
|
||||
|
||||
public:
|
||||
static GC::Ref<CSSTransition> start_a_transition(DOM::Element&, Optional<PseudoElement>, PropertyID,
|
||||
size_t transition_generation, double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value,
|
||||
NonnullRefPtr<CSSStyleValue const> end_value, NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
|
||||
size_t transition_generation, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value,
|
||||
NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
|
||||
|
||||
StringView transition_property() const { return string_from_property_id(m_transition_property); }
|
||||
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
|
||||
double transition_start_time() const { return m_start_time; }
|
||||
double transition_end_time() const { return m_end_time; }
|
||||
NonnullRefPtr<CSSStyleValue const> transition_start_value() const { return m_start_value; }
|
||||
NonnullRefPtr<CSSStyleValue const> transition_end_value() const { return m_end_value; }
|
||||
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value() const { return m_reversing_adjusted_start_value; }
|
||||
NonnullRefPtr<StyleValue const> transition_start_value() const { return m_start_value; }
|
||||
NonnullRefPtr<StyleValue const> transition_end_value() const { return m_end_value; }
|
||||
NonnullRefPtr<StyleValue const> reversing_adjusted_start_value() const { return m_reversing_adjusted_start_value; }
|
||||
double reversing_shortening_factor() const { return m_reversing_shortening_factor; }
|
||||
|
||||
double timing_function_output_at_time(double t) const;
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
|
||||
private:
|
||||
CSSTransition(JS::Realm&, DOM::Element&, Optional<PseudoElement>, PropertyID, size_t transition_generation,
|
||||
double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value, NonnullRefPtr<CSSStyleValue const> end_value,
|
||||
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
|
||||
double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value,
|
||||
NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
@@ -73,13 +73,13 @@ private:
|
||||
double m_end_time;
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transition-start-value
|
||||
NonnullRefPtr<CSS::CSSStyleValue const> m_start_value;
|
||||
NonnullRefPtr<CSS::StyleValue const> m_start_value;
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transition-end-value
|
||||
NonnullRefPtr<CSS::CSSStyleValue const> m_end_value;
|
||||
NonnullRefPtr<CSS::StyleValue const> m_end_value;
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transition-reversing-adjusted-start-value
|
||||
NonnullRefPtr<CSS::CSSStyleValue const> m_reversing_adjusted_start_value;
|
||||
NonnullRefPtr<CSS::StyleValue const> m_reversing_adjusted_start_value;
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transition-reversing-shortening-factor
|
||||
double m_reversing_shortening_factor;
|
||||
|
||||
@@ -22,7 +22,7 @@ Optional<Angle> AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedSt
|
||||
return calculated->resolve_angle_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> AngleOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> AngleOrCalculated::create_style_value() const
|
||||
{
|
||||
return AngleStyleValue::create(value());
|
||||
}
|
||||
@@ -32,7 +32,7 @@ Optional<Flex> FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyl
|
||||
return calculated->resolve_flex_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> FlexOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> FlexOrCalculated::create_style_value() const
|
||||
{
|
||||
return FlexStyleValue::create(value());
|
||||
}
|
||||
@@ -42,7 +42,7 @@ Optional<Frequency> FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<Calc
|
||||
return calculated->resolve_frequency_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> FrequencyOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> FrequencyOrCalculated::create_style_value() const
|
||||
{
|
||||
return FrequencyStyleValue::create(value());
|
||||
}
|
||||
@@ -52,7 +52,7 @@ Optional<i64> IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedSt
|
||||
return calculated->resolve_integer_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> IntegerOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> IntegerOrCalculated::create_style_value() const
|
||||
{
|
||||
return IntegerStyleValue::create(value());
|
||||
}
|
||||
@@ -62,7 +62,7 @@ Optional<Length> LengthOrCalculated::resolve_calculated(NonnullRefPtr<Calculated
|
||||
return calculated->resolve_length_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> LengthOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> LengthOrCalculated::create_style_value() const
|
||||
{
|
||||
return LengthStyleValue::create(value());
|
||||
}
|
||||
@@ -72,7 +72,7 @@ Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<Calculated
|
||||
return calculated->resolve_number_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> NumberOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> NumberOrCalculated::create_style_value() const
|
||||
{
|
||||
return NumberStyleValue::create(value());
|
||||
}
|
||||
@@ -82,7 +82,7 @@ Optional<Percentage> PercentageOrCalculated::resolve_calculated(NonnullRefPtr<Ca
|
||||
return calculated->resolve_percentage_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> PercentageOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> PercentageOrCalculated::create_style_value() const
|
||||
{
|
||||
return PercentageStyleValue::create(value());
|
||||
}
|
||||
@@ -92,7 +92,7 @@ Optional<Resolution> ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<Ca
|
||||
return calculated->resolve_resolution_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> ResolutionOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> ResolutionOrCalculated::create_style_value() const
|
||||
{
|
||||
return ResolutionStyleValue::create(value());
|
||||
}
|
||||
@@ -102,7 +102,7 @@ Optional<Time> TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyl
|
||||
return calculated->resolve_time_deprecated(context);
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> TimeOrCalculated::create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> TimeOrCalculated::create_style_value() const
|
||||
{
|
||||
return TimeStyleValue::create(value());
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
return m_value.template get<T>();
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> as_style_value() const
|
||||
NonnullRefPtr<StyleValue const> as_style_value() const
|
||||
{
|
||||
if (is_calculated())
|
||||
return calculated();
|
||||
@@ -104,7 +104,7 @@ protected:
|
||||
{
|
||||
return static_cast<Self const*>(this)->resolve_calculated(calculated, context);
|
||||
}
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const
|
||||
{
|
||||
return static_cast<Self const*>(this)->create_style_value();
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Angle> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class FlexOrCalculated : public CalculatedOr<FlexOrCalculated, Flex> {
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Flex> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class FrequencyOrCalculated : public CalculatedOr<FrequencyOrCalculated, Frequency> {
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Frequency> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class IntegerOrCalculated : public CalculatedOr<IntegerOrCalculated, i64> {
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<i64> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class LengthOrCalculated : public CalculatedOr<LengthOrCalculated, Length> {
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Length> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class NumberOrCalculated : public CalculatedOr<NumberOrCalculated, double> {
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<double> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class PercentageOrCalculated : public CalculatedOr<PercentageOrCalculated, Percentage> {
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Percentage> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class ResolutionOrCalculated : public CalculatedOr<ResolutionOrCalculated, Resolution> {
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Resolution> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
class TimeOrCalculated : public CalculatedOr<TimeOrCalculated, Time> {
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
using CalculatedOr::CalculatedOr;
|
||||
|
||||
Optional<Time> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
|
||||
NonnullRefPtr<CSSStyleValue const> create_style_value() const;
|
||||
NonnullRefPtr<StyleValue const> create_style_value() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void CascadedProperties::resolve_unresolved_properties(GC::Ref<DOM::Element> ele
|
||||
}
|
||||
}
|
||||
|
||||
void CascadedProperties::set_property(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value, Important important, CascadeOrigin origin, Optional<FlyString> layer_name, GC::Ptr<CSS::CSSStyleDeclaration const> source)
|
||||
void CascadedProperties::set_property(PropertyID property_id, NonnullRefPtr<StyleValue const> value, Important important, CascadeOrigin origin, Optional<FlyString> layer_name, GC::Ptr<CSS::CSSStyleDeclaration const> source)
|
||||
{
|
||||
auto& entries = m_properties.ensure(property_id);
|
||||
|
||||
@@ -99,9 +99,9 @@ void CascadedProperties::set_property(PropertyID property_id, NonnullRefPtr<CSSS
|
||||
});
|
||||
}
|
||||
|
||||
void CascadedProperties::set_property_from_presentational_hint(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value)
|
||||
void CascadedProperties::set_property_from_presentational_hint(PropertyID property_id, NonnullRefPtr<StyleValue const> value)
|
||||
{
|
||||
StyleComputer::for_each_property_expanding_shorthands(property_id, value, [this](PropertyID longhand_property_id, CSSStyleValue const& longhand_value) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(property_id, value, [this](PropertyID longhand_property_id, StyleValue const& longhand_value) {
|
||||
auto& entries = m_properties.ensure(longhand_property_id);
|
||||
|
||||
entries.append(Entry {
|
||||
@@ -117,7 +117,7 @@ void CascadedProperties::set_property_from_presentational_hint(PropertyID proper
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> CascadedProperties::property(PropertyID property_id) const
|
||||
RefPtr<StyleValue const> CascadedProperties::property(PropertyID property_id) const
|
||||
{
|
||||
auto it = m_properties.find(property_id);
|
||||
if (it == m_properties.end())
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/CascadeOrigin.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -23,12 +23,12 @@ class CascadedProperties final : public JS::Cell {
|
||||
public:
|
||||
virtual ~CascadedProperties() override;
|
||||
|
||||
[[nodiscard]] RefPtr<CSSStyleValue const> property(PropertyID) const;
|
||||
[[nodiscard]] RefPtr<StyleValue const> property(PropertyID) const;
|
||||
[[nodiscard]] GC::Ptr<CSSStyleDeclaration const> property_source(PropertyID) const;
|
||||
[[nodiscard]] bool is_property_important(PropertyID) const;
|
||||
|
||||
void set_property(PropertyID, NonnullRefPtr<CSSStyleValue const>, Important, CascadeOrigin, Optional<FlyString> layer_name, GC::Ptr<CSS::CSSStyleDeclaration const> source);
|
||||
void set_property_from_presentational_hint(PropertyID, NonnullRefPtr<CSSStyleValue const>);
|
||||
void set_property(PropertyID, NonnullRefPtr<StyleValue const>, Important, CascadeOrigin, Optional<FlyString> layer_name, GC::Ptr<CSS::CSSStyleDeclaration const> source);
|
||||
void set_property_from_presentational_hint(PropertyID, NonnullRefPtr<StyleValue const>);
|
||||
|
||||
void revert_property(PropertyID, Important, CascadeOrigin);
|
||||
void revert_layer_property(PropertyID, Important, Optional<FlyString> layer_name);
|
||||
|
||||
@@ -85,7 +85,7 @@ void ComputedProperties::set_property_inherited(PropertyID property_id, Inherite
|
||||
m_property_inherited[n / 8] &= ~(1 << (n % 8));
|
||||
}
|
||||
|
||||
void ComputedProperties::set_property(PropertyID id, NonnullRefPtr<CSSStyleValue const> value, Inherited inherited, Important important)
|
||||
void ComputedProperties::set_property(PropertyID id, NonnullRefPtr<StyleValue const> value, Inherited inherited, Important important)
|
||||
{
|
||||
m_property_values[to_underlying(id)] = move(value);
|
||||
set_property_important(id, important);
|
||||
@@ -99,7 +99,7 @@ void ComputedProperties::revert_property(PropertyID id, ComputedProperties const
|
||||
set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No);
|
||||
}
|
||||
|
||||
void ComputedProperties::set_animated_property(PropertyID id, NonnullRefPtr<CSSStyleValue const> value)
|
||||
void ComputedProperties::set_animated_property(PropertyID id, NonnullRefPtr<StyleValue const> value)
|
||||
{
|
||||
m_animated_property_values.set(id, move(value));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void ComputedProperties::reset_animated_properties(Badge<Animations::KeyframeEff
|
||||
m_animated_property_values.clear();
|
||||
}
|
||||
|
||||
CSSStyleValue const& ComputedProperties::property(PropertyID property_id, WithAnimationsApplied return_animated_value) const
|
||||
StyleValue const& ComputedProperties::property(PropertyID property_id, WithAnimationsApplied return_animated_value) const
|
||||
{
|
||||
if (return_animated_value == WithAnimationsApplied::Yes) {
|
||||
if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
@@ -120,7 +120,7 @@ CSSStyleValue const& ComputedProperties::property(PropertyID property_id, WithAn
|
||||
return *m_property_values[to_underlying(property_id)];
|
||||
}
|
||||
|
||||
CSSStyleValue const* ComputedProperties::maybe_null_property(PropertyID property_id) const
|
||||
StyleValue const* ComputedProperties::maybe_null_property(PropertyID property_id) const
|
||||
{
|
||||
if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
return animated_value.value();
|
||||
@@ -359,7 +359,7 @@ Optional<int> ComputedProperties::z_index() const
|
||||
return {};
|
||||
}
|
||||
|
||||
float ComputedProperties::resolve_opacity_value(CSSStyleValue const& value)
|
||||
float ComputedProperties::resolve_opacity_value(StyleValue const& value)
|
||||
{
|
||||
float unclamped_opacity = 1.0f;
|
||||
|
||||
@@ -581,7 +581,7 @@ JustifySelf ComputedProperties::justify_self() const
|
||||
return keyword_to_justify_self(value.to_keyword()).release_value();
|
||||
}
|
||||
|
||||
Vector<Transformation> ComputedProperties::transformations_for_style_value(CSSStyleValue const& value)
|
||||
Vector<Transformation> ComputedProperties::transformations_for_style_value(StyleValue const& value)
|
||||
{
|
||||
if (value.is_keyword() && value.to_keyword() == Keyword::None)
|
||||
return {};
|
||||
@@ -629,7 +629,7 @@ Optional<Transformation> ComputedProperties::scale() const
|
||||
return value.as_transformation().to_transformation();
|
||||
}
|
||||
|
||||
static Optional<LengthPercentage> length_percentage_for_style_value(CSSStyleValue const& value)
|
||||
static Optional<LengthPercentage> length_percentage_for_style_value(StyleValue const& value)
|
||||
{
|
||||
if (value.is_length())
|
||||
return value.as_length().length();
|
||||
@@ -648,7 +648,7 @@ TransformBox ComputedProperties::transform_box() const
|
||||
|
||||
TransformOrigin ComputedProperties::transform_origin() const
|
||||
{
|
||||
auto length_percentage_with_keywords_resolved = [](CSSStyleValue const& value) -> Optional<LengthPercentage> {
|
||||
auto length_percentage_with_keywords_resolved = [](StyleValue const& value) -> Optional<LengthPercentage> {
|
||||
if (value.is_keyword()) {
|
||||
auto keyword = value.to_keyword();
|
||||
if (keyword == Keyword::Left || keyword == Keyword::Top)
|
||||
@@ -1170,7 +1170,7 @@ Vector<ShadowData> ComputedProperties::shadow(PropertyID property_id, Layout::No
|
||||
{
|
||||
auto const& value = property(property_id);
|
||||
|
||||
auto resolve_to_length = [&layout_node](NonnullRefPtr<CSSStyleValue const> const& value) -> Optional<Length> {
|
||||
auto resolve_to_length = [&layout_node](NonnullRefPtr<StyleValue const> const& value) -> Optional<Length> {
|
||||
if (value->is_length())
|
||||
return value->as_length().length();
|
||||
if (value->is_calculated())
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
Yes
|
||||
};
|
||||
|
||||
HashMap<PropertyID, NonnullRefPtr<CSSStyleValue const>> const& animated_property_values() const { return m_animated_property_values; }
|
||||
HashMap<PropertyID, NonnullRefPtr<StyleValue const>> const& animated_property_values() const { return m_animated_property_values; }
|
||||
void reset_animated_properties(Badge<Animations::KeyframeEffect>);
|
||||
|
||||
bool is_property_important(PropertyID property_id) const;
|
||||
@@ -56,14 +56,14 @@ public:
|
||||
void set_property_important(PropertyID, Important);
|
||||
void set_property_inherited(PropertyID, Inherited);
|
||||
|
||||
void set_property(PropertyID, NonnullRefPtr<CSSStyleValue const> value, Inherited = Inherited::No, Important = Important::No);
|
||||
void set_animated_property(PropertyID, NonnullRefPtr<CSSStyleValue const> value);
|
||||
void set_property(PropertyID, NonnullRefPtr<StyleValue const> value, Inherited = Inherited::No, Important = Important::No);
|
||||
void set_animated_property(PropertyID, NonnullRefPtr<StyleValue const> value);
|
||||
enum class WithAnimationsApplied {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
CSSStyleValue const& property(PropertyID, WithAnimationsApplied = WithAnimationsApplied::Yes) const;
|
||||
CSSStyleValue const* maybe_null_property(PropertyID) const;
|
||||
StyleValue const& property(PropertyID, WithAnimationsApplied = WithAnimationsApplied::Yes) const;
|
||||
StyleValue const* maybe_null_property(PropertyID) const;
|
||||
void revert_property(PropertyID, ComputedProperties const& style_for_revert);
|
||||
|
||||
GC::Ptr<CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
MixBlendMode mix_blend_mode() const;
|
||||
Optional<FlyString> view_transition_name() const;
|
||||
|
||||
static Vector<Transformation> transformations_for_style_value(CSSStyleValue const& value);
|
||||
static Vector<Transformation> transformations_for_style_value(StyleValue const& value);
|
||||
Vector<Transformation> transformations() const;
|
||||
TransformBox transform_box() const;
|
||||
TransformOrigin transform_origin() const;
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
|
||||
static NonnullRefPtr<Gfx::Font const> font_fallback(bool monospace, bool bold, float point_size);
|
||||
|
||||
static float resolve_opacity_value(CSSStyleValue const& value);
|
||||
static float resolve_opacity_value(StyleValue const& value);
|
||||
|
||||
bool has_attempted_match_against_pseudo_class(PseudoClass pseudo_class) const
|
||||
{
|
||||
@@ -263,11 +263,11 @@ private:
|
||||
GC::Ptr<CSSStyleDeclaration const> m_animation_name_source;
|
||||
GC::Ptr<CSSStyleDeclaration const> m_transition_property_source;
|
||||
|
||||
Array<RefPtr<CSSStyleValue const>, number_of_properties> m_property_values;
|
||||
Array<RefPtr<StyleValue 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_inherited {};
|
||||
|
||||
HashMap<PropertyID, NonnullRefPtr<CSSStyleValue const>> m_animated_property_values;
|
||||
HashMap<PropertyID, NonnullRefPtr<StyleValue const>> m_animated_property_values;
|
||||
|
||||
int m_math_depth { InitialValues::math_depth() };
|
||||
RefPtr<Gfx::FontCascadeList const> m_font_list;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Descriptor.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ struct Descriptor {
|
||||
~Descriptor();
|
||||
|
||||
DescriptorID descriptor_id;
|
||||
NonnullRefPtr<CSSStyleValue const> value;
|
||||
NonnullRefPtr<StyleValue const> value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/Variant.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
|
||||
font_face->m_ascent_override = try_parse_descriptor(DescriptorID::AscentOverride, descriptors.ascent_override);
|
||||
font_face->m_descent_override = try_parse_descriptor(DescriptorID::DescentOverride, descriptors.descent_override);
|
||||
font_face->m_line_gap_override = try_parse_descriptor(DescriptorID::LineGapOverride, descriptors.line_gap_override);
|
||||
RefPtr<CSSStyleValue const> parsed_source;
|
||||
RefPtr<StyleValue const> parsed_source;
|
||||
if (auto* source_string = source.get_pointer<String>()) {
|
||||
parsed_source = parse_css_descriptor(parsing_params, AtRuleID::FontFace, DescriptorID::Src, *source_string);
|
||||
if (!parsed_source) {
|
||||
|
||||
@@ -49,7 +49,7 @@ static T interpolate_raw(T from, T to, float delta)
|
||||
return static_cast<AK::Detail::RemoveCVReference<T>>(from + (to - from) * delta);
|
||||
}
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue const> with_keyword_values_resolved(DOM::Element& element, PropertyID property_id, CSSStyleValue const& value)
|
||||
static NonnullRefPtr<StyleValue const> with_keyword_values_resolved(DOM::Element& element, PropertyID property_id, StyleValue const& value)
|
||||
{
|
||||
if (value.is_guaranteed_invalid()) {
|
||||
// At the moment, we're only dealing with "real" properties, so this behaves the same as `unset`.
|
||||
@@ -71,7 +71,7 @@ static NonnullRefPtr<CSSStyleValue const> with_keyword_values_resolved(DOM::Elem
|
||||
return value;
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> interpolate_discrete(CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_discrete(StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (from.equals(to))
|
||||
return from;
|
||||
@@ -80,7 +80,7 @@ static RefPtr<CSSStyleValue const> interpolate_discrete(CSSStyleValue const& fro
|
||||
return delta >= 0.5f ? to : from;
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> interpolate_scale(DOM::Element& element, CalculationContext calculation_context, CSSStyleValue const& a_from, CSSStyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_scale(DOM::Element& element, CalculationContext calculation_context, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (a_from.to_keyword() == Keyword::None && a_to.to_keyword() == Keyword::None)
|
||||
return a_from;
|
||||
@@ -99,7 +99,7 @@ static RefPtr<CSSStyleValue const> interpolate_scale(DOM::Element& element, Calc
|
||||
auto interpolated_y = interpolate_value(element, calculation_context, from_transform.values()[1], to_transform.values()[1], delta, allow_discrete);
|
||||
if (!interpolated_y)
|
||||
return {};
|
||||
RefPtr<CSSStyleValue const> interpolated_z;
|
||||
RefPtr<StyleValue const> interpolated_z;
|
||||
|
||||
if (from_transform.values().size() == 3 || to_transform.values().size() == 3) {
|
||||
static auto one_value = NumberStyleValue::create(1);
|
||||
@@ -155,7 +155,7 @@ static Optional<FilterValue> interpolate_filter_function(DOM::Element& element,
|
||||
return {};
|
||||
},
|
||||
[&](FilterOperation::Color const& from_value) -> Optional<FilterValue> {
|
||||
auto resolve_number_percentage = [](NumberPercentage const& amount) -> ValueComparingNonnullRefPtr<CSSStyleValue const> {
|
||||
auto resolve_number_percentage = [](NumberPercentage const& amount) -> ValueComparingNonnullRefPtr<StyleValue const> {
|
||||
if (amount.is_number())
|
||||
return NumberStyleValue::create(amount.number().value());
|
||||
if (amount.is_percentage())
|
||||
@@ -168,7 +168,7 @@ static Optional<FilterValue> interpolate_filter_function(DOM::Element& element,
|
||||
auto from_style_value = resolve_number_percentage(from_value.amount);
|
||||
auto to_style_value = resolve_number_percentage(to_value.amount);
|
||||
if (auto interpolated_style_value = interpolate_value(element, calculation_context, from_style_value, to_style_value, delta, allow_discrete)) {
|
||||
auto to_number_percentage = [&](CSSStyleValue const& style_value) -> NumberPercentage {
|
||||
auto to_number_percentage = [&](StyleValue const& style_value) -> NumberPercentage {
|
||||
if (style_value.is_number())
|
||||
return Number {
|
||||
Number::Type::Number,
|
||||
@@ -196,9 +196,9 @@ static Optional<FilterValue> interpolate_filter_function(DOM::Element& element,
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/filter-effects/#interpolation-of-filters
|
||||
static RefPtr<CSSStyleValue const> interpolate_filter_value_list(DOM::Element& element, CalculationContext calculation_context, CSSStyleValue const& a_from, CSSStyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_filter_value_list(DOM::Element& element, CalculationContext calculation_context, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
auto is_filter_value_list_without_url = [](CSSStyleValue const& value) {
|
||||
auto is_filter_value_list_without_url = [](StyleValue const& value) {
|
||||
if (!value.is_filter_value_list())
|
||||
return false;
|
||||
auto const& filter_value_list = value.as_filter_value_list();
|
||||
@@ -240,7 +240,7 @@ static RefPtr<CSSStyleValue const> interpolate_filter_value_list(DOM::Element& e
|
||||
});
|
||||
};
|
||||
|
||||
auto interpolate_filter_values = [&](CSSStyleValue const& from, CSSStyleValue const& to) -> RefPtr<FilterValueListStyleValue const> {
|
||||
auto interpolate_filter_values = [&](StyleValue const& from, StyleValue const& to) -> RefPtr<FilterValueListStyleValue const> {
|
||||
auto const& from_filter_values = from.as_filter_value_list().filter_value_list();
|
||||
auto const& to_filter_values = to.as_filter_value_list().filter_value_list();
|
||||
Vector<FilterValue> interpolated_filter_values;
|
||||
@@ -276,8 +276,8 @@ static RefPtr<CSSStyleValue const> interpolate_filter_value_list(DOM::Element& e
|
||||
}
|
||||
return FilterValueListStyleValue::create(move(new_filter_list));
|
||||
};
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> from = from_list.size() < to_list.size() ? append_missing_values_to(from_list, to_list) : a_from;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> to = to_list.size() < from_list.size() ? append_missing_values_to(to_list, from_list) : a_to;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> from = from_list.size() < to_list.size() ? append_missing_values_to(from_list, to_list) : a_from;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> to = to_list.size() < from_list.size() ? append_missing_values_to(to_list, from_list) : a_to;
|
||||
|
||||
// 2. Interpolate each <filter-function> pair following the rules in section Interpolation of Filter Functions.
|
||||
return interpolate_filter_values(from, to);
|
||||
@@ -296,8 +296,8 @@ static RefPtr<CSSStyleValue const> interpolate_filter_value_list(DOM::Element& e
|
||||
return FilterValueListStyleValue::create(move(initial_values));
|
||||
};
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> from = a_from.is_keyword() ? replace_none_with_initial_filter_list_values(a_to.as_filter_value_list()) : a_from;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> to = a_to.is_keyword() ? replace_none_with_initial_filter_list_values(a_from.as_filter_value_list()) : a_to;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> from = a_from.is_keyword() ? replace_none_with_initial_filter_list_values(a_to.as_filter_value_list()) : a_from;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> to = a_to.is_keyword() ? replace_none_with_initial_filter_list_values(a_from.as_filter_value_list()) : a_to;
|
||||
|
||||
// 2. Interpolate each <filter-function> pair following the rules in section Interpolation of Filter Functions.
|
||||
return interpolate_filter_values(from, to);
|
||||
@@ -308,7 +308,7 @@ static RefPtr<CSSStyleValue const> interpolate_filter_value_list(DOM::Element& e
|
||||
return {};
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> interpolate_translate(DOM::Element& element, CalculationContext calculation_context, CSSStyleValue const& a_from, CSSStyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_translate(DOM::Element& element, CalculationContext calculation_context, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (a_from.to_keyword() == Keyword::None && a_to.to_keyword() == Keyword::None)
|
||||
return a_from;
|
||||
@@ -329,7 +329,7 @@ static RefPtr<CSSStyleValue const> interpolate_translate(DOM::Element& element,
|
||||
if (!interpolated_y)
|
||||
return {};
|
||||
|
||||
RefPtr<CSSStyleValue const> interpolated_z;
|
||||
RefPtr<StyleValue const> interpolated_z;
|
||||
|
||||
if (from_transform.values().size() == 3 || to_transform.values().size() == 3) {
|
||||
auto from_z = from_transform.values().size() == 3 ? from_transform.values()[2] : zero_px;
|
||||
@@ -364,7 +364,7 @@ static FloatVector4 slerp(FloatVector4 const& from, FloatVector4 const& to, floa
|
||||
return from * (cosf(delta * theta) - (product * w)) + to * w;
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> interpolate_rotate(DOM::Element& element, CalculationContext calculation_context, CSSStyleValue const& a_from, CSSStyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_rotate(DOM::Element& element, CalculationContext calculation_context, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (a_from.to_keyword() == Keyword::None && a_to.to_keyword() == Keyword::None)
|
||||
return a_from;
|
||||
@@ -447,7 +447,7 @@ static RefPtr<CSSStyleValue const> interpolate_rotate(DOM::Element& element, Cal
|
||||
{ interpolated_x_axis, interpolated_y_axis, interpolated_z_axis, interpolated_angle });
|
||||
}
|
||||
|
||||
ValueComparingRefPtr<CSSStyleValue const> interpolate_property(DOM::Element& element, PropertyID property_id, CSSStyleValue const& a_from, CSSStyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
ValueComparingRefPtr<StyleValue const> interpolate_property(DOM::Element& element, PropertyID property_id, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
auto from = with_keyword_values_resolved(element, property_id, a_from);
|
||||
auto to = with_keyword_values_resolved(element, property_id, a_to);
|
||||
@@ -565,7 +565,7 @@ ValueComparingRefPtr<CSSStyleValue const> interpolate_property(DOM::Element& ele
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transitionable
|
||||
bool property_values_are_transitionable(PropertyID property_id, CSSStyleValue const& old_value, CSSStyleValue const& new_value, DOM::Element& element, TransitionBehavior transition_behavior)
|
||||
bool property_values_are_transitionable(PropertyID property_id, StyleValue const& old_value, StyleValue const& new_value, DOM::Element& element, TransitionBehavior transition_behavior)
|
||||
{
|
||||
// When comparing the before-change style and after-change style for a given property,
|
||||
// the property values are transitionable if they have an animation type that is neither not animatable nor discrete.
|
||||
@@ -582,7 +582,7 @@ bool property_values_are_transitionable(PropertyID property_id, CSSStyleValue co
|
||||
}
|
||||
|
||||
// A null return value means the interpolated matrix was not invertible or otherwise invalid
|
||||
RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete)
|
||||
RefPtr<StyleValue const> interpolate_transform(DOM::Element& element, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete)
|
||||
{
|
||||
// Note that the spec uses column-major notation, so all the matrix indexing is reversed.
|
||||
|
||||
@@ -591,10 +591,10 @@ RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyl
|
||||
|
||||
for (auto const& value : transformation.values()) {
|
||||
switch (value->type()) {
|
||||
case CSSStyleValue::Type::Angle:
|
||||
case StyleValue::Type::Angle:
|
||||
values.append(AngleOrCalculated { value->as_angle().angle() });
|
||||
break;
|
||||
case CSSStyleValue::Type::Calculated: {
|
||||
case StyleValue::Type::Calculated: {
|
||||
auto& calculated = value->as_calculated();
|
||||
if (calculated.resolves_to_angle()) {
|
||||
values.append(AngleOrCalculated { calculated });
|
||||
@@ -608,13 +608,13 @@ RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyl
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CSSStyleValue::Type::Length:
|
||||
case StyleValue::Type::Length:
|
||||
values.append(LengthPercentage { value->as_length().length() });
|
||||
break;
|
||||
case CSSStyleValue::Type::Percentage:
|
||||
case StyleValue::Type::Percentage:
|
||||
values.append(LengthPercentage { value->as_percentage().percentage() });
|
||||
break;
|
||||
case CSSStyleValue::Type::Number:
|
||||
case StyleValue::Type::Number:
|
||||
values.append(NumberPercentage { Number(Number::Type::Number, value->as_number().number()) });
|
||||
break;
|
||||
default:
|
||||
@@ -639,7 +639,7 @@ RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyl
|
||||
return {};
|
||||
};
|
||||
|
||||
static constexpr auto style_value_to_matrix = [](DOM::Element& element, CSSStyleValue const& value) -> FloatMatrix4x4 {
|
||||
static constexpr auto style_value_to_matrix = [](DOM::Element& element, StyleValue const& value) -> FloatMatrix4x4 {
|
||||
if (value.is_transformation())
|
||||
return transformation_style_value_to_matrix(element, value.as_transformation()).value_or(FloatMatrix4x4::identity());
|
||||
|
||||
@@ -910,14 +910,14 @@ Color interpolate_color(Color from, Color to, float delta, ColorSyntax syntax)
|
||||
return result;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& element, CalculationContext const& calculation_context, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
// https://drafts.csswg.org/css-backgrounds/#box-shadow
|
||||
// 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
|
||||
// the shorter list is otherwise compatible with the longer one
|
||||
|
||||
static constexpr auto process_list = [](CSSStyleValue const& value) {
|
||||
static constexpr auto process_list = [](StyleValue const& value) {
|
||||
StyleValueVector shadows;
|
||||
if (value.is_value_list()) {
|
||||
for (auto const& element : value.as_value_list().values()) {
|
||||
@@ -999,7 +999,7 @@ RefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& element, Calcul
|
||||
return StyleValueList::create(move(result_shadows), StyleValueList::Separator::Comma);
|
||||
}
|
||||
|
||||
static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element, CalculationContext const& calculation_context, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (from.type() != to.type()) {
|
||||
// Handle mixed percentage and dimension types
|
||||
@@ -1007,27 +1007,27 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
|
||||
struct NumericBaseTypeAndDefault {
|
||||
CSSNumericType::BaseType base_type;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> default_value;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> default_value;
|
||||
};
|
||||
static constexpr auto numeric_base_type_and_default = [](CSSStyleValue const& value) -> Optional<NumericBaseTypeAndDefault> {
|
||||
static constexpr auto numeric_base_type_and_default = [](StyleValue const& value) -> Optional<NumericBaseTypeAndDefault> {
|
||||
switch (value.type()) {
|
||||
case CSSStyleValue::Type::Angle: {
|
||||
case StyleValue::Type::Angle: {
|
||||
static auto default_angle_value = AngleStyleValue::create(Angle::make_degrees(0));
|
||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Angle, default_angle_value };
|
||||
}
|
||||
case CSSStyleValue::Type::Frequency: {
|
||||
case StyleValue::Type::Frequency: {
|
||||
static auto default_frequency_value = FrequencyStyleValue::create(Frequency::make_hertz(0));
|
||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Frequency, default_frequency_value };
|
||||
}
|
||||
case CSSStyleValue::Type::Length: {
|
||||
case StyleValue::Type::Length: {
|
||||
static auto default_length_value = LengthStyleValue::create(Length::make_px(0));
|
||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Length, default_length_value };
|
||||
}
|
||||
case CSSStyleValue::Type::Percentage: {
|
||||
case StyleValue::Type::Percentage: {
|
||||
static auto default_percentage_value = PercentageStyleValue::create(Percentage { 0.0 });
|
||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Percent, default_percentage_value };
|
||||
}
|
||||
case CSSStyleValue::Type::Time: {
|
||||
case StyleValue::Type::Time: {
|
||||
static auto default_time_value = TimeStyleValue::create(Time::make_seconds(0));
|
||||
return NumericBaseTypeAndDefault { CSSNumericType::BaseType::Time, default_time_value };
|
||||
}
|
||||
@@ -1036,17 +1036,17 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
}
|
||||
};
|
||||
|
||||
static auto to_calculation_node = [calculation_context](CSSStyleValue const& value) -> NonnullRefPtr<CalculationNode const> {
|
||||
static auto to_calculation_node = [calculation_context](StyleValue const& value) -> NonnullRefPtr<CalculationNode const> {
|
||||
switch (value.type()) {
|
||||
case CSSStyleValue::Type::Angle:
|
||||
case StyleValue::Type::Angle:
|
||||
return NumericCalculationNode::create(value.as_angle().angle(), calculation_context);
|
||||
case CSSStyleValue::Type::Frequency:
|
||||
case StyleValue::Type::Frequency:
|
||||
return NumericCalculationNode::create(value.as_frequency().frequency(), calculation_context);
|
||||
case CSSStyleValue::Type::Length:
|
||||
case StyleValue::Type::Length:
|
||||
return NumericCalculationNode::create(value.as_length().length(), calculation_context);
|
||||
case CSSStyleValue::Type::Percentage:
|
||||
case StyleValue::Type::Percentage:
|
||||
return NumericCalculationNode::create(value.as_percentage().percentage(), calculation_context);
|
||||
case CSSStyleValue::Type::Time:
|
||||
case StyleValue::Type::Time:
|
||||
return NumericCalculationNode::create(value.as_time().time(), calculation_context);
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
@@ -1087,9 +1087,9 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
};
|
||||
|
||||
switch (from.type()) {
|
||||
case CSSStyleValue::Type::Angle:
|
||||
case StyleValue::Type::Angle:
|
||||
return AngleStyleValue::create(Angle::make_degrees(interpolate_raw(from.as_angle().angle().to_degrees(), to.as_angle().angle().to_degrees(), delta)));
|
||||
case CSSStyleValue::Type::BackgroundSize: {
|
||||
case StyleValue::Type::BackgroundSize: {
|
||||
auto interpolated_x = interpolate_length_percentage(from.as_background_size().size_x(), to.as_background_size().size_x(), delta);
|
||||
auto interpolated_y = interpolate_length_percentage(from.as_background_size().size_y(), to.as_background_size().size_y(), delta);
|
||||
if (!interpolated_x.has_value() || !interpolated_y.has_value())
|
||||
@@ -1097,7 +1097,7 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
|
||||
return BackgroundSizeStyleValue::create(*interpolated_x, *interpolated_y);
|
||||
}
|
||||
case CSSStyleValue::Type::Color: {
|
||||
case StyleValue::Type::Color: {
|
||||
ColorResolutionContext color_resolution_context {};
|
||||
if (auto node = element.layout_node()) {
|
||||
color_resolution_context = ColorResolutionContext::for_layout_node_with_style(*element.layout_node());
|
||||
@@ -1121,7 +1121,7 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
|
||||
return CSSColorValue::create_from_color(interpolated_color, ColorSyntax::Modern);
|
||||
}
|
||||
case CSSStyleValue::Type::Edge: {
|
||||
case StyleValue::Type::Edge: {
|
||||
auto resolved_from = from.as_edge().resolved_value(calculation_context);
|
||||
auto resolved_to = to.as_edge().resolved_value(calculation_context);
|
||||
auto const& edge = delta >= 0.5f ? resolved_to->edge() : resolved_from->edge();
|
||||
@@ -1132,7 +1132,7 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
|
||||
return {};
|
||||
}
|
||||
case CSSStyleValue::Type::FontStyle: {
|
||||
case StyleValue::Type::FontStyle: {
|
||||
auto const& from_font_style = from.as_font_style();
|
||||
auto const& to_font_style = to.as_font_style();
|
||||
auto interpolated_font_style = interpolate_value(element, calculation_context, CSSKeywordValue::create(to_keyword(from_font_style.font_style())), CSSKeywordValue::create(to_keyword(to_font_style.font_style())), delta, allow_discrete);
|
||||
@@ -1147,23 +1147,23 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
|
||||
return FontStyleStyleValue::create(*keyword_to_font_style(interpolated_font_style->to_keyword()));
|
||||
}
|
||||
case CSSStyleValue::Type::Integer: {
|
||||
case StyleValue::Type::Integer: {
|
||||
// https://drafts.csswg.org/css-values/#combine-integers
|
||||
// Interpolation of <integer> is defined as Vresult = round((1 - p) × VA + p × VB);
|
||||
// that is, interpolation happens in the real number space as for <number>s, and the result is converted to an <integer> by rounding to the nearest integer.
|
||||
auto interpolated_value = interpolate_raw(from.as_integer().value(), to.as_integer().value(), delta);
|
||||
return IntegerStyleValue::create(round_to<i64>(interpolated_value));
|
||||
}
|
||||
case CSSStyleValue::Type::Length: {
|
||||
case StyleValue::Type::Length: {
|
||||
auto const& from_length = from.as_length().length();
|
||||
auto const& to_length = to.as_length().length();
|
||||
return LengthStyleValue::create(Length(interpolate_raw(from_length.raw_value(), to_length.raw_value(), delta), from_length.type()));
|
||||
}
|
||||
case CSSStyleValue::Type::Number:
|
||||
case StyleValue::Type::Number:
|
||||
return NumberStyleValue::create(interpolate_raw(from.as_number().number(), to.as_number().number(), delta));
|
||||
case CSSStyleValue::Type::Percentage:
|
||||
case StyleValue::Type::Percentage:
|
||||
return PercentageStyleValue::create(Percentage(interpolate_raw(from.as_percentage().percentage().value(), to.as_percentage().percentage().value(), delta)));
|
||||
case CSSStyleValue::Type::Position: {
|
||||
case StyleValue::Type::Position: {
|
||||
// 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>.
|
||||
auto const& from_position = from.as_position();
|
||||
@@ -1174,7 +1174,7 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
return {};
|
||||
return PositionStyleValue::create(interpolated_edge_x->as_edge(), interpolated_edge_y->as_edge());
|
||||
}
|
||||
case CSSStyleValue::Type::Ratio: {
|
||||
case StyleValue::Type::Ratio: {
|
||||
auto from_ratio = from.as_ratio().ratio();
|
||||
auto to_ratio = to.as_ratio().ratio();
|
||||
|
||||
@@ -1193,7 +1193,7 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
auto interp_number = interpolate_raw(from_number, to_number, delta);
|
||||
return RatioStyleValue::create(Ratio(pow(M_E, interp_number)));
|
||||
}
|
||||
case CSSStyleValue::Type::Rect: {
|
||||
case StyleValue::Type::Rect: {
|
||||
auto from_rect = from.as_rect().rect();
|
||||
auto to_rect = to.as_rect().rect();
|
||||
|
||||
@@ -1207,9 +1207,9 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
Length(interpolate_raw(from_rect.left_edge.raw_value(), to_rect.left_edge.raw_value(), delta), from_rect.left_edge.type()),
|
||||
});
|
||||
}
|
||||
case CSSStyleValue::Type::Transformation:
|
||||
case StyleValue::Type::Transformation:
|
||||
VERIFY_NOT_REACHED();
|
||||
case CSSStyleValue::Type::ValueList: {
|
||||
case StyleValue::Type::ValueList: {
|
||||
auto const& from_list = from.as_value_list();
|
||||
auto const& to_list = to.as_value_list();
|
||||
if (from_list.size() != to_list.size())
|
||||
@@ -1235,14 +1235,14 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> interpolate_repeatable_list(DOM::Element& element, CalculationContext const& calculation_context, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
RefPtr<StyleValue const> interpolate_repeatable_list(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
// https://www.w3.org/TR/web-animations/#repeatable-list
|
||||
// Same as by computed value except that if the two lists have differing numbers of items, they are first repeated to the least common multiple number of items.
|
||||
// Each item is then combined by computed value.
|
||||
// If a pair of values cannot be combined or if any component value uses discrete animation, then the property values combine as discrete.
|
||||
|
||||
auto make_repeatable_list = [&](auto const& from_list, auto const& to_list, Function<void(NonnullRefPtr<CSSStyleValue const>)> append_callback) -> bool {
|
||||
auto make_repeatable_list = [&](auto const& from_list, auto const& to_list, Function<void(NonnullRefPtr<StyleValue const>)> append_callback) -> bool {
|
||||
// If the number of components or the types of corresponding components do not match,
|
||||
// or if any component value uses discrete animation and the two corresponding values do not match,
|
||||
// then the property values combine as discrete
|
||||
@@ -1280,7 +1280,7 @@ RefPtr<CSSStyleValue const> interpolate_repeatable_list(DOM::Element& element, C
|
||||
return StyleValueList::create(move(interpolated_values), from_list->as_value_list().separator());
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, CalculationContext const& calculation_context, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
RefPtr<StyleValue const> interpolate_value(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
|
||||
{
|
||||
if (auto result = interpolate_value_impl(element, calculation_context, from, to, delta, allow_discrete))
|
||||
return result;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
@@ -19,15 +19,15 @@ enum class AllowDiscrete {
|
||||
Yes,
|
||||
No,
|
||||
};
|
||||
ValueComparingRefPtr<CSSStyleValue const> interpolate_property(DOM::Element&, PropertyID, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete);
|
||||
ValueComparingRefPtr<StyleValue const> interpolate_property(DOM::Element&, PropertyID, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete);
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transitionable
|
||||
bool property_values_are_transitionable(PropertyID, CSSStyleValue const& old_value, CSSStyleValue const& new_value, DOM::Element&, TransitionBehavior);
|
||||
bool property_values_are_transitionable(PropertyID, StyleValue const& old_value, StyleValue const& new_value, DOM::Element&, TransitionBehavior);
|
||||
|
||||
RefPtr<CSSStyleValue const> interpolate_value(DOM::Element&, CalculationContext const&, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<CSSStyleValue const> interpolate_repeatable_list(DOM::Element&, CalculationContext const&, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element&, CalculationContext const&, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element&, CSSStyleValue const& from, CSSStyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<StyleValue const> interpolate_value(DOM::Element&, CalculationContext const&, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<StyleValue const> interpolate_repeatable_list(DOM::Element&, CalculationContext const&, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element&, CalculationContext const&, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete);
|
||||
RefPtr<StyleValue const> interpolate_transform(DOM::Element&, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete);
|
||||
|
||||
Color interpolate_color(Color from, Color to, float delta, ColorSyntax syntax);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
|
||||
~LengthBox();
|
||||
|
||||
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue const> member, but we can't include the header CSSStyleValue.h as it includes
|
||||
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue const> member, but we can't include the header StyleValue.h as it includes
|
||||
// this file already. To break the cyclic dependency, we must initialize these members in the constructor.
|
||||
LengthPercentage& top() { return m_top; }
|
||||
LengthPercentage& right() { return m_right; }
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
static FlyString extract_font_name(CSSStyleValue const& value)
|
||||
static FlyString extract_font_name(StyleValue const& value)
|
||||
{
|
||||
if (value.is_string())
|
||||
return value.as_string().string_value();
|
||||
@@ -31,7 +31,7 @@ static FlyString extract_font_name(CSSStyleValue const& value)
|
||||
return FlyString {};
|
||||
}
|
||||
|
||||
Vector<ParsedFontFace::Source> ParsedFontFace::sources_from_style_value(CSSStyleValue const& style_value)
|
||||
Vector<ParsedFontFace::Source> ParsedFontFace::sources_from_style_value(StyleValue const& style_value)
|
||||
{
|
||||
Vector<Source> sources;
|
||||
auto add_source = [&sources](FontSourceStyleValue const& font_source) {
|
||||
@@ -55,7 +55,7 @@ Vector<ParsedFontFace::Source> ParsedFontFace::sources_from_style_value(CSSStyle
|
||||
|
||||
ParsedFontFace ParsedFontFace::from_descriptors(CSSFontFaceDescriptors const& descriptors)
|
||||
{
|
||||
auto extract_percentage_or_normal = [](CSSStyleValue const& value) -> Optional<Percentage> {
|
||||
auto extract_percentage_or_normal = [](StyleValue const& value) -> Optional<Percentage> {
|
||||
if (value.is_percentage())
|
||||
return value.as_percentage().percentage();
|
||||
if (value.is_calculated()) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
Vector<FontTech> tech;
|
||||
};
|
||||
|
||||
static Vector<Source> sources_from_style_value(CSSStyleValue const&);
|
||||
static Vector<Source> sources_from_style_value(StyleValue const&);
|
||||
static ParsedFontFace from_descriptors(CSSFontFaceDescriptors const&);
|
||||
|
||||
ParsedFontFace(GC::Ptr<CSSStyleSheet> parent_style_sheet, FlyString font_family, Optional<int> weight, Optional<int> slope, Optional<int> width, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges, Optional<Percentage> ascent_override, Optional<Percentage> descent_override, Optional<Percentage> line_gap_override, FontDisplay font_display, Optional<FlyString> font_named_instance, Optional<FlyString> font_language_override, Optional<OrderedHashMap<FlyString, i64>> font_feature_settings, Optional<OrderedHashMap<FlyString, double>> font_variation_settings);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream<ComponentValue>& unprocessed_tokens)
|
||||
Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream<ComponentValue>& unprocessed_tokens)
|
||||
{
|
||||
if (!at_rule_supports_descriptor(at_rule_id, descriptor_id)) {
|
||||
ErrorReporter::the().report(UnknownPropertyError {
|
||||
@@ -46,7 +46,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
|
||||
[&](Keyword keyword) {
|
||||
return parse_all_as_single_keyword_value(tokens, keyword);
|
||||
},
|
||||
[&](PropertyID property_id) -> RefPtr<CSSStyleValue const> {
|
||||
[&](PropertyID property_id) -> RefPtr<StyleValue const> {
|
||||
auto value_or_error = parse_css_value(property_id, tokens);
|
||||
if (value_or_error.is_error())
|
||||
return nullptr;
|
||||
@@ -59,7 +59,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
|
||||
return nullptr;
|
||||
return value_for_property;
|
||||
},
|
||||
[&](DescriptorMetadata::ValueType value_type) -> RefPtr<CSSStyleValue const> {
|
||||
[&](DescriptorMetadata::ValueType value_type) -> RefPtr<StyleValue const> {
|
||||
switch (value_type) {
|
||||
case DescriptorMetadata::ValueType::CropOrCross: {
|
||||
// crop || cross
|
||||
@@ -70,8 +70,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
|
||||
if (!first)
|
||||
return nullptr;
|
||||
|
||||
RefPtr<CSSStyleValue const> crop;
|
||||
RefPtr<CSSStyleValue const> cross;
|
||||
RefPtr<StyleValue const> crop;
|
||||
RefPtr<StyleValue const> cross;
|
||||
|
||||
if (first->to_keyword() == Keyword::Crop)
|
||||
crop = first;
|
||||
@@ -149,8 +149,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
|
||||
}
|
||||
|
||||
// [ <page-size> || [ portrait | landscape ] ]
|
||||
RefPtr<CSSStyleValue const> page_size;
|
||||
RefPtr<CSSStyleValue const> orientation;
|
||||
RefPtr<StyleValue const> page_size;
|
||||
RefPtr<StyleValue const> orientation;
|
||||
if (auto first_keyword = parse_keyword_value(tokens)) {
|
||||
if (first_is_one_of(first_keyword->to_keyword(), Keyword::Landscape, Keyword::Portrait)) {
|
||||
orientation = first_keyword.release_nonnull();
|
||||
@@ -203,7 +203,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
|
||||
case DescriptorMetadata::ValueType::String:
|
||||
return parse_string_value(tokens);
|
||||
case DescriptorMetadata::ValueType::UnicodeRangeTokens: {
|
||||
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<CSSStyleValue const> {
|
||||
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<StyleValue const> {
|
||||
return parse_unicode_range_value(tokens);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ Optional<Vector<TElement>> Parser::parse_color_stop_list(TokenStream<ComponentVa
|
||||
if (!tokens.has_next_token())
|
||||
return ElementType::Garbage;
|
||||
|
||||
RefPtr<CSSStyleValue const> color;
|
||||
RefPtr<StyleValue const> color;
|
||||
Optional<typename TElement::PositionType> position;
|
||||
Optional<typename TElement::PositionType> second_position;
|
||||
if (position = parse_position(tokens); position.has_value()) {
|
||||
|
||||
@@ -71,14 +71,14 @@ Vector<CSS::Descriptor> parse_css_descriptor_declaration_block(CSS::Parser::Pars
|
||||
return CSS::Parser::Parser::create(parsing_params, css).parse_as_descriptor_declaration_block(at_rule_id);
|
||||
}
|
||||
|
||||
RefPtr<CSS::CSSStyleValue const> parse_css_value(CSS::Parser::ParsingParams const& context, StringView string, CSS::PropertyID property_id)
|
||||
RefPtr<CSS::StyleValue const> parse_css_value(CSS::Parser::ParsingParams const& context, StringView string, CSS::PropertyID property_id)
|
||||
{
|
||||
if (string.is_empty())
|
||||
return nullptr;
|
||||
return CSS::Parser::Parser::create(context, string).parse_as_css_value(property_id);
|
||||
}
|
||||
|
||||
RefPtr<CSS::CSSStyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const& parsing_params, CSS::AtRuleID at_rule_id, CSS::DescriptorID descriptor_id, StringView string)
|
||||
RefPtr<CSS::StyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const& parsing_params, CSS::AtRuleID at_rule_id, CSS::DescriptorID descriptor_id, StringView string)
|
||||
{
|
||||
if (string.is_empty())
|
||||
return nullptr;
|
||||
|
||||
@@ -1377,7 +1377,7 @@ Parser::PropertiesAndCustomProperties Parser::parse_as_property_declaration_bloc
|
||||
Vector<StyleProperty> expanded_properties;
|
||||
for (auto& property : properties) {
|
||||
if (property_is_shorthand(property.property_id)) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(property.property_id, *property.value, [&](PropertyID longhand_property_id, CSSStyleValue const& longhand_value) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(property.property_id, *property.value, [&](PropertyID longhand_property_id, StyleValue const& longhand_value) {
|
||||
expanded_properties.append(CSS::StyleProperty {
|
||||
.important = property.important,
|
||||
.property_id = longhand_property_id,
|
||||
@@ -1696,7 +1696,7 @@ Vector<ComponentValue> Parser::parse_as_list_of_component_values()
|
||||
return parse_a_list_of_component_values(m_token_stream);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_as_css_value(PropertyID property_id)
|
||||
RefPtr<StyleValue const> Parser::parse_as_css_value(PropertyID property_id)
|
||||
{
|
||||
auto component_values = parse_a_list_of_component_values(m_token_stream);
|
||||
auto tokens = TokenStream(component_values);
|
||||
@@ -1706,7 +1706,7 @@ RefPtr<CSSStyleValue const> Parser::parse_as_css_value(PropertyID property_id)
|
||||
return parsed_value.release_value();
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_as_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id)
|
||||
RefPtr<StyleValue const> Parser::parse_as_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id)
|
||||
{
|
||||
auto component_values = parse_a_list_of_component_values(m_token_stream);
|
||||
auto tokens = TokenStream(component_values);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <LibGfx/Font/UnicodeRange.h>
|
||||
#include <LibWeb/CSS/BooleanExpression.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Descriptor.h>
|
||||
#include <LibWeb/CSS/DescriptorID.h>
|
||||
#include <LibWeb/CSS/MediaQuery.h>
|
||||
@@ -33,6 +32,7 @@
|
||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/CSS/Supports.h>
|
||||
#include <LibWeb/CSS/URL.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
@@ -127,14 +127,14 @@ public:
|
||||
|
||||
RefPtr<Supports> parse_as_supports();
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_as_css_value(PropertyID);
|
||||
RefPtr<CSSStyleValue const> parse_as_descriptor_value(AtRuleID, DescriptorID);
|
||||
RefPtr<StyleValue const> parse_as_css_value(PropertyID);
|
||||
RefPtr<StyleValue const> parse_as_descriptor_value(AtRuleID, DescriptorID);
|
||||
|
||||
Optional<ComponentValue> parse_as_component_value();
|
||||
|
||||
Vector<ComponentValue> parse_as_list_of_component_values();
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue const> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional<GuardedSubstitutionContexts&> = {});
|
||||
static NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional<GuardedSubstitutionContexts&> = {});
|
||||
|
||||
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr);
|
||||
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
};
|
||||
static Optional<Vector<ComponentValue>> parse_declaration_value(TokenStream<ComponentValue>&, StopAtComma = StopAtComma::No);
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> parse_with_a_syntax(Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element = {});
|
||||
NonnullRefPtr<StyleValue const> parse_with_a_syntax(Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element = {});
|
||||
|
||||
private:
|
||||
Parser(ParsingParams const&, Vector<Token>);
|
||||
@@ -292,7 +292,7 @@ private:
|
||||
Vector<Gfx::UnicodeRange> parse_unicode_ranges(TokenStream<ComponentValue>&);
|
||||
RefPtr<UnicodeRangeStyleValue const> parse_unicode_range_value(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_value(ValueType, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_value(ValueType, TokenStream<ComponentValue>&);
|
||||
|
||||
Optional<GridSize> parse_grid_track_breadth(TokenStream<ComponentValue>&);
|
||||
Optional<GridSize> parse_grid_inflexible_breadth(TokenStream<ComponentValue>&);
|
||||
@@ -327,7 +327,7 @@ private:
|
||||
RefPtr<URLStyleValue const> parse_url_value(TokenStream<ComponentValue>&);
|
||||
|
||||
Optional<ShapeRadius> parse_shape_radius(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_basic_shape_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_basic_shape_value(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<FitContentStyleValue const> parse_fit_content_value(TokenStream<ComponentValue>&);
|
||||
|
||||
@@ -341,157 +341,157 @@ private:
|
||||
RefPtr<ConicGradientStyleValue const> parse_conic_gradient_function(TokenStream<ComponentValue>&);
|
||||
RefPtr<RadialGradientStyleValue const> parse_radial_gradient_function(TokenStream<ComponentValue>&);
|
||||
|
||||
ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> parse_css_value(PropertyID, TokenStream<ComponentValue>&, Optional<String> original_source_text = {});
|
||||
ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> parse_descriptor_value(AtRuleID, DescriptorID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&);
|
||||
ParseErrorOr<NonnullRefPtr<StyleValue const>> parse_css_value(PropertyID, TokenStream<ComponentValue>&, Optional<String> original_source_text = {});
|
||||
ParseErrorOr<NonnullRefPtr<StyleValue const>> parse_descriptor_value(AtRuleID, DescriptorID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&);
|
||||
struct PropertyAndValue {
|
||||
PropertyID property;
|
||||
RefPtr<CSSStyleValue const> style_value;
|
||||
RefPtr<StyleValue const> style_value;
|
||||
};
|
||||
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_builtin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_calculated_value(ComponentValue const&);
|
||||
RefPtr<StyleValue const> parse_builtin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_calculated_value(ComponentValue const&);
|
||||
Optional<FlyString> parse_custom_ident(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist);
|
||||
RefPtr<CustomIdentStyleValue const> parse_custom_ident_value(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist);
|
||||
Optional<FlyString> parse_dashed_ident(TokenStream<ComponentValue>&);
|
||||
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
|
||||
RefPtr<CalculationNode const> parse_math_function(Function const&, CalculationContext const&);
|
||||
RefPtr<CalculationNode const> parse_a_calc_function_node(Function const&, CalculationContext const&);
|
||||
RefPtr<CSSStyleValue const> parse_keyword_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_hue_none_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_solidus_and_alpha_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_rgb_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_hsl_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_hwb_color_value(TokenStream<ComponentValue>&);
|
||||
Optional<Array<RefPtr<CSSStyleValue const>, 4>> parse_lab_like_color_value(TokenStream<ComponentValue>&, StringView);
|
||||
RefPtr<CSSStyleValue const> parse_lab_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_oklab_color_value(TokenStream<ComponentValue>&);
|
||||
Optional<Array<RefPtr<CSSStyleValue const>, 4>> parse_lch_like_color_value(TokenStream<ComponentValue>&, StringView);
|
||||
RefPtr<CSSStyleValue const> parse_lch_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_oklch_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_color_function(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_color_mix_function(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_light_dark_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_color_scheme_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_counter_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_keyword_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_hue_none_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_solidus_and_alpha_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_rgb_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_hsl_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_hwb_color_value(TokenStream<ComponentValue>&);
|
||||
Optional<Array<RefPtr<StyleValue const>, 4>> parse_lab_like_color_value(TokenStream<ComponentValue>&, StringView);
|
||||
RefPtr<StyleValue const> parse_lab_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_oklab_color_value(TokenStream<ComponentValue>&);
|
||||
Optional<Array<RefPtr<StyleValue const>, 4>> parse_lch_like_color_value(TokenStream<ComponentValue>&, StringView);
|
||||
RefPtr<StyleValue const> parse_lch_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_oklch_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_color_function(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_color_mix_function(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_light_dark_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_color_scheme_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_counter_value(TokenStream<ComponentValue>&);
|
||||
enum class AllowReversed {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
RefPtr<CSSStyleValue const> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed);
|
||||
RefPtr<CSSStyleValue const> parse_rect_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_ratio_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed);
|
||||
RefPtr<StyleValue const> parse_rect_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_ratio_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StringStyleValue const> parse_string_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<AbstractImageStyleValue const> parse_image_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_paint_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_paint_value(TokenStream<ComponentValue>&);
|
||||
enum class PositionParsingMode {
|
||||
Normal,
|
||||
BackgroundPosition,
|
||||
};
|
||||
RefPtr<PositionStyleValue const> parse_position_value(TokenStream<ComponentValue>&, PositionParsingMode = PositionParsingMode::Normal);
|
||||
RefPtr<CSSStyleValue const> parse_filter_value_list_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_contain_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_filter_value_list_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_contain_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StringStyleValue const> parse_opentype_tag_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<FontSourceStyleValue const> parse_font_source_value(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_anchor(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_anchor_size(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_angle_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_angle_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_flex_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_frequency_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_frequency_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_integer_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_length_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_length_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_number_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_number_percentage_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<CSSStyleValue const> parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<CSSStyleValue const> parse_percentage_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<CSSStyleValue const> parse_resolution_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_time_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_time_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_anchor(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_anchor_size(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_angle_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_angle_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_flex_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_frequency_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_frequency_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_integer_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_length_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_length_percentage_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_number_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_number_percentage_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<StyleValue const> parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<StyleValue const> parse_percentage_value(TokenStream<ComponentValue>& tokens);
|
||||
RefPtr<StyleValue const> parse_resolution_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_time_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_time_percentage_value(TokenStream<ComponentValue>&);
|
||||
|
||||
using ParseFunction = AK::Function<RefPtr<CSSStyleValue const>(TokenStream<ComponentValue>&)>;
|
||||
RefPtr<CSSStyleValue const> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
|
||||
RefPtr<CSSStyleValue const> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_all_as_single_keyword_value(TokenStream<ComponentValue>&, Keyword);
|
||||
using ParseFunction = AK::Function<RefPtr<StyleValue const>(TokenStream<ComponentValue>&)>;
|
||||
RefPtr<StyleValue const> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
|
||||
RefPtr<StyleValue const> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_all_as_single_keyword_value(TokenStream<ComponentValue>&, Keyword);
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_background_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID);
|
||||
RefPtr<CSSStyleValue const> parse_single_background_size_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_border_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_border_image_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_border_image_slice_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_border_radius_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_columns_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_content_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_counter_increment_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_counter_reset_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_counter_set_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_cursor_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_display_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_flex_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_family_name_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_family_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_language_override_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_feature_settings_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_style_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variation_settings_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant_alternates_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant_east_asian_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant_emoji(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant_ligatures_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_font_variant_numeric_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_list_style_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_mask_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_math_depth_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_opacity_value(PropertyID property_id, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_overflow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_place_content_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_place_items_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_place_self_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_quotes_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_single_repeat_style_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_scrollbar_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_background_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID);
|
||||
RefPtr<StyleValue const> parse_single_background_size_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_border_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_border_image_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_border_image_slice_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_border_radius_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_columns_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_content_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_counter_increment_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_counter_reset_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_counter_set_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_cursor_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_display_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_flex_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_family_name_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_family_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_language_override_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_feature_settings_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_style_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variation_settings_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant_alternates_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant_east_asian_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant_emoji(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant_ligatures_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_font_variant_numeric_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_list_style_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_mask_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_math_depth_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_opacity_value(PropertyID property_id, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_overflow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_place_content_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_place_items_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_place_self_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_quotes_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_single_repeat_style_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_scrollbar_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&);
|
||||
enum class AllowInsetKeyword {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
RefPtr<CSSStyleValue const> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||
RefPtr<CSSStyleValue const> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||
RefPtr<CSSStyleValue const> parse_text_decoration_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_text_decoration_line_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_rotate_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_stroke_dasharray_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_easing_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_transform_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_transform_origin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_transition_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_transition_property_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_translate_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_scale_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_track_size_list(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||
RefPtr<StyleValue const> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
|
||||
RefPtr<StyleValue const> parse_text_decoration_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_text_decoration_line_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_rotate_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_stroke_dasharray_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_easing_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_transform_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_transform_origin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_transition_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_transition_property_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_translate_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_scale_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_track_size_list(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
|
||||
RefPtr<GridAutoFlowStyleValue const> parse_grid_auto_flow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&, bool include_grid_auto_properties = false);
|
||||
RefPtr<StyleValue const> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&, bool include_grid_auto_properties = false);
|
||||
RefPtr<GridTrackPlacementStyleValue const> parse_grid_track_placement(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_template_areas_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_grid_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_touch_action_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_white_space_shorthand(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue const> parse_white_space_trim_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_template_areas_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_grid_shorthand_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_touch_action_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_white_space_shorthand(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_white_space_trim_value(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_list_of_time_values(PropertyID, TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue const> parse_list_of_time_values(PropertyID, TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<CalculationNode const> convert_to_calculation_node(CalcParsing::Node const&, CalculationContext const&);
|
||||
RefPtr<CalculationNode const> parse_a_calculation(Vector<ComponentValue> const&, CalculationContext const&);
|
||||
@@ -520,9 +520,9 @@ private:
|
||||
|
||||
OwnPtr<BooleanExpression> parse_supports_feature(TokenStream<ComponentValue>&);
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> resolve_unresolved_style_value(DOM::AbstractElement&, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&);
|
||||
NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(DOM::AbstractElement&, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&);
|
||||
|
||||
RefPtr<CSSStyleValue const> parse_according_to_syntax_node(TokenStream<ComponentValue>& tokens, SyntaxNode const& syntax_node, Optional<DOM::AbstractElement> const& element);
|
||||
RefPtr<StyleValue const> parse_according_to_syntax_node(TokenStream<ComponentValue>& tokens, SyntaxNode const& syntax_node, Optional<DOM::AbstractElement> const& element);
|
||||
|
||||
static bool has_ignored_vendor_prefix(StringView);
|
||||
|
||||
@@ -573,8 +573,8 @@ namespace Web {
|
||||
GC::Ref<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::Parser::ParsingParams const&, StringView, Optional<::URL::URL> location = {}, Vector<NonnullRefPtr<CSS::MediaQuery>> = {});
|
||||
CSS::Parser::Parser::PropertiesAndCustomProperties parse_css_property_declaration_block(CSS::Parser::ParsingParams const&, StringView);
|
||||
Vector<CSS::Descriptor> parse_css_descriptor_declaration_block(CSS::Parser::ParsingParams const&, CSS::AtRuleID, StringView);
|
||||
RefPtr<CSS::CSSStyleValue const> parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
|
||||
RefPtr<CSS::CSSStyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const&, CSS::AtRuleID, CSS::DescriptorID, StringView);
|
||||
RefPtr<CSS::StyleValue const> parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
|
||||
RefPtr<CSS::StyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const&, CSS::AtRuleID, CSS::DescriptorID, StringView);
|
||||
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingParams const&, StringView);
|
||||
Optional<CSS::SelectorList> parse_selector_for_nested_style_rule(CSS::Parser::ParsingParams const&, StringView);
|
||||
Optional<CSS::PageSelectorList> parse_page_selector_list(CSS::Parser::ParsingParams const&, StringView);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -720,7 +720,7 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
|
||||
|
||||
Optional<FlyString> syntax_maybe;
|
||||
Optional<bool> inherits_maybe;
|
||||
RefPtr<CSSStyleValue const> initial_value_maybe;
|
||||
RefPtr<StyleValue const> initial_value_maybe;
|
||||
|
||||
rule.for_each_as_declaration_list([&](auto& declaration) {
|
||||
if (auto descriptor = convert_to_descriptor(AtRuleID::Property, declaration); descriptor.has_value()) {
|
||||
|
||||
@@ -214,12 +214,12 @@ OwnPtr<SyntaxNode> parse_as_syntax(Vector<ComponentValue> const& component_value
|
||||
return AlternativesSyntaxNode::create(move(syntax_components));
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> parse_with_a_syntax(ParsingParams const& parsing_params, Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element)
|
||||
NonnullRefPtr<StyleValue const> parse_with_a_syntax(ParsingParams const& parsing_params, Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element)
|
||||
{
|
||||
return Parser::create(parsing_params, ""sv).parse_with_a_syntax(input, syntax, element);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_according_to_syntax_node(TokenStream<ComponentValue>& tokens, SyntaxNode const& syntax_node, Optional<DOM::AbstractElement> const& element)
|
||||
RefPtr<StyleValue const> Parser::parse_according_to_syntax_node(TokenStream<ComponentValue>& tokens, SyntaxNode const& syntax_node, Optional<DOM::AbstractElement> const& element)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
@@ -301,7 +301,7 @@ RefPtr<CSSStyleValue const> Parser::parse_according_to_syntax_node(TokenStream<C
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-values-5/#parse-with-a-syntax
|
||||
NonnullRefPtr<CSSStyleValue const> Parser::parse_with_a_syntax(Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element)
|
||||
NonnullRefPtr<StyleValue const> Parser::parse_with_a_syntax(Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element)
|
||||
{
|
||||
// 1. Parse a list of component values from values, and let raw parse be the result.
|
||||
// NB: Already done before this point.
|
||||
|
||||
@@ -15,6 +15,6 @@ namespace Web::CSS::Parser {
|
||||
|
||||
OwnPtr<SyntaxNode> parse_as_syntax(Vector<ComponentValue> const&);
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> parse_with_a_syntax(ParsingParams const&, Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element = {});
|
||||
NonnullRefPtr<StyleValue const> parse_with_a_syntax(ParsingParams const&, Vector<ComponentValue> const& input, SyntaxNode const& syntax, Optional<DOM::AbstractElement> const& element = {});
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
|
||||
RefPtr<StyleValue const> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
|
||||
{
|
||||
auto first = parse_one_value(tokens);
|
||||
if (!first || !tokens.has_next_token())
|
||||
@@ -403,7 +403,7 @@ Optional<Ratio> Parser::parse_ratio(TokenStream<ComponentValue>& tokens)
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-fonts-4/#family-name-syntax
|
||||
RefPtr<CSSStyleValue const> Parser::parse_family_name_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_family_name_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
tokens.discard_whitespace();
|
||||
@@ -770,7 +770,7 @@ RefPtr<UnicodeRangeStyleValue const> Parser::parse_unicode_range_value(TokenStre
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto const& peek_token = tokens.next_token();
|
||||
if (peek_token.is(Token::Type::Number) && peek_token.token().number().is_integer()) {
|
||||
@@ -787,7 +787,7 @@ RefPtr<CSSStyleValue const> Parser::parse_integer_value(TokenStream<ComponentVal
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_number_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_number_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto const& peek_token = tokens.next_token();
|
||||
if (peek_token.is(Token::Type::Number)) {
|
||||
@@ -804,7 +804,7 @@ RefPtr<CSSStyleValue const> Parser::parse_number_value(TokenStream<ComponentValu
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_number_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_number_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// Parses [<percentage> | <number>] (which is equivalent to [<alpha-value>])
|
||||
if (auto value = parse_number_value(tokens))
|
||||
@@ -814,7 +814,7 @@ RefPtr<CSSStyleValue const> Parser::parse_number_percentage_value(TokenStream<Co
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// Parses [<percentage> | <number> | none] (which is equivalent to [<alpha-value> | none])
|
||||
if (auto value = parse_number_value(tokens))
|
||||
@@ -830,7 +830,7 @@ RefPtr<CSSStyleValue const> Parser::parse_number_percentage_none_value(TokenStre
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto const& peek_token = tokens.next_token();
|
||||
if (peek_token.is(Token::Type::Percentage)) {
|
||||
@@ -848,7 +848,7 @@ RefPtr<CSSStyleValue const> Parser::parse_percentage_value(TokenStream<Component
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-anchor-position-1/#funcdef-anchor
|
||||
RefPtr<CSSStyleValue const> Parser::parse_anchor(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_anchor(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// <anchor()> = anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )
|
||||
|
||||
@@ -860,8 +860,8 @@ RefPtr<CSSStyleValue const> Parser::parse_anchor(TokenStream<ComponentValue>& to
|
||||
auto argument_tokens = TokenStream { function_token.function().value };
|
||||
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
|
||||
Optional<FlyString> anchor_name;
|
||||
RefPtr<CSSStyleValue const> anchor_side_value;
|
||||
RefPtr<CSSStyleValue const> fallback_value;
|
||||
RefPtr<StyleValue const> anchor_side_value;
|
||||
RefPtr<StyleValue const> fallback_value;
|
||||
for (auto i = 0; i < 2; ++i) {
|
||||
argument_tokens.discard_whitespace();
|
||||
|
||||
@@ -917,7 +917,7 @@ RefPtr<CSSStyleValue const> Parser::parse_anchor(TokenStream<ComponentValue>& to
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-anchor-position-1/#sizing
|
||||
RefPtr<CSSStyleValue const> Parser::parse_anchor_size(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_anchor_size(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// anchor-size() = anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
|
||||
|
||||
@@ -966,7 +966,7 @@ RefPtr<CSSStyleValue const> Parser::parse_anchor_size(TokenStream<ComponentValue
|
||||
|
||||
Optional<FlyString> anchor_name;
|
||||
Optional<AnchorSize> anchor_size;
|
||||
ValueComparingRefPtr<CSSStyleValue const> fallback_value;
|
||||
ValueComparingRefPtr<StyleValue const> fallback_value;
|
||||
|
||||
// Parse optional anchor name and anchor size in arbitrary order.
|
||||
for (auto i = 0; i < 2; ++i) {
|
||||
@@ -1022,7 +1022,7 @@ RefPtr<CSSStyleValue const> Parser::parse_anchor_size(TokenStream<ComponentValue
|
||||
return AnchorSizeStyleValue::create(anchor_name, anchor_size, fallback_value);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_angle_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_angle_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1053,7 +1053,7 @@ RefPtr<CSSStyleValue const> Parser::parse_angle_value(TokenStream<ComponentValue
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_angle_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_angle_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1087,7 +1087,7 @@ RefPtr<CSSStyleValue const> Parser::parse_angle_percentage_value(TokenStream<Com
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1109,7 +1109,7 @@ RefPtr<CSSStyleValue const> Parser::parse_flex_value(TokenStream<ComponentValue>
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_frequency_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_frequency_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1131,7 +1131,7 @@ RefPtr<CSSStyleValue const> Parser::parse_frequency_value(TokenStream<ComponentV
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_frequency_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_frequency_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1156,7 +1156,7 @@ RefPtr<CSSStyleValue const> Parser::parse_frequency_percentage_value(TokenStream
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_length_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_length_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1203,7 +1203,7 @@ RefPtr<CSSStyleValue const> Parser::parse_length_value(TokenStream<ComponentValu
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_length_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_length_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1253,7 +1253,7 @@ RefPtr<CSSStyleValue const> Parser::parse_length_percentage_value(TokenStream<Co
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_resolution_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_resolution_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1280,7 +1280,7 @@ RefPtr<CSSStyleValue const> Parser::parse_resolution_value(TokenStream<Component
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_time_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_time_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1302,7 +1302,7 @@ RefPtr<CSSStyleValue const> Parser::parse_time_value(TokenStream<ComponentValue>
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_time_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_time_percentage_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.next_token().is(Token::Type::Dimension)) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
@@ -1327,7 +1327,7 @@ RefPtr<CSSStyleValue const> Parser::parse_time_percentage_value(TokenStream<Comp
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_keyword_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_keyword_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto const& peek_token = tokens.next_token();
|
||||
if (peek_token.is(Token::Type::Ident)) {
|
||||
@@ -1342,7 +1342,7 @@ RefPtr<CSSStyleValue const> Parser::parse_keyword_value(TokenStream<ComponentVal
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/CSS2/visufx.html#value-def-shape
|
||||
RefPtr<CSSStyleValue const> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
auto const& function_token = tokens.consume_a_token();
|
||||
@@ -1425,7 +1425,7 @@ RefPtr<CSSStyleValue const> Parser::parse_rect_value(TokenStream<ComponentValue>
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#typedef-hue
|
||||
RefPtr<CSSStyleValue const> Parser::parse_hue_none_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_hue_none_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// Parses [<hue> | none]
|
||||
// <hue> = <number> | <angle>
|
||||
@@ -1443,7 +1443,7 @@ RefPtr<CSSStyleValue const> Parser::parse_hue_none_value(TokenStream<ComponentVa
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#typedef-color-alpha-value
|
||||
RefPtr<CSSStyleValue const> Parser::parse_solidus_and_alpha_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_solidus_and_alpha_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// [ / [<alpha-value> | none] ]?
|
||||
// <alpha-value> = <number> | <percentage>
|
||||
@@ -1464,7 +1464,7 @@ RefPtr<CSSStyleValue const> Parser::parse_solidus_and_alpha_value(TokenStream<Co
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-rgb
|
||||
RefPtr<CSSStyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// rgb() = [ <legacy-rgb-syntax> | <modern-rgb-syntax> ]
|
||||
// rgba() = [ <legacy-rgba-syntax> | <modern-rgba-syntax> ]
|
||||
@@ -1488,10 +1488,10 @@ RefPtr<CSSStyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentV
|
||||
|
||||
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
|
||||
|
||||
RefPtr<CSSStyleValue const> red;
|
||||
RefPtr<CSSStyleValue const> green;
|
||||
RefPtr<CSSStyleValue const> blue;
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> red;
|
||||
RefPtr<StyleValue const> green;
|
||||
RefPtr<StyleValue const> blue;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
|
||||
auto inner_tokens = TokenStream { function_token.function().value };
|
||||
inner_tokens.discard_whitespace();
|
||||
@@ -1547,7 +1547,7 @@ RefPtr<CSSStyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentV
|
||||
}
|
||||
|
||||
// Verify we're all percentages or all numbers
|
||||
auto is_percentage = [](CSSStyleValue const& style_value) {
|
||||
auto is_percentage = [](StyleValue const& style_value) {
|
||||
return style_value.is_percentage()
|
||||
|| (style_value.is_calculated() && style_value.as_calculated().resolves_to_percentage());
|
||||
};
|
||||
@@ -1586,7 +1586,7 @@ RefPtr<CSSStyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentV
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-hsl
|
||||
RefPtr<CSSStyleValue const> Parser::parse_hsl_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_hsl_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// hsl() = [ <legacy-hsl-syntax> | <modern-hsl-syntax> ]
|
||||
// hsla() = [ <legacy-hsla-syntax> | <modern-hsla-syntax> ]
|
||||
@@ -1612,10 +1612,10 @@ RefPtr<CSSStyleValue const> Parser::parse_hsl_color_value(TokenStream<ComponentV
|
||||
|
||||
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
|
||||
|
||||
RefPtr<CSSStyleValue const> h;
|
||||
RefPtr<CSSStyleValue const> s;
|
||||
RefPtr<CSSStyleValue const> l;
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> h;
|
||||
RefPtr<StyleValue const> s;
|
||||
RefPtr<StyleValue const> l;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
|
||||
auto inner_tokens = TokenStream { function_token.function().value };
|
||||
inner_tokens.discard_whitespace();
|
||||
@@ -1698,7 +1698,7 @@ RefPtr<CSSStyleValue const> Parser::parse_hsl_color_value(TokenStream<ComponentV
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-hwb
|
||||
RefPtr<CSSStyleValue const> Parser::parse_hwb_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_hwb_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// hwb() = hwb(
|
||||
// [<hue> | none]
|
||||
@@ -1715,10 +1715,10 @@ RefPtr<CSSStyleValue const> Parser::parse_hwb_color_value(TokenStream<ComponentV
|
||||
|
||||
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
|
||||
|
||||
RefPtr<CSSStyleValue const> h;
|
||||
RefPtr<CSSStyleValue const> w;
|
||||
RefPtr<CSSStyleValue const> b;
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> h;
|
||||
RefPtr<StyleValue const> w;
|
||||
RefPtr<StyleValue const> b;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
|
||||
auto inner_tokens = TokenStream { function_token.function().value };
|
||||
inner_tokens.discard_whitespace();
|
||||
@@ -1751,7 +1751,7 @@ RefPtr<CSSStyleValue const> Parser::parse_hwb_color_value(TokenStream<ComponentV
|
||||
return CSSHWB::create(h.release_nonnull(), w.release_nonnull(), b.release_nonnull(), alpha.release_nonnull());
|
||||
}
|
||||
|
||||
Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lab_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
|
||||
Optional<Array<RefPtr<StyleValue const>, 4>> Parser::parse_lab_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
|
||||
{
|
||||
// This helper is designed to be compatible with lab and oklab and parses a function with a form like:
|
||||
// f() = f( [ <percentage> | <number> | none]
|
||||
@@ -1766,10 +1766,10 @@ Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lab_like_color_val
|
||||
if (!function_token.is_function(function_name))
|
||||
return OptionalNone {};
|
||||
|
||||
RefPtr<CSSStyleValue const> l;
|
||||
RefPtr<CSSStyleValue const> a;
|
||||
RefPtr<CSSStyleValue const> b;
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> l;
|
||||
RefPtr<StyleValue const> a;
|
||||
RefPtr<StyleValue const> b;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
|
||||
auto inner_tokens = TokenStream { function_token.function().value };
|
||||
inner_tokens.discard_whitespace();
|
||||
@@ -1804,7 +1804,7 @@ Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lab_like_color_val
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-lab
|
||||
RefPtr<CSSStyleValue const> Parser::parse_lab_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_lab_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// lab() = lab( [<percentage> | <number> | none]
|
||||
// [ <percentage> | <number> | none]
|
||||
@@ -1824,7 +1824,7 @@ RefPtr<CSSStyleValue const> Parser::parse_lab_color_value(TokenStream<ComponentV
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-oklab
|
||||
RefPtr<CSSStyleValue const> Parser::parse_oklab_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_oklab_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// oklab() = oklab( [ <percentage> | <number> | none]
|
||||
// [ <percentage> | <number> | none]
|
||||
@@ -1843,7 +1843,7 @@ RefPtr<CSSStyleValue const> Parser::parse_oklab_color_value(TokenStream<Componen
|
||||
color_values[3].release_nonnull());
|
||||
}
|
||||
|
||||
Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lch_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
|
||||
Optional<Array<RefPtr<StyleValue const>, 4>> Parser::parse_lch_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
|
||||
{
|
||||
// This helper is designed to be compatible with lch and oklch and parses a function with a form like:
|
||||
// f() = f( [<percentage> | <number> | none]
|
||||
@@ -1876,7 +1876,7 @@ Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lch_like_color_val
|
||||
return OptionalNone {};
|
||||
inner_tokens.discard_whitespace();
|
||||
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
if (inner_tokens.has_next_token()) {
|
||||
alpha = parse_solidus_and_alpha_value(inner_tokens);
|
||||
if (!alpha || inner_tokens.has_next_token())
|
||||
@@ -1892,7 +1892,7 @@ Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lch_like_color_val
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-lch
|
||||
RefPtr<CSSStyleValue const> Parser::parse_lch_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_lch_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// lch() = lch( [<percentage> | <number> | none]
|
||||
// [ <percentage> | <number> | none]
|
||||
@@ -1912,7 +1912,7 @@ RefPtr<CSSStyleValue const> Parser::parse_lch_color_value(TokenStream<ComponentV
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-oklch
|
||||
RefPtr<CSSStyleValue const> Parser::parse_oklch_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_oklch_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// oklch() = oklch( [ <percentage> | <number> | none]
|
||||
// [ <percentage> | <number> | none]
|
||||
@@ -1932,7 +1932,7 @@ RefPtr<CSSStyleValue const> Parser::parse_oklch_color_value(TokenStream<Componen
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#funcdef-color
|
||||
RefPtr<CSSStyleValue const> Parser::parse_color_function(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_color_function(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
// color() = color( <colorspace-params> [ / [ <alpha-value> | none ] ]? )
|
||||
// <colorspace-params> = [ <predefined-rgb-params> | <xyz-params>]
|
||||
@@ -1975,7 +1975,7 @@ RefPtr<CSSStyleValue const> Parser::parse_color_function(TokenStream<ComponentVa
|
||||
return {};
|
||||
inner_tokens.discard_whitespace();
|
||||
|
||||
RefPtr<CSSStyleValue const> alpha;
|
||||
RefPtr<StyleValue const> alpha;
|
||||
if (inner_tokens.has_next_token()) {
|
||||
alpha = parse_solidus_and_alpha_value(inner_tokens);
|
||||
if (!alpha || inner_tokens.has_next_token())
|
||||
@@ -1994,7 +1994,7 @@ RefPtr<CSSStyleValue const> Parser::parse_color_function(TokenStream<ComponentVa
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-color-5/#color-mix
|
||||
RefPtr<CSSStyleValue const> Parser::parse_color_mix_function(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_color_mix_function(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto parse_color_interpolation_method = [this](TokenStream<ComponentValue>& function_tokens) -> Optional<ColorMixStyleValue::ColorInterpolationMethod> {
|
||||
// <rectangular-color-space> = srgb | srgb-linear | display-p3 | a98-rgb | prophoto-rgb | rec2020 | lab | oklab | <xyz-space>
|
||||
@@ -2126,7 +2126,7 @@ RefPtr<CSSStyleValue const> Parser::parse_color_mix_function(TokenStream<Compone
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-color-5/#funcdef-light-dark
|
||||
RefPtr<CSSStyleValue const> Parser::parse_light_dark_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_light_dark_color_value(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
auto transaction = outer_tokens.begin_transaction();
|
||||
|
||||
@@ -2160,7 +2160,7 @@ RefPtr<CSSStyleValue const> Parser::parse_light_dark_color_value(TokenStream<Com
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#color-syntax
|
||||
RefPtr<CSSStyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
|
||||
// Keywords: <system-color> | <deprecated-color> | currentColor
|
||||
@@ -2308,7 +2308,7 @@ RefPtr<CSSStyleValue const> Parser::parse_color_value(TokenStream<ComponentValue
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-lists-3/#counter-functions
|
||||
RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto parse_counter_name = [this](TokenStream<ComponentValue>& tokens) -> Optional<FlyString> {
|
||||
// https://drafts.csswg.org/css-lists-3/#typedef-counter-name
|
||||
@@ -2330,7 +2330,7 @@ RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentVal
|
||||
return counter_name->custom_ident();
|
||||
};
|
||||
|
||||
auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<CSSStyleValue const> {
|
||||
auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<StyleValue const> {
|
||||
// https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style
|
||||
// <counter-style> = <counter-style-name> | <symbols()>
|
||||
// For now we just support <counter-style-name>, found here:
|
||||
@@ -2368,7 +2368,7 @@ RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentVal
|
||||
if (!counter_name.has_value())
|
||||
return nullptr;
|
||||
|
||||
RefPtr<CSSStyleValue const> counter_style;
|
||||
RefPtr<StyleValue const> counter_style;
|
||||
if (function_values.size() > 1) {
|
||||
TokenStream counter_style_tokens { function_values[1] };
|
||||
counter_style = parse_counter_style(counter_style_tokens);
|
||||
@@ -2405,7 +2405,7 @@ RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentVal
|
||||
if (!join_string || string_tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
RefPtr<CSSStyleValue const> counter_style;
|
||||
RefPtr<StyleValue const> counter_style;
|
||||
if (function_values.size() > 2) {
|
||||
TokenStream counter_style_tokens { function_values[2] };
|
||||
counter_style = parse_counter_style(counter_style_tokens);
|
||||
@@ -2423,7 +2423,7 @@ RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentVal
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto ratio = parse_ratio(tokens); ratio.has_value())
|
||||
return RatioStyleValue::create(ratio.release_value());
|
||||
@@ -2471,11 +2471,11 @@ RefPtr<AbstractImageStyleValue const> Parser::parse_image_value(TokenStream<Comp
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
|
||||
RefPtr<CSSStyleValue const> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
|
||||
|
||||
auto parse_color_or_none = [&]() -> Optional<RefPtr<CSSStyleValue const>> {
|
||||
auto parse_color_or_none = [&]() -> Optional<RefPtr<StyleValue const>> {
|
||||
if (auto color = parse_color_value(tokens))
|
||||
return color;
|
||||
|
||||
@@ -2817,7 +2817,7 @@ RefPtr<PositionStyleValue const> Parser::parse_position_value(TokenStream<Compon
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
@@ -3195,7 +3195,7 @@ RefPtr<FitContentStyleValue const> Parser::parse_fit_content_value(TokenStream<C
|
||||
return FitContentStyleValue::create(maybe_length.release_value());
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
auto& component_value = tokens.consume_a_token();
|
||||
@@ -3477,7 +3477,7 @@ RefPtr<CSSStyleValue const> Parser::parse_basic_shape_value(TokenStream<Componen
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
auto& component_value = tokens.consume_a_token();
|
||||
@@ -4062,7 +4062,7 @@ RefPtr<GridTrackPlacementStyleValue const> Parser::parse_grid_track_placement(To
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_calculated_value(ComponentValue const& component_value)
|
||||
RefPtr<StyleValue const> Parser::parse_calculated_value(ComponentValue const& component_value)
|
||||
{
|
||||
if (!component_value.is_function())
|
||||
return nullptr;
|
||||
@@ -4625,10 +4625,10 @@ RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<C
|
||||
return FontSourceStyleValue::create(url.release_value(), move(format), move(tech));
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional<GuardedSubstitutionContexts&> existing_guarded_contexts)
|
||||
NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional<GuardedSubstitutionContexts&> existing_guarded_contexts)
|
||||
{
|
||||
// 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 CSSStyleValue from it.
|
||||
// to produce a different StyleValue from it.
|
||||
VERIFY(unresolved.contains_arbitrary_substitution_function());
|
||||
|
||||
DOM::AbstractElement abstract_element { element, pseudo_element };
|
||||
@@ -4640,7 +4640,7 @@ NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(Parsin
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-values-5/#property-replacement
|
||||
NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(DOM::AbstractElement& element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved)
|
||||
NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(DOM::AbstractElement& element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved)
|
||||
{
|
||||
// AD-HOC: Report that we might rely on custom properties.
|
||||
if (unresolved.includes_attr_function())
|
||||
@@ -4679,7 +4679,7 @@ NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(DOM::A
|
||||
return parsed_value.release_value();
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> Parser::parse_value(ValueType value_type, TokenStream<ComponentValue>& tokens)
|
||||
RefPtr<StyleValue const> Parser::parse_value(ValueType value_type, TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
switch (value_type) {
|
||||
case ValueType::Anchor:
|
||||
|
||||
@@ -627,7 +627,7 @@ static void sort_matching_rules(Vector<MatchingRule const*>& matching_rules)
|
||||
});
|
||||
}
|
||||
|
||||
void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_id, CSSStyleValue const& value, Function<void(PropertyID, CSSStyleValue const&)> const& set_longhand_property)
|
||||
void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_id, StyleValue const& value, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property)
|
||||
{
|
||||
if (property_is_shorthand(property_id) && (value.is_unresolved() || value.is_pending_substitution())) {
|
||||
// If a shorthand property contains an arbitrary substitution function in its value, the longhand properties
|
||||
@@ -655,7 +655,7 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
||||
|
||||
// FIXME: We should add logic in parse_css_value to parse "positional-value-list-shorthand"s as
|
||||
// ShorthandStyleValues to avoid the need for this (and assign_start_and_end_values).
|
||||
auto assign_edge_values = [&](PropertyID top_property, PropertyID right_property, PropertyID bottom_property, PropertyID left_property, CSSStyleValue const& value) {
|
||||
auto assign_edge_values = [&](PropertyID top_property, PropertyID right_property, PropertyID bottom_property, PropertyID left_property, StyleValue const& value) {
|
||||
if (value.is_value_list()) {
|
||||
auto values = value.as_value_list().values();
|
||||
|
||||
@@ -842,7 +842,7 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
||||
set_longhand_property(CSS::PropertyID::TransitionBehavior, CSSKeywordValue::create(Keyword::Normal));
|
||||
} else if (value.is_transition()) {
|
||||
auto const& transitions = value.as_transition().transitions();
|
||||
Array<Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>>, 5> transition_values;
|
||||
Array<Vector<ValueComparingNonnullRefPtr<StyleValue const>>, 5> transition_values;
|
||||
for (auto const& transition : transitions) {
|
||||
transition_values[0].append(*transition.property_name);
|
||||
transition_values[1].append(transition.duration.as_style_value());
|
||||
@@ -936,7 +936,7 @@ void StyleComputer::cascade_declarations(
|
||||
}
|
||||
}
|
||||
|
||||
for_each_property_expanding_shorthands(property.property_id, property_value, [&](PropertyID longhand_id, CSSStyleValue const& longhand_value) {
|
||||
for_each_property_expanding_shorthands(property.property_id, property_value, [&](PropertyID longhand_id, StyleValue const& longhand_value) {
|
||||
// If we're a PSV that's already been seen, that should mean that our shorthand already got
|
||||
// resolved and gave us a value, so we don't want to overwrite it with a PSV.
|
||||
if (seen_properties.get(to_underlying(longhand_id)) && property_value->is_pending_substitution())
|
||||
@@ -1057,7 +1057,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||
|
||||
// FIXME: Follow https://drafts.csswg.org/web-animations-1/#ref-for-computed-keyframes in whatever the right place is.
|
||||
auto compute_keyframe_values = [refresh, &computed_properties, &element, &pseudo_element, this](auto const& keyframe_values) {
|
||||
HashMap<PropertyID, RefPtr<CSSStyleValue const>> result;
|
||||
HashMap<PropertyID, RefPtr<StyleValue const>> result;
|
||||
HashMap<PropertyID, PropertyID> longhands_set_by_property_id;
|
||||
auto property_is_set_by_use_initial = MUST(Bitmap::create(to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1, false));
|
||||
|
||||
@@ -1108,7 +1108,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||
bool is_use_initial = false;
|
||||
|
||||
auto style_value = value.visit(
|
||||
[&](Animations::KeyframeEffect::KeyFrameSet::UseInitial) -> RefPtr<CSSStyleValue const> {
|
||||
[&](Animations::KeyframeEffect::KeyFrameSet::UseInitial) -> RefPtr<StyleValue const> {
|
||||
if (refresh == AnimationRefresh::Yes)
|
||||
return {};
|
||||
if (property_is_shorthand(property_id))
|
||||
@@ -1116,7 +1116,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||
is_use_initial = true;
|
||||
return computed_properties.property(property_id);
|
||||
},
|
||||
[&](RefPtr<CSSStyleValue const> value) -> RefPtr<CSSStyleValue const> {
|
||||
[&](RefPtr<StyleValue const> value) -> RefPtr<StyleValue const> {
|
||||
return value;
|
||||
});
|
||||
|
||||
@@ -1135,7 +1135,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||
if (style_value->is_unresolved())
|
||||
style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, element, pseudo_element, property_id, style_value->as_unresolved());
|
||||
|
||||
for_each_property_expanding_shorthands(property_id, *style_value, [&](PropertyID longhand_id, CSSStyleValue const& longhand_value) {
|
||||
for_each_property_expanding_shorthands(property_id, *style_value, [&](PropertyID longhand_id, StyleValue const& longhand_value) {
|
||||
auto physical_longhand_id = map_logical_alias_to_physical_property(longhand_id, LogicalAliasMappingContext { computed_properties.writing_mode(), computed_properties.direction() });
|
||||
auto physical_longhand_id_bitmap_index = to_underlying(physical_longhand_id) - to_underlying(first_longhand_property_id);
|
||||
|
||||
@@ -1154,8 +1154,8 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
||||
}
|
||||
return result;
|
||||
};
|
||||
HashMap<PropertyID, RefPtr<CSSStyleValue const>> computed_start_values = compute_keyframe_values(keyframe_values);
|
||||
HashMap<PropertyID, RefPtr<CSSStyleValue const>> computed_end_values = compute_keyframe_values(keyframe_end_values);
|
||||
HashMap<PropertyID, RefPtr<StyleValue const>> computed_start_values = compute_keyframe_values(keyframe_values);
|
||||
HashMap<PropertyID, RefPtr<StyleValue const>> computed_end_values = compute_keyframe_values(keyframe_end_values);
|
||||
|
||||
for (auto const& it : computed_start_values) {
|
||||
auto resolved_start_property = it.value;
|
||||
@@ -1677,7 +1677,7 @@ DOM::Element const* element_to_inherit_style_from(DOM::Element const* element, O
|
||||
return parent_element;
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> StyleComputer::get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::PseudoElement> pseudo_element)
|
||||
NonnullRefPtr<StyleValue const> StyleComputer::get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::PseudoElement> pseudo_element)
|
||||
{
|
||||
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
||||
|
||||
@@ -1909,7 +1909,7 @@ CSSPixelFraction StyleComputer::absolute_size_mapping(Keyword keyword)
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> 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
|
||||
RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> 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
|
||||
{
|
||||
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
||||
|
||||
@@ -2560,7 +2560,7 @@ GC::Ptr<ComputedProperties> StyleComputer::compute_style_impl(DOM::Element& elem
|
||||
return computed_properties;
|
||||
}
|
||||
|
||||
static bool is_monospace(CSSStyleValue const& value)
|
||||
static bool is_monospace(StyleValue const& value)
|
||||
{
|
||||
if (value.to_keyword() == Keyword::Monospace)
|
||||
return true;
|
||||
@@ -2579,7 +2579,7 @@ static bool is_monospace(CSSStyleValue const& value)
|
||||
// instead of the default font size (16px).
|
||||
// See this blog post for a lot more details about this weirdness:
|
||||
// https://manishearth.github.io/blog/2017/08/10/font-size-an-unexpectedly-complex-css-property/
|
||||
RefPtr<CSSStyleValue const> StyleComputer::recascade_font_size_if_needed(
|
||||
RefPtr<StyleValue const> StyleComputer::recascade_font_size_if_needed(
|
||||
DOM::Element& element,
|
||||
Optional<CSS::PseudoElement> pseudo_element,
|
||||
CascadedProperties& cascaded_properties) const
|
||||
@@ -2603,7 +2603,7 @@ RefPtr<CSSStyleValue const> StyleComputer::recascade_font_size_if_needed(
|
||||
for (auto ancestor = element.parent_element(); ancestor; ancestor = ancestor->parent_element())
|
||||
ancestors.append(*ancestor);
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> new_font_size = CSS::LengthStyleValue::create(CSS::Length::make_px(default_monospace_font_size_in_px));
|
||||
NonnullRefPtr<StyleValue const> new_font_size = CSS::LengthStyleValue::create(CSS::Length::make_px(default_monospace_font_size_in_px));
|
||||
CSSPixels current_size_in_px = default_monospace_font_size_in_px;
|
||||
|
||||
for (auto& ancestor : ancestors.in_reverse()) {
|
||||
@@ -2959,9 +2959,9 @@ void StyleComputer::make_rule_cache_for_cascade_origin(CascadeOrigin cascade_ori
|
||||
auto const& keyframe_style = *keyframe.style();
|
||||
for (auto const& it : keyframe_style.properties()) {
|
||||
// Unresolved properties will be resolved in collect_animation_into()
|
||||
for_each_property_expanding_shorthands(it.property_id, it.value, [&](PropertyID shorthand_id, CSSStyleValue const& shorthand_value) {
|
||||
for_each_property_expanding_shorthands(it.property_id, it.value, [&](PropertyID shorthand_id, StyleValue const& shorthand_value) {
|
||||
animated_properties.set(shorthand_id);
|
||||
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<CSSStyleValue const> { shorthand_value });
|
||||
resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr<StyleValue const> { shorthand_value });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3169,7 +3169,7 @@ void StyleComputer::unload_fonts_from_sheet(CSSStyleSheet& sheet)
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> StyleComputer::compute_value_of_custom_property(DOM::AbstractElement abstract_element, FlyString const& name, Optional<Parser::GuardedSubstitutionContexts&> guarded_contexts)
|
||||
NonnullRefPtr<StyleValue const> StyleComputer::compute_value_of_custom_property(DOM::AbstractElement abstract_element, FlyString const& name, Optional<Parser::GuardedSubstitutionContexts&> guarded_contexts)
|
||||
{
|
||||
// https://drafts.csswg.org/css-variables/#propdef-
|
||||
// The computed value of a custom property is its specified value with any arbitrary-substitution functions replaced.
|
||||
@@ -3247,7 +3247,7 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element c
|
||||
}
|
||||
auto const& math_depth = value.as_math_depth();
|
||||
|
||||
auto resolve_integer = [&](CSSStyleValue const& integer_value) {
|
||||
auto resolve_integer = [&](StyleValue const& integer_value) {
|
||||
if (integer_value.is_integer())
|
||||
return integer_value.as_integer().integer();
|
||||
if (integer_value.is_calculated())
|
||||
|
||||
@@ -131,8 +131,8 @@ class StyleComputer final : public GC::Cell {
|
||||
GC_DECLARE_ALLOCATOR(StyleComputer);
|
||||
|
||||
public:
|
||||
static void for_each_property_expanding_shorthands(PropertyID, CSSStyleValue const&, Function<void(PropertyID, CSSStyleValue const&)> const& set_longhand_property);
|
||||
static NonnullRefPtr<CSSStyleValue const> get_inherit_value(CSS::PropertyID, DOM::Element const*, Optional<CSS::PseudoElement> = {});
|
||||
static void for_each_property_expanding_shorthands(PropertyID, StyleValue const&, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property);
|
||||
static NonnullRefPtr<StyleValue const> get_inherit_value(CSS::PropertyID, DOM::Element const*, Optional<CSS::PseudoElement> = {});
|
||||
|
||||
static Optional<String> user_agent_style_sheet_source(StringView name);
|
||||
|
||||
@@ -172,9 +172,9 @@ public:
|
||||
|
||||
static CSSPixels default_user_font_size();
|
||||
static CSSPixelFraction absolute_size_mapping(Keyword);
|
||||
RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> 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;
|
||||
RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> 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;
|
||||
|
||||
[[nodiscard]] RefPtr<CSSStyleValue const> recascade_font_size_if_needed(DOM::Element&, Optional<CSS::PseudoElement> pseudo_element, CascadedProperties&) const;
|
||||
[[nodiscard]] RefPtr<StyleValue const> recascade_font_size_if_needed(DOM::Element&, Optional<CSS::PseudoElement> pseudo_element, CascadedProperties&) const;
|
||||
|
||||
void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
|
||||
[[nodiscard]] inline bool should_reject_with_ancestor_filter(Selector const&) const;
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue const> compute_value_of_custom_property(DOM::AbstractElement, FlyString const& custom_property, Optional<Parser::GuardedSubstitutionContexts&> = {});
|
||||
static NonnullRefPtr<StyleValue const> compute_value_of_custom_property(DOM::AbstractElement, FlyString const& custom_property, Optional<Parser::GuardedSubstitutionContexts&> = {});
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSSStyleValue const> const& old_value, RefPtr<CSSStyleValue const> const& new_value)
|
||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<StyleValue const> const& old_value, RefPtr<StyleValue const> const& new_value)
|
||||
{
|
||||
RequiredInvalidationAfterStyleChange invalidation;
|
||||
|
||||
|
||||
@@ -29,6 +29,6 @@ struct RequiredInvalidationAfterStyleChange {
|
||||
static RequiredInvalidationAfterStyleChange full() { return { true, true, true, true }; }
|
||||
};
|
||||
|
||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<CSSStyleValue const> const& old_value, RefPtr<CSSStyleValue const> const& new_value);
|
||||
RequiredInvalidationAfterStyleChange compute_property_invalidation(CSS::PropertyID property_id, RefPtr<StyleValue const> const& old_value, RefPtr<StyleValue const> const& new_value);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ struct StyleProperty {
|
||||
|
||||
Important important { Important::No };
|
||||
CSS::PropertyID property_id;
|
||||
NonnullRefPtr<CSSStyleValue const> value;
|
||||
NonnullRefPtr<StyleValue const> value;
|
||||
FlyString custom_name {};
|
||||
|
||||
bool operator==(StyleProperty const& other) const;
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class AbstractImageStyleValue : public CSSStyleValue {
|
||||
class AbstractImageStyleValue : public StyleValue {
|
||||
public:
|
||||
using CSSStyleValue::CSSStyleValue;
|
||||
using StyleValue::StyleValue;
|
||||
|
||||
virtual Optional<CSSPixels> natural_width() const { return {}; }
|
||||
virtual Optional<CSSPixels> natural_height() const { return {}; }
|
||||
@@ -165,7 +165,7 @@ struct ColorStopListElement {
|
||||
|
||||
Optional<ColorHint> transition_hint;
|
||||
struct ColorStop {
|
||||
RefPtr<CSSStyleValue const> color;
|
||||
RefPtr<StyleValue const> color;
|
||||
Optional<TPosition> position;
|
||||
Optional<TPosition> second_position = {};
|
||||
inline bool operator==(ColorStop const&) const = default;
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<AnchorSizeStyleValue const> AnchorSizeStyleValue::create(
|
||||
Optional<FlyString> const& anchor_name, Optional<AnchorSize> const& anchor_size,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value)
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) AnchorSizeStyleValue(anchor_name, anchor_size, fallback_value));
|
||||
}
|
||||
|
||||
AnchorSizeStyleValue::AnchorSizeStyleValue(Optional<FlyString> const& anchor_name, Optional<AnchorSize> const& anchor_size,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value)
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value)
|
||||
: StyleValueWithDefaultOperators(Type::AnchorSize)
|
||||
, m_properties { .anchor_name = anchor_name, .anchor_size = anchor_size, .fallback_value = fallback_value }
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -17,7 +17,7 @@ class AnchorSizeStyleValue final : public StyleValueWithDefaultOperators<AnchorS
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<AnchorSizeStyleValue const> create(Optional<FlyString> const& anchor_name,
|
||||
Optional<AnchorSize> const& anchor_size,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value);
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value);
|
||||
virtual ~AnchorSizeStyleValue() override = default;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
@@ -26,19 +26,19 @@ public:
|
||||
|
||||
Optional<FlyString const&> anchor_name() const { return m_properties.anchor_name; }
|
||||
Optional<AnchorSize> anchor_size() const { return m_properties.anchor_size; }
|
||||
ValueComparingRefPtr<CSSStyleValue const> fallback_value() const
|
||||
ValueComparingRefPtr<StyleValue const> fallback_value() const
|
||||
{
|
||||
return m_properties.fallback_value;
|
||||
}
|
||||
|
||||
private:
|
||||
AnchorSizeStyleValue(Optional<FlyString> const& anchor_name, Optional<AnchorSize> const& anchor_size,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value);
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value);
|
||||
|
||||
struct Properties {
|
||||
Optional<FlyString> anchor_name;
|
||||
Optional<AnchorSize> anchor_size;
|
||||
ValueComparingRefPtr<CSSStyleValue const> fallback_value;
|
||||
ValueComparingRefPtr<StyleValue const> fallback_value;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
@@ -10,15 +10,15 @@ namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<AnchorStyleValue const> AnchorStyleValue::create(
|
||||
Optional<FlyString> const& anchor_name,
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value)
|
||||
ValueComparingNonnullRefPtr<StyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) AnchorStyleValue(anchor_name, anchor_side, fallback_value));
|
||||
}
|
||||
|
||||
AnchorStyleValue::AnchorStyleValue(Optional<FlyString> const& anchor_name,
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value)
|
||||
ValueComparingNonnullRefPtr<StyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value)
|
||||
: StyleValueWithDefaultOperators(Type::Anchor)
|
||||
, m_properties { .anchor_name = anchor_name, .anchor_side = anchor_side, .fallback_value = fallback_value }
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Web::CSS {
|
||||
class AnchorStyleValue final : public StyleValueWithDefaultOperators<AnchorStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<AnchorStyleValue const> create(Optional<FlyString> const& anchor_name,
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<CSSStyleValue const> const& fallback_value);
|
||||
ValueComparingNonnullRefPtr<StyleValue const> const& anchor_side,
|
||||
ValueComparingRefPtr<StyleValue const> const& fallback_value);
|
||||
virtual ~AnchorStyleValue() override = default;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
@@ -25,22 +25,22 @@ public:
|
||||
bool properties_equal(AnchorStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
Optional<FlyString const&> anchor_name() const { return m_properties.anchor_name; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> anchor_side() const
|
||||
ValueComparingNonnullRefPtr<StyleValue const> anchor_side() const
|
||||
{
|
||||
return m_properties.anchor_side;
|
||||
}
|
||||
ValueComparingRefPtr<CSSStyleValue const> fallback_value() const
|
||||
ValueComparingRefPtr<StyleValue const> fallback_value() const
|
||||
{
|
||||
return m_properties.fallback_value;
|
||||
}
|
||||
|
||||
private:
|
||||
AnchorStyleValue(Optional<FlyString> const& anchor_name, ValueComparingNonnullRefPtr<CSSStyleValue const> const& anchor_side, ValueComparingRefPtr<CSSStyleValue const> const& fallback_value);
|
||||
AnchorStyleValue(Optional<FlyString> const& anchor_name, ValueComparingNonnullRefPtr<StyleValue const> const& anchor_side, ValueComparingRefPtr<StyleValue const> const& fallback_value);
|
||||
|
||||
struct Properties {
|
||||
Optional<FlyString> anchor_name;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> anchor_side;
|
||||
ValueComparingRefPtr<CSSStyleValue const> fallback_value;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> anchor_side;
|
||||
ValueComparingRefPtr<StyleValue const> fallback_value;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ String AngleStyleValue::to_string(SerializationMode serialization_mode) const
|
||||
return m_angle.to_string(serialization_mode);
|
||||
}
|
||||
|
||||
bool AngleStyleValue::equals(CSSStyleValue const& other) const
|
||||
bool AngleStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
bool equals(CSSStyleValue const& other) const override;
|
||||
bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
explicit AngleStyleValue(Angle angle);
|
||||
|
||||
@@ -26,7 +26,7 @@ String BackgroundSizeStyleValue::to_string(SerializationMode mode) const
|
||||
return MUST(String::formatted("{} {}", m_properties.size_x.to_string(mode), m_properties.size_y.to_string(mode)));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> BackgroundSizeStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
ValueComparingNonnullRefPtr<StyleValue const> BackgroundSizeStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
{
|
||||
auto absolutized_size_x = m_properties.size_x.absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||
auto absolutized_size_y = m_properties.size_y.absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
LengthPercentage size_y() const { return m_properties.size_y; }
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
|
||||
bool properties_equal(BackgroundSizeStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include <AK/Variant.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/LengthBox.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/SVG/AttributeParser.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -6,23 +6,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class BorderImageSliceStyleValue final : public StyleValueWithDefaultOperators<BorderImageSliceStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<BorderImageSliceStyleValue const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> top, ValueComparingNonnullRefPtr<CSSStyleValue const> right, ValueComparingNonnullRefPtr<CSSStyleValue const> bottom, ValueComparingNonnullRefPtr<CSSStyleValue const> left, bool fill)
|
||||
static ValueComparingNonnullRefPtr<BorderImageSliceStyleValue const> create(ValueComparingNonnullRefPtr<StyleValue const> top, ValueComparingNonnullRefPtr<StyleValue const> right, ValueComparingNonnullRefPtr<StyleValue const> bottom, ValueComparingNonnullRefPtr<StyleValue const> left, bool fill)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) BorderImageSliceStyleValue(top, right, bottom, left, fill));
|
||||
}
|
||||
|
||||
virtual ~BorderImageSliceStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> top() const { return m_properties.top; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> left() const { return m_properties.left; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> bottom() const { return m_properties.bottom; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> right() const { return m_properties.right; }
|
||||
ValueComparingNonnullRefPtr<StyleValue const> top() const { return m_properties.top; }
|
||||
ValueComparingNonnullRefPtr<StyleValue const> left() const { return m_properties.left; }
|
||||
ValueComparingNonnullRefPtr<StyleValue const> bottom() const { return m_properties.bottom; }
|
||||
ValueComparingNonnullRefPtr<StyleValue const> right() const { return m_properties.right; }
|
||||
|
||||
bool fill() const { return m_properties.fill; }
|
||||
|
||||
@@ -31,17 +31,17 @@ public:
|
||||
bool properties_equal(BorderImageSliceStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
BorderImageSliceStyleValue(ValueComparingNonnullRefPtr<CSSStyleValue const> top, ValueComparingNonnullRefPtr<CSSStyleValue const> right, ValueComparingNonnullRefPtr<CSSStyleValue const> bottom, ValueComparingNonnullRefPtr<CSSStyleValue const> left, bool fill)
|
||||
BorderImageSliceStyleValue(ValueComparingNonnullRefPtr<StyleValue const> top, ValueComparingNonnullRefPtr<StyleValue const> right, ValueComparingNonnullRefPtr<StyleValue const> bottom, ValueComparingNonnullRefPtr<StyleValue const> left, bool fill)
|
||||
: StyleValueWithDefaultOperators(Type::BorderImageSlice)
|
||||
, m_properties { .top = move(top), .right = move(right), .bottom = move(bottom), .left = move(left), .fill = fill }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> top;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> right;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> bottom;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> left;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> top;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> right;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> bottom;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> left;
|
||||
bool fill;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
|
||||
@@ -18,7 +18,7 @@ String BorderRadiusStyleValue::to_string(SerializationMode mode) const
|
||||
return MUST(String::formatted("{} {}", m_properties.horizontal_radius.to_string(mode), m_properties.vertical_radius.to_string(mode)));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
ValueComparingNonnullRefPtr<StyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
{
|
||||
auto absolutized_horizontal_radius = m_properties.horizontal_radius.absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||
auto absolutized_vertical_radius = m_properties.vertical_radius.absolutized(viewport_rect, font_metrics, root_font_metrics);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
|
||||
struct Properties {
|
||||
bool is_elliptical;
|
||||
|
||||
@@ -30,7 +30,7 @@ ValueComparingNonnullRefPtr<CSSColorValue const> CSSColorValue::create_from_colo
|
||||
name);
|
||||
}
|
||||
|
||||
Optional<double> CSSColorValue::resolve_hue(CSSStyleValue const& style_value, CalculationResolutionContext const& resolution_context)
|
||||
Optional<double> CSSColorValue::resolve_hue(StyleValue const& style_value, CalculationResolutionContext const& resolution_context)
|
||||
{
|
||||
// <number> | <angle> | none
|
||||
auto normalized = [](double number) {
|
||||
@@ -74,7 +74,7 @@ Optional<double> CSSColorValue::resolve_hue(CSSStyleValue const& style_value, Ca
|
||||
return 0;
|
||||
}
|
||||
|
||||
Optional<double> CSSColorValue::resolve_with_reference_value(CSSStyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context)
|
||||
Optional<double> CSSColorValue::resolve_with_reference_value(StyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context)
|
||||
{
|
||||
// <percentage> | <number> | none
|
||||
auto normalize_percentage = [one_hundred_percent_value](Percentage const& percentage) {
|
||||
@@ -111,7 +111,7 @@ Optional<double> CSSColorValue::resolve_with_reference_value(CSSStyleValue const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Optional<double> CSSColorValue::resolve_alpha(CSSStyleValue const& style_value, CalculationResolutionContext const& resolution_context)
|
||||
Optional<double> CSSColorValue::resolve_alpha(StyleValue const& style_value, CalculationResolutionContext const& resolution_context)
|
||||
{
|
||||
// <number> | <percentage> | none
|
||||
auto normalized = [](double number) {
|
||||
@@ -153,7 +153,7 @@ Optional<double> CSSColorValue::resolve_alpha(CSSStyleValue const& style_value,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CSSColorValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min, Optional<double> clamp_max) const
|
||||
void CSSColorValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min, Optional<double> clamp_max) const
|
||||
{
|
||||
if (component.to_keyword() == Keyword::None) {
|
||||
builder.append("none"sv);
|
||||
@@ -185,7 +185,7 @@ void CSSColorValue::serialize_color_component(StringBuilder& builder, Serializat
|
||||
builder.append(resolved_string);
|
||||
}
|
||||
|
||||
void CSSColorValue::serialize_alpha_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component) const
|
||||
void CSSColorValue::serialize_alpha_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const
|
||||
{
|
||||
if (component.to_keyword() == Keyword::None) {
|
||||
builder.append("none"sv);
|
||||
@@ -206,7 +206,7 @@ void CSSColorValue::serialize_alpha_component(StringBuilder& builder, Serializat
|
||||
builder.appendff("{}", maybe_resolved_value.value());
|
||||
}
|
||||
|
||||
void CSSColorValue::serialize_hue_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component) const
|
||||
void CSSColorValue::serialize_hue_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const
|
||||
{
|
||||
if (component.to_keyword() == Keyword::None) {
|
||||
builder.append("none"sv);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -21,7 +21,7 @@ enum class ColorSyntax : u8 {
|
||||
};
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue
|
||||
class CSSColorValue : public CSSStyleValue {
|
||||
class CSSColorValue : public StyleValue {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<CSSColorValue const> create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name = {});
|
||||
virtual ~CSSColorValue() override = default;
|
||||
@@ -52,19 +52,19 @@ public:
|
||||
|
||||
protected:
|
||||
explicit CSSColorValue(ColorType color_type, ColorSyntax color_syntax)
|
||||
: CSSStyleValue(Type::Color)
|
||||
: StyleValue(Type::Color)
|
||||
, m_color_type(color_type)
|
||||
, m_color_syntax(color_syntax)
|
||||
{
|
||||
}
|
||||
|
||||
static Optional<double> resolve_hue(CSSStyleValue const&, CalculationResolutionContext const&);
|
||||
static Optional<double> resolve_with_reference_value(CSSStyleValue const&, float one_hundred_percent_value, CalculationResolutionContext const&);
|
||||
static Optional<double> resolve_alpha(CSSStyleValue const&, CalculationResolutionContext const&);
|
||||
static Optional<double> resolve_hue(StyleValue const&, CalculationResolutionContext const&);
|
||||
static Optional<double> resolve_with_reference_value(StyleValue const&, float one_hundred_percent_value, CalculationResolutionContext const&);
|
||||
static Optional<double> resolve_alpha(StyleValue const&, CalculationResolutionContext const&);
|
||||
|
||||
void serialize_color_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min = {}, Optional<double> clamp_max = {}) const;
|
||||
void serialize_alpha_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component) const;
|
||||
void serialize_hue_component(StringBuilder& builder, SerializationMode mode, CSSStyleValue const& component) const;
|
||||
void serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min = {}, Optional<double> clamp_max = {}) const;
|
||||
void serialize_alpha_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const;
|
||||
void serialize_hue_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const;
|
||||
|
||||
ColorType m_color_type;
|
||||
ColorSyntax m_color_syntax;
|
||||
|
||||
@@ -25,7 +25,7 @@ Optional<Color> CSSHSL::to_color(ColorResolutionContext color_resolution_context
|
||||
return Color::from_hsla(h_val.value(), s_val.value() / 100.0f, l_val.value() / 100.0f, alpha_val.value());
|
||||
}
|
||||
|
||||
bool CSSHSL::equals(CSSStyleValue const& other) const
|
||||
bool CSSHSL::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Web::CSS {
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csshsl
|
||||
class CSSHSL final : public CSSColorValue {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<CSSHSL const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> s, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax)
|
||||
static ValueComparingNonnullRefPtr<CSSHSL const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax)
|
||||
{
|
||||
// alpha defaults to 1
|
||||
if (!alpha)
|
||||
@@ -24,29 +24,29 @@ public:
|
||||
}
|
||||
virtual ~CSSHSL() override = default;
|
||||
|
||||
CSSStyleValue const& h() const { return *m_properties.h; }
|
||||
CSSStyleValue const& s() const { return *m_properties.s; }
|
||||
CSSStyleValue const& l() const { return *m_properties.l; }
|
||||
CSSStyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
StyleValue const& h() const { return *m_properties.h; }
|
||||
StyleValue const& s() const { return *m_properties.s; }
|
||||
StyleValue const& l() const { return *m_properties.l; }
|
||||
StyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
|
||||
virtual Optional<Color> to_color(ColorResolutionContext color_resolution_context) const override;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
CSSHSL(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> s, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax)
|
||||
CSSHSL(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> alpha, ColorSyntax color_syntax)
|
||||
: CSSColorValue(ColorType::HSL, color_syntax)
|
||||
, m_properties { .h = move(h), .s = move(s), .l = move(l), .alpha = move(alpha) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> s;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> s;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ Optional<Color> CSSHWB::to_color(ColorResolutionContext color_resolution_context
|
||||
return Color::from_hsv(h_val.value(), saturation, value).with_opacity(alpha_val.value());
|
||||
}
|
||||
|
||||
bool CSSHWB::equals(CSSStyleValue const& other) const
|
||||
bool CSSHWB::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Web::CSS {
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csshwb
|
||||
class CSSHWB final : public CSSColorValue {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<CSSHWB const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> w, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
|
||||
static ValueComparingNonnullRefPtr<CSSHWB const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {})
|
||||
{
|
||||
// alpha defaults to 1
|
||||
if (!alpha)
|
||||
@@ -24,29 +24,29 @@ public:
|
||||
}
|
||||
virtual ~CSSHWB() override = default;
|
||||
|
||||
CSSStyleValue const& h() const { return *m_properties.h; }
|
||||
CSSStyleValue const& w() const { return *m_properties.w; }
|
||||
CSSStyleValue const& b() const { return *m_properties.b; }
|
||||
CSSStyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
StyleValue const& h() const { return *m_properties.h; }
|
||||
StyleValue const& w() const { return *m_properties.w; }
|
||||
StyleValue const& b() const { return *m_properties.b; }
|
||||
StyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
|
||||
virtual Optional<Color> to_color(ColorResolutionContext color_resolution_context) const override;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
CSSHWB(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> w, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSHWB(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSColorValue(ColorType::HWB, ColorSyntax::Modern)
|
||||
, m_properties { .h = move(h), .w = move(w), .b = move(b), .alpha = move(alpha) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> w;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> w;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Keyword.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
Keyword m_keyword { Keyword::Invalid };
|
||||
};
|
||||
|
||||
inline Keyword CSSStyleValue::to_keyword() const
|
||||
inline Keyword StyleValue::to_keyword() const
|
||||
{
|
||||
if (is_keyword())
|
||||
return static_cast<CSSKeywordValue const&>(*this).keyword();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
bool CSSLCHLike::equals(CSSStyleValue const& other) const
|
||||
bool CSSLCHLike::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Web::CSS {
|
||||
class CSSLCHLike : public CSSColorValue {
|
||||
public:
|
||||
template<DerivedFrom<CSSLCHLike> T>
|
||||
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
|
||||
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingRefPtr<StyleValue const> alpha = {})
|
||||
{
|
||||
// alpha defaults to 1
|
||||
if (!alpha)
|
||||
@@ -24,25 +24,25 @@ public:
|
||||
}
|
||||
virtual ~CSSLCHLike() override = default;
|
||||
|
||||
CSSStyleValue const& l() const { return *m_properties.l; }
|
||||
CSSStyleValue const& c() const { return *m_properties.c; }
|
||||
CSSStyleValue const& h() const { return *m_properties.h; }
|
||||
CSSStyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
StyleValue const& l() const { return *m_properties.l; }
|
||||
StyleValue const& c() const { return *m_properties.c; }
|
||||
StyleValue const& h() const { return *m_properties.h; }
|
||||
StyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
protected:
|
||||
CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSColorValue(color_type, ColorSyntax::Modern)
|
||||
, m_properties { .l = move(l), .c = move(c), .h = move(h), .alpha = move(alpha) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> c;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> c;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> h;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
@@ -50,7 +50,7 @@ protected:
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csslch
|
||||
class CSSLCH final : public CSSLCHLike {
|
||||
public:
|
||||
CSSLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSLCHLike(ColorType::LCH, move(l), move(c), move(h), move(alpha))
|
||||
{
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssoklch
|
||||
class CSSOKLCH final : public CSSLCHLike {
|
||||
public:
|
||||
CSSOKLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSOKLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSLCHLike(ColorType::OKLCH, move(l), move(c), move(h), move(alpha))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
#include "CSSLabLike.h"
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
bool CSSLabLike::equals(CSSStyleValue const& other) const
|
||||
bool CSSLabLike::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Web::CSS {
|
||||
class CSSLabLike : public CSSColorValue {
|
||||
public:
|
||||
template<typename T>
|
||||
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
|
||||
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {})
|
||||
{
|
||||
// alpha defaults to 1
|
||||
if (!alpha)
|
||||
@@ -25,25 +25,25 @@ public:
|
||||
|
||||
virtual ~CSSLabLike() override = default;
|
||||
|
||||
CSSStyleValue const& l() const { return *m_properties.l; }
|
||||
CSSStyleValue const& a() const { return *m_properties.a; }
|
||||
CSSStyleValue const& b() const { return *m_properties.b; }
|
||||
CSSStyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
StyleValue const& l() const { return *m_properties.l; }
|
||||
StyleValue const& a() const { return *m_properties.a; }
|
||||
StyleValue const& b() const { return *m_properties.b; }
|
||||
StyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
protected:
|
||||
CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSColorValue(color_type, ColorSyntax::Modern)
|
||||
, m_properties { .l = move(l), .a = move(a), .b = move(b), .alpha = move(alpha) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> a;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> l;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> a;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
CSSOKLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSOKLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSLabLike(ColorType::OKLab, move(l), move(a), move(b), move(alpha))
|
||||
{
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
CSSLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
CSSLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSLabLike(ColorType::Lab, move(l), move(a), move(b), move(alpha))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ Optional<Color> CSSLightDark::to_color(ColorResolutionContext color_resolution_c
|
||||
return m_properties.light->to_color(color_resolution_context);
|
||||
}
|
||||
|
||||
bool CSSLightDark::equals(CSSStyleValue const& other) const
|
||||
bool CSSLightDark::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -15,25 +15,25 @@ class CSSLightDark final : public CSSColorValue {
|
||||
public:
|
||||
virtual ~CSSLightDark() override = default;
|
||||
|
||||
static ValueComparingNonnullRefPtr<CSSLightDark const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> light, ValueComparingNonnullRefPtr<CSSStyleValue const> dark)
|
||||
static ValueComparingNonnullRefPtr<CSSLightDark const> create(ValueComparingNonnullRefPtr<StyleValue const> light, ValueComparingNonnullRefPtr<StyleValue const> dark)
|
||||
{
|
||||
return AK::adopt_ref(*new (nothrow) CSSLightDark(move(light), move(dark)));
|
||||
}
|
||||
|
||||
virtual bool equals(CSSStyleValue const&) const override;
|
||||
virtual bool equals(StyleValue const&) const override;
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
private:
|
||||
CSSLightDark(ValueComparingNonnullRefPtr<CSSStyleValue const> light, ValueComparingNonnullRefPtr<CSSStyleValue const> dark)
|
||||
CSSLightDark(ValueComparingNonnullRefPtr<StyleValue const> light, ValueComparingNonnullRefPtr<StyleValue const> dark)
|
||||
: CSSColorValue(CSSColorValue::ColorType::LightDark, ColorSyntax::Modern)
|
||||
, m_properties { .light = move(light), .dark = move(dark) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> light;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> dark;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> light;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> dark;
|
||||
bool operator==(Properties const&) const = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue
|
||||
class CSSNumericValue : public CSSStyleValue {
|
||||
class CSSNumericValue : public StyleValue {
|
||||
public:
|
||||
virtual ~CSSNumericValue() override = default;
|
||||
|
||||
protected:
|
||||
explicit CSSNumericValue(Type type)
|
||||
: CSSStyleValue(type)
|
||||
: StyleValue(type)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Web::CSS {
|
||||
|
||||
Optional<Color> CSSRGB::to_color(ColorResolutionContext color_resolution_context) const
|
||||
{
|
||||
auto resolve_rgb_to_u8 = [&color_resolution_context](CSSStyleValue const& style_value) -> Optional<u8> {
|
||||
auto resolve_rgb_to_u8 = [&color_resolution_context](StyleValue const& style_value) -> Optional<u8> {
|
||||
// <number> | <percentage> | none
|
||||
auto normalized = [](double number) {
|
||||
if (isnan(number))
|
||||
@@ -54,7 +54,7 @@ Optional<Color> CSSRGB::to_color(ColorResolutionContext color_resolution_context
|
||||
return 0;
|
||||
};
|
||||
|
||||
auto resolve_alpha_to_u8 = [&color_resolution_context](CSSStyleValue const& style_value) -> Optional<u8> {
|
||||
auto resolve_alpha_to_u8 = [&color_resolution_context](StyleValue const& style_value) -> Optional<u8> {
|
||||
auto alpha_0_1 = resolve_alpha(style_value, color_resolution_context.calculation_resolution_context);
|
||||
if (alpha_0_1.has_value())
|
||||
return llround(clamp(alpha_0_1.value() * 255.0f, 0.0f, 255.0f));
|
||||
@@ -72,7 +72,7 @@ Optional<Color> CSSRGB::to_color(ColorResolutionContext color_resolution_context
|
||||
return Color(r_val.value(), g_val.value(), b_val.value(), alpha_val.value());
|
||||
}
|
||||
|
||||
bool CSSRGB::equals(CSSStyleValue const& other) const
|
||||
bool CSSRGB::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Web::CSS {
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssrgb
|
||||
class CSSRGB final : public CSSColorValue {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<CSSRGB const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> r, ValueComparingNonnullRefPtr<CSSStyleValue const> g, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
|
||||
static ValueComparingNonnullRefPtr<CSSRGB const> create(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
|
||||
{
|
||||
// alpha defaults to 1
|
||||
if (!alpha)
|
||||
@@ -24,29 +24,29 @@ public:
|
||||
}
|
||||
virtual ~CSSRGB() override = default;
|
||||
|
||||
CSSStyleValue const& r() const { return *m_properties.r; }
|
||||
CSSStyleValue const& g() const { return *m_properties.g; }
|
||||
CSSStyleValue const& b() const { return *m_properties.b; }
|
||||
CSSStyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
StyleValue const& r() const { return *m_properties.r; }
|
||||
StyleValue const& g() const { return *m_properties.g; }
|
||||
StyleValue const& b() const { return *m_properties.b; }
|
||||
StyleValue const& alpha() const { return *m_properties.alpha; }
|
||||
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
CSSRGB(ValueComparingNonnullRefPtr<CSSStyleValue const> r, ValueComparingNonnullRefPtr<CSSStyleValue const> g, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
|
||||
CSSRGB(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
|
||||
: CSSColorValue(ColorType::RGB, color_syntax)
|
||||
, m_properties { .r = move(r), .g = move(g), .b = move(b), .alpha = move(alpha), .name = name }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> r;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> g;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> r;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> g;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> b;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
Optional<FlyString> name;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
|
||||
@@ -664,11 +664,11 @@ CalculatedStyleValue::CalculationResult NumericCalculationNode::resolve(Calculat
|
||||
return CalculatedStyleValue::CalculationResult::from_value(m_value, context, numeric_type());
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue const> NumericCalculationNode::to_style_value(CalculationContext const& context) const
|
||||
RefPtr<StyleValue const> NumericCalculationNode::to_style_value(CalculationContext const& context) const
|
||||
{
|
||||
// TODO: Clamp values to the range allowed by the context.
|
||||
return m_value.visit(
|
||||
[&](Number const& number) -> RefPtr<CSSStyleValue const> {
|
||||
[&](Number const& number) -> RefPtr<StyleValue const> {
|
||||
// FIXME: Returning infinity or NaN as a NumberStyleValue isn't valid.
|
||||
// This is a temporary fix until value-clamping is implemented here.
|
||||
// In future, we can remove these two lines and return NonnullRefPtr again.
|
||||
@@ -679,13 +679,13 @@ RefPtr<CSSStyleValue const> NumericCalculationNode::to_style_value(CalculationCo
|
||||
return IntegerStyleValue::create(llround(number.value()));
|
||||
return NumberStyleValue::create(number.value());
|
||||
},
|
||||
[](Angle const& angle) -> RefPtr<CSSStyleValue const> { return AngleStyleValue::create(angle); },
|
||||
[](Flex const& flex) -> RefPtr<CSSStyleValue const> { return FlexStyleValue::create(flex); },
|
||||
[](Frequency const& frequency) -> RefPtr<CSSStyleValue const> { return FrequencyStyleValue::create(frequency); },
|
||||
[](Length const& length) -> RefPtr<CSSStyleValue const> { return LengthStyleValue::create(length); },
|
||||
[](Percentage const& percentage) -> RefPtr<CSSStyleValue const> { return PercentageStyleValue::create(percentage); },
|
||||
[](Resolution const& resolution) -> RefPtr<CSSStyleValue const> { return ResolutionStyleValue::create(resolution); },
|
||||
[](Time const& time) -> RefPtr<CSSStyleValue const> { return TimeStyleValue::create(time); });
|
||||
[](Angle const& angle) -> RefPtr<StyleValue const> { return AngleStyleValue::create(angle); },
|
||||
[](Flex const& flex) -> RefPtr<StyleValue const> { return FlexStyleValue::create(flex); },
|
||||
[](Frequency const& frequency) -> RefPtr<StyleValue const> { return FrequencyStyleValue::create(frequency); },
|
||||
[](Length const& length) -> RefPtr<StyleValue const> { return LengthStyleValue::create(length); },
|
||||
[](Percentage const& percentage) -> RefPtr<StyleValue const> { return PercentageStyleValue::create(percentage); },
|
||||
[](Resolution const& resolution) -> RefPtr<StyleValue const> { return ResolutionStyleValue::create(resolution); },
|
||||
[](Time const& time) -> RefPtr<StyleValue const> { return TimeStyleValue::create(time); });
|
||||
}
|
||||
|
||||
Optional<NonFiniteValue> NumericCalculationNode::infinite_or_nan_value() const
|
||||
@@ -2722,7 +2722,7 @@ String CalculatedStyleValue::to_string(SerializationMode serialization_mode) con
|
||||
return serialize_a_math_function(m_calculation, m_context, serialization_mode);
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> CalculatedStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
ValueComparingNonnullRefPtr<StyleValue const> CalculatedStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
{
|
||||
Length::ResolutionContext length_resolution_context {
|
||||
.viewport_rect = viewport_rect,
|
||||
@@ -2733,7 +2733,7 @@ ValueComparingNonnullRefPtr<CSSStyleValue const> CalculatedStyleValue::absolutiz
|
||||
return CalculatedStyleValue::create(simplify_a_calculation_tree(m_calculation, m_context, { .length_resolution_context = length_resolution_context }), m_resolved_type, m_context);
|
||||
}
|
||||
|
||||
bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
||||
bool CalculatedStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include <AK/Function.h>
|
||||
#include <LibWeb/CSS/Angle.h>
|
||||
#include <LibWeb/CSS/CSSNumericType.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/Flex.h>
|
||||
#include <LibWeb/CSS/Frequency.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/Resolution.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
@@ -32,7 +32,7 @@ struct CalculationContext {
|
||||
bool resolve_numbers_as_integers = false;
|
||||
};
|
||||
|
||||
class CalculatedStyleValue : public CSSStyleValue {
|
||||
class CalculatedStyleValue : public StyleValue {
|
||||
public:
|
||||
class CalculationResult {
|
||||
public:
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
}
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
Optional<CalculationResult> resolve_value(CalculationResolutionContext const&) const;
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
|
||||
private:
|
||||
explicit CalculatedStyleValue(NonnullRefPtr<CalculationNode const> calculation, CSSNumericType resolved_type, CalculationContext context)
|
||||
: CSSStyleValue(Type::Calculated)
|
||||
: StyleValue(Type::Calculated)
|
||||
, m_resolved_type(move(resolved_type))
|
||||
, m_calculation(move(calculation))
|
||||
, m_context(move(context))
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(CalculationResolutionContext const&) const override;
|
||||
virtual NonnullRefPtr<CalculationNode const> with_simplified_children(CalculationContext const&, CalculationResolutionContext const&) const override { return *this; }
|
||||
|
||||
RefPtr<CSSStyleValue const> to_style_value(CalculationContext const&) const;
|
||||
RefPtr<StyleValue const> to_style_value(CalculationContext const&) const;
|
||||
|
||||
virtual Vector<NonnullRefPtr<CalculationNode const>> children() const override { return {}; }
|
||||
NumericValue const& value() const { return m_value; }
|
||||
|
||||
@@ -59,7 +59,7 @@ StringView string_view_from_color_type(CSSColorValue::ColorType color_type)
|
||||
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> ColorFunctionStyleValue::create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingRefPtr<CSSStyleValue const> alpha)
|
||||
ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> ColorFunctionStyleValue::create(StringView color_space, ValueComparingNonnullRefPtr<StyleValue const> c1, ValueComparingNonnullRefPtr<StyleValue const> c2, ValueComparingNonnullRefPtr<StyleValue const> c3, ValueComparingRefPtr<StyleValue const> alpha)
|
||||
{
|
||||
VERIFY(any_of(s_supported_color_space, [=](auto supported) { return color_space == supported; }));
|
||||
|
||||
@@ -71,7 +71,7 @@ ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> ColorFunctionStyleVal
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool ColorFunctionStyleValue::equals(CSSStyleValue const& other) const
|
||||
bool ColorFunctionStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
@@ -103,7 +103,7 @@ Optional<ColorFunctionStyleValue::Resolved> ColorFunctionStyleValue::resolve_pro
|
||||
// https://www.w3.org/TR/css-color-4/#serializing-color-function-values
|
||||
String ColorFunctionStyleValue::to_string(SerializationMode mode) const
|
||||
{
|
||||
auto convert_percentage = [&](ValueComparingNonnullRefPtr<CSSStyleValue const> const& value) -> RemoveReference<decltype(value)> {
|
||||
auto convert_percentage = [&](ValueComparingNonnullRefPtr<StyleValue const> const& value) -> RemoveReference<decltype(value)> {
|
||||
if (value->is_percentage())
|
||||
return NumberStyleValue::create(value->as_percentage().value() / 100);
|
||||
if (mode == SerializationMode::ResolvedValue && value->is_calculated()) {
|
||||
|
||||
@@ -15,9 +15,9 @@ class ColorFunctionStyleValue final : public CSSColorValue {
|
||||
public:
|
||||
virtual ~ColorFunctionStyleValue() override = default;
|
||||
|
||||
static ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingRefPtr<CSSStyleValue const> alpha = {});
|
||||
static ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> create(StringView color_space, ValueComparingNonnullRefPtr<StyleValue const> c1, ValueComparingNonnullRefPtr<StyleValue const> c2, ValueComparingNonnullRefPtr<StyleValue const> c3, ValueComparingRefPtr<StyleValue const> alpha = {});
|
||||
|
||||
virtual bool equals(CSSStyleValue const&) const override;
|
||||
virtual bool equals(StyleValue const&) const override;
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
@@ -26,15 +26,15 @@ public:
|
||||
static constexpr Array s_supported_color_space = { "a98-rgb"sv, "display-p3"sv, "srgb"sv, "srgb-linear"sv, "prophoto-rgb"sv, "rec2020"sv, "xyz"sv, "xyz-d50"sv, "xyz-d65"sv };
|
||||
|
||||
private:
|
||||
ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
|
||||
ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> c1, ValueComparingNonnullRefPtr<StyleValue const> c2, ValueComparingNonnullRefPtr<StyleValue const> c3, ValueComparingNonnullRefPtr<StyleValue const> alpha)
|
||||
: CSSColorValue(color_type, ColorSyntax::Modern)
|
||||
, m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
Array<ValueComparingNonnullRefPtr<CSSStyleValue const>, 3> channels;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
|
||||
Array<ValueComparingNonnullRefPtr<StyleValue const>, 3> channels;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> alpha;
|
||||
bool operator==(Properties const&) const = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ ColorMixStyleValue::ColorMixStyleValue(ColorInterpolationMethod color_interpolat
|
||||
{
|
||||
}
|
||||
|
||||
bool ColorMixStyleValue::equals(CSSStyleValue const& other) const
|
||||
bool ColorMixStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -22,14 +22,14 @@ public:
|
||||
};
|
||||
|
||||
struct ColorMixComponent {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> color;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> color;
|
||||
Optional<PercentageOrCalculated> percentage;
|
||||
bool operator==(ColorMixComponent const&) const = default;
|
||||
};
|
||||
|
||||
static ValueComparingNonnullRefPtr<ColorMixStyleValue const> create(ColorInterpolationMethod, ColorMixComponent first_component, ColorMixComponent second_component);
|
||||
|
||||
virtual bool equals(CSSStyleValue const&) const override;
|
||||
virtual bool equals(StyleValue const&) const override;
|
||||
virtual Optional<Color> to_color(ColorResolutionContext) const override;
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ void ConicGradientStyleValue::paint(DisplayListRecordingContext& context, Device
|
||||
context.display_list_recorder().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position);
|
||||
}
|
||||
|
||||
bool ConicGradientStyleValue::equals(CSSStyleValue const& other) const
|
||||
bool ConicGradientStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
void paint(DisplayListRecordingContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
||||
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
Vector<AngularColorStopListElement> const& color_stop_list() const
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct CounterDefinition {
|
||||
FlyString name;
|
||||
bool is_reversed;
|
||||
ValueComparingRefPtr<CSSStyleValue const> value;
|
||||
ValueComparingRefPtr<StyleValue const> value;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style, FlyString join_string)
|
||||
CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style, FlyString join_string)
|
||||
: StyleValueWithDefaultOperators(Type::Counter)
|
||||
, m_properties {
|
||||
.function = function,
|
||||
@@ -31,7 +31,7 @@ CounterStyleValue::CounterStyleValue(CounterFunction function, FlyString counter
|
||||
CounterStyleValue::~CounterStyleValue() = default;
|
||||
|
||||
// https://drafts.csswg.org/css-counter-styles-3/#generate-a-counter
|
||||
static String generate_a_counter_representation(CSSStyleValue const& counter_style, i32 value)
|
||||
static String generate_a_counter_representation(StyleValue const& counter_style, i32 value)
|
||||
{
|
||||
// When asked to generate a counter representation using a particular counter style for a particular
|
||||
// counter value, follow these steps:
|
||||
@@ -149,7 +149,7 @@ String CounterStyleValue::to_string(SerializationMode mode) const
|
||||
|
||||
// 4. Let list be a list of CSS component values belonging to <counter>,
|
||||
// omitting the last CSS component value if it is "decimal".
|
||||
Vector<RefPtr<CSSStyleValue const>> list;
|
||||
Vector<RefPtr<StyleValue const>> list;
|
||||
list.append(CustomIdentStyleValue::create(m_properties.counter_name));
|
||||
if (m_properties.function == CounterFunction::Counters)
|
||||
list.append(StringStyleValue::create(m_properties.join_string.to_string()));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
@@ -19,11 +19,11 @@ public:
|
||||
Counters,
|
||||
};
|
||||
|
||||
static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
|
||||
static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {}));
|
||||
}
|
||||
static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
|
||||
static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
|
||||
{
|
||||
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;
|
||||
|
||||
private:
|
||||
explicit CounterStyleValue(CounterFunction, FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style, FlyString join_string);
|
||||
explicit CounterStyleValue(CounterFunction, FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style, FlyString join_string);
|
||||
|
||||
struct Properties {
|
||||
CounterFunction function;
|
||||
FlyString counter_name;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style;
|
||||
ValueComparingNonnullRefPtr<StyleValue const> counter_style;
|
||||
FlyString join_string;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
|
||||
@@ -28,7 +28,7 @@ String CursorStyleValue::to_string(SerializationMode mode) const
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> CursorStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
ValueComparingNonnullRefPtr<StyleValue const> CursorStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
|
||||
{
|
||||
return CursorStyleValue::create(
|
||||
m_properties.image->absolutized(viewport_rect, font_metrics, root_font_metrics)->as_abstract_image(),
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <AK/Optional.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Cursor.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
|
||||
bool properties_equal(CursorStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Display.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class FitContentStyleValue final : public CSSStyleValue {
|
||||
class FitContentStyleValue final : public StyleValue {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<FitContentStyleValue const> create()
|
||||
{
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
return MUST(String::formatted("fit-content({})", m_length_percentage.to_string(mode)));
|
||||
}
|
||||
|
||||
bool equals(CSSStyleValue const& other) const override
|
||||
bool equals(StyleValue const& other) const override
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
FitContentStyleValue(LengthPercentage length_percentage)
|
||||
: CSSStyleValue(Type::FitContent)
|
||||
: StyleValue(Type::FitContent)
|
||||
, m_length_percentage(move(length_percentage))
|
||||
{
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user