Commit graph

233 commits

Author SHA1 Message Date
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Andreas Kling
4c75d4af28 LibWeb: Stop using NonnullRefPtrVector for StyleValueVector 2023-03-06 23:46:35 +01:00
Andreas Kling
f11899f885 LibWeb+LibIDL: Fix (or paper over) various const-correctness issues
There's definitely stuff to iterate on here, but this takes care of
making the libraries compile with stricter RP and NNRP.
2023-02-21 00:54:04 +01:00
MacDue
3676f5085e LibWeb: Replace RefPtr with ValueComparingRefPtr in StyleValue
Like the name suggests this pointer type compares its pointees by value
rather than just by the pointer. This is needed for the defaulted
struct Properties equality operator.

This commit also contains a few changes to StyleValue such as replacing
the operator==()s with a .equals() again. This is done to avoid the new
reversed operator==()s ambiguity in C++20.
2023-02-20 10:50:20 +01:00
MacDue
e2691fcdf2 LibWeb: Always move (Nonnull)RefPtr parameters into StyleValues
This is done for consistency rather than any performance concerns.
2023-02-17 16:22:56 +00:00
MacDue
ac3af6624b LibWeb: Use default equality operators for StyleValues
This removes a load of manually implemented equality operators. This
is done with a little pattern where all properties of a StyleValue are
placed inside a Properties member struct, with a defaulted equality
operator. This is then used to do the actual StyleValue compare.

