Commit graph

1309 commits

Author SHA1 Message Date
Andreas Kling
737d9727c2 LibJS+LibWeb: Add various fast_is<T>() helpers for common things 2025-12-20 09:13:19 -06:00
Andreas Kling
9e5ce016d5 LibWeb: Add fast_is<T>() for variously commonly-checked DOM node types 2025-12-20 09:13:19 -06:00
Andreas Kling
2bbb5a455f LibWeb: Remove unused HTML::Worker::m_document pointer 2025-12-20 12:46:52 +01:00
Andreas Kling
6975c31b4d LibWeb: Keep underlying data alive for transferred image bitmaps 2025-12-19 20:21:07 -06:00
Sam Atkins
cb0c428b3a LibWeb/DOM: Use a single scroll queue for all events
Corresponds to:
36f05864a6
302490c80c
https://github.com/w3c/csswg-drafts/pull/13238
https://github.com/w3c/csswg-drafts/pull/13239

The latter two are my own corrections which haven't been merged yet.
2025-12-19 12:09:19 -06:00
Gingeh
dd15dfffd1 LibWeb: Check null in getComputedStyle on inactive view transition 2025-12-17 14:12:47 +00:00
Aliaksandr Kalenik
551ea7d6fc LibWeb: Use incrementally_read() for media fetching 2025-12-16 02:42:48 -06:00
Aliaksandr Kalenik
c5d8cb5c47 LibMedia: Change demuxers to use IncrementallyPopulatedStream as input
Refactor the FFmpeg and Matroska demuxers to consume data through
`IncrementallyPopulatedStream::Cursor` instead of a pointer to fully
buffered.

This change establishes a new rule: each track must be initialized with
its own cursor. Data providers now explicitly create a per-track context
via `Demuxer::create_context_for_track(track, cursor)`, and own pointer
to that cursor. In the upcoming changes, holding the cursor in the
provider would allow to signal "cancel blocking reads" so an
in-flight seek can fail immediately when a newer seek request arrives.
2025-12-16 02:42:48 -06:00
Tim Ledbetter
244c33112b LibWeb: Handle errors when capturing screenshots
Previously, the browser would crash if the screenshot bitmap it
attempted to capture was too large.
2025-12-16 09:16:23 +01:00
Sam Atkins
f9f4c36f20 LibWeb: Implement the headingoffset and headingreset attributes
:heading() now matches based on a computed heading level, which is based
on the level of the tag (h1, h2, etc) and then modified by these two new
attributes.

I'm caching this heading level on HTMLHeadingElement, based on the dom
tree version. That's more invalidation than is actually needed, but it
saves us calculating it over and over when the document hasn't changed.

The failing test cases are:
- Implicit headingreset for modal dialogs which is apparently unspecced
  and controversial.
- Not walking the flat tree properly. A flat tree ancestor of a
  slot-assigned element is its slot, which is something we don't do
  anywhere that I could find. I've made a note to look into this later.

We also don't implement the `ReflectRange` IDL attribute yet, which
means we're not clamping the read value of `headingOffset`.

Corresponds to:
e774e8e318
2025-12-15 14:08:24 +00:00
Psychpsyo
3a4f7eeb4a LibWeb: Prevent scrolling viewport with overflow:hidden 2025-12-15 09:47:25 +00:00
Tim Ledbetter
81cac9b11a LibWeb: Use a more sensible order of precedence for rel keywords
`preload` now has higher precedence than `preconnect` which in turn
takes precedence over `dns-prefetch`.
2025-12-13 10:52:25 -05:00
Tim Ledbetter
ac2334453b LibWeb: Use default fetch processing for any applicable rel keyword
Previously, the `preload`, `preconnect` and `dns-prefetch` keywords
took precedence over the others. When these keywords were present
the default fetch processing steps would not occur even when a relevant
keyword such as `stylesheet` or `icon` was present.
2025-12-13 10:52:25 -05:00
Feng Yu
b58fcaeecf LibWeb: Add HTMLSelectedContentElement for customizable select
Introduce the HTMLSelectedContentElement and integrate it into
<select>, <option> and HTMLParser.

See whatwg/html#10548.

There are two bugs with WPT tests which causes the third subtest
in selectedcontent.html and selectedcontent-mutations.html fail.
See whatwg/html#11882, web-platform-tests/wpt#55849.
2025-12-12 12:06:24 +00:00
Feng Yu
89d50befb0 LibWeb: Sync <select> options handling with latest spec changes
- Rename HTMLOptionElement's `owner_select_element()` to
  `nearest_select_element()` to better match spec terminology.
- Update HTMLSelectElement's option list related algorithms.

