Commit graph

64819 commits

Author SHA1 Message Date
Timothy Flynn
c3dfef3861 AK: Allow creating a JsonArray with an initial size 2024-11-03 17:51:58 +01:00
Andreas Kling
88a4a86ece Tests: Import many HTML parsing tests from WPT
I had to skip a lot of these due to assertion failures that we need to
investigate before unskipping.
2024-11-03 17:51:44 +01:00
Andreas Kling
102cf345ba LibWeb: Recompute targetStep once more in "apply the history step"
This is an ad-hoc change to account for the fact that we may run
arbitrary code while waiting for the tasks in this function to complete.

Same exact idea as ac48222ed7, once again.
2024-11-03 17:51:44 +01:00
Andreas Kling
b82e34ed00 LibWeb: Flesh out the "in frameset" parsing state and add spec comments
This also implements two FIXMEs, which were covered by WPT tests.
2024-11-03 17:51:44 +01:00
Andreas Kling
ecc9fdf377 LibWeb: Fix incomplete assertion in the "in body" parsing state
We were incorrectly tripping an assertion failure on some WPT tests.
2024-11-03 17:51:44 +01:00
Andreas Kling
40ac3cc2c8 LibWeb: Implement HTML frameset parsing in the "in body" state
Covered by many WPT parsing tests, which will be imported.
2024-11-03 17:51:44 +01:00
Andreas Kling
cfa820922b LibWeb: Bail nicely on EOF in HTML parser "in body" state
If we reach the end of the token stream when "ignoring and moving on
to the next token" in the "in body" state, we should just not move
on to the next token, since there isn't one.

Covered by various WPT HTML parsing tests that will be imported in
a subsequent commit.
2024-11-03 17:51:44 +01:00
Gingeh
c2cd191864 LibWeb: Use machine epsilon when approximating cubic bezier 2024-11-03 17:35:20 +01:00
BenJilks
9395b266c6 LibWeb: Support vertical text hit detection and selection
If a PaintableFragment has a vertical orientation, use y instead of x to
compute the offset of each character in the text fragment.
2024-11-03 17:01:54 +01:00
BenJilks
02276360e9 LibWeb: Draw text vertically, for fragments with vertical writing-mode
For fragments with a vertical `writing-mode`. Rotate the text, so that
it is rendered on its side. This makes it fit into its layout box.
2024-11-03 17:01:54 +01:00
BenJilks
80e7e6dd7d LibWeb: Layout inline elements respective of writing-mode
Use the `writing-mode` property to determine what values should be used
for computing each element's rect on the screen. If it is a vertical
mode, swap the inline and block, lengths and offsets.

This only lays out whole inline formatting contexts vertically, and does
not currently support mixing the two orientations in a single context.
2024-11-03 17:01:54 +01:00
BenJilks
ede9012723 LibWeb: Make inline layout independent of direction
This patch separates the notion of x, y, width, and height, from
inline_offset, block_offset, inline_length, and block_length.
These can then be used to compute the final screen positions,
in respect of the desired layout direction. This is the terminology
used in https://drafts.csswg.org/css-writing-modes/#text-flow

This makes it possible to use this layout algorithm to flow
text in any direction. For example, vertically.
2024-11-03 17:01:54 +01:00
BenJilks
c3f3e93b7e LibWeb: Add writing-mode CSS property, and its values
Introduce the `writing-mode` property, as specified in
https://drafts.csswg.org/css-writing-modes/#block-flow
2024-11-03 17:01:54 +01:00
Jonne Ransijn
755b83c01a LibJS: Implement tc39/proposal-atomics-microwait (Atomics.pause)
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Implements the https://github.com/tc39/proposal-atomics-microwait
proposal which has recently hit Stage 3.

This commit passes all relevant tests in `test262`.
2024-11-03 08:05:58 -05:00
Shannon Booth
01c2ecf355 LibJS: Update comments for WrappedFunction [[Call]] implementation 2024-11-03 07:41:49 -05:00
Shannon Booth
b5536db915 LibJS: Return void from SetDefaultGlobalBindings
Aligning with spec change:

https://github.com/tc39/ecma262/commit/052def
2024-11-03 07:41:49 -05:00
Shannon Booth
0a1c9e4038 LibJS: Inline somes AO's into InitializeHostDefinedRealm
Aligning with the editorial change in the spec of:

https://github.com/tc39/ecma262/commit/977a6c
2024-11-03 07:41:49 -05:00
Jonne Ransijn
f4e2476284 LibJS: Remember the position into the cached indices
There is no need to do a full linear search from start to end when
we can just remember the position and continue where we left off.
2024-11-03 11:26:23 +01:00
Aliaksandr Kalenik
2bd43e3603 LibWeb: Remove save() call in DisplayListPlayerSkia::add_mask()
This save() call did not have matching restore(). For mask application
it's display list builder responsibility to emit save() and restore()
so mask is applied only to relevant portion.

Progress on https://www.jetbrains.com/
2024-11-03 11:25:01 +01:00
rmg-x
c042971293 LibRequests+LibWeb: Propagate HTTP reason phrase
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-11-02 21:05:07 +01:00
rmg-x
79046c73da RequestServer: Extract HTTP reason phrase from headers 2024-11-02 21:05:07 +01:00
Pavel Shliak
dcf8f2a31d LibGfx: Respect unpremultiplied alpha for JPEG XL 2024-11-02 18:48:35 +01:00
Timothy Flynn
13b7355ec1 LibWeb: Move some classes from the DOM namespace to the HTML namespace
The following classes are in the HTML spec and thus belong in the HTML
namespace:

* BeforeUnloadEvent
* HTMLFormControlsCollection
* RadioNodeList
2024-11-02 11:16:45 -04:00
Jonne Ransijn
69f96122b6 LibJS+LibWeb: Prevent double invocation of [[GetOwnProperty]]
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
The `[[GetOwnProperty]]` internal method invocation in
`OrdinarySetWithOwnDescriptor` was being invocated again with the same
parameters in the `[[DefineOwnProperty]]` internal method that is also
later called in `OrdinarySetWithOwnDescriptor`.

The `PlatformObject.[[DefineOwnProperty]]` has similair logic.

This change adds an optional parameter to the `[[DefineOwnProperty]]`
internal method so the results of the previous `[[GetOwnProperty]]`
internal method invocation can be re-used.
2024-11-02 12:27:02 +01:00
Jonne Ransijn
641c549463 LibJS: Split Call Instruction by CallType
Instead of branching on the `CallType` at runtime in a hot
instruction like `Call`, lets emit separate instructions
for each call type during codegen.
2024-11-02 11:15:58 +01:00
Jonne Ransijn
80f0900565 LibJS: Share argument values buffer between calls
This buffer is being created and then immediately destroyed,
let's reuse it to reduce memory allocations.
2024-11-02 11:15:58 +01:00
Timothy Flynn
f16eebb95c WebContent: Begin handling user prompts asynchronously
We have to handle user prompts during the exection of most WebDriver
endpoints. Of the ~50 endpoints which call this AO, ~20 are currently
currently async and handled here.
2024-11-02 11:09:41 +01:00
Timothy Flynn
5515cb56e8 WebContent: Deprecate the curent implementation of handling user prompts
There are approximately 1000 WPT subtests that rely on the handling of
user prompts being completely asynchronous. It will take a bit of elbow
grease to make all of our WebDriver endpoints comply with this. So for
now, we will deprecate the currently synchronous implementation, and a
future patch will implement an asynchronous version that already-async
endpoints can use.
2024-11-02 11:09:41 +01:00
Timothy Flynn
9dc1302768 WebContent+WebDriver: Consolidate driver execution completion callbacks
Some WebDriver hooks will need to inform the client that execution has
completed, but without any knowledge of what endpoint was running. Since
there can only ever be a single WebDriver endpoint executing at once, we
can replace the completion callbacks with a single callback.
2024-11-02 11:09:41 +01:00
Timothy Flynn
1be67faab7 LibWeb+WebContent: Handle user prompts that open during script execution
If a dialog is opened while a script is executing, we must give control
back to the WebDriver client. The script must also continue executing
though, so once it completes, we ignore its result.
2024-11-02 11:09:41 +01:00
Timothy Flynn
3cc7118bf4 LibWeb: Insert newlines around WebDriver scripts
This allows the script to end with a comment, which is tested by WPT.
Otherwise, an ending comment would create a function of the form:

    function() { return 1; // comment }

And the script would fail to parse.
2024-11-02 11:09:41 +01:00
Shannon Booth
371ddf9dc3 LibWeb: Don't assume a Window global object in HostEnqueuePromiseJob
This was causing crashes in Worker test cases making use of promises,
fixing a regression introduced in
da18551f10
2024-11-02 09:41:58 +00:00
Gingeh
c4e8eeb9a3 LibWeb: Don't crash on transformed clip-paths
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
We can remove this check and FIXME because we already support them
2024-11-02 04:30:14 +00:00
Shannon Booth
da18551f10 LibWeb: Change HTML::Script to hold a realm instead of settings object
This is part of a refactor needed for introduction of the shadow realm
proposal in the web platform.
2024-11-01 18:55:23 -06:00
Shannon Booth
0382933a0a LibWeb: Add AO for 'module map of realm'
This allows you to get the module map for any realm, whether it is a
principal or synthetic realm. We don't yet have the concept of a
synethetic realm, but this puts the groundwork in place for it.
2024-11-01 18:55:23 -06:00
Shannon Booth
1871b744ff LibWeb: Add principal settings object helper function
To more clearly represent the host binding which a principal setting
realm has.
2024-11-01 18:55:23 -06:00
Shannon Booth
cc91473f4d LibWeb: Make TemporaryExecutionContext take a Realm& 2024-11-01 18:55:23 -06:00
Shannon Booth
f7a4d94b24 LibWeb: Add scaffold for 'principal realm of realm'
Allowing us to implement other AOs in terms of this one.
2024-11-01 18:55:23 -06:00
Hermes Junior
cdd78be2d3 LibWeb: Make javascript mime matching spec compliant
When mime essence matching, the spec only asks for a string comparison
ignoring ascii case. The whitespace trimming and parsing of the mime
produces unexpected and wrong results.
Fixes tests on WPT html/semantics/scripting-1/the-script-element :^)
2024-11-01 22:51:00 +00:00
sideshowbarker
437879f849 LibWeb: Correctly descend element nodes when computing accessible name
This change implements the “is a descendant of a native host language
text alternative element” condition in the “F: Name From Content” step
at https://w3c.github.io/accname/#step2F in the “Accessible Name and
Description Computation” spec — to ensure that all descendant nodes get
included as expected in computations for accessible names for elements.

Otherwise, without this change, Ladybird unexpectedly skips descendant
element nodes when computing accessible names — which can result in the
wrong accessible name being returned.
2024-11-01 18:13:41 -04:00
Kostya Farber
aeab342fd7 Documentation: Add VSCode debugger instructions
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Co-authored-by: sideshowbarker <mike@w3.org>
2024-11-01 12:25:28 -07:00
Shannon Booth
d7023f5f45 LibWeb: Change backup imcumbent stack to hold Realm instead of Settings
This is a bit of a chonkier commit as it results in both:

clean_up_after_running_callback and prepare_to_run_callback being
changed to accept a realm instead of an environment settings object,
which has a bunch of fallout, particuarly for IDL abstract operations.
2024-11-01 12:15:17 -07:00
Shannon Booth
8dffd8e7d6 LibWeb: Implement prepare_to_run_script on a Realm&
Making further progress porting away from depending on the
EnvironmentSettingObject.
2024-11-01 12:15:17 -07:00
Shannon Booth
d6fdaf6b26 LibWeb: Implement clean_up_after_running_script on a Realm
Taking further steps towards implementing the shadow realm spec :^)
2024-11-01 12:15:17 -07:00
Shannon Booth
0628b74272 LibWeb: Add scaffold for for "execution context of a realm"
Alongside some const qualfied getters that this requires.
2024-11-01 12:15:17 -07:00
Shannon Booth
aef18435fb LibWeb: Implement whether scripting is disabled based on a realm
Instead of a settings object. This matches updates to the HTML spec as
part of the shadow realm proposal, and begins the refactor of running
scripts on a realm instead of a settings environment object.

Some of the spec steps are slightly messy here (such as in
MainThreadVM.cpp) as this partially implements the ShadowRealm changes
but not other pieces which we have not implemented yet, such as
preparing to run a script also being based on a realm instead of an
environment. But this will be addressed in further commits.
2024-11-01 12:15:17 -07:00
Shannon Booth
583a8f41d3 LibWeb: Update spec comments for 'create a classic script'
To align with spec updates. No functional changes.
2024-11-01 12:15:17 -07:00
Shannon Booth
738e603c2f LibWeb: Implement current_principal_global_object to shadow realm spec
No functional change, as it is using the yet to be fully implemented
'current_principal_realm'.
2024-11-01 12:15:17 -07:00
Shannon Booth
84dc83e0e0 LibWeb: Rename current_global_object to current_principal_global_object
Again, following a rename as part of the introduction of shadow realms
inducing a bunch of mechanical changes.
2024-11-01 12:15:17 -07:00
Shannon Booth
0c2400641e LibWeb: Fill out implementation of current_principal_settings_object
In terms of the 'current principal realm' definition.

No functional impact, as we still need to implement current principal
realm once the surrounding infrastructure is in place. But it is one
less place which needs to be updated when that is all in place :^)
2024-11-01 12:15:17 -07:00