mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-21 07:29:53 +00:00
This excludes `step-end` and `step-start` which are expected to be converted to the equivalent function at parse time. We are expected to serialize these as the explicit keywords - previously we would parse as `EasingStyleValue` and serialize equivalent functions as the keywords. This caused issues as we would incorrectly serialize even explicit functions as the keyword. This also allows us to move the magic easing functions to `EasingFunction` rather than `EasingStyleValue` which is a bit tidier
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/Enums.h>
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
struct LinearEasingFunction {
|
|
struct ControlPoint {
|
|
Optional<double> input;
|
|
double output;
|
|
};
|
|
|
|
Vector<ControlPoint> control_points;
|
|
String stringified;
|
|
|
|
double evaluate_at(double input_progress, bool before_flag) const;
|
|
};
|
|
|
|
struct CubicBezierEasingFunction {
|
|
double x1;
|
|
double y1;
|
|
double x2;
|
|
double y2;
|
|
String stringified;
|
|
|
|
struct CachedSample {
|
|
double x;
|
|
double y;
|
|
double t;
|
|
};
|
|
|
|
mutable Vector<CachedSample> m_cached_x_samples {};
|
|
|
|
double evaluate_at(double input_progress, bool before_flag) const;
|
|
};
|
|
|
|
struct StepsEasingFunction {
|
|
long interval_count;
|
|
StepPosition position;
|
|
String stringified;
|
|
|
|
double evaluate_at(double input_progress, bool before_flag) const;
|
|
};
|
|
|
|
struct EasingFunction : public Variant<LinearEasingFunction, CubicBezierEasingFunction, StepsEasingFunction> {
|
|
using Variant::Variant;
|
|
|
|
static EasingFunction linear();
|
|
static EasingFunction ease_in();
|
|
static EasingFunction ease_out();
|
|
static EasingFunction ease_in_out();
|
|
static EasingFunction ease();
|
|
|
|
static EasingFunction from_style_value(StyleValue const&);
|
|
|
|
double evaluate_at(double input_progress, bool before_flag) const;
|
|
String to_string() const;
|
|
};
|
|
|
|
}
|