73242 Commits

Author SHA1 Message Date
Timothy Flynn
0480934afb LibHTTP+LibWeb: Remove unused HTTP::HTTPResponse
The only thing in HTTPResponse being used is reason_phrase_for_code,
which is just a static helper method. Move it to its own file and remove
HTTPResponse.

This is just one less thing to have to port to an upcoming HTTP header
refactor.
2025-11-27 14:57:29 +01:00
Timothy Flynn
bf75f52ce0 UI/AppKit: Store the original key-down event for WebContent processing
When a shortcut is an alternative key, macOS first fires a key event for
the primary key. Then if it is not handled, it fires an event for the
alternative key. For example, we see these two events in a row when we
press cmd and =/+:

    NSEvent: type=KeyDown flags=0x100108 chars="=" keyCode=25
    NSEvent: type=KeyDown flags=0x100108 chars="+" keyCode=24

For dead key processing, we don't handle these events right away. By the
time we get to doCommandBySelector, when we call [NSApp currentEvent],
we see the following events:

    NSEvent: type=KeyDown flags=0x100108 chars="=" keyCode=24
    NSEvent: type=AppDefined flags=0

The AppDefined event is internally posted by our event loop. So it seems
we cannot rely on currentEvent being the key-down event we are looking
for.

Instead, we can store the key-down event that we last saw.
2025-11-27 13:51:45 +00:00
aplefull
934817d45e LibRegex: Add missing StringSet cases 2025-11-27 14:02:04 +01:00
Rocco Corsi
0738be817b Documentation: Correct small typo in AdvancedBuildInstructions 2025-11-27 07:21:34 -05:00
Sam Atkins
936c7f05df LibWeb/HTML: Account for User-Agent not starting with "Mozilla/"
Corresponds to:
a93c6fa9fa
2025-11-27 07:20:32 -05:00
Sam Atkins
37d0741099 LibWeb/HTML: Implement HTMLTemplateElement.content to spec
No real behaviour change - it just means we VERIFY before returning the
value we returned before.
2025-11-27 10:26:13 +00:00
Sam Atkins
a25cb679fb LibWeb/HTML: Update spec text related to template's content
Corresponds to:
aa52274b5a
2025-11-27 10:26:13 +00:00
Jelle Raaijmakers
39ad7833f0 LibWeb: Do not render SVG <symbol> elements unless part of <use>
We were always rendering <symbol> SVG elements, but we should only
render them if they are a child of a <use>'s shadow root. This caused
practically all instances of <symbol> to be drawn at least one time too
many.
2025-11-27 07:55:29 +01:00
Jelle Raaijmakers
632854d870 LibWeb: Move qualified_name in SVGUseElement constructor 2025-11-27 07:55:29 +01:00
Jelle Raaijmakers
df3d68f849 LibWeb: Remove unused ::inserted() override from SVGUseElement 2025-11-27 07:55:29 +01:00
Jelle Raaijmakers
9b1ee8f3e2 LibWeb: Remove unused includes from SVGSymbolElement.cpp 2025-11-27 07:55:29 +01:00
Tim Ledbetter
cfce5dc970 LibJS: Add fast path for loosely comparing object and nullish values 2025-11-26 22:03:31 -05:00
Tete17
5e736d4e07 LibWeb: Expose SHA3 hashing algorithm through WebCryptoAPI
This give us 48 WPT subtests :)
2025-11-26 22:01:00 -05:00
Tete17
0786486aa2 LibCrypto: SHA3 hashing algorithm 2025-11-26 22:01:00 -05:00
Timothy Flynn
7b0dfa61b1 LibWeb: Do not move header name/values that are re-used
Fixes a regression from commit:
f675cfe90f
2025-11-26 21:22:35 -05:00
Timothy Flynn
cbfae97101 LibWeb: Include empty header values when joining duplicated headers
Fixes a regression from commit:
f675cfe90f

It is not sufficient to only check if the builder is empty, as we will
then drop empty header values (when the first found value is empty).

This is tested in WPT by /cors/origin.htm, but that requires an HTTP
server.
2025-11-26 21:22:35 -05:00
Timothy Flynn
00070455fd LibWeb: Parse the correct header list for CSP-Report-Only
Fixes a regression from a copy-paste mistake in commit:
ed27eea091

The regressed CSP tests aren't able to be imported, unfortunately. They
do not work with the file-based test-web infra.
2025-11-26 21:22:35 -05:00
Psychpsyo
693dd7b6f6 LibWeb: Avoid unnecessary sorting work when getting animations
Some checks failed
Close stale PRs / stale (push) Has been cancelled
Package the js repl as a binary artifact / Linux, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / macOS, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / Linux, x86_64 (push) Has been cancelled
Label PRs with merge conflicts / auto-labeler (push) Has been cancelled
Nightly Lagom / Linux, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / Linux, arm64, Sanitizer, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Distribution, GNU (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Windows, x86_64, Windows_Sanitizer_CI, ClangCL (push) Has been cancelled
Nightly Lagom / Flatpak aarch64 (push) Has been cancelled
Nightly Lagom / Flatpak x86_64 (push) Has been cancelled
This way, the list is not re-sorted on every recursive call.
2025-11-26 22:19:23 +01:00
Tim Ledbetter
1abc91ccc6 LibRegex: Put debug mode code block behind a flag
This block should be optimized out anyway, but putting the whole thing
behind a flag makes the intent clearer.
2025-11-26 14:33:59 +00:00
Tim Ledbetter
4c491b8920 LibRegex: Remove unused code from RegexStringView 2025-11-26 14:33:59 +00:00
Tim Ledbetter
061b457bac LibRegex: Use unchecked_empend() where possible 2025-11-26 14:33:59 +00:00
Tim Ledbetter
c1742fa989 AK: Introduce Vector::unchecked_empend()
This does the same thing as `Vector::empend()` without attempting to
grow the underlying buffer.
2025-11-26 14:33:59 +00:00
Timothy Flynn
f675cfe90f LibWeb: Store HTTP methods and headers as ByteString
The spec declares these as a byte sequence, which we then implemented as
a ByteBuffer. This has become pretty awkward to deal with, as evidenced
by the plethora of `MUST(ByteBuffer::copy(...))` and `.bytes()` calls
everywhere inside Fetch. We would then treat the bytes as a string
anyways by wrapping them in StringView everywhere.

We now store these as a ByteString. This is more comfortable to deal
with, and we no longer need to continually copy underlying storage (as
ByteString is ref-counted).

This work is largely preparatory for an upcoming HTTP header refactor.
2025-11-26 09:15:06 -05:00
Timothy Flynn
ed27eea091 LibWeb: Do not copy the result of HeaderList::extract_header_list_values
There's no need to copy the Vector out of this result every time we call
it. We can move it out or access it directly.
2025-11-26 09:15:06 -05:00
Timothy Flynn
44fbf6451e LibWeb: Simplify Fetch's build-content-range implementation
* Don't pass u64 by reference
* Don't double-format the range numbers
2025-11-26 09:15:06 -05:00
Timothy Flynn
d70224ad2e LibWeb: Organize Fetch Headers.h/Headers.cpp a bit
Generally just define things in the order they are declared (will make a
change to use ByteString in this file a bit easier to follow). Also make
a couple of free functions be class methods on Header / HeaderList.
2025-11-26 09:15:06 -05:00
Timothy Flynn
556364fd76 LibWeb: Remove unused LoadRequest facilities
We could probably do with removing LoadRequest altogether. But this just
removes unused methods for now to make an upcoming HTTP header change a
bit simpler.
2025-11-26 09:15:06 -05:00
Prajjwal
1f5ffe04c8 LibWeb: Fix race condition between read_all_bytes and stream population
There might be a race between read_all_bytes and stream population.
If document load reads stream before it is populated, the stream will
be empty and might lead to hang in SessionHistoryTraversalQueue which
is expecting a promise to be resolved on document load.

This race can occur when stream population and document source are set
very close to each other. For example, when a newly generated blob is
set as the source of an iframe.
- navigation/multiple-navigable-cross-document-navigation.html has been
modified to trigger this race.
2025-11-26 12:27:12 +01:00
Prajjwal
50a79c6af8 LibWeb: Change SessionHistoryTraversalQueue to use Promises
If multiple cross-document navigations are queued on
SessionHistoryTraversalQueue, running the next entry before the current
document load is finished may result in a deadlock. If the new document
has a navigable element of its own, it will append steps to SHTQ and
hang in nested spin_until.
This change uses promises to ensure that the current document loads
before the next entry is executed.

Fixes timeouts in the imported tests.

Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-11-26 12:27:12 +01:00
aplefull
eed4dd3745 LibRegex: Add support for string literals in character classes 2025-11-26 11:34:38 +01:00
aplefull
a49c39de32 LibRegex: Support matching unicode multi-character sequences 2025-11-26 11:34:38 +01:00
SvDp
5b7c9af340 UI/AppKit: Auto-focus location bar when opening new tabs on macOS
When a new tab is created, the location bar should automatically
receive keyboard focus so users can immediately start typing a URL.
However, the onURLChange callback was stealing focus back to the
web view when loading the new tab page.

This fix:
1. Calls focusLocationToolbarItem when activating a new tab
2. Prevents onURLChange from stealing focus when loading the new
   tab page URL

Fixes #1512
2025-11-26 10:47:37 +01:00
Sam Atkins
aac387bcc6 LibWeb/DOM: Copy "allow declarative shadow roots" to template document
This flag defaults to false for new Documents, such as the one created
here for use by template elements' contents. Without setting it to
true, nothing inside a template can have a declarative shadow dom.

As noted, this appears to be a spec issue. I am not convinced that this
is the correct fix, but it is simple and does solve the issue without
any apparent regressions.
2025-11-26 09:52:47 +01:00
Sam Atkins
8ca4833885 LibWeb/HTML: Update spec text in create_element_for()
No behaviour changes.
2025-11-26 09:52:47 +01:00
Sam Atkins
6e2f8166f4 LibWeb/HTML: Combine duplicate parsing branches
These are combined in the current spec. No behaviour change.
2025-11-26 09:52:47 +01:00
Sam Atkins
91e73ecde1 LibWeb/DOM: Stop early-out of assigning slottables when root is a slot
This would happen for example when removing a slot element from the DOM,
in which case it would keep its old list of assigned slottables even
though it now has none. Fixes a couple of WPT tests.
2025-11-26 09:52:47 +01:00
Sam Atkins
4f4e94dc9c LibWeb/DOM: Update spec steps for Node::remove()
No behaviour changes.
2025-11-26 09:52:47 +01:00
Sam Atkins
6a4ab26b48 LibWeb/HTML: Return early from find_appropriate_place_for_inserting_node
Step 2.(a).5 says to abort, but we were instead carrying on and would
run steps 3 and 4. Those steps would not change the result at all, but
this avoids a little unnecessary work.

I wrapped a couple of comments at 120 columns while I was at it.
2025-11-26 09:52:47 +01:00
Sam Atkins
418e22d65a LibWeb/HTML: Bring hand_in_head in HTML parser more up to date
A couple of spec text changes I noticed, and use `has_attribute()`
instead of manually checking it.
2025-11-26 09:52:47 +01:00
Sam Atkins
dde1560dd9 Tests: Import some declarative shadow dom tests 2025-11-26 09:52:47 +01:00
Tim Ledbetter
7ce103b96a LibJS: Demote VERIFY to ASSERT in JS value casting functions
This yields a ~3% performance increase across the board in JS
benchmarks.
2025-11-26 09:38:00 +01:00
Jelle Raaijmakers
3b7eede694 LibGfx: Report premultiplied alpha type for opaque Skia surfaces
We don't discern between opaque and non-opaque alpha types in LibGfx,
which at some point we might need to do. But for now, assume all opaque
Skia surfaces have premultiplied alpha.

Fixes #6892.
2025-11-26 09:24:38 +01:00
Zaggy1024
6790a695da Tests: Wait for PulseAudio context destruction in TestPlaybackStream
The stream was being kept alive until the moment before we check if the
context is still alive. The stream's control thread holds a reference
to the PulseAudioContext, so that should almost never be destroyed
before the VERIFY in the test. Instead, wait at most 100ms for it to be
destroyed.
2025-11-25 13:13:32 -06:00
Aliaksandr Kalenik
69cede4a0f AK+LibWeb: Make StringBase::bytes() lvalue-only
Disallow calling `StringBase::bytes()` on temporaries to avoid returning
`ReadonlyBytes` that outlive the underlying string.

With this change, we catch a real UAF:
`load_result.data = maybe_response.release_value().bytes();`
All other updated call sites were already safe, they just needed to use
an intermediate named variable to satisfy the new lvalue-only
requirement.
2025-11-25 13:02:20 -05:00
Aliaksandr Kalenik
d1f34efa64 LibWeb: Avoid whole DOM traversal in document_tree_child_navigables()
Instead, iterate through all registered navigables and pick the ones
that belong to document's tree, preserving tree order.
2025-11-25 09:16:17 +01:00
Aliaksandr Kalenik
4c22c372a4 LibWeb: Avoid full DOM tree traversal in Window::named_objects()
Instead, take advantage of `ElementByIdMap` and
`m_potentially_named_elements` to gather elements with specified name
more efficiently.
2025-11-25 09:16:17 +01:00
Aliaksandr Kalenik
e80d1bcee7 LibWeb: Avoid full DOM tree traversal in supported_property_names()
Instead, take advantage of `ElementByIdMap` and
`m_potentially_named_elements` to gather named elements more
efficiently.
2025-11-25 09:16:17 +01:00
dependabot[bot]
5fa3b48a57 CI: Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-25 08:44:55 +01:00
Tim Ledbetter
e20e79e7a5 LibJS: Demote VERIFY in ThrowCompletionOr() to ASSERT
This improves JetStream performance by ~16% on my machine.
2025-11-25 08:38:23 +01:00
Zaggy1024
fab987d937 LibMedia: Ensure that PulseAudioContext's atexit() is only called once
Some checks failed
Close stale PRs / stale (push) Has been cancelled
Package the js repl as a binary artifact / Linux, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / macOS, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / Linux, x86_64 (push) Has been cancelled
Label PRs with merge conflicts / auto-labeler (push) Has been cancelled
Nightly Lagom / Linux, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / Linux, arm64, Sanitizer, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Distribution, GNU (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Windows, x86_64, Windows_Sanitizer_CI, ClangCL (push) Has been cancelled
Nightly Lagom / Flatpak aarch64 (push) Has been cancelled
Nightly Lagom / Flatpak x86_64 (push) Has been cancelled
2025-11-24 15:09:34 -06:00