This change is part of the customizable <select> spec work.
See whatwg/html#10548.
2025-12-12 12:06:24 +00:00
Sam Atkins
83880235ca LibWeb/HTML: Use available screen area to set up browsing context feats
The spec text mentions using this instead of just the screen area.
2025-12-12 10:17:00 +00:00
Carlos Sousa
9e3f4c7639 LibWeb: Return custom validity error message
Previously, validation_message() always returned a hardcoded "Invalid
form" string, now it correctly returns the custom validity error
message when the element is suffering from a custom error.
Other validation errors still return the "Invalid form" message.
2025-12-11 22:06:25 +00:00
Glenn Skrzypczak
d2cb8057c3 LibWeb/HTML: Account for floating point error in step mismatch check
This introduces a new `is_integral_multiple` method that replaces the
`fmod(...) != 0` check. This fixes some WPT-Tests, where the step
cannot be accurately represented as a double.
2025-12-11 16:17:56 +01:00
pepperoni21
a3984c4382 LibWeb: Filter input events by page_id in EventLoop 2025-12-11 09:01:50 +01:00
Zaggy1024
d0d10b4200 LibWeb: Update the duration of an element based on media data 2025-12-10 16:02:40 -06:00
Andreas Kling
cb23d65625 LibJS: Pass JS::Value directly to string formatting functions
We don't need to call .to_string_without_side_effects() when passing
a JS::Value in for string formatting. The Formatter will do it for us.
2025-12-09 21:44:13 -06:00
Aliaksandr Kalenik
9f60828a57 LibMedia+LibWeb: Create demuxer and extract tracks on a separate thread
Demuxer creation and track+duration extraction are moved to a separate
thread so that the media data byte buffer is no longer accessed from the
main thread. This will be important once the buffer is populated
incrementally, as having the main thread both populate and read from the
same buffer could easily lead to deadlocks. Aside from that, moving
demuxer creation off the main thread helps to be more responsive.

`VideoDataProvider` and `AudioDataProvider` now accept the main thread
event loop pointer as they are constructed from the thread responsible
for demuxer creation.
2025-12-09 17:36:18 -06:00
Callum Law
09b20f172f LibWeb: Set background-image presentational hint as StyleValueList
This fixes a crash introduced in a11666e
2025-12-09 12:08:40 +00:00
Lorenz A
924e4d2baa LibWeb: Add sorting to Table row HTMLCollection
Add an optional sorting function to HTMLCollection. We use
insertion_sort as a stable sorting algorithm so tree order can be
maintained.
2025-12-09 09:26:49 +00:00
Jelle Raaijmakers
aa1abe778a LibWeb: Misc. code improvements
More usage of `as_if<T>`, fewer unnecessary `const_cast`s, etc. No
functional changes.
2025-12-08 20:12:23 +01:00
Sam Atkins
16c12c1485 LibWeb: Parse the ::part() pseudo-element selector
It doesn't yet do anything, but it helps a few tests that just check
serialization.
2025-12-08 09:44:32 +00:00
Sam Atkins
01b7800068 LibWeb/DOM: Add the Element.part attribute 2025-12-08 09:44:32 +00:00
Sam Atkins
f1f7f4fbbf LibWeb/DOM: Use GC::Ptr/Ref instead of raw pointers on DOM::Element APIs
No behaviour change, though this does clarify that class_list() always
returns a value.
2025-12-08 09:44:32 +00:00
Callum Law
dca80ad5eb LibWeb: Account for animated values when computing font
Computing the font for an element in `compute_font` is premature since
we are yet to apply animated properties - instead we should compute the
value on the fly (with a cache to avoid unnecessary work) to ensure we
are respecting the latest values
2025-12-05 10:03:15 +00:00
Callum Law
6c236d04d8 LibWeb: Separate font computation logic from StyleComputer
Font computation and loading is distinct enough from style computation
that it makes more sense to have this in it's own class.

This will be useful later when we move the font loading process to
`ComputedProperties` in order to respect animated values.
2025-12-05 10:03:15 +00:00
Callum Law
dfa47d9ed6 LibWeb: Simplify handling of font-variation-settings
Since we resolve any relative lengths at compute time there's no need
for the value to be passed around as a `NumberOrCalculated` and we can
just resolve it within `ComputedProperties::font_variation_settings`.

The only place this is used it is used with value_or so there's no need
to return it is an `Optional`.

This is only used for loading fonts (which occurs during style
computation) so there's no need to store it in `ComputedValues`
2025-12-05 10:03:15 +00:00
Sam Atkins
4fb28539a9 LibWeb/HTML: Implement NavigationTransition committed promise 2025-12-05 09:20:02 +00:00
Sam Atkins
945c4ca5b3 LibWeb/HTML: Implement NavigationTransition.to
Corresponds to:
f19930f98a
2025-12-05 09:20:02 +00:00
Sam Atkins
43bd5342c5 LibWeb/HTML: Create a temporary execution context to abort navigation
Stops this WPT test from crashing:
navigation-api/ordering-and-transition/transition-to.html

...it now times out instead, so more work is needed before importing.
2025-12-05 09:20:02 +00:00
Feng Yu
d2029b1814 LibWeb: Relax HTML parser to allow more tags inside <select>
This implements parsing part of customizable <select> spec update.
See whatwg/html PR #10548.

