Commit Graph

59947 Commits

Author SHA1 Message Date
Matthew Olsson
7dcf060927 LibWeb: Limit ratio parts to 5 decimal places when printing
Printing 15 or so decimal places for each value is a bit excessive
2024-03-03 19:50:25 +01:00
Matthew Olsson
4d9f2bf5f1 LibWeb: Add interpolation for ratio values 2024-03-03 19:50:25 +01:00
Matthew Olsson
f02cd4d0b0 LibWeb: Add a spec comment for color interpolation 2024-03-03 19:50:25 +01:00
Matthew Olsson
29b70485fc LibGfx: Add formatters for Gfx::Color's different representations
This makes debugging these values a bit easier
2024-03-03 19:50:25 +01:00
Matthew Olsson
1f88ca2a03 LibWeb: Remove transform interpolation optimization
The property values here will always be StyleValueLists and not
TransformationStyleValues. The handling of interpolation in this case
gets quite a bit more complex, so let's just remove the dead code for
now and attempt this optimization again in the future if it's needed.
2024-03-03 19:50:25 +01:00
Aliaksandr Kalenik
ee1d8a534d LibWeb: Remove wrappers for gradient painting command recording
These were adding unnecessary indirection, whereas recording painter
could be called directly.
2024-03-03 18:19:20 +01:00
Nico Weber
c6b484a728 LibPDF: Make image creation in Renderer::load_image() fallible 2024-03-03 11:18:37 -05:00
Nico Weber
9bff8abcc7 LibPDF: Add support for array image masks
An array image mask contains a min/max range for each channel,
and if each channel of a given pixel is in that channel's range,
that pixel is masked out (i.e. transparent). (It's similar to
having a single color or palette index be transparent, but it
supports a range of transparent colors if desired.)

What makes this a bit awkward is that the range is relative to the
origin bits per pixel and the inputs to the image's color space.

So an indexed (palettized) image with 4bpp has a 2-element mask
array where both entries are between 0 and 15.

We currently apply masks after converting images to a Gfx::Bitmap,
that is after converting to 8bpp sRGB. And we do this by mapping
everything to 8bpp very early on in load_image().

This leaves us with a bunch of options that are all a bit awkward:

1. Make load_image() store the up- (or for 16bpp inputs, down-)
   sampled-to-8bpp pixel data. And also return if we expanded the
   pixel range while resampling (for color values) or not (for
   palettized images). Then, when applying the image filter,
   resample the array bounds in exactly the same way. This requires
   passing around more stuff.

2. Like 1, but pass in the mask array to load_image() and apply
   the mask right there and then. This means we'd apply mask arrays
   at a different time than other masks.

3. Make the function that computes the mask from the mask array
   work from the original, unprocessed image data. This is the most
   local change, but probably also requires the largest amount of
   code (in return, the color mask for 16bpp images is precise, in
   addition that it separates concerns the most nicely).

This goes with 3 for now.
2024-03-03 11:18:37 -05:00
Hugh Davenport
0d6573be14 Escalator: Set focus to password input automatically 2024-03-03 11:00:05 -05:00
Bastiaan van der Plaat
a2f101c10b LibWeb: Add input and textarea minlength and maxlength support 2024-03-03 10:02:30 -05:00
Bastiaan van der Plaat
9b645d20b9 LibWeb: Refactor input range sanitization code use min and max getters 2024-03-03 10:02:30 -05:00
Zac Brannelly
9165faca5e LibWeb: Support CSS property background-clip: text
From https://drafts.csswg.org/css-backgrounds-4/#background-clip
"The background is painted within (clipped to) the intersection of the
border box and the geometry of the text in the element and its in-flow
and floated descendants"

This change implements it in the following way:
1. Traverse the descendants of the element, collecting the Gfx::Path of
   glyphs into a vector.
2. The vector of collected paths is saved in the background painting
   command.
3. The painting commands executor uses the list of glyphs to paint a
   mask for background clipping.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2024-03-03 15:33:12 +01:00
Zac Brannelly
4a3680cafc LibWeb/CSS: Add "text" into list of possible "background-box" values 2024-03-03 15:33:12 +01:00
Andreas Kling
0c18450c4f LibJS/Bytecode: Fix bad serialization of Postfix{Increment,Decrement}
We were serializing the dst operand twice in both instructions.
2024-03-03 09:08:20 +01:00
Shannon Booth
4bce61e508 patch+LibDiff: Add support for applying patches with preprocessor macro 2024-03-03 08:56:00 +01:00
Shannon Booth
ee643b6417 LibDiff: Prevent negative underflow calculating suffix and prefix fuzz
In the situation where the amount of content preceeding the hunk was
greater than the max context of the hunk there would be an unsigned
underflow, as the logic was assuming signed arithmitic.

