Commit graph

66818 commits

Author SHA1 Message Date
Feng Yu
8b097b38dd LibWeb: Implement formData() for "multipart/form-data" 2025-01-20 23:33:51 +00:00
Andreas Kling
7ae46bf8b7 LibWeb: Allow partial update of SVG subtrees in layout tree
We were incorrectly always appending to the nearest ancestor in the
partial update case, even when the node was eligible for replacement.
2025-01-21 00:08:25 +01:00
Rok Povsic
026fc6c1ca UI/Qt: Add '.com' to the URL if CTRL is held while pressing return 2025-01-20 19:21:56 +00:00
Aliaksandr Kalenik
3b81d9d91d LibWeb: Delete "names used in attribute selectors" from SelectorInsights
These are no longer needed because it's possible to tell if attribute
name is used in any selector by using invalidation sets.
2025-01-20 18:23:34 +01:00
Aliaksandr Kalenik
e0051db62e LibWeb: Use invalidation sets for "style" attribute invalidation 2025-01-20 18:23:34 +01:00
Gingeh
bf36d829ef LibWeb: Only reload link on rel change if it became a stylesheet 2025-01-20 18:21:20 +01:00
mikiubo
cd576e594d LibXml: Notify listener when doctype is parsed 2025-01-20 14:48:19 +01:00
Shannon Booth
fe7d7f6f6b LibWeb/HTML: Enable callbacks in postMessage deserialization
Interestingly, the spec has a note saying:

> window.postMessage() performs StructuredSerializeWithTransfer on
> its arguments, but is careful to do so immediately, inside the
> synchronous portion of its algorithm. Thus it is able to use the
> algorithms without needing to prepare to run script and prepare
> to run a callback.

But there is no note about the deserialization steps. In any case, we do
need callbacks enabled here.
2025-01-20 07:52:30 -05:00
Shannon Booth
bfbc0124c0 LibWeb/HTML: Pubically expose entangled port and post message steps
These are needed for the implementation of Transferable streams.
2025-01-20 07:52:30 -05:00
Shannon Booth
9f0660c8f0 LibWeb/HTML: Start MessagePort's port messsge queue in onmessage setter
...Which doesn't do anything given start() itself doesn't do anything,
but this is a subtle enough point of the spec that it seems worthwhile
to implement now for whenever this does become meaningful.
2025-01-20 07:52:30 -05:00
Shannon Booth
f8df624171 LibWeb/HTML: Do not use macro to implement MessagePort event handlers
This is not really any more code, and will make it easier to implement
the custom behaviour specified for the onmessage setter.
2025-01-20 07:52:30 -05:00
Timothy Flynn
43dc0f52a6 LibWeb: Do not run microtasks when the event loop is paused
For example, running `alert(1)` will pause the event loop, during which
time no JavaScript should execute. This patch extends this disruption to
microtasks. This avoids a crash inside the microtask executor, which
asserts the JS execution context stack is empty.

This makes us behave the same as Firefox in the following page:

    <script>
        queueMicrotask(() => {
            console.log("inside microtask");
        });

        alert("hi");
    </script>

Before the aforementioned assertion was added, we would execute that
microtask before showing the alert. Firefox does not do this, and now
we don't either.
2025-01-19 20:47:50 +00:00
Aliaksandr Kalenik
34bf833a0a LibWeb: Expand invalidation sets usage to any attribute change
Before this change invalidation sets were only used for "class" and "id"
attribute changes.
2025-01-19 19:54:38 +01:00
Aliaksandr Kalenik
039e0d478a LibWeb: Use invalidation sets for id attribute style invalidation 2025-01-19 19:54:38 +01:00
Aliaksandr Kalenik
c5f2a88f69 LibWeb: Use invalidation sets to reduce style recalculation
Implements idea described in
https://docs.google.com/document/d/1vEW86DaeVs4uQzNFI5R-_xS9TcS1Cs_EUsHRSgCHGu8

Invalidation sets are used to reduce the number of elements marked for
style recalculation by collecting metadata from style rules about the
dependencies between properties that could affect an element’s style.

Currently, this optimization is only applied to style invalidation
triggered by class list mutations on an element.
2025-01-19 19:54:38 +01:00
Gingeh
58c78cb003 LibWeb: Update the select label when option's children are changed 2025-01-19 19:22:32 +01:00
Tim Ledbetter
c87f80454b LibWeb/WebAudio: Implement automation rate constraints
Some nodes have parameters whose automation rate is not allowed to be
changed. This change enforces that constraint for all parameters it
applies to.
2025-01-19 17:24:55 +01:00
Tim Ledbetter
575edf8a90 LibWeb: Use correct automation rate for AudioBufferSourceNode parameters 2025-01-19 17:24:55 +01:00
Tim Ledbetter
400aefb784 LibWeb: Resolve SVGImageElement source URL correctly
This fixes an issue where an SVGImageElement, whose source was a
relative URL would not load inside an iframe.
2025-01-19 15:02:38 +01:00
Shannon Booth
b7512deada LibWeb/SVG: Fix crash when SVG use element is used on an external SVG
We were previously crashing when invoking 'scroll to the fragment' on
such documents as it was unable to find the active document. This is
as a result of our AD-HOC implementation not setting up the document
fully to mark it is active before running the parser.

Fixes a crash on https://tweakers.net.
2025-01-19 15:01:39 +01:00
Andreas Kling
ceb6348811 LibWeb: Invalidate entire layout tree on SVG <use> clone instantiation
This is sub-optimal but let's rebuild the whole tree for now, since this
case gets quite complicated and there are more valuable things to chase
after first.

Thanks to Gingeh for the reduced test case!
2025-01-19 14:38:14 +01:00
Timothy Flynn
6a564376fc Meta+LibUnicode+LibJS: Upgrade to ICU 76.1
This updates our local ICU overlay port to use ICU 76.1. This includes
Unicode 16 and CLDR 46.

Upstream vcpkg is not able to supply versions past 74 yet due to various
dependency issues, but we are able to use this version ourselves. The
overlay port now includes a patch to revert ICU's dependence on autoconf
2.72 for now, as this version is not yet available on all systems.

All of the test changes were cross-referenced with Firefox to ensure
correctness.
2025-01-18 17:56:40 -05:00
Timothy Flynn
0763997591 LibJS: Ensure tests using the "ar" locale use the "arab" number system
In ICU 76, the default was changed from "arab" to "latn". See:
c149724509

The whole point of these tests was to use a non-Latin numbering system.
This patch ensures that is the case to make following patches easier to
grok.
2025-01-18 17:56:40 -05:00
Timothy Flynn
96558b98f9 Meta: Add an overlay port for ICU
This will allow us to upgrade to ICU 76 independent of upstream vcpkg.
2025-01-18 17:56:40 -05:00
Timothy Flynn
c2741ea85e AK: Remove default parameter from StringBuilder's constructor
This separates the StringBuilder constructor into 2 constructors. This
essentially allows forming code of the following pattern:

    StringBuilder foo() { return {}; }

Otherwise, we would get the following compiler error:

    chosen constructor is explicit in copy-initialization

Due to the explicitness of the StringBuilder constructor.

This is required for an upcoming update to ICU 76, where we use our
StringBuilder in templated ICU code.
2025-01-18 17:56:40 -05:00
Andreas Kling
e5d521bef8 LibWeb: Enable partial layout tree update in a bunch of cases
These common cases now cause us to invalidate the layout tree starting
at the relevant parent node instead of invalidating the entire tree.

- DOM node insertion
- DOM node removal
- innerHTML setter
- textContent setter

This makes a lot of dynamic content much faster. For example, demos
on shadertoy.com go from ~18 fps to ~28 fps on my machine.
2025-01-18 21:01:01 +01:00
Andreas Kling
c01d810e5a LibWeb: Implement partial layout tree updates
DOM nodes now have two additional flags:

- Needs layout tree update
- Child needs layout tree update

These work similarly to the needs-style-update flags, but instead signal
the need to rebuild the corresponding part of the layout tree.

When a specific DOM node needs a layout tree update, we try to create
a new subtree starting at that node, and then replace the subtree in the
old layout tree with the newly created subtree.

This required some refactoring in TreeBuilder so that we can skip over
entire subtrees during a tree update.

Note that no partial updates happen yet (as of this commit) since we
always invalidate the full layout tree still. That will change in the
next commit.
2025-01-18 21:01:01 +01:00
Andreas Kling
b41a490e40 LibWeb: Don't (anonymously) wrap table boxes that are already wrapped
Instead just update the existing wrapper with computed values from the
table box, to insure that upside-down "inheritance" works as expected.

This allows table fixup to run on partially updated layout trees without
adding a new layer of unnecessary wrappers every time.
2025-01-18 21:01:01 +01:00
Andreas Kling
e8b5667a9e LibWeb: Add TreeNode<T>::replace_child(new_child, old_child)
This will be used to make local patches to layout trees.
2025-01-18 21:01:01 +01:00
Andreas Kling
b798b1c07d Tests: Add some tests for partial layout tree updates 2025-01-18 21:01:01 +01:00
Shannon Booth
add8bf4790 LibWeb/Streams: Ensure pending pull into's objects are visited by GC
While PendingPullIntos are typically visted by their controller there
were some cases that we were removing those references from the
controller and storing them in a SinglyLinkedList on the stack which
is not safe.

Instead, make PendingPullInto a GC::Cell type, which also allows us
to remove an awkward copy of the struct where the underlying reference
was previously being destroyed.
2025-01-18 10:26:40 +01:00
Luke Wilde
927bdf909b LibWeb/WebGL2: Implement a bunch of parameters read by CreepJS
This also fixes GLfloat and GLboolean to use their appropriate glGet
functions.
2025-01-18 10:23:07 +01:00
Tim Ledbetter
5fd130b02d LibWeb: Add BaseAudioContext.createStereoPanner() factory method 2025-01-18 10:20:41 +01:00
Tim Ledbetter
56907e2de6 LibWeb: Add StereoPannerNode interface 2025-01-18 10:20:41 +01:00
Timothy Flynn
26c2484c2f LibJS: Implement the AsyncDisposableStack interface
This is very similar to the DisposableStack interface, except disposal
of resources is promise-based.
2025-01-17 20:46:32 +01:00
Timothy Flynn
5ea0aa5f08 LibJS: Bring the explicit resource management implementation up to date
While we don't yet have a working `using` implementation with our byte
code, we can still keep our DisposableStack implementation up to date.
The changes brought in here are all editorial, and set us up to start
an AsyncDisposableStack implementation.
2025-01-17 20:46:32 +01:00
Timothy Flynn
f82b1c5a2d LibJS: Alphabetically sort the list of well-known symbols 2025-01-17 20:46:32 +01:00
Tim Ledbetter
31532e36a8 LibWeb: Add AudioContext.createMediaElementSource() factory method 2025-01-17 19:04:47 +00:00
Tim Ledbetter
aa39aa50f7 LibWeb: Add MediaElementAudioSourceNode interface 2025-01-17 19:04:47 +00:00
Luke Wilde
a588756105 LibJS: Use correct this value for tagged template literals with members
Required by creepjs, which does Date().split` `[3] to get the current
year.
2025-01-17 17:15:12 +01:00
Luke Wilde
5f33383a7b LibJS: Propagate direct eval presence if the current scope is screwed
Previously it only deoptimized the parent scope if the current scope
contains direct eval, which is incorrect because code ran in direct
eval mode has access to the entire scope chain it was executed in.
The fix is to also propagate direct eval's presence if the current
scope is marked as being screwed by direct eval.

This fixes Google's botguard failing to complete on Google sign in, as
it tried to access local variables outside of a direct parent function
with eval, causing it throw "unhandled" exceptions. Unhandled is in
quotes because their bytecode VM _technically_ caught it, but it was
considered an unhandled exception. This was determined by removing get
optimizations and then adding debug output for every get operation.
Using this, I noticed that for these errors, it would access the
'message' and 'stack' properties. This is because their error handler
function noticed this was not a synthesised error, which is never
expected to happen. That was determined by using Chrome Devtools 'pause
on handled exception' feature, and noticing it never threw a '[var] is
not defined' exception, but only synthesized error objects which
contained a sentinel value to let it know it was synthesized.

I added debug output to eval to print out what was being eval'd because
it makes heavy use of eval. This revealed that the exceptions only came
from eval.

I then dumped every generated executable and noticed the variables it
was trying to access were generated as local variables in the top
scope. This led to checking what makes a variable considered local or
not, which then lead to this block of code in ~ScopePusher that
propagates eval presence only to the immediate parent scope. This
variable directly controls whether to create all variables properly
with variable environments and bindings or allow them to be stored as
local registers tied to that function's executable.

Since this now lets botguard run to completion, it no longer considers
us to be an insecure/potential bot browser when signing in, now
allowing us to be able to sign in to Google.
2025-01-17 14:36:03 +01:00
devgianlu
991cb8942d LibWeb: Always return a KeyAlgorithm from RsaHashedKeyAlgorithm
The spec never mentions the possibility for the `hash` member of
`RsaHashedKeyAlgorithm` to be a string, it should be a `KeyAlgorithm`
object containing a `name` string member.

Spec: https://w3c.github.io/webcrypto/#dfn-RsaHashedKeyAlgorithm
2025-01-17 12:43:03 +01:00
devgianlu
999f456ba4 LibWeb: Support RSASSA-PKCS1-v1_5 in WebCryptoAPI 2025-01-17 12:43:03 +01:00
devgianlu
e05ee9d297 LibWeb: Support RSA-PSS in WebCryptoAPI 2025-01-17 12:43:03 +01:00
devgianlu
3eeb35e787 LibCrypto: Implement RSA_PSS_EMSA with OpenSSL 2025-01-17 12:43:03 +01:00
Ali Mohammad Pur
cce000d57c LibRegex: Don't repeat the same fork again
If some state has already been tried, skip over it as it would never
lead to a match regardless.
This fixes performance/memory issues in cases like
/(a+)+b/.exec("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
or
/(a|a?)+b/...

Fixes #2622.
2025-01-17 10:13:51 +01:00
Ali Mohammad Pur
7ceeb85ba7 LibRegex: Avoid use-after-move of trivial object
This is not an actual problem as the object is just an enum, but clion
was bugging me.
2025-01-17 10:13:51 +01:00
Ali Mohammad Pur
5876417357 AK: Add a const iterator for COWVector 2025-01-17 10:13:51 +01:00
Timothy Flynn
59a4203cf0 LibWeb: Implement the exclusive <details> accordion
This is a relatively new feature which allows naming <details> groups to
ensure only one <details> element in that group is opened at a time.
2025-01-17 10:13:35 +01:00
Timothy Flynn
1fb1d5fcb9 LibWeb: Update the HTMLDetailsElement attribute change steps
No functional change here, but this contains spec steps to handle the
'name' attribute (not implemented here).
2025-01-17 10:13:35 +01:00