Commit graph

3238 commits

Author SHA1 Message Date
sideshowbarker
062e33438e LibWeb: Space-separate parts of multi-label accessible names
This change ensures that when an accessible name is computed from
multiple labels, the parts computed from each label are separated by
spaces. Otherwise, without this change, the parts are run together in
the accessible name, with no space in between.
2024-12-26 20:44:14 +00:00
Andreas Kling
3bfb0534be LibGC: Rename MarkedVector => RootVector
Let's try to make it a bit more clear that this is a Vector of GC roots.
2024-12-26 19:10:44 +01:00
Shannon Booth
3913e9f948 LibWeb/Fetch: Return a cloned cached response body
Otherwise we will fully read from the cached response and invalidate
it's stream, invalidating it for the next time it is read from. Fixes
a crash when reloading linegoup.lol after two reloads.
2024-12-26 13:44:52 +01:00
Lucas CHOLLET
1c61ccef40 LibWeb/DOM: Fire transition[cancel,start,run,end] events 2024-12-25 17:14:08 +01:00
Lucas CHOLLET
a2ab3769f4 LibWeb/CSS: Don't assume that animations have an associated effect
... when computing properties.
2024-12-25 17:14:08 +01:00
Lucas CHOLLET
c39ef2a738 LibWeb/Animations: Don't assume that animations have an effect
I agree that the spec definition of this function isn't super clear
about that, but from "Web Animations 1 - 4.5. Animations"[1]:

An animation is a timing node that binds an animation effect child,
called its associated effect, to a timeline parent so that it runs. Both
of these associations are optional and configurable such that an
animation can have no associated effect or timeline at a given moment.

[1]: https://drafts.csswg.org/web-animations-1/#animations
2024-12-25 17:14:08 +01:00
Lucas CHOLLET
441c1a29ae LibWeb/Animations: Consider CSSTransitions in is_replaceable() 2024-12-25 17:14:08 +01:00
Lucas CHOLLET
c2165fb6b8 LibWeb/Animations: Don't try to associate animations to null timelines
The input to `set_timeline` is user controlled, it can be null.
2024-12-25 17:14:08 +01:00
Lucas CHOLLET
55b4a983a7 LibWeb/CSS: Add the TransitionEvent type 2024-12-25 17:14:08 +01:00
Andreas Kling
56e6d4f42d LibWeb: Protect HTTP cache entries from garbage collector
One day we'll have an eviction strategy, too, but for now let's not
allow these to get collected.

Co-Authored-By: Gingeh <39150378+Gingeh@users.noreply.github.com>
2024-12-25 17:11:16 +01:00
Glenn Skrzypczak
08589741f5 LibWeb: Correctly implement event listeners default passive attribute
This commit implements the default value of the passive attribute of
event listeners according to the spec.
2024-12-25 14:57:22 +00:00
Pavel Shliak
4c7cd05078 LibWeb: Update FormData constructor to reflect the spec 2024-12-25 14:52:57 +00:00
sideshowbarker
72a86f2df3 LibWeb: Fix selector matching for non-HTML mixed-case element names
This change fixes selector matching for non-HTML elements that have
mixed-case names — such as the SVG foreignObject element.

Otherwise, without this change, attempting to use a selector to match
such an element — e.g., document.querySelector("foreignObject") — fails.
2024-12-25 13:54:06 +00:00
Andreas Kling
f625ea27d0 LibWeb: Use the right StyleInvalidationReason for iframe geometry change 2024-12-25 13:26:51 +01:00
Andreas Kling
f45e24864b LibWeb: Skip unneeded style invalidation on custom element state change
If there are no :defined pseudo-class selectors anywhere in the
document, we don't have to invalidate style at all when an element's
custom element state changes.
2024-12-25 13:26:51 +01:00
Andrew Kaster
202bf901d7 LibWeb: List supported media types publicly for HTMLMediaElement 2024-12-25 12:02:39 +01:00
Saksham Goyal
8ebf2c3007 LibWeb: Add missing attributes in Event Handlers 2024-12-25 12:01:56 +01:00
Shannon Booth
5f2b75852f LibWeb: Add an 'enqueue' helper method on TransformStream 2024-12-25 12:00:54 +01:00
Shannon Booth
9ce0c5914b LibWeb: Add a 'get a reader' helper method on ReadableStream 2024-12-25 12:00:54 +01:00
Shannon Booth
da408cb09a LibWeb: Add a 'piped through' helper method on ReadableStream
This reads a bit nicer, and follows the streams spec pattern on
performing operations on a stream outside of the streams spec.
2024-12-25 12:00:54 +01:00
sideshowbarker
f2ac591614 LibWeb: Compute default ARIA roles for SVG elements
This change adds support for computing default ARIA roles for (selected)
SVG elements, per the requirements in the SVG Accessibility API Mappings
spec at https://w3c.github.io/svg-aam/#mapping_role_table.

