Commit graph

5883 commits

Author SHA1 Message Date
stelar7
684c543ddb LibWeb/IDB: Handle cursor iteration more correctly 2025-11-13 08:52:16 -05:00
Callum Law
d6bb247bf7 LibWeb: Reject non-exclusive none in text-decoration-line
This updates the `parse_text_decoration_line_value` to reject values
which non-exclusively include `none` e.g. `underline none`.

It also simplifies handling by always producing a Vector (except for
`none`) and adding VERIFY_NOT_REACHED in more places which shouldn't be
reachable.
2025-11-13 10:15:02 +01:00
Psychpsyo
d284b4c2b8 LibWeb: Clamp any values less than 1 in perspective() transform function 2025-11-12 18:45:09 +01:00
Timothy Flynn
0cb9f4b66f LibWeb: Do not fetch empty CSS URLs
If a CSS rule has a URL like `url("")`, it would resolve to the document
URL itself. There isn't a context in which this would result in a valid
resource, so the spec tells us to drop it.

No test here because there isn't really a way to know when a CSS URL is
fetched. We could use PerformanceResourceTiming, but that is only for
HTTP(S) URLs. There is already an existing test for serialization of
empty URLs, which still passes.
2025-11-12 18:30:16 +01:00
Timothy Flynn
d8ec204be8 LibWeb: Do not return an exception from fetching CSS resources
The exception returned here is never used or logged. Let's just return
a null request, to make it clearer that these are not exceptions shown
to the user (thus not observable).
2025-11-12 18:30:16 +01:00
Jelle Raaijmakers
2811c75031 LibWeb: Use anti-aliasing to draw images and painting surfaces
Fixes the jagged edges on the transformed badge on
https://aaronfrancis.com/backstage.
2025-11-12 17:43:02 +01:00
Jelle Raaijmakers
489dea58ba LibWeb: Make all clip rects anti-aliased
This fixes aliased edges when e.g. applying rotation transforms to
certain shapes or SVGs. Although the clip rects themselves are
rectangular, a non-identity matrix transform can be active for the
canvas.

Fixes #5909.
2025-11-12 17:43:02 +01:00
Jelle Raaijmakers
b9244903fc LibWeb: Undo ScalingMode::None for identical bitmap sizes
We always want to return the mapped scaling mode here, since the bitmap
might end up transformed, scaled, etc. and we do not want to fall back
to nearest neighbour in those cases.
2025-11-12 17:43:02 +01:00
Jelle Raaijmakers
d352c4673c LibWeb: Pass sizes instead of rects to to_gfx_scaling_mode()
Position is irrelevant when determining the right scaling mode. No
functional changes.
2025-11-12 15:59:01 +01:00
Jelle Raaijmakers
3f6cbeb87e LibGfx+LibWeb: Use mipmaps for downscaling images
This changes Gfx::ScalingMode to reflect the three modes of scaling we
support using Skia, which makes it a bit easier to reason about the mode
to select. New is ::BilinearMipmap, which uses linear interpolation
between mipmap levels to produce higher quality downscaled images.

