Commit Graph

1542 Commits

Author SHA1 Message Date
Lorenz A
528695230b LibWeb: Implement set_value_of_indexed_property closer to spec text 2026-01-06 13:03:41 +01:00
Lorenz A
7e50dcb687 LibWeb: Update spec text for set_value_of_indexed_property
https://github.com/whatwg/html/pull/11932 resolved the AD-HOC comment
and adjusted the spec text.
2026-01-06 13:03:41 +01:00
Lorenz A
48f08ba09d LibWeb: Bump dom tree version to invalid cache on select select_options 2026-01-06 13:03:41 +01:00
Lorenz A
3e296a1b92 LibWeb: Mirror options collection on the select element 2026-01-06 13:03:41 +01:00
Tim Ledbetter
584e0996c9 LibWeb: Store color as a StyleValue in FilterOperation::DropShadow 2026-01-06 12:13:13 +01:00
Shannon Booth
8a8383d59d LibWeb/HTML: Invalidate frozen ports array on initMessageEvent
In the case that initMessageEvent is called (even with the same
ports), we should return a new array object. This fixes an issue
where the cached m_ports_array was not cleared, causing the
attribute to return the old object identity.
2026-01-06 11:49:06 +01:00
InvalidUsernameException
831cecd644 LibJS+LibWeb: Add missing visits for cached cross-origin properties
This was causing GC-related crashes on various websites, most
prominently on any site that contains embedded YouTube videos. The issue
can be reproduced by going to any YouTube video, using the _Share_
button below it and pasting the embed code into an empty HTML file and
loading it through localhost.

This is technically a regression from
89dbdd3411 in that the problem became
visible with that commit. However, there is nothing wrong with the
commit by itself. It just happens that `Origin::is_same_origin_domain()`
prior to that commit was completely bogus and would mistakenly return
true in almost all cases, so the cross-origin code paths were not
exercised.

I am uncertain how to make a automatic test case for this problem, given
the nature of it being GC- and cross-origin-related. So there is no
regression test included in this commit.
2026-01-06 00:01:01 +01:00
Luke Wilde
2058c05d50 LibGfx: Create Gfx::Bitmap for PaintingSurface in ImmutableBitmap 2026-01-05 15:56:15 +01:00
Callum Law
79740b04b3 LibWeb: Don't generate layer for background-image none entry
Reduces the time spent in `background_layers()` from 1.5% to 0.04% when
loading https://en.wikipedia.org/wiki/2023_in_American_television
2026-01-05 11:35:26 +00:00
Jonathan Gamble
7385569a02 LibWeb: Selection toString focused text control delegation
Allows selected text in form controls to be copied to clipboard.
2026-01-02 18:40:05 +01:00
R-Goc
15cb3e872e LibWeb: Use static cast to cast from base class
It is not guaranteed that inherited classes have the same address as the
base of the derived class. In that case a reinterpret cast leads to
undefined behavior. This occured on msvc ABI. See:
https://godbolt.org/z/jGeEW3c48

Co-authored-by: ayeteadoe <ayeteadoe@gmail.com>
2026-01-01 12:23:15 +01:00
Shannon Booth
f9a996650b LibWeb/HTML: Implement the Origin interface
See: https://github.com/whatwg/html/commit/68909b2
2025-12-30 12:40:27 +01:00
Jonathan Gamble
f6f4d7f497 LibWeb: Move <input> handle_return_key logic to HTMLInputElement 2025-12-29 19:59:42 +01:00
Jonathan Gamble
e39f73f978 LibWeb: Fix tofu in textarea newlines on MacOS
Do not insert the codepoint from the platform event. Always insert 10
2025-12-29 19:59:42 +01:00
Shannon Booth
2a8b83a568 LibWeb/WebIDL: Upgrade QuotaExceededError to its own interface
See https://github.com/whatwg/webidl/commit/48eba6d
2025-12-29 17:15:11 +01:00
Tete17
fdb01e7f93 LibWeb: Add the Crypto task source
This is used by the spec to queue tasks to resolve or reject promises
created in response to calls to methods of SubtleCrypto.
2025-12-28 18:56:50 +01:00
Aliaksandr Kalenik
9a2931527a LibWeb: Use ConservativeVector in get_session_history_entries()
This way we ensure doc states traversal queue elements are visited.
2025-12-27 18:40:21 +01:00
Aliaksandr Kalenik
38af5d623c LibWeb: Avoid shifting vector elements in get_session_history_entries()
This function essentially performs a BFS traversal over document states.
With this change, we let `doc_states` grow instead of removing traversed
states, avoiding shifting elements on every iteration.