This only computes roles for the elements which are covered in the WPT
test at https://wpt.fyi/results/svg-aam/role/roles.html — that is, the
“a”, “g”, and “image” elements.
2024-12-25 10:58:48 +00:00
Shannon Booth
f3e92f2ae5 LibWeb/HTML: Implement the StorageEvent interface 2024-12-25 11:57:14 +01:00
Lucas CHOLLET
c5f9710492 LibWeb/CSS: Create a MediaQueryListEvent when calling MQLE::create()
Otherwise, if not implemented, `MediaQueryListEvent::create()` would
result in a call to `DOM::Event::create()`. This issue exists here:
673537b26b/Libraries/LibWeb/DOM/Document.cpp (L2865)
2024-12-25 11:56:37 +01:00
rmg-x
ceb7f5f017 LibWeb: Use Crypto::fill_with_secure_random instead of PRNG 2024-12-24 17:54:52 +01:00
Andreas Kling
b981e6f7bc LibWeb: Avoid many style invalidations on DOM attribute mutation
Many times, attribute mutation doesn't necessitate a full style
invalidation on the element. However, the conditions are pretty
elaborate, so this first version has a lot of false positives.

We only need to invalidate style when any of these things apply:

1. The change may affect the match state of a selector somewhere.
2. The change may affect presentational hints applied to the element.

For (1) in this first version, we have a fixed list of attribute names
that may affect selectors. We also collect all names referenced by
attribute selectors anywhere in the document.

For (2), we add a new Element::is_presentational_hint() virtual that
tells us whether a given attribute name is a presentational hint.

This drastically reduces style work on many websites. As an example,
https://cnn.com/ is once again browseable.
2024-12-24 17:17:09 +01:00
Andrew Kaster
44e3817219 LibWeb: Add WebAssembly.Global and exports support for global instances 2024-12-24 15:20:28 +01:00
Shannon Booth
910ff8b694 LibWeb/HTML: Consider <a> all-named elements instead of <link>
Leaving only the unimplemented legacy [[Call]] override funkiness
of HTMLAllCollection left not passing in the WPT tests.
2024-12-23 21:19:08 +01:00
Andreas Kling
d5bbf8dcf8 LibWeb: Do lighter style invalidation for style attribute changes
When the `style` attribute changes, we only need to update style on the
element itself (unless there are [style] attribute selectors somewhere).

Descendants of the element don't need a full style update, a simple
inheritance propagation is enough.
2024-12-23 17:05:09 +01:00
Andreas Kling
6983c65c54 LibWeb: Collect interesting document-wide insights about CSS selectors
Starting out with these two things:
- Whether any :has() selectors are present
- The set of all names referenced by attribute selectors
2024-12-23 17:05:09 +01:00
Andreas Kling
dc8343cc23 LibWeb: Add mechanism to invalidate only inherited styles
We can now mark an element as needing an "inherited style update" rather
than a full "style update". This effectively means that the next style
update will visit the element and pull all of its inherited properties
from the relevant ancestor element.

This is now used for descendants of elements with animated style.
2024-12-23 17:05:09 +01:00
Andreas Kling
92ac702c0c LibWeb: Always note whether a CSS property was inherited
This will be relevant when we start recomputing inherited style only.
2024-12-23 17:05:09 +01:00
sideshowbarker
966c68ae0e LibWeb: Align accname alt-vs-title behavior w/ HTML-AAM spec & WPT tests
The https://wpt.fyi/results/accname/name/comp_tooltip.tentative.html
test was recently added by moving an existing subtest out from the test
at https://wpt.fyi/results/accname/name/comp_tooltip.html, and changing
the test expectations to match the HTML-AAM spec requirements at
https://w3c.github.io/html-aam/#img-element-accessible-name-computation.
See https://github.com/web-platform-tests/wpt/pull/49552.