This underflow would result in the patch not applying, as patch would
assume the massive calculated fuzz would result in the patch matching
against any file.
2024-03-03 08:56:00 +01:00
Shannon Booth
abf35f5bd6 LibCore: Support Optional<StringView> as an argument to ArgsParser
While StringView does have a null state, we have been moving away from
this in our other String classes. To represent a StringView not being
given at all on the commandline, use an Optional.
2024-03-03 08:56:00 +01:00
Shannon Booth
3e61d20b40 LibDiff: Handle parsing patches containing timestamps separated by \t
This is still a very naive implementation and there are plenty of other
cases that we should handle (like a quoted path) - but just looking for
a tab handles the common case.
2024-03-03 08:56:00 +01:00
circl
3e3a200eee LibWeb: Do not issue change event for every update of color input
Per spec, the change event shall only be issued once the change is
finally committed by the user, IE by closing the color picker window.
2024-03-03 08:42:41 +01:00
Johannes Røsvik
bad7f0091f Tests/LibWeb: Add test for SubtleCrypto digest 2024-03-03 08:41:32 +01:00
Johannes Røsvik
d89e617a42 LibWeb: Make SubtleCrypto use the correct algorithm name for SHA-1
The spec defines "SHA-1" as a recognized algorithm name, not "SHA1".

This makes SHA-1 hash values show up on string.248.no.
2024-03-03 08:41:32 +01:00
Aliaksandr Kalenik
d5e74b1bdc LibWeb: Use a precalculated list of positioned descendants for painting
This allows us to avoid the need for costly traversals to gather
boxes that have been saved during the construction of the stacking
context tree.

No behavior change intended.
2024-03-03 08:40:46 +01:00
Kenneth Myhra
cd0302426f LibWeb: Move serialization of serializable object's interface name
To be consistent with the deserialization steps, move serialization of
the serializable object's interface name out of the serialization steps.
2024-03-02 17:04:09 -07:00
Kenneth Myhra
4751ab9f0b LibWeb: Add convenience methods {,de}serialize_{u,i}64()
To avoid differing logic for serializing and deserializing similar
types, move the logic into separate helpers.

Also, adds security checks like VERIFY to avoid reading past the end of
the serialized data. If we try to read past the end of the serialized
data, either our program logic is wrong or our serialized data has
somehow been corrupted. Therefore, at least currently, it is better to
crash by VERIFYing.
2024-03-02 17:04:09 -07:00
Kenneth Myhra
d269ac611e Tests/LibWeb: Prove we do not fail serialization of empty arrays 2024-03-02 17:04:09 -07:00
Kenneth Myhra
77b1469900 Tests/LibWeb: Prove we do not fail serialization of empty strings 2024-03-02 17:04:09 -07:00
Kenneth Myhra
79978063b9 LibWeb: Extract deserialization logic for {,object} primitives
To avoid differing logic for deserializing similar types, move the logic
into separate helpers.

Also, adds security checks like VERIFY to avoid reading past the end of
the serialized data. If we try to read past the end of the serialized
data, either our program logic is wrong or our serialized data has
somehow been corrupted. Therefore, at least currently, it is better to
crash by VERIFYing.
2024-03-02 17:04:09 -07:00
Kenneth Myhra
c384f22d67 LibWeb: Extract serialization logic for primitives and object primitives
To avoid differing logic for serializing similar types, move the logic
into separate helpers.
2024-03-02 17:04:09 -07:00
Nico Weber
98e272ce15 LibPDF: Silently ignore BX / EX operators
See the added comment for reasoning.
2024-03-02 17:43:53 -05:00
Timothy Flynn
2d40df821a Keymap: Draw the current keymap text with the correct theme color
Otherwise it is dark and hard to read against dark themes.
2024-03-02 19:24:53 +00:00
Matthew Olsson
3ca827d27a LibWeb: Add a test for changing animation-name 2024-03-02 19:58:12 +01:00
Matthew Olsson
c1ab6ca6b4 LibWeb: Do not invalidate elements with animations in the CSS cascade
See the note added to Animation::cancel for more info
2024-03-02 19:58:12 +01:00
Ali Mohammad Pur
b9d2d1b478 LibHTTP: Disable finish repeat timer before deferring job completion
It was possible to reach this via the timer itself (when the client is
only slightly busy), and then to have the timer fire before the deferred
invocation fires.
This commit removes the race by disabling the timer when the final
deferred-accept state is reached.
2024-03-02 20:45:35 +03:30
Matthew Olsson
ec766e8669 LibWeb: Correctly set @keyframe rule's effect target 2024-03-02 15:36:48 +01:00
Aliaksandr Kalenik
1bd20a4595 LibWeb: Skip large stacking context in gpu painter only if it allocates
Skipping all stacking contexts with a size larger than 10000px in one
dimension was a mistake because it also affects pages that are simply
tall due to having a lot of content. Instead, we only need to skip if
the stacking context requires the allocation of a framebuffer that
could possibly fail.