There is also a CTRP class to avoid manually implementing the virtual
operator==()s for all StyleValues.
2023-02-17 16:22:56 +00:00
MacDue
9337892ce0 LibWeb: Use default equality operators for StyleValue helper structs
Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2023-02-17 16:22:56 +00:00
kleines Filmröllchen
d00a6ca11f AK+LibWeb: Implement Variant equality operator
And make use of it for CSS StyleValues.
2023-02-17 16:22:56 +00:00
Sam Atkins
85f3de6331 LibWeb: Port CSS/Serialize.{h,cpp} to new Strings, and propagate errors 2023-02-15 12:48:26 -05:00
Sam Atkins
a168cda4a7 LibWeb: Port CSS::Parser::ComponentValue to new Strings 2023-02-15 12:48:26 -05:00
MacDue
b0846ec78a LibWeb: Propagate more StringBuilder errors in from StyleValues 2023-01-24 21:12:44 -05:00
MacDue
95aacd4f78 LibWeb: Remove some unchecked .value() calls in StyleValue
Here .to_string() was being called, which gives an ErrorOr<String>,
then .value() was called on that without any checks. Cases like this
should at least be .release_value_but_fixme_should_propagate_errors()
which makes it clear the error is ignored, but here it's easy to
propagate.
2023-01-24 21:12:44 -05:00
martinfalisse
9bc001f410 LibWeb: Parse grid-area CSS property 2023-01-21 14:35:00 +01:00
martinfalisse
a6548c4d80 LibWeb: Parse grid-template-areas CSS property 2023-01-21 14:35:00 +01:00
MacDue
fc7099b032 LibWeb: Use failable StringBuilder methods in StyleValue
This is quite verbose... but the errors must flow!
2023-01-14 12:37:00 +01:00
MacDue
0c688fa117 LibWeb: Remove some unnecessary .release_value()s in StyleValue
And instead propagate these errors.
Also while here add my copyright (I've touched these files a lot)
2023-01-14 12:37:00 +01:00
MacDue
f428d17a17 LibWeb: Fix more ignored .to_string() errors in StyleValue 2023-01-13 21:09:26 +00:00
MacDue
0e3e9d9883 LibWeb: Fix ignored .to_string() errors in StyleValue 2023-01-12 23:29:57 +00:00
martinfalisse
ce0f41b9fb LibWeb+WebContent: Use new String class in CSS::StyleValue
Converts uses of DeprecatedString to String in StyleValue, and patches
surrounding files that depend on these functions.
2023-01-09 11:09:31 +01:00
Sam Atkins
4084c66ad2 LibWeb: Use CSS Pixels for viewport rects 2023-01-05 17:42:31 +01:00
Sam Atkins
8cc0bdf777 LibWeb: Resolve Lengths to CSSPixels 2023-01-05 17:42:31 +01:00
Sam Atkins
13b1952929 LibWeb: Convert AbstractImageStyleValue to new pixel units 2023-01-05 17:42:31 +01:00
MacDue
a9ea0ee9af LibWeb: Fix passing size/position to paint_radial_gradient()
This was wrong twice making it right... But let's fix that.

The center was being passed as a DevicePixelPoint, but was in fact in
CSS pixels, the size was passed as a Gfx::FloatSize but was in
CSS pixels again. Then we were scaling from device pixels to CSS pixels
when painting which does not need to be done if everything is passed
which the correct scale factors already applied.
2022-12-20 11:03:18 +01:00
Sam Atkins
9d1f30b533 LibWeb: Convert gradient painting to new pixel units
Co-authored-by: MacDue <macdue@dueutil.tech>
2022-12-14 16:47:57 +00:00
MacDue
1574f2c3f6 Meta+Userland: Pass Gfx::FloatSize by value
Just two floats like Gfx::FloatPoint.
2022-12-07 11:48:27 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
MacDue
28028be2fc LibWeb: Support repeating-radial-gradient()s 2022-12-03 09:06:51 -05:00
Marco Cutecchia
07fb0882bf LibWeb: Add null checks before derefencing Bitmaps in ImageStyleValue 2022-12-02 11:26:29 +01:00
MacDue
65acfe6c60 LibWeb: Handle degenerate radial gradients 2022-11-30 14:24:04 +00:00
MacDue
476acae04f LibWeb: Paint radial-gradient()s
This almost looks too easy now :^), but it's just another way to sample
the gradient line.
2022-11-30 14:24:04 +00:00
MacDue
d1b06af307 LibWeb: Add missing equals() function for ConicGradientStyleValue
Also, tidy up the one for LinearGradientStyleValue.
2022-11-30 14:24:04 +00:00
MacDue
040dac558e LibWeb: Implement RadialGradientStyleValue
Adds a style value for `radial-gradient()`s and implements some helpers
for resolving their properties.
2022-11-30 14:24:04 +00:00
Moustafa Raafat
6ff9a88c3b LibWeb: Support animated backgrounds 2022-11-13 16:53:22 -07:00
MacDue
2c2b9fb1d7 LibWeb: Parse repeating-conic-gradient()s 2022-11-07 13:13:22 +00:00
MacDue
fdcc73d4b1 LibWeb: Paint conic-gradient()s
This is a first pass at painting conic-gradient()s, I've yet to try to
optimize this much, but I feel like you could do better than atan2
in a loop.
2022-11-01 23:07:05 +00:00
MacDue
e568c93404 LibWeb: Add PositionValue class to represent CSS <position>s
This class represents a <position> and handles resolving it to a
Gfx::FloatPoint relative to some rectangle.

It can handle all forms of <position>:

- Two presets:
  left center
- A preset + a length percentage:
  10% bottom
- Or relative to some edges:
  right 20% bottom 30px
2022-11-01 23:07:05 +00:00
MacDue
067759c0e9 LibWeb: Add ConicGradientStyleValue
This commit adds a simple style value (which is an abstract image)
to represent conic-gradient()s.

This commit also starts to factor out some reusable parts of the
linear-gradient() style value for other gradient types.
2022-11-01 23:07:05 +00:00
martinfalisse
b2b677e984 LibWeb: Refactor GridTrackSize classes
Refactor various classes in the GridTrackSize file for the incoming
named_tracks feature.

Previously the ExplicitTrackSizing had mixed responsiblities with the
newly-named GridRepeat class. This made it so it was not possible to
have multiple repeats within a single 'GridTrackSizeList' definition.

The MetaGridTrackSize class had both the responsibilities of being a
container for minmax values as well as for simple GridSizes. By uniting
the different possible values (repeat, minmax, default) into the
ExplicitGridTrack class are able to be more expressive as to the
different grid size modalities.