This reduces `./test-web -j 1` from ~7m to ~5m on my machine.
2025-12-27 18:40:21 +01:00
Andreas Kling
207d82f8bc LibWeb: Actually protect buffer in create_bitmap_from_bitmap_data()
We were capturing a copy of the ByteBuffer instead of moving it into the
closure.
2025-12-27 16:40:34 +01:00
Andreas Kling
ade167ed33 LibWeb: Always return task's ID after adding to a queue (or not)
Now that we don't always honor requests to add tasks to a queue, we
can't rely on "last added task" as the place to find the task's ID.
Fortunately we can just get it from the task itself.
2025-12-27 16:40:34 +01:00
Andreas Kling
418a243c04 LibWeb: Don't run tasks in documents that haven't been BC associated
Documents that have never been associated with a browsing context will
never become "fully active" so we shouldn't schedule tasks in them since
they'll never run.
2025-12-27 16:40:34 +01:00
Andreas Kling
7bc07662be LibWeb: Ignore HTML tasks enqueued in document used for fragment parsing
The inert temporary documents used for fragment parsing will never
become "fully active" and so any tasks associated with them will never
run. To avoid memory leaks, we now simply ignore any attempts to enqueue
tasks associated with such documents.
2025-12-27 16:40:34 +01:00
Aliaksandr Kalenik
f6a7df78e7 LibWeb: Add missing GC visits for XHR::FormDataEntry
3a6782689 fix up that changes `Vector<XHR::FormDataEntry>` to
`GC::ConservativeVector<XHR::FormDataEntry>`.
2025-12-26 19:48:46 +01:00
Tim Ledbetter
70671b4c11 Revert "LibWeb/HTML: Return Promises from Window scroll methods"
This reverts commit a610639119.
2025-12-26 19:33:51 +01:00
Andreas Kling
3a6782689f LibWeb: Don't use GC::Root in FormDataEntryValue variant
This was causing reference cycles and leaking entire realms.
2025-12-26 11:57:00 +01:00
Aliaksandr Kalenik
b5bb0ef5d4 LibWeb: Use GC::Weak in BroadcastChannelRepository
Previously `BroadcastChannelRepository` held strong references to
`BroadcastChannel` instances, which is removed only after `close()` on
corresponding `BroadcastChannel` was called, which might never happen.

This would have to be revisited once we will implement broadcast
channels messaging across different WebContent processes, but for now
using weak references in the repository saves us from leaking all
unclosed `BroadcastChannel`s.
2025-12-26 06:17:01 +01:00
Andreas Kling
9a5c648b2f LibWeb: Use weak references in the custom elements reaction stack 2025-12-25 20:21:37 +01:00
Andreas Kling
aa9c478ee9 LibWeb: Don't leak the about-to-be-notified rejected promises list
Use GC::HeapVector instead of Vector<GC::Root> to prevent this list from
creating reference cycles and leaking the world.
2025-12-25 20:21:37 +01:00
Andreas Kling
f64b0e0351 LibWeb: Avoid GC::Root capture in check_if_unloading_is_canceled()
We never want to capture GC::Roots in GC::Function lambdas, since that
very easily creates reference cycles and leak huge object graphs.
Capturing a raw pointer or GC::Ptr/Ref is fine, since that's exactly
what GC::Function is good at.
2025-12-24 10:19:28 +01:00
Andreas Kling
1640b7957c LibWeb: Don't use GC::Root for 2D canvas fill/stroke styles
Using GC::Roots here was causing a reference cycle and leaking the world
whenever gradients or patterns were used on a 2D canvas.
2025-12-24 10:19:28 +01:00
Andreas Kling
52da7b649b LibWeb: Move vector of navigables in check_if_unloading_is_canceled
If we copy instead of move, the GC::Root source locations get
overwritten and we can't tell from a heap dump who created the roots.

(And it's also more efficient to move instead of copy ofc.)
2025-12-24 10:19:28 +01:00
Aliaksandr Kalenik
8af78cff30 LibWeb: Skip scroll promise allocation in mouse event handling
Fixes crashing introduced in a610639 when `scroll_viewport_by_delta()`
is called from `EventHandler::handle_mousewheel()` and there's no
running execution context to grab current realm from to allocate a
promise.
2025-12-23 17:36:48 +01:00
Sam Atkins
a610639119 LibWeb/HTML: Return Promises from Window scroll methods
Corresponds to part of:
c548a9a1d4
2025-12-23 14:24:28 +01:00
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