Sam Atkins
76daba3069
LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue
...
This matches the name in the CSS Typed OM spec. There's quite a lot
still to do to make it match the spec behavior, but this is the first
step.
2024-09-18 20:38:41 +01:00
Aliaksandr Kalenik
41e37f0079
LibWeb: Use correct resolved type for round() CSS function
...
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Function is defined as `round(<rounding-strategy>?, A, B?)`
With this change resolved type is `typeof(resolve(A))`, instead of
`typeof(A)`.
For example `round(up, 20%, 1px)` with 200px percentage basis is now
correctly resolved in 40px instead of 40%.
Progress on https://www.notion.so/ landing page.
2024-09-17 20:02:29 +02:00
Sam Atkins
5bd585d446
LibWeb/CSS: Add dump method to CalculatedStyleValue
...
The individual nodes all have dump methods, but there was no way of
calling them from the outside. So now there is.
2024-08-21 10:51:48 +01:00
Sam Atkins
0e3487b9ab
LibWeb: Rename StyleValue -> CSSStyleValue
...
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue
No behaviour changes.
2024-08-15 13:58:38 +01:00
Andreas Kling
546143e9a6
LibWeb: Fix vector OOB access when comparing some calc() values
...
Before comparing the elements of two vectors, we have to check that
they have the same length. :^)
Fixes a crash seen on https://chat.openai.com/
2024-01-27 17:06:43 +01:00
Aliaksandr Kalenik
225ed58f7e
LibWeb/CSS: Resolve NumericCalculationNode to percentage when requested
...
When the caller of NumericCalculationNode::resolve() does not provide
a percentage_basis, it expects the method to return a raw percentage
value.
Fixes crashing on https://discord.com/login
2024-01-11 08:01:47 +01:00
Andreas Kling
5b7a8891a6
LibWeb: Implement calc() value equality check in a more efficient way
...
Instead of serializing two calc() values to String and then comparing
those strings, we can now compare calc() values by actually traversing
their internal CalculationNode tree.
This makes style recomputation faster on pages with lots of calc()
values since it's now much cheaper to check whether a property with
some calc() value actually changed.
2024-01-09 14:15:27 +01:00
Aliaksandr Kalenik
3f52d6045a
LibWeb/CSS: Resolve percentages in NumericCalculationNode
...
Percentages should be resolved against the provided percentage basis
instead of just returning the underlying value.
Fixes https://github.com/SerenityOS/serenity/issues/22654
2024-01-08 15:57:42 +00:00
Sam Atkins
30dcbc306c
LibWeb: Make resolution calculable
...
No tests unfortunately, because no CSS property we currently support
accepts `<resolution>`.
2023-12-30 20:11:24 +01:00
Aliaksandr Kalenik
28c9015bd8
LibWeb: Resolve percentages in calc() for font-size
...
Fixes crashing on https://react.dev/
2023-10-06 08:23:03 +02:00
Sam Atkins
b0317bb3a1
LibWeb: Implement Flex and FlexStyleValue types
2023-09-28 20:33:20 +01:00
Sam Atkins
53f3ed026a
LibWeb: Mark CalculatedStyleValue::resolve_integer() as const
2023-09-11 17:03:22 +01:00
Aliaksandr Kalenik
0fb571c1c2
LibWeb: Add Length::resolved()
overload for CSSPixels
...
Since we always pass the px value as an argument to resolved(), we can
pass it directly as CSSPixels instead of wrapping it in Length. This
approach allows us to avoid converting to a double, resulting in fewer
precision issues.
2023-08-30 20:09:15 +02:00
MacDue
71baa8c31a
LibWeb: Add CSSPixels::nearest_value_for(FloatingPoint)
...
This is intended to annotate conversions from unknown floating-point
values to CSSPixels, and make it more obvious the fp value will be
rounded to the nearest fixed-point value.
2023-08-26 23:53:45 +02:00
MacDue
360c0eb509
LibWeb: Remove implicit conversion from float and double to CSSPixels
...
In general it is not safe to convert any arbitrary floating-point value
to CSSPixels. CSSPixels has a resolution of 0.015625, which for small
values (e.g. scale factors between 0 and 1), can produce bad results
if converted to CSSPixels then scaled back up. In the worst case values
can underflow to zero and produce incorrect results.
2023-08-26 23:53:45 +02:00
Sam Atkins
c171810030
LibWeb: Make CalculatedStyleValue::dump() infallible
2023-08-22 17:51:48 +01:00
Sam Atkins
7fe97ee6c5
LibWeb: Make StyleValue::to_string() infallible
2023-08-22 17:51:48 +01:00
Sam Atkins
6bee81cfb6
LibWeb: Make serializing basic CSS types infallible
2023-08-22 17:51:48 +01:00
Sam Atkins
c20df751c9
LibWeb: Use correct NumericLimits in CalculatedStyleValue
2023-08-20 14:25:18 +01:00
Sam Atkins
2038cb3c81
LibWeb: Make CSS math function parsing infallible
2023-08-19 17:34:22 +02:00
Lucas CHOLLET
3f35ffb648
Userland: Prefer _string
over _short_string
...
As `_string` can't fail anymore (since 3434412
), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Sam Atkins
dd1156fb17
LibWeb: Update spec comments for math function determined types
...
The spec was corrected here:
de4119a6e3
2023-07-19 11:12:53 +01:00
Sam Atkins
136dc7a1c3
LibWeb: Extract CalculationNode::constant_type_from_string() function
...
This is needed by some upcoming generated code. Renamed "PI" member to
"Pi" while I was at it.
2023-07-15 10:23:33 +02:00
Sam Atkins
e4a2bd7a44
LibWeb: Move RoundingMode to Enums.json
...
In the spec this is a `<rounding-strategy>`, so let's use that name.
This also fixes a bug where we were serializing `to-zero` as
`toward-zero`.
2023-07-15 10:23:33 +02:00
Timothy Flynn
c911781c21
Everywhere: Remove needless trailing semi-colons after functions
...
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Sam Atkins
4d84080fdc
LibWeb: Implement "Determine the type of a calculation" algorithm
...
This is sitting alongside our old implementation for the moment.
2023-07-06 09:28:16 +02:00
stelar7
d6db924d47
LibWeb: Implement CSS rem()
2023-06-17 12:13:28 +01:00
stelar7
dc042662d1
LibWeb: Implement CSS mod()
2023-06-17 12:13:28 +01:00
stelar7
b2230c826b
LibWeb: Implement CSS round()
2023-06-17 12:13:28 +01:00
stelar7
5727e276ea
LibWeb: Implement CSS exp()
2023-06-16 14:58:47 +01:00
stelar7
6dde49404a
LibWeb: Implement CSS log()
2023-06-16 14:58:47 +01:00
stelar7
fa37bb8b76
LibWeb: Implement CSS hypot()
2023-06-16 14:58:47 +01:00
stelar7
0d30fb5a6e
LibWeb: Implement CSS sqrt()
2023-06-16 14:58:47 +01:00
stelar7
9aed8ec7f0
LibWeb: Implement CSS pow()
2023-06-16 14:58:47 +01:00
stelar7
a9a62ad8c9
LibWeb: Implement CSS atan2()
2023-06-15 16:54:14 +01:00
stelar7
1aa84dfddd
LibWeb: Implement CSS atan()
2023-06-15 16:54:14 +01:00
stelar7
784e1cfb72
LibWeb: Implement CSS acos()
2023-06-15 16:54:14 +01:00
stelar7
708b5ef447
LibWeb: Implement CSS asin()
2023-06-15 16:54:14 +01:00
stelar7
64f0349a9e
LibWeb: Implement CSS tan()
2023-06-15 16:54:14 +01:00
stelar7
46a5efe388
LibWeb: Implement CSS cos()
2023-06-15 16:54:14 +01:00
stelar7
c73f476915
LibWeb: Implement CSS sin()
2023-06-15 16:54:14 +01:00
stelar7
ba7af82c5c
LibWeb: Parse css math constants
2023-06-15 15:40:55 +01:00
stelar7
e1e382152c
LibWeb: Implement CSS sign()
2023-06-15 12:26:34 +01:00
stelar7
79fc4c8a82
LibWeb: Implement CSS abs()
2023-06-15 12:26:34 +01:00
Aliaksandr Kalenik
147c3b3d97
LibWeb+WebContent: Forbid access to underlying type of CSSPixels
...
Although DistinctNumeric, which is supposed to abstract the underlying
type, was used to represent CSSPixels, we have a whole bunch of places
in the layout code that assume CSSPixels::value() returns a
floating-point type. This assumption makes it difficult to replace the
underlying type in CSSPixels with a non-floating type.
To make it easier to transition CSSPixels to fixed-point math, one step
we can take is to prevent access to the underlying type using value()
and instead use explicit conversions with the to_float(), to_double(),
and to_int() methods.
2023-06-13 06:08:27 +02:00
Andreas Kling
df8a96ee00
LibWeb: Add a way to resolve calc() values without a layout node
...
Instead of a layout node, you can pass a new Length::ResolutionContext
struct which contains everything needed to resolve calc() lengths.
2023-06-02 20:03:28 +02:00
stelar7
2ef6aa5f3d
LibWeb: Parse clamp()
css math function
2023-06-02 05:22:12 +02:00
stelar7
eaee0ecd88
LibWeb: Parse max()
css math function
2023-06-02 05:22:12 +02:00
stelar7
6a10821bfd
LibWeb: Parse min()
css math function
2023-06-02 05:22:12 +02:00
stelar7
421559d725
LibWeb: Change calc node representation from float to double
2023-05-31 10:56:32 +02:00