Two failing subtests in `html5lib_innerHTML_tests_innerHTML_1.html`
and `customizable-select/select-parsing.html` are due to the spec
still disallowing `<input>` inside `<select>`, even though Chrome
has already implemented this behavoir (see whatwg/html#11288).
2025-12-04 17:17:01 +00:00
Timothy Flynn
674075f79e Everywhere: Remove LibCore/System.h includes from header files
This reduces the number of compilation jobs when System.h changes from
about 750 to 60. (There are still a large number of linker jobs.)
2025-12-04 15:40:46 +00:00
Sam Atkins
58b32814e0 LibWeb/HTML: Bring HTMLDialogElement up to spec
I missed when these changes actually happened, but the big differences
here are that a few steps got extracted into their own algorithms; and
the dialog now only does things when it's attached to a fully-active
document, instead of immediately.

I've imported a WPT test that exercises this by calling show() on an
unattached dialog.
2025-12-04 14:47:16 +00:00
Sam Atkins
a1fbcfb4c6 LibWeb/HTML: Implement CloseWatcher::getEnabledState closer to spec
We previously had this implemented in an ad-hoc way, where we used a
boolean on the CloseWatcher instead of a proper function with steps.
This worked at the time, but causes problems with the current version
of the spec, so let's just implement it properly.

This commit consciously does not update the spec text, because it's
diverted quite a lot. That will happen in a subsequent commit.
2025-12-04 14:47:16 +00:00
Sam Atkins
c541d14232 LibWeb/HTML: Add spec asserts to HTMLDialogElement::set_close_watcher()
Not sure when this change happened. This does include the fixed assert
from here though:
71e70e9006
2025-12-04 14:47:16 +00:00
Andreas Kling
4d27e9aa5e LibWeb: Make setInterval() reuse the timer to reduce drift
Instead of creating a new single-shot timer every time a setInterval
timer reschedules itself, we now use a repeating Core::Timer internally.

This dramatically reduces timer drift, since the next timeout is now
based on when the timer fired, rather than when the timer callback
completed (which could take arbitrarily long since we run JS).

It's not perfect, but it's a huge improvement and allows us to play
DiabloWeb at full framerate (20 fps).
2025-12-01 19:58:47 +01:00
Sam Atkins
e5ea4f9bdf LibWeb/HTML: Add source field to ToggleEventInit
Corresponds to:
95131eec8f

As we now have a field in that dictionary, I removed the separate
`source` parameter from ToggleEvent::create(). Also updated the
relevant test.
2025-12-01 14:58:20 +00:00
Andreas Kling
1c45930767 LibWeb+LibWebView+LibRequests: Reduce dependency on LibIPC includes
Let's try to include the IPC encoder/decoder stuff in fewer headers
to make rebuilds more pleasant when editing these files.
2025-12-01 15:12:52 +01:00
Sam Atkins
62d7011f45 LibWeb/HTML: Update worker construction spec steps
This is largely editorial. One behaviour change is that events are now
sent from a global task on the DOMManipulation task source.

Somewhat awkwardly, the spec refers to `this` before the Worker exists.
As it's for getting the relevant global object / settings object, I've
had to work around that.

Corresponds to:
917c2f6a73
2025-12-01 15:02:27 +01:00
Sam Atkins
d5d1b5351e LibWeb: Hide stepper buttons on appearance: textfield number inputs
The spec says:

> For the purpose of this specification, they all have the same effect
  as auto. However, the host language may also take these values into
  account when defining the native appearance of the element.

https://drafts.csswg.org/css-ui/#typedef-appearance-compat-special

Firefox at least hides the stepper buttons when this is set.
2025-12-01 11:10:13 +00:00
Sam Atkins
c3d23a2487 LibWeb/HTML: Clone integrity policy when cloning policy container
Corresponds to:
3c6cb6c0c5
2025-12-01 11:07:16 +00:00
Sam Atkins
b3d9ffdfce LibWeb/HTML: Update ImageRequest::prepare_for_presentation spec steps
Corresponds to:
ad281924e2

We don't implement this at all yet, it's still just FIXMEs.
2025-12-01 11:07:16 +00:00
Sam Atkins
573d5362f4 LibWeb/HTML: Add FIXMEs to honor WebDriver BiDi emulated language
Corresponds to:
547f8044b0

We currently don't follow the spec for these language getters, and the
BiDi changes are still ongoing, so it seems better to leave a FIXME for
them rather than try to make any changes right now.
2025-12-01 11:07:16 +00:00
Sam Atkins
c8990697d1 LibWeb: Add FIXME for moving "stop parsing" step for error documents
Corresponds to:
48cd393d1e

Actually doing so was causing crashes and other issues, so I'll leave it
as a FIXME for later.
2025-12-01 11:07:16 +00:00
Sam Atkins
2feff2b519 LibWeb/HTML: Capitalize autocorrection and autocapitalization states
Only comment changes.

Corresponds to:
ea29ce1963
2025-12-01 11:07:16 +00:00
Sam Atkins
c0b8f47a76 LibWeb/HTML: Move connectedness check for script post_connection()
Corresponds to:
905384d140

Also import the test added along with that change.
2025-12-01 11:07:16 +00:00