Commit Graph

1571 Commits

Author SHA1 Message Date
Andreas Kling
1b55ff6f4c LibWeb: Expand CSS var() inside calc() paren blocks
Before this change, this var() would get expanded:

    calc(10px * var(--one))

But this one would not:

    calc(10px * (var(--one))
2023-06-19 17:54:07 +02:00
Andi Gallo
db121c7af1 LibWeb: Handle leading whitespace in grid-template-* block components
We're already handling whitespace between components, do the same for
leading whitespace. Fixes crash on https://distill.pub/2021/gnn-intro.
2023-06-18 13:41:15 +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
4436ab0cb1 LibWeb: Handle calculated vertical-align 2023-06-17 06:33:52 +02:00
kamp
c476ff10a5 LibWeb/CSS: Update Default.css from the HTML specification 2023-06-17 06:31:28 +02:00
Andi Gallo
52956d355c LibWeb: Make border-collapse actually inherited
Move it to the inherited section of ComputedValues.
2023-06-16 17:21:15 +02: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
Sam Atkins
8ef25989b6 LibWeb: Parse identifiers last in parse_paint_value()
Previously, using an identifier color like `currentColor` would fail to
parse, since we look at ident tokens (and reject unrecognised ones)
before trying to parse colors.
2023-06-16 15:39:32 +02:00
Andi Gallo
396f1a977c LibWeb: Add CSS support for border-spacing property 2023-06-16 13:57:31 +02:00
Sam Atkins
cbf84152df LibWeb: Resolve fill and stroke related CSS properties 2023-06-16 07:03:57 +02:00
Sam Atkins
af51095fe2 LibWeb: Stop making ComputedValues::stroke_width() optional
This defaults to 1px and should always have some kind of value.
2023-06-16 07:03:57 +02:00
Sam Atkins
5cdcd135ab LibWeb: Add parsing for CSS <paint> values
This gets rid of a couple of FIXMEs in Properties.json :^)
2023-06-16 07:03:57 +02:00
kamp
4ac7c41483 LibWeb: Add -libweb-left and -libweb-right text-align values
These ensure that block level elements are also left and right aligned
respectively on top of the regular text alignment, matching
-libweb-center.
2023-06-16 06:55:21 +02: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
Ben Wiederhake
efbf6b7e5f LibWeb: Make HashMap copy of inline CSS declarations fallible 2023-06-15 08:07:17 +02:00
Andreas Kling
34591ff3d9 LibWeb: Use a separate class for shared image requests
As it turns out, making everyone piggyback on HTML::ImageRequest had
some major flaws, as HTMLImageElement may decide to abort an ongoing
fetch or wipe out image data, even when someone else is using the same
image request.

To avoid this issue, this patch introduces SharedImageRequest, and then
implements ImageRequest on top of that.

Other clients of the ImageRequest API are moved to SharedImageRequest
as well, and ImageRequest is now only used by HTMLImageElement.

This fixes an issue with image data disappearing and leading to asserts
and/or visually absent images.
2023-06-14 14:23:17 +02: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
Hendiadyoin1
eeb15fc10b LibWeb: Stop lying about string types 2023-06-13 01:49:02 +02:00
Andreas Kling
741c7aef21 LibWeb: Support more CSS functions in grid track size lists
Instead of hard-coding a check for "calc", we now call out to
parse_dynamic_value() which allows use of other functions like min(),
max(), clamp(), etc.
2023-06-12 17:51:08 +02:00
Andreas Kling
680fc3f90a LibWeb: Piggyback on HTML::ImageRequest in CSS ImageStyleValue
This is all ad-hoc since no spec currently exists for this behavior.
Basically, ImageStyleValue now uses ImageRequest for fetching and
decoding of images.

