Commit Graph

73682 Commits

Author SHA1 Message Date
Shannon Booth
c12f21498c LibWeb: Support implicit downcast to DOMException in ExceptionOr 2025-12-29 17:15:11 +01:00
Callum Law
cbd07b2153 LibWeb: Don't mark whether shorthand properties are inherited
Inheritance applies to longhands individually so whether a shorthand was
marked as inherit or not is irrelevant
2025-12-29 16:11:13 +01:00
Callum Law
e79644bf6b LibWeb: Mark scrollbar-color property as inherited 2025-12-29 16:11:13 +01:00
Jacob M Hunter
51114d12fb Documentation: Fix typos in build instructions 2025-12-29 09:02:34 -05:00
Andreas Kling
3ee80b23d3 LibJS: Store full realized SourceRange with each AST node
We were spending way too much time converting unrealized source ranges
into line/column pairs on real web content.

This improves JS parsing speed on x.com by 1.13x
2025-12-29 13:36:01 +01:00
Aliaksandr Kalenik
711100e3b7 LibJS: Avoid unnecessary NewArray in yield* iterator method calls
Use `Op::Call` directly instead of creating a single-element array and
using `CallWithArgumentArray` when calling iterator methods (`next`,
`throw`, `return`) in `yield*` expressions.
2025-12-28 19:12:15 +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
Tete17
305e9c1b0f LibWeb: Implement decapsulateBits for SubtleCrypto 2025-12-28 18:56:50 +01:00
Tete17
c9b8b4557d LibWeb: Implement decapsulateKey for SubtleCrypto 2025-12-28 18:56:50 +01:00
Aliaksandr Kalenik
ebcf85f6e8 LibWeb: Lowercase attribute only once in NamedNodeMap::get_attribute()
...instead of doing it on every iteration.

This function is hot in profiles on github.com landing page (invoked
through `for_each_matching_attribute()`), so this helps a bit.
2025-12-28 14:11:36 +00:00
breakgimme
4f74ced414 LibWeb: Make User-Agent updates apply to HTTP requests on reload 2025-12-28 09:11:13 -05:00
Aliaksandr Kalenik
763d638353 LibGC: Fix incorrect &cell key in GraphConstructorVisitor 2025-12-27 19:06:56 +01:00
Aliaksandr Kalenik
c26c9a9e45 LibGC: Skip not live cells in GraphConstructorVisitor
Makes `GraphConstructorVisitor` consistent with `MarkingVisitor`.
2025-12-27 19:06:56 +01:00
Aliaksandr Kalenik
ed58f85b75 LibGC: Introduce separate GC root type for "must survive GC" cells
This way `GraphConstructorVisitor` is aware of `MustSurviveGC` roots and
could include them in a dump.
2025-12-27 19:06:56 +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
692368696f LibWeb: Use the WEB_SET_PROTOTYPE_FOR_INTERFACE pattern consistently 2025-12-27 16:40:34 +01:00
Andreas Kling
0949d4d193 LibWeb: Make PseudoElementTreeNode protect its tree pointers from GC 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
Andreas Kling
f12f72f139 LibWeb: Don't associate mutation observer microtask with a document
The microtask is conceptually global and fires pending observers at the
agent level. As such, it doesn't make sense for it to be associated with
any specific document.
2025-12-27 16:40:34 +01:00
Aliaksandr Kalenik
a3a00b0658 LibWeb/IndexedDB: Use GC::Weak for Database in "database registry"
This way databases are allowed to be GC'ed when there are no open
connections to them.

As a side effect, databases are no longer kept alive for the duration of
a browsing session. This will be addressed once IndexedDB gets proper
on-disk persistence. For now, avoiding memory leaks is the better
trade-off.

With this change the number of live `Window` objects in GC graph
captured by `test-web -j 1 --dump-gc-graph` goes down from 50 to 25.
2025-12-27 16:25:51 +01:00
Undefine
f27847274c Meta: Correctly bootstrap vcpkg on musl libc systems 2025-12-26 14:13:55 -07: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
Aliaksandr Kalenik
64f91c41d9 LibGC: Allow construction of ConservativeVector from Vector 2025-12-26 19:48:46 +01:00
Aliaksandr Kalenik
bfd9658181 LibGC: Add handling for ConservativeVector in dump() 2025-12-26 19:48:46 +01:00
Aliaksandr Kalenik
45c22b0313 LibGC: Implement copy assignment operator for ConservativeVector
- Delete defined but not implemented
  `ConservativeVectorBase& operator=(ConservativeVectorBase const&);`
- Mark `ConservativeVectorBase` as non-copyable because underlying
  `m_list_node` cannot be copied safely.