The GridTrackSizeList will be useful as compared to a
Vector<ExplicitGridTrack> since this way can keep track of the declared
line names. These same line names are able to be declared within the
values of a repeat function, hence the presence of a GridTrackSizeList
inside the GridRepeat class.
2022-11-01 11:19:41 +01:00
martinfalisse
f7af190de0 LibWeb: Add parent classes for managing GridTrackSizes
Add classes ExplicitTrackSizing and MetaGridTrackSize which will allow
for managing properties like auto-fill and minmax.

In the following CSS example there are 3 classes that will be used:
grid-template-column: repeat(auto-fill, minmax(50px, 1fr) 75px);

ExplicitTrackSizing - will contain the entire value. e.g.
repeat(auto-fill, minmax(50px, 1fr) 75px)

With a flag if it's a repeat, as well as references to the
MetaGridTrackSizes which is the next step down.

MetaGridTrackSize:
Contain the individual grid track sizes. Here there are two:
minmax(50px, 1fr) as well as 75px.

This way can keep track if it's a minmax function or not, and the
references to both GridTrackSizes in the case it is, or in just the one
if it is not.

GridTrackSize:
Is the most basic element, in this case there are three in total; two of
which are held by the first MetaGridTrackSize, and the third is held by
the second MetaGridTrackSize.
Examples: 50px, 1fr and 75px.
2022-10-15 16:04:01 +02:00
martinfalisse
86ce1b64f0 LibWeb: Fix bug in checking if GridTrackPlacement is auto-positioned
This fixes something I thought I had already fixed everywhere, where
previously there wasn't the possibility to have an Auto
GridTrackPlacement and so the Auto "implementation" was simply checking
if the position of the track was 0.
2022-10-06 21:16:01 +02:00
Andreas Kling
7abb512a86 LibWeb: Make PercentageOr<T>::contains_percentage() handle more cases 2022-09-29 20:09:44 +02:00
MacDue
980c92e9b5 LibWeb: Add FilterValueListStyleValue
This style value holds a list of CSS filter function calls e.g.

blur(10px) invert() grayscale()

It will be used to implement backdrop-filter, but the same style value
can be used for the image filter property.

(The name is a little awkward but it's referenced to as
filter-value-list in the spec too).
2022-09-16 10:50:48 +01:00
MacDue
b219931dfc LibWeb: Pass values by reference in style value operator== functions 2022-09-16 10:50:48 +01:00
Andreas Kling
55ad9591df LibWeb: Add a way to ask if a PercentageOr<T> value contains percentages
Values that contain percentages require special treatment in various
parts of layout. Previously we had no way of peeking into calc() values
to see if their expression contains one or more percentages. That's the
bulk of what we're adding here.
2022-09-14 14:43:17 +02:00
Andreas Kling
9018b58875 LibWeb: Only schedule ImageStyleValue resource load once
load_any_resources() may get called multiple times during layout, but
once we've started a resource load, we don't need to do it again.
2022-09-07 17:47:33 +02:00
martinfalisse
c40dd9ee78 LibWeb: Add GridTrackPlacementShorthandStyleValue
Add GridTrackPlacementShorthandStyleValue for the use of grid-column and
grid-row.
2022-08-25 13:47:48 +02:00
martinfalisse
08b832eb69 LibWeb: Add GridTrackPlacementStyleValue
Add GridTrackPlacementStyleValue for the use of CSS properties
grid-column-start, grid-column-end, grid-row-start, grid-row-end.
2022-08-25 13:47:48 +02:00
martinfalisse
0148260b5f LibWeb: Add GridTrackSizeStyleValue
Add GridTrackSizeStyleValue for the use of CSS properties
grid-template-columns, grid-template-rows.
2022-08-25 13:47:48 +02:00
MacDue
fa5c2183df LibWeb: Don't regenerate linear gradient data unless size changes
This is an easy check to add and seems like it makes things a
tiny bit smoother.
2022-08-23 01:02:49 +02:00