This already leads to visible improvements on many websites.
2023-06-11 20:37:12 +02:00
MacDue
377ff0ac26 LibWeb: Implement SVG fill-rule attribute
Previously, we did an evenodd fill for everything which while for most
SVGs works, it is not correct default (it should be nonzero), and broke
some SVGs. This fixes a few of the icons on https://shopify.com/.
2023-06-11 19:34:24 +02:00
Andi Gallo
940d9b98ae LibWeb: Add support for table caption
Adds layout support and the CSS caption-side property.
2023-06-10 07:09:11 +02:00
Sam Atkins
6fd3b39bef LibWeb: Parse aspect-ratio property
Parse it, store the result in the ComputedValues, and also expose it to
ResolvedCSSStyleDeclaration.
2023-06-09 20:37:51 +02:00
Sam Atkins
5e3da93f1a LibWeb: Add RatioStyleValue and parsing 2023-06-09 20:37:51 +02:00
Sam Atkins
b9f9d87bd0 LibWeb: Allow calc() and friends inside <ratio> values
Anywhere that `<number>` appears in the grammar, `calc()` that resolves
to a number is valid, including inside the `<ratio>` grammar.
Thankfully, a calculation that produces a number cannot rely on any
context information for the calculation, so we can resolve them
straight away and just pretend they were a `<number>` the whole
time. :^)
2023-06-09 20:37:51 +02:00
Sam Atkins
57a247530c LibWeb: Introduce and use ComponentValue::is_delim() helper
`foo.is(Token::Type::Delim) && foo.token().delim() == '!'` becomes
`foo.is_delim('!')`, which is a lot less verbose. I really should have
done this ages ago.
2023-06-09 20:37:51 +02:00
Sam Atkins
7a2c8d30b9 LibWeb: Allow auto as animation-duration and make that the default
This is a spec change: 2a7cc4b58f
2023-06-09 17:13:19 +02:00
Sam Atkins
c4c35ce9b9 LibWeb: Alphabetize animation properties
I didn't notice this when they were added, whoops
2023-06-09 17:13:19 +02:00
Ali Mohammad Pur
141143a1c6 LibWeb: Serialize custom properties in CSSStyleDeclaration::serialized()
Prior to this commit, PropertyOwningCSSStyleDeclaration::serialized()
did not include custom properties, which lead to an incomplete
`cssRule.cssText` result.
This commit makes that class also serialize the custom properties and
place them before the regular properties in the rule text.
2023-06-09 11:17:44 +01:00
Andreas Kling
102b8d717f LibWeb: Set flex-basis to 0% when omitted from flex shorthand
This doesn't match the spec, *but* matches what other engines do, and it
turns out this is required for web compat. (It fixes the menu on MDN.)
2023-06-08 10:05:56 +02:00
Aliaksandr Kalenik
3b3ade0b8d LibWeb: Use none as initial value for grid-template-column/rows
This fixes the issue that currently we use "auto" as initial value for
grid-template-column and grid-template-rows although spec says it
should be "none". This makes a lot of difference for these properties
because currently we represent "auto" as a list with one auto-sized
track which means initial value for grid-template-column defines one
"explicit" track while it should define none of them.

This change makes grid-auto-columns/rows be applied to the correct
tracks when initial values is used for grid-template-column/rows.
2023-06-07 14:13:07 +02:00
Andreas Kling
2c16e8371f LibWeb: Add naive support for {margin,padding}-{block,inline}
Like other logical properties, we just alias these to the LTR TB default
properties for now.
2023-06-07 11:20:42 +02:00
Andreas Kling
0c2fcffba3 LibWeb: Make text-shadow inherited in CSS::ComputedValues
CSS text-shadow is an inherited property, so we have to make sure it's
part of the inherited substructure in ComputedValues, otherwise it gets
incorrectly reset in children.
2023-06-07 06:29:59 +02:00
Luke Wilde
42a183720b LibWeb/SVG: Support url() in the stroke attribute
This allows you to draw gradients in strokes, for example.
2023-06-07 06:29:46 +02:00
Andreas Kling
9e807d7c6a LibWeb: Support start and end alignment values in flex layout
These should just behave the same as `flex-start` and `flex-end`.
2023-06-06 21:02:04 +02:00