The cubic resampling options Mitchell and its sibling CatmullRom both
produced weird artifacts or resulted in a worse quality than
BilinearMipmap when downscaling. We might not have been using these
correctly, but the new ::BilinearMipmap method seems to mirror what
Chrome uses for downscaled images.
2025-11-12 15:59:01 +01:00
Jelle Raaijmakers
7544066c0c LibWeb: Scale blur filter's radius by device pixel scale
The blur filter's effect was reduced on higher DPI displays.
2025-11-12 15:59:01 +01:00
Psychpsyo
e064fa19d2 LibWeb: Add transform-style and have it make a stacking context 2025-11-12 15:47:36 +01:00
Lorenz A
bd56fdc57b LibWeb: Allow focusable for the first summary child of a detail element 2025-11-12 13:57:05 +01:00
Lorenz A
8ca59e7c7e LibWeb: AnchorElement should be focusable with tabindex 2025-11-12 13:57:05 +01:00
Lorenz A
3bc061d028 LibWeb: Allow all elements with tabindex attribute to be focusable 2025-11-12 13:57:05 +01:00
Tim Ledbetter
154e9db033 LibWeb: Cache the value of Element::lang()
This reduces the time spent in
`SelectorEngine::matches_lang_pseudo_class()` from 1.9% to 0.41% on
https://cloudflare.com
2025-11-12 12:36:16 +01:00
Tim Ledbetter
0ec97eabab LibWeb: Extract device_pixels_per_css_pixel getter from loop
This reduces time spent in StyleComputer::compute_property_values() by
~10% when loading https://html.spec.whatwg.org/
2025-11-12 11:21:17 +01:00
Tim Ledbetter
df23b42b37 LibWeb: Don't store custom name on StyleProperty
This reduces time spent in `~StyleProperty()` from 2.18% to 0.67% on
https://cloudflare.com.
2025-11-12 11:19:37 +01:00
Psychpsyo
eb21ea890c LibWeb: Implement CSS perspective property 2025-11-12 00:41:14 +01:00
Psychpsyo
e44a97e508 LibWeb: Pass 3D transforms to Skia 2025-11-12 00:41:14 +01:00
Psychpsyo
e0b5bd7894 LibWeb: Make transition order return -1 and 1 instead of 0 and 1
The old behavior was plain incorrect for a sorting function.
2025-11-11 21:57:47 +01:00
Psychpsyo
2c4f2a3cb6 LibWeb: Make transition order consider property name
class_specific_composite_order() also has no reason to return an
Optional<int>, since it can just return 0.
2025-11-11 13:46:56 +01:00
Jelle Raaijmakers
c845e2cef7 LibWeb: Don't join anonymous pseudo wrappers for block node insertion
This can happen if pseudo elements are absolutely positioned, they need
the nearest non-inline parent to determine their position.
2025-11-11 10:49:49 +01:00
Jelle Raaijmakers
ac829cf60a LibWeb: Hoist anonymous wrappers out of parent inline nodes
When we generate pseudo elements, we create anonymous wrappers that
might end up in an InlineNode, even if they have `display: block` set.
This causes them not to be rendered.

Do not rely on inline continuation logic for these anonymous wrappers,
but rather find the first layout parent that's not an InlineNode and
insert it into that.

Fixes #5042.
2025-11-11 10:49:49 +01:00
Tete17
6d173d931a LibWeb: Allow eval to execute TrustedScripts 2025-11-11 09:58:34 +01:00
Tete17
fb2062a9db LibWeb: Allow CSP to block eval invocations based on TrustedTypes
This allows trusted types directives to also restrict the contents
passed to eval.
2025-11-11 09:58:34 +01:00
Callum Law
55afa9d37e LibWeb: Avoid unnecessary work when element display property changes
`play_or_cancel_animations_after_display_property_change` is called
whenever an element is inserted or removed, or it's display property
changes, but it is only required to run if we actually have animations
to play or cancel.

Reduces time spent in the aforementioned function from ~2% to ~0.03%
when loading https://en.wikipedia.org/wiki/2023_in_American_television
2025-11-11 08:35:39 +00:00
Callum Law
cfc22a4075 LibWeb: Dont try to transition custom properties
Fixes a crash introduced in dd9d6d2
2025-11-11 07:53:41 +00:00
Tim Ledbetter
ec435a12ca LibWeb: Lower case only ASCII characters for selector comparisons
According to the specificcation all selector syntax is ASCII
case-insensitive.
2025-11-10 22:55:38 +01:00
Tim Ledbetter
61af399b50 LibWeb: Remove unnecessary lowercase name property from Attr 2025-11-10 22:55:38 +01:00
Psychpsyo
b7a71ca950 LibWeb: Correctly sort animations returned by getAnimations() 2025-11-10 18:29:07 +01:00
Callum Law
9d515ec666 LibWeb: Share a ColorResolutionContext in apply_style
There is no need to recreate this each time we need it when we can
instead create it once and then reuse it.

This is stop-gap since we should resolve colors to their computed forms
as part of StyleComputer::compute_properties

