1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 13:37:10 +09:00
Commit graph

29 commits

Author SHA1 Message Date
Tim Ledbetter
17f14a277b LibWeb: Don't crash when interpolating single-value repeatable lists
Previously, when interpolating a repeatable list from a list with
multiple values to a single value, we would crash.
2025-06-02 11:33:01 +01:00
Tim Ledbetter
b16f34767e LibWeb: Ensure discrete interpolated properties are non-transitionable
If a property is uses discrete interpolation and TransitionBehavior is
not set to `AllowDiscrete` that property should be non-transitionable.

This is now true for properties whose animation type is not discrete,
but the animation type falls back to discrete.
2025-05-27 13:33:29 +02:00
Tim Ledbetter
09f4d90594 LibWeb: Clamp interpolated values to the range of their numeric type
This fixes a UBSAN warning that we previously hit when interpolating
color values.
2025-05-19 11:31:47 +01:00
Sam Atkins
eec4365542 LibWeb/CSS: Extract SerializationMode into its own header
Prep for using this to serialize dimension types, and perhaps other
things in the future.
2025-05-17 07:53:24 +01:00
Sam Atkins
4edafb35cd LibWeb/CSS: Use PendingSubstitutionValue for unresolved shorthands
Previously, we would just assign the UnresolvedStyleValue to each
longhand, which was completely wrong but happened to work if it was a
ShorthandStyleValue (because that's basically a list of "set property X
to Y", and doesn't care which property it's the value of).

For example, the included `var-in-margin-shorthand.html` test would:
1. Set `margin-top` to `var(--a) 10px`
2. Resolve it to `margin-top: 5px 10px`
3. Reject that as invalid

What now happens is:
1. Set `margin-top` to a PendingSubstitutionValue
2. Resolve `margin` to `5px 10px`
3. Expand that out into its longhands
4. `margin-top` is `5px` 🎉

In order to support this, `for_each_property_expanding_shorthands()` now
runs the callback for the shorthand too if it's an unresolved or
pending-substitution value. This is so that we can store those in the
CascadedProperties until they can be resolved - otherwise, by the time
we want to resolve them, we don't have them any more.

`cascade_declarations()` has an unfortunate hack: it tracks, for each
declaration, which properties have already been given values, so that
it can avoid overwriting an actual value with a pending one. This is
necessary because of the unfortunate way that CSSStyleProperties holds
expanded longhands, and not just the original declarations. The spec
disagrees with itself about this, but we do need to do that expansion
for `element.style` to work correctly. This HashTable is unfortunate
but it does solve the problem until a better solution can be found.
2025-05-14 11:46:47 +01:00
Tim Ledbetter
03e34db9f8 LibWeb: Interpolate the content-visibility property correctly 2025-05-13 11:24:05 +01:00
Tim Ledbetter
882ad4726e LibWeb: Interpolate the visibility property correctly 2025-05-13 11:24:05 +01:00
Tim Ledbetter
23009779e1 LibWeb: Interpolate font-style values correctly
These are interpolated by computed value, except a value of `normal` is
treated as `oblique 0deg`.
2025-05-03 12:05:22 +02:00
Tim Ledbetter
542c3cbe51 LibWeb: Implement the transition-behavior CSS property
This specifies whether transitions should be started for transitions
whose animation behavior is discrete.
2025-05-02 11:07:19 +01:00
Tim Ledbetter
c72d5943e6 LibWeb: Support interpolating translate values 2025-04-30 19:36:56 +02:00
Tim Ledbetter
f854f644a7 LibWeb: Don't crash when interpolating non <number> scale values 2025-04-28 11:46:34 +02:00
Andreas Kling
cf704cfbfc LibWeb: Implement interpolation for CSS scale values
And let's handle the 3rd (Z) scale parameter as well, while we're here.

At least 242 new passes on WPT.
2025-04-25 14:08:12 +02:00
Tim Ledbetter
04d7228c51 LibWeb: Implement interpolation of repeatable lists 2025-04-23 09:13:45 +01:00
Tim Ledbetter
0beb22f19e LibWeb: Implement interpolation of edge values 2025-04-23 09:13:45 +01:00
Andrew Kaster
d1f6f5649e LibWeb: Make storage of CSS::CalculationNodes const-correct
Now we consistently use `RefPtr<CalculationNode const>` for all
CalculationNodes.
2025-04-16 10:41:44 -06:00
Andrew Kaster
6d11414957 LibWeb: Make storage of CSS::StyleValues const-correct
Now we consistently use `RefPtr<StyleValue const>` for all StyleValues.
2025-04-16 10:41:44 -06:00
Tim Ledbetter
f07a3fe6da LibWeb: Use discrete interpolation for degenerate ratios
Degenerate ratios cannot be interpolated.
2025-04-11 11:38:05 +01:00
Tim Ledbetter
b3980d40f7 LibWeb: Round to the nearest integer when interpolating integer values 2025-04-11 11:31:54 +01:00
Gingeh
31853c13d3 LibWeb: Implement css gradient-interpolation-method 2025-03-06 11:33:12 +00:00
InvalidUsernameException
f7276bfab3 LibWeb: Reduced number of recompiled files for CSS property headers
This reduces the number of `.cpp` files that need to be recompiled when
one of the below header files changes as follows:

CSS/ComputedProperties.h: 1113 -> 49
CSS/ComputedValues.h: 1120 -> 209
2025-02-23 10:14:39 -05:00
Sam Atkins
c3d61020e7 LibWeb/CSS: Make CalculationNodes ref-counted
Calc simplification (which I'm working towards) involves repeatedly
deriving a new calculation tree from an existing one, and in many
cases, either the whole result or a portion of it will be identical to
that of the original. Using RefPtr lets us avoid making unnecessary
copies. As a bonus it will also make it easier to return either `this`
or a new node.

In future we could also cache commonly-used nodes, similar to how we do
so for 1px and 0px LengthStyleValues and various keywords.
2025-01-30 19:31:54 +01:00
Sam Atkins
ac15e626dd LibWeb/CSS: Merge ScaleStyleValue into TransformationStyleValue
The only ways this varies from the `scale()` function is with parsing
and serialization. Parsing stays separate, and serialization is done by
telling `TransformationStyleValue` which property it is, and overriding
its normal `to_string()` code for properties other than `transform`.
2025-01-17 10:12:39 +01:00
Sam Atkins
18e0ff6537 LibWeb/CSS: Properly classify calculations inside transform functions
Assuming all calculations produce `<length-percentage>` is a very bad
assumption, and was causing crashes on https://ai.cloudflare.com/
2025-01-15 14:29:08 +00:00
Sam Atkins
4efdb76857 LibWeb/CSS: Give calc() a CalculationContext for resolving percentages
This is passed in at construction, meaning we will be able to refer to
it later, when we're no longer inside the Parser.
2025-01-13 10:59:16 +00:00
Sam Atkins
69a0f28d04 Revert "LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue"
This reverts commit 76daba3069.

We're going to need separate types for the JS-exposed style values, so
it doesn't make sense for us to match their names with our internal
types.
2024-12-21 18:14:28 +01:00
Sam Atkins
ee9db99961 LibWeb: Remove unused Realm arg from StyleComputer::get_inherit_value()
We no longer need this now that property_initial_value() doesn't take a
Realm.
2024-12-05 19:59:57 +01:00
Sam Atkins
2c3c821305 LibWeb: Remove Realm parameter from property_initial_value()
We don't need the Realm to parse a style value.

Fixes #2720
2024-12-05 19:59:57 +01:00
Glenn Skrzypczak
0d15cc4672 LibWeb/Animation: Fall back to discrete animation in more cases
Use discrete animation when the number of components or the types
of corresponding components do not match. This commit does not cover
all cases, but adds FIXME comments in the appropriate places.
2024-11-25 18:10:24 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibWeb/CSS/Interpolation.cpp (Browse further)