So this code change updates Ladybird to match the updated WPT test
expectations — and to match the existing HTML-AAM spec requirements.
2024-12-23 14:01:37 +01:00
Pavel Shliak
b6561f5e2b LibWeb: Make is_identifier always return false the simple way 2024-12-22 12:33:41 +01:00
Pavel Shliak
d6466da4db LibWeb: Correct interception state assertion logic
The previous VERIFY statement incorrectly asserted that the
interception state was not "committed" or "scrolled". Updated
the condition to ensure the interception state is either
"committed" or "scrolled" as intended.
2024-12-22 12:33:41 +01:00
Sam Atkins
349caecc18 LibWeb/CSS: Use fetch for CSS import rules
This still has a few FIXMEs, but it's a ResourceLoader use gone! :^)
2024-12-22 12:30:09 +01:00
Sam Atkins
a4db7e9e23 LibWeb: Add method for "is CORS-same-origin" 2024-12-22 12:30:09 +01:00
Sam Atkins
ae943965dc LibWeb/CSS: Implement "fetch a style resource" algorithm 2024-12-22 12:30:09 +01:00
Sam Atkins
00948c4746 LibWeb/CSS: Expose CSSStyleSheet's origin clean flag 2024-12-22 12:30:09 +01:00
Andreas Kling
74469a0c1f LibWeb: Make CSS::ComputedProperties GC-allocated 2024-12-22 10:12:49 +01:00
Andreas Kling
c1cad8fa0e LibWeb: Rename CSS::StyleProperties => CSS::ComputedProperties
Now that StyleProperties is only used to hold computed properties, let's
name it ComputedProperties.
2024-12-22 10:12:49 +01:00
Andreas Kling
ed7f4664c2 LibWeb: Split StyleComputer work into two phases with separate outputs
Before this change, StyleComputer would essentially take a DOM element,
find all the CSS rules that apply to it, and resolve the computed value
for each CSS property for that element.

This worked great, but it meant we had to do all the work of selector
matching and cascading every time.

To enable new optimizations, this change introduces a break in the
middle of this process where we've produced a "CascadedProperties".
This object contains the result of the cascade, before we've begun
turning cascaded values into computed values.

The cascaded properties are now stored with each element, which will
later allow us to do partial updates without re-running the full
StyleComputer machine. This will be particularly valuable for
re-implementing CSS inheritance, which is extremely heavy today.

Note that CSS animations and CSS transitions operate entirely on the
computed values, even though the cascade order would have you believe
they happen earlier. I'm not confident we have the right architecture
for this, but that's a separate issue.
2024-12-22 10:12:49 +01:00
Jelle Raaijmakers
4d9f17eddf LibGfx+LibWeb: Draw glyph runs with subpixel accuracy
This improves the quality of our font rendering, especially when
animations are involved. Relevant changes:

  * Skia fonts have their subpixel flag set, which means that individual
    glyphs are rendered at subpixel offsets causing glyph runs as a
    whole to look better.

  * Fragment offsets are no longer rounded to whole device pixels, and
    instead the floating point offset is kept. This allows us to pass
    through the floating point baseline position all the way to the Skia
    calls, which already expected that to be a float position.

The `scrollable-contains-table.html` ref test needed different table
headings since they would slightly inflate the column size in the test
file, but not the reference.
2024-12-21 23:09:52 +01:00
Ali Mohammad Pur
e32a9b2c6f LibWeb/WebAssembly: Use wasm funcaddr of exported functions on import
Previously this was proxying the call through javascript, which lead to
unexpected crashes when functions returned things that js-api did not
like.
This commit also adds in the spec comments and fixes a few inaccuracies
that were present in the process.
2024-12-21 20:16:12 +01:00
Jelle Raaijmakers
c0285f4a7e LibWeb: Do not require visible nodes in the wrap editing algorithm
The spec doesn't say they should exist, so we should not
`VERIFY_NOT_REACHED()` when they don't. Prevents a crash in the WPT
`editing/event.html` tests.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
c093c895da LibWeb: Implement step 15 of the editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
30a3fe8387 LibWeb: Remove unnecessary condition from editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
ff25d66dae LibWeb: Prevent potential null deref in editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
a7c75f6fdb LibWeb: Update CSS resolved values spec link to editor's draft URL 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
e6631a4216 LibWeb: Add concept of boundary point to DOM::AbstractRange
This makes comparing the relative position of boundary points a bit
nicer when one of the boundary points is the range's start or end.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
a3b3f2f30d LibWeb: Prevent null deref in the "restore the values of nodes" algo 2024-12-21 19:15:58 +01:00