Commit graph

25 commits

Author SHA1 Message Date
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
stelar7
344f37986f LibWeb: Allow calculated values in transform 2023-05-31 05:57:53 +02:00
Andreas Kling
655d9d1462 LibWeb: Make CSSPixels and Length use 64-bit (double) floating point
This fixes a plethora of rounding problems on many websites.
In the future, we may want to replace this with fixed-point arithmetic
(bug #18566) for performance (and consistency with other engines),
but in the meantime this makes the web look a bit better. :^)

There's a lot more things that could be converted to doubles, which
would reduce the amount of casting necessary in this patch.
We can do that incrementally, however.
2023-05-24 14:40:35 +02:00
Andreas Kling
e81d4ca1ac LibWeb: Fix off-by-one in CSS calc() "negate" operation
When negating a number, we should subtract it from 0, not 1. :^)
2023-05-17 07:40:17 +02:00
Sam Atkins
d0f80b40b2 LibWeb: Reimplement CalculatedStyleValue as a calculation node tree
VALUES-4 defines the internal representation of `calc()` as a tree of
calculation nodes. ( https://www.w3.org/TR/css-values-4/#calc-internal )

VALUES-3 lacked any definition here, so we had our own ad-hoc
implementation based around the spec grammar. This commit replaces that
with CalculationNodes representing each possible node in the tree.

There are no intended functional changes, though we do now support
nested calc() which previously did not work. For example:
    `width: calc( 42 * calc(3 + 7) );`

I have added an example of this to our test page.

A couple of the layout tests that used `calc()` now return values that
are 0.5px different from before. There's no visual difference, so I
have updated the tests to use the new results.
2023-04-13 09:53:47 +02:00
Sam Atkins
1352f8820b LibWeb: Simplify CalculatedStyleValue types to match CSS-VALUES-4 :^)
Level 4 drops the limitations of what types can be a denominator, which
means `<calc-number-sum>`, `<calc-number-product>` and
`<calc-number-value>` all go away.
2023-04-13 09:53:47 +02:00
Sam Atkins
bab968867d LibWeb: Move StyleValue::absolutized() back where it belongs
I accidentally moved this when moving the CalculatedStyleValue methods,
and didn't notice because it was hidden in the middle. Oops!
2023-04-13 09:53:47 +02:00
Sam Atkins
1280d70d74 LibWeb: Split CalculatedStyleValue out of StyleValue.{h,cpp} 2023-03-30 21:29:50 +02:00