- Change `ConservativeVector` copy assignment to simply copy elements
  from one vector to another, since we don't have to worry about
  `ConservativeVectorBase` while copying.
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
Tim Ledbetter
cacadc8806 Revert "LibWeb/HTML: Return Promises from Element scroll methods"
This reverts commit 3a7fcde341.
2025-12-26 19:33:51 +01:00
Jani Hautakangas
95ba98785b Meta/CMake: Avoid -march=native when cross-compiling
The introduction of ENABLE_CI_BASELINE_CPU made -march=native
the default for non-CI builds. This breaks cross-compilation
with Clang, where native CPU detection is explicitly unsupported
when a target triple is set.

Guard the use of -march=native behind NOT CMAKE_CROSSCOMPILING
so native tuning is only applied for true host builds, while
cross builds continue to use the toolchain defaults.
2025-12-26 13:40:03 +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
Andreas Kling
e2d5802942 LibJS: Don't capture CSS::FontFace in GC::Root while loading fonts
This prevents a reference cycle that was leaking entire realms on
test-web.
2025-12-26 11:57:00 +01:00
Andreas Kling
2d2078d439 LibWeb: Don't store GC::Root<JS::ArrayBuffer> in FileAPI::FileReader
This was creating a reference cycle and leaking the realm.
2025-12-26 11:57:00 +01:00
Aliaksandr Kalenik
b291d75289 LibWeb/IndexedDB: Use GC::Weak in RequestList
By doing this we allow unclosed `IDBRequest`s to be GC-ed, instead of
keeping them alive forever in the `RequestList`.
2025-12-26 06:17:01 +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
ce0a16d11c LibJS: Simplify how we know which builtin a FunctionObject represents
Instead of storing a list of builtin function objects with the realm,
just move the builtin field from NativeFunction up to FunctionObject.

Now you can ask any FunctionObject for its builtin(), and we no longer
need the get_builtin_value() API.

Fixes 10 test262 tests that were querying the realm builtins at a
bad time.

Regressed in 54b755126c.
2025-12-25 23:59:21 +01:00
Andreas Kling
df88938b61 LibJS: Propagate function length etc to new Function objects
Fixes 12 test262 tests.

Regressed in 63eccc5640.
2025-12-25 23:59:21 +01:00
Andreas Kling
b6bd38c55d AK+LibJS: Make SinglyLinkedList::remove() return a new iterator
This fixes an issue where the iterator could be in a bad state after
removing something from the list.

The behavior is also more idiomatic in general.
2025-12-25 20:21:37 +01:00
Andreas Kling
da42846d84 AK: Make DoublyLinkedList::remove(Iterator) return Iterator for next
This allows continuing iteration after a removal.
2025-12-25 20:21:37 +01:00
Andreas Kling
72886c4999 LibJS: Don't iterate finalization registry cleanup jobs in silly way
Pop jobs from the end of the vector instead of from the front. This
avoids shifting all the memory around. Also use GC::Ref instead of Ptr.
2025-12-25 20:21:37 +01:00
Andreas Kling
2d29ca7e59 LibGC: Dump GC block allocator stats before running post-GC tasks
Post-GC tasks may trigger another GC, and things got very confusing
when that happened. Just dump all stats before running tasks.

Also add a separate Heap function to run these tasks. This makes
backtraces much easier to understand.
2025-12-25 20:21:37 +01:00
Andreas Kling
0504fffe6b LibJS: Don't unregister WeakRef during finalization phase
This "optimization" was not safe as it caused the ongoing iteration
of GC::Heap's weak container list to end immediately.
2025-12-25 20:21:37 +01:00
Andreas Kling
2a4a8a15f5 LibGC: Make must_survive_garbage_collection() actually work
This had two fatal bugs:

1. We didn't actually mark the cell that must survive GC, we only
   visited its edges.

2. Worse, we didn't actually mark anything at all! We just added
   cells to MarkingVisitor's work queue, but this happened after
   the work queue had already been processed.

This commit fixes these issues by moving the "must survive" pass
earlier in the mark phase.
2025-12-25 20:21:37 +01:00
Andreas Kling
d1e8189f3f LibWeb: Make WebIDL::property_to_callback() return GC::Ptr
...instead of GC::Root. The roots were causing reference cycles
somewhere, and there was no need for them to be roots.
2025-12-25 20:21:37 +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
0ac48b6e08 LibGC: Add GC::HeapVector<T>, a fully GC-aware vector container
HeapVector inherits from GC::Cell, and thus participates in tracing
garbage collection. It's not a standalone vector of roots like
RootVector or ConservativeVector. It must be marked for its elements to
be marked.
2025-12-25 20:21:37 +01:00
InvalidUsernameException
5b4341996b LibWeb: Align table-fixup algorithm with spec
While this is likely a slight behavioral change, WPT tests are not
affected by this as far as I could find.
2025-12-24 14:10:27 +01:00