Fixes https://github.com/SerenityOS/serenity/issues/23397
2024-03-02 14:36:33 +01:00
Andreas Kling
d8e8293b7e LibWeb: Add PercentageOr<Length>::to_px() fast path for absolute lengths
We can avoid round-tripping through a temporary Length in the simple
case here.
2024-03-02 13:00:09 +01:00
Andreas Kling
1e14264d13 LibWeb: Avoid repeated layout lookups in resolve_paint_only_properties()
By caching the layout node and its computed values in locals, we can
avoid the small amount of redundant work needed to look them up every
single time.
2024-03-02 13:00:09 +01:00
Andreas Kling
8303e61912 LibWeb: Pass BorderRadiusData const& to normalize_border_radii_data()
This avoids making a bunch of temporary copies for no reason.
2024-03-02 13:00:09 +01:00
Andreas Kling
3ff5beb229 LibWeb: Add fast_is<T>() for SVGPaintable 2024-03-02 13:00:09 +01:00
Andreas Kling
b66033720a LibWeb: Let Length::to_px(Layout::Node) be inline for absolute lengths 2024-03-02 13:00:09 +01:00
Andreas Kling
881e7fcee1 LibWeb: Copy various flags from layout node to paintable
This removes indirection when asking if a paintable is positioned,
floating, etc.

Removes a bunch of 1-1.5% items in the profile when hovering links
on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
c69b266e43 LibGfx: Add fast path for multiply() with identity transforms
This is a no-op, and exiting early is useful as it cuts time spent in
AffineTransform::multiply() from 3% to 2% when hovering links on
ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
e46deec846 LibGfx: Inline some AffineTransform functions
Asking if an AffineTransform is identity or translate-only can be done
inline and avoid the cost of a function call in tight loops.
2024-03-02 13:00:09 +01:00
Andreas Kling
2dacd1252c LibGfx: Add fast paths for identity/translate-only transforms
This shrinks time spent in AffineTransform::map() from 3.3% to 1.6%
when hovering links on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
20ff69cd41 LibWeb: Add fast_is<T>() for InlinePaintable
dynamic_cast<InlinePaintable> was showing up in profiles when hovering
links on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
c4403fd28c LibWeb: Fix bogus ReplacedBox type check in StackingContext
We should be asking if the layout node is a ReplacedBox, not the
paintable.
2024-03-02 13:00:09 +01:00
Shannon Booth
cb1c3e5ea5 LibJS: Use TimeZoneMethods in DisambiguatePossibleInstants
This commit partially updates the DisambiguatePossibleInstants AO to use
a time zone methods record in line with the latest spec.
2024-03-02 12:27:20 +01:00
Shannon Booth
f95117f75d LibJS: Use TimeZoneMethods in GetOffsetNanosecondsFor
Update to the latest version of the spec which was refactored to use
time zone methods record. This requires updating a whole bunch of
callers to pass through a record too.

This also ends up improving exceptions on a missing
getOffsetNanosecondsFor method.
2024-03-02 12:27:20 +01:00
Shannon Booth
230ffc022c LibJS: Update Temporal's GetPossibleInstantsFor to latest spec
The most noteworthy change is that we now pass through a Time Zone
Methods Record to this function instead of a raw object.
2024-03-02 12:27:20 +01:00
Shannon Booth
aa9cdc2205 LibJS: Make DisambiguatePossibleInstants take a vector of NonullGCPtr
Instead of a raw pointer. Then deal with the fallout of making that
change.
2024-03-02 12:27:20 +01:00