mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00: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:
parent
0d8ad0a9fe
commit
c57975c9fd
Notes:
github-actions[bot]
2025-08-08 14:20:54 +00:00
Author: https://github.com/AtkinsSJ
Commit: c57975c9fd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5775
Reviewed-by: https://github.com/tcl3 ✅
167 changed files with 989 additions and 990 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue