Commit graph

1164 commits

Author SHA1 Message Date
Tim Ledbetter
e1ff1e2095 LibWeb: Implement CanvasPattern.setTransform()
This method applies the given transformation matrix to a pattern.
2025-10-27 16:41:02 -07:00
Tete17
c591f8c14f LibWeb: Amend DomParser to make it compatible with TrustedTypes 2025-10-27 16:14:20 +00:00
Tete17
db41ea8117 LibWeb: Amend Element interface to make it compatible with TrustedTypes 2025-10-27 16:14:20 +00:00
Tete17
2fa84f1683 LibWeb: Properly propagate errors for Node set_text_content
This function was supposed to throw errors even before the TrustedTypes
spec thanks to the CharacterData replaceData call but had a MUST.

This changes this to ensure this function can throw an error
2025-10-27 16:14:20 +00:00
Callum Law
5381146e85 LibWeb: Include PropertyID.h in fewer header files
This reduces the size of the recompile when PropertyID.h is modified
from ~1500 to ~125
2025-10-27 14:50:54 +00:00
Callum Law
12716dccf0 LibWeb: Avoid including ComputedProperties.h in Element.h
This reduces the size of the recompile when ComputedProperties.h is
modified from ~1200 to ~70
2025-10-27 14:50:54 +00:00
Callum Law
64f438857b LibWeb: Factor out some class template methods into implementation files
Reduces the rebuild required for changes to the .cpp parts (or their
includes)
2025-10-27 14:50:54 +00:00
Rocco Corsi
633fc45e0f LibWeb: Make Worker.cpp compile again with WEB_WORKER_DEBUG enabled 2025-10-26 12:47:06 -04:00
Tim Ledbetter
9dceb06992 LibWeb: Don't paint canvas objects with non-visible fill styles 2025-10-26 16:45:38 +01:00
ayeteadoe
5abb5d555a LibWeb: Implement createImageBitmap() with an ImageBitmap source 2025-10-26 09:01:20 +01:00
Lorenz A
fb258639d1 LibWeb: CSS selector read-write honor is_allowed_to_be_readonly 2025-10-24 19:15:58 +01:00
Andreas Kling
3593c3b687 LibWeb: Throw out decoded UTF-32 data in HTMLTokenizer after parser runs
This ends up saving quite a bit of memory on many pages, since UTF-32
uses 4 bytes per code points.

As an example, it reduces the footprint on https://gymgrossisten.com/
by 2 MiB.
2025-10-24 08:52:53 +02:00
Andreas Kling
b10f2993b3 LibWeb: Use Optional<ssize_t> for the HTMLTokenizer insertion points
Instead of making a custom struct, we can just use Optional here,
to make the code feel a bit more idiomatic.
2025-10-24 08:52:53 +02:00
Tim Ledbetter
1c00279488 LibWeb: Reset Painter when resetting canvas to its initial state 2025-10-23 18:52:36 +02:00
Andreas Kling
dbf041aa98 LibWeb: Ignore repaint requests inside iframes with visibility: hidden
This reduces idle CPU usage on https://gymgrossisten.com/ from 100%
(split between WebContent and Ladybird) to ~4% on my machine.
2025-10-23 17:42:37 +02:00
Jelle Raaijmakers
62ae4e878f LibWeb: Implement support for drawing with CanvasPattern
We already had the API, but drawing to the canvas was not affected by
any created CanvasPattern. This moves CanvasPatternPaintStyle to LibGfx
so we don't have to reach into LibWeb, and implements the plumbing to
let Skia use images as a fill pattern.
2025-10-23 13:20:03 +01:00
mikiubo
0b715b20a2 LibWeb: Make HTML fragment parsing return ExceptionOr
Update Element::parse_fragment and Node::unsafely_set_html to
propagate exceptions.

This refactor is needed as a prerequisite for implementing the XML
fragment parser, which requires consistent error handling in fragment
parsing.
2025-10-23 11:06:39 +01:00
Tim Ledbetter
2fd424ccb6 LibWeb: Draw canvas arcs and ellipses correctly when radius is zero
In this case, we should just draw a line from the last point in the
path to the start point. Previously, a division by zero caused nothing
to be drawn.
2025-10-22 16:08:57 +02:00
Tim Ledbetter
976912f3e9 LibWeb: Normalize negative drawImage() source/destination dimensions 2025-10-22 12:29:04 +02:00
Tim Ledbetter
c4e56cc845 LibWeb: Throw error when calling drawImage() with a broken image 2025-10-22 10:44:58 +02:00
Tim Ledbetter
f1571c4217 LibWeb: Ensure drawImage() always uses the first image frame 2025-10-22 01:25:46 +02:00
Callum Law
f49cf75d44 LibWeb: Don't pass unnecessary PropertyComputationDependencies struct
Since we now have access to the `AbstractElement` through the
`ComputationContext` we can just set the flag that this element relies
on tree counting functions directly, no need to pass this struct around.
2025-10-22 00:01:30 +02:00
Callum Law
5b9a36b172 LibWeb: Pass AbstractElement in ComputationContext
Passing the `AbstractElement` rather than the
`TreeCountingFunctionResolutionContext` allows us to only compute the
resolution context when necessary (i.e. when we actually need to resolve
a tree counting function)
2025-10-22 00:01:30 +02:00
Lorenz A
6afd39b16a LibWeb: Keep the tokens in ListOfActiveFormattingElements 2025-10-21 23:36:07 +02:00
Tim Ledbetter
7db73118e9 LibWeb+LibGfx: Draw shadows for stroke joins and caps 2025-10-21 18:55:08 +02:00
Tim Ledbetter
0f295e8989 LibWeb: Take transforms into account when drawing shadows 2025-10-21 18:55:08 +02:00
Tim Ledbetter
0516c414d4 LibWeb: Don't draw shadows for transparent gradient fills 2025-10-21 18:55:08 +02:00
Tim Ledbetter
13f551612c LibWeb: Don't draw shadows if shadow offset and blur are not set 2025-10-21 18:55:08 +02:00
Tim Ledbetter
eb44cca5bd LibWeb: Ignore non-finite shadow offset values 2025-10-21 18:55:08 +02:00
Tim Ledbetter
b99c0c6a7f LibWeb: Account for paint style and global alpha when drawing shadows 2025-10-21 18:55:08 +02:00
Tim Ledbetter
494fcc40ac LibWeb: Account for transforms in isPointInPath() 2025-10-21 17:42:28 +02:00
Andreas Kling
9e064bd3ff LibWeb: Make input type=text placeholder render as a block-level element
This will make the width: 100% we already apply actually do something
useful to the placeholders.
2025-10-21 16:42:00 +02:00
Tim Ledbetter
d3ca038b2c LibWeb: Ensure putImageData() is unaffected by drawing state 2025-10-21 09:52:16 +02:00
Tim Ledbetter
2ac4544a81 LibWeb: Align CanvasRenderingContext2D::putImageData() with the spec
This change implements `putImageData()` with `dirtyX`, `dirtyY`,
`dirtyWidth` and `dirtyHeight` arguments.
2025-10-21 09:52:16 +02:00
Callum Law
2404f95e03 LibWeb: Invalidate style for tree counting functions when required
We mark any element that relies on tree counting functions as needing a
style update when a sibling is inserted/removed.
2025-10-20 16:12:08 +01:00
Callum Law
9cd23e3ae5 LibWeb: Compute and propagate tree-counting function resolution context
Tree counting functions should be resolved at style computation time -
to do this we will need to know the element's sibling count and index.

This commit computes that information and propagates it to the various
`StyleValue::to_computed_value` methods.
2025-10-20 16:12:08 +01:00
Callum Law
28451b16c9 LibWeb: Absolutize StyleValues before computing font properties
We also avoid prematurely constructing CSSPixels when computing
font-size which gains us a couple of test passes
2025-10-20 16:12:08 +01:00
Lorenz A
eeef370902 LibWeb: Check that elements are HTML elements in StackOfOpenElements 2025-10-20 12:14:14 +01:00
Tim Ledbetter
08641c9e15 LibWeb: Ensure CanvasPath::arc() nonfinite radius argument is ignored 2025-10-20 12:12:16 +01:00
Tim Ledbetter
303ebc0a67 LibWeb: Ignore non-finite arguments to canvas text drawing methods 2025-10-20 12:12:16 +01:00
Luke Wilde
eeb5446c1b LibWeb: Avoid including Navigable.h in headers
This greatly reduces how much is recompiled when changing Navigable.h,
from >1000 to 82.
2025-10-20 10:16:55 +01:00
ljamar
7fb65283c2 LibWeb: Ignore non-finite args in CanvasRenderingContext2D::clear_rect() 2025-10-17 17:41:58 +01:00
Andreas Kling
dfa796a4e4 LibJS+LibWeb: Use GC::Weak instead of AK::WeakPtr for GC-allocated types
This makes some common types like JS::Object smaller (by 8 bytes) and
yields a minor speed improvement on many benchmarks.
2025-10-17 17:22:16 +02:00
Tim Ledbetter
62c00712fa LibWeb: Update HTMLScriptElement::prepare_script() spec text 2025-10-16 16:46:48 +02:00
Tim Ledbetter
24a7eac4ab LibWeb: Delay module script execution until current script has ended 2025-10-16 16:46:48 +02:00
Lorenz A
e73e0b3c92 LibWeb: Implement CSS decode bytes algo 2025-10-16 16:44:42 +02:00
mikiubo
d4df0e1db9 LibWeb: Make Event.currentTarget return WindowProxy instead of Window
Make WindowProxy implement the EventTarget interface. Add a new method
current_target_for_bindings() that returns a WindowProxy object instead
of directly exposing the Window object.

These changes fixes several WPT tests that contain `window ===
currentTarget`.
2025-10-15 15:36:34 +02:00
ayeteadoe
0d5136ae5c LibWeb: Add support for bitmap scaling in createImageBitmap() 2025-10-14 12:19:33 +02:00
Aliaksandr Kalenik
9e838cffb4 LibWeb: Copy "is inert" attribute into Paintable
...instead of reaching into DOM tree during hit-testing in order to
figure out if an element is inert. This is a part of the effert to make
possible running hit-testing solely based on data contained by the
paintable tree.
2025-10-14 11:23:29 +02:00
Tete17
74aa7e8a82 LibWeb: Hook TrustedTypes to the Workers api 2025-10-13 13:22:01 +01:00