Reduces time spent in ColorResolutionContext::for_layout_node from ~1.1%
to ~0.1% when loading
https://en.wikipedia.org/wiki/2023_in_American_television
2025-11-10 12:11:36 +01:00
Callum Law
dd9d6d22ee LibWeb: Iterate over fewer properties in start_needed_transitions
We don't need to iterate every property in start_needed_transitions,
only those that appear in transition-property or have an existing
transition

Reduces the time spent in start_needed_transitions from ~5% to ~0.03%
when loading https://en.wikipedia.org/wiki/2023_in_American_television
2025-11-10 12:11:36 +01:00
Callum Law
bbb344d534 LibWeb: Compute font features in ComputedProperties
By doing this in computed properties rather than InlineLevelIterator we
only do it once per element rather than once per text fragment.

Reduces runtime of this process from ~15% to ~0.2% when loading
https://en.wikipedia.org/wiki/2023_in_American_television
2025-11-10 12:11:36 +01:00
Callum Law
7a5b948b5b LibWeb: Resolve more calculated values in ComputedProperties
We simplify these at style computation time so there is no need to
maintain them as {Number|Length}OrCalculated

Reduces the time spent in `Length::ResolutionContext::for_layout_node`
from 3.3% to 0.4% when loading
https://en.wikipedia.org/wiki/2023_in_American_television
2025-11-10 12:11:36 +01:00
Andreas Kling
0dacc94edd LibJS: Have JS::Lexer take a JS::SourceCode as input
This moves the responsibility of setting up a SourceCode object to the
users of JS::Lexer.

This means Lexer and Parser are free to use string views into the
SourceCode internally while working.

It also means Lexer no longer has to think about anything other than
UTF-16 (or ASCII) inputs. So the unit test for parsing various invalid
UTF-8 sequences is deleted here.
2025-11-09 12:14:03 +01:00
Lorenz A
f8330a2ec5 LibWeb: Do not execute unclosed SVG script tags 2025-11-09 01:43:46 +01:00
Jelle Raaijmakers
b4810f47a3 LibWeb: Hook up SVG component transfer filter to Skia 2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
70e98e72a8 LibWeb: Add SVGFEFunc{A,B,G,R}Element 2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
db321cb74f LibWeb: Add SVGComponentTransferFunctionElement
This will be the base for <feFuncR>, <feFuncG>, <feFuncB> and <feFuncA>.
2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
03a8de566b LibWeb: Add SVGFEComponentTransferElement 2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
c0630c700f LibWeb: Add SVGAnimatedNumberList 2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
c5e7276c2f LibWeb: Add SVGNumberList 2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
9991205403 LibWeb: Add SVGList<T> and use it for SVGTransformList
The spec defines a generic list interfaces that we can reuse. Currently
we only have SVGTransformList, but we will need this to add
SVGNumberList as well.
2025-11-09 01:22:48 +01:00
Jelle Raaijmakers
7e869c7816 LibWeb: Add SVGNumber 2025-11-09 01:22:48 +01:00
Andreas Kling
b28480f62d LibWeb: Propagate layout tree update in display: contents to parent
When an element has `display: contents` and it gets marked for a layout
tree rebuild, we actually have to mark its parent for rebuild as well.

The structure of the parent (and siblings) may change depending on how
the `display: contents` element changes (e.g position, display, etc.)
2025-11-08 11:20:32 +01:00
Jelle Raaijmakers
b6f5c91a35 LibWeb: Shave 168 bytes off of ARIAMixin
Instead of keeping the vectors inside ARIAMixin, point to the heap using
OwnPtrs.
2025-11-07 16:59:26 +01:00
Jelle Raaijmakers
9d26626200 LibWeb: Shave 24 bytes off of each DOM::Element 2025-11-07 16:59:26 +01:00
Jelle Raaijmakers
02611c9c12 LibWeb: Shave 16 bytes off of each HTMLElement 2025-11-07 16:59:26 +01:00
Andreas Kling
6894034774 LibWeb: Mark flex item main size definite if resolved from aspect-ratio
This matches the behavior of other engines and makes the cards on the
Apple App Store appear in the narrower layouts.
2025-11-07 16:42:32 +01:00