Commit graph

33184 commits

Author SHA1 Message Date
Aliaksandr Kalenik
7f0bafdbd0 LibWeb: Log error instead of crashing if stacking context painted twice
Turns out this mistake happens fairly often, so it is more preferable to
log message and proceed instead of crashing.
2024-05-05 18:23:41 +02:00
MacDue
130aff12b1 LibWeb: Fix null layout node dereference in SVGMaskable
This makes sure `get_mask_type_of_svg()` finds the mask or clipPath by
looking at its child layout nodes. Previously, it went via the DOM node
of the mask or clipPath, which is not always correct as there is not a
1-to-1 mapping from mask DOM node to SVGMaskBox (or SVGClipBox).

Fixes #24186
2024-05-05 13:35:14 +00:00
Ava Rider
3a7bea7402 LibPDF: Added empty read check to parse_hex_string 2024-05-05 06:45:42 +01:00
Andreas Kling
8ff16c1b57 LibJS: Cache access to properties found in prototype chain
We already had fast access to own properties via shape-based IC.
This patch extends the mechanism to properties on the prototype chain,
using the "validity cell" technique from V8.

- Prototype objects now have unique shape
- Each prototype has an associated PrototypeChainValidity
- When a prototype shape is mutated, every prototype shape "below" it
  in any prototype chain is invalidated.
- Invalidation happens by marking the validity object as invalid,
  and then replacing it with a new validity object.
- Property caches keep a pointer to the last seen valid validity.
  If there is no validity, or the validity is invalid, the cache
  misses and gets repopulated.

This is very helpful when using JavaScript to access DOM objects,
as we frequently have to traverse 4+ prototype objects before finding
the property we're interested in on e.g EventTarget or Node.
2024-05-04 21:42:59 +02:00
Andreas Kling
493a04d5fe LibJS: Add PropertyLookupPhase enum to distinguish Object [[Get]] calls
We can now tell the difference between an own property access and a
subsequent (automatic) prototype chain access.

This will be used to implement caching of prototype chain accesses.
2024-05-04 21:42:59 +02:00
Andreas Kling
3945e1a82a LibJS: Make JS::Cell a Weakable
This makes things easier downstream of Cell, and is preparation for
using weak pointers in prototype chain property caches.
2024-05-04 21:42:59 +02:00
MacDue
561beb5e95 LibWeb: Move SVG mask/clip layout node creation under DOM::Element
This is a non-functional change, but makes it clearer other element
properties (like `display=none`) apply to these too.
2024-05-04 21:24:37 +02:00
MacDue
033877f628 LibWeb: Fix painting masks/clipPaths that are not local to the SVG
Previously, the SVGPathPaintable walked up the DOM tree to find the
containing SVG, however, this does not hold for masks/clipPaths that
are not local to the current SVG. Instead, we should walk the layout
tree where we should always be able to find the current SVG as an
ancestor.
2024-05-04 21:24:37 +02:00
Shannon Booth
f7ba07cc8b LibWeb: Handle non-object JSON in XMLHttpRequest response
This fixes a crash seen on https://web.basemark.com/run/
2024-05-04 14:11:10 +02:00
Sam Atkins
3695344d6f LibGUI: Add tooltips to DynamicWidgetContainer control buttons 2024-05-04 14:01:57 +02:00
Shannon Booth
94354ea7fb LibWeb: Clamp AudioParam's value between min and max
The spec isn't _super_ clear on how this is meant to be done, but the
way I understand this is that we should simply clamp the returned
'current value' between 'min' and 'max'.

Firefox does not appear to do this clamping, but Chrome does.
2024-05-04 14:01:38 +02:00
Shannon Booth
e2b5ff2450 LibWeb: Implement OscillatorNode.frequency
Which is an AudioParam clamped by the nyquist_frequency.
2024-05-04 14:01:38 +02:00
Shannon Booth
5f57596520 LibWeb: Pass through sample rate in OfflineAudioContext constructor
I can't actually spot in the spec where it explicitly says to pass this
through (unlike the AudioContext constructor) - but clearly this needs
to be passed through for an OfflineAudioContext to actually have a
sample rate!
2024-05-04 14:01:38 +02:00
Shannon Booth
303958a803 LibWeb: Add BaseAudioContext::nyquist_frequency helper function
As a convenient shorthand :^)
2024-05-04 14:01:38 +02:00
Shannon Booth
099c9e4a7e LibWeb: Implement OscillatorNode.type
This is a simple getter and setter of the OscillatorType enum, with
error checking to not allow 'custom', as that should only be changed
through 'setPeriodicWave()'.
2024-05-04 14:01:38 +02:00
Shannon Booth
b48ba823b9 LibWeb: Implement AudioNode.context
This is just a simple getter which returns the audio context that
created this audio node.
2024-05-04 14:01:38 +02:00
Shannon Booth
97576d27b9 LibWeb: Add constructor for OscillatorNode
This is still missing a bunch of spec steps to construct the
audio node based on the parameters of the OscillatorNode, but it is at
least enough to construct an object to be able to add a basic test which
can get built upon as more is implemented.
2024-05-04 14:01:38 +02:00
Andreas Kling
c8821cf8e0 js: Don't try to call a null Function on SIGINT
This stops `js` from asserting when pressing ^C in the middle of
executing a long-running script.
2024-05-04 13:56:13 +02:00
Shannon Booth
e070309258 LibWeb: Implement Element.outerHTML setter 2024-05-04 13:54:33 +02:00
Shannon Booth
faf33056da LibWeb: Update spec links for outer HTML element attributes
It was moved from the DOM parsing spec to the HTML spec.
2024-05-04 13:54:33 +02:00
Nico Weber
dd020a108a LibGfx/WebP: Rename two variables to be a bit clearer
No behavior change.
2024-05-04 13:46:53 +02:00
Aliaksandr Kalenik
4d5823a5bc LibWeb+LibJS: Skip function environment allocation if possible
If a function has the following properties:
- uses only local variables and registers
- does not use `this`
- does not use `new.target`
- does not use `super`
- does not use direct eval() calls

then it is possible to entirely skip function environment allocation
because it will never be used

This change adds gathering of information whether a function needs to
access `this` from environment and updates `prepare_for_ordinary_call()`
to skip allocation when possible.

For now, this optimisation is too aggressively blocked; e.g. if `this`
is used in a function scope, then all functions in outer scopes have to
allocate an environment. It could be improved in the future, although
this implementation already allows skipping >80% of environment
allocations on Discord, GitHub and Twitter.
2024-05-04 06:48:07 +02:00
Shannon Booth
aede010096 LibWeb: Use GCPtr for Element::layout_node
This improves debuggability by converting a SIGSEGV into a
verification failed on a null dereference.
2024-05-03 20:48:32 +02:00
Sergey Bugaev
51707a4dbd LibGfx: Explicitly cast literals to size_t in JBIG2Loader
width is size_t, so 8 should be that too, not unsigned long long.
2024-05-02 07:46:53 -06:00
Sergey Bugaev
9d2d78c57c LibCore: Make MachPort build on GNU Mach 2024-05-02 07:46:53 -06:00
Sergey Bugaev
e720eadd9e LibCrypto: Skip the check against 2^32 on 32-bit
We can't have a length that large there. This was causing a build error
about shifting a 32-bit value by 32 bits.
2024-05-02 07:46:53 -06:00
Sergey Bugaev
d458471e09 LibPDF: Convert byte offsets to u64
This fixes a build failure on 32-bit.

Suggested-by: Nico Weber <thakis@chromium.org>
2024-05-02 07:46:53 -06:00
Hendiadyoin1
b17f080dcc Kernel/riscv: Use new DeviceTree helpers in PCI initializations
This also changes the PCI interface slightly to be a bit nicer to work
with.
2024-05-02 07:44:13 -06:00
Hendiadyoin1
e014296092 LibDeviceTree: Make DeviceTreeProperty::as_stream return a ValueStream
This new Stream class adds an interface to work in cell-sized chunks,
which is useful for parsing the data in a DeviceTreeProperty.
2024-05-02 07:44:13 -06:00
Hendiadyoin1
ffa9875fa6 LibDeviceTree: Fix stale pointers in phandle and parent handling
We need to set them after we've created the full tree, as otherwise the
HashMap containing the nodes may reallocate and invalidate the pointers.
2024-05-02 07:44:13 -06:00
Shannon Booth
1678f43c38 LibWeb: Implement BaseAudioContext.createOscillator
Which currently will always throw an exception as it is unimplemented
under the hood - but this gives all of the plumbing we need in order to
create a oscillator node as used in the reduced turnstyle testcase.
2024-05-02 07:49:23 +02:00
Shannon Booth
a83f4216a5 LibWeb: Add stub IDL interface for OscillatorNode
This source node generates a periodic wave form.
2024-05-02 07:49:23 +02:00
Shannon Booth
c9b2c1c747 LibWeb: Add stub IDL interface for AudioScheduledSourceNode
This is a base class of a few different audio nodes, most notably for
our immediate needs - OscillatorNode.
2024-05-02 07:49:23 +02:00
Shannon Booth
6661c68b28 LibWeb: Add stub IDL interface for AudioNode
An AudioNode is the fundamental building block used in 'Audio
Contexts'. In our immediate case, the audio node we are working towards
implementing is an oscillating source node.
2024-05-02 07:49:23 +02:00
Shannon Booth
5ae0ac7b73 LibWeb: Add stub IDL interface for AudioParam
An AudioParam is a fundamental building block in WebAudio as it controls
the value of an individual parameter of an AudioNode, such as volume.
2024-05-02 07:49:23 +02:00
Shannon Booth
b1b7e2324a LibWeb: Add stub IDL interface for PeriodicWave
PeriodicWave represents an arbitrary periodic waveform to be used
with an OscillatorNode.
2024-05-02 07:49:23 +02:00
Andreas Kling
5cb127819c LibJS: Fix build after merging CallFrame removal and finally fixes 2024-05-02 07:42:09 +02:00
Hendiadyoin1
ada5027163 LibJS: Cleanup unwind state when transferring control out of a finalizer
This does two things:
* Clear exceptions when transferring control out of a finalizer
  Otherwise they would resurface at the end of the next finalizer
  (see test the new test case), or at the end of a function
* Pop one scheduled jump when transferring control out of a finalizer
  This removes one old FIXME
2024-05-02 07:27:45 +02:00
Hendiadyoin1
27b238d9af LibJS: Stop swallowing exceptions in finalizers
This also fixes one of the try-catch-finally tests, and adds a new one.
2024-05-02 07:27:45 +02:00
Hendiadyoin1
b4b9c4b383 LibJS: Restore scheduled jumps in catch blocks without finalizers 2024-05-02 07:27:45 +02:00
Hendiadyoin1
301a1fc763 LibJS: Propagate finalizers into nested try-catch blocks without them 2024-05-02 07:27:45 +02:00
Aliaksandr Kalenik
865e651a7d LibJS: Merge CallFrame into ExecutionContext
Before this change both ExecutionContext and CallFrame were created
before executing function/module/script with a couple exceptions:
- executable created for default function argument evaluation has to
  run in function's execution context.
- `execute_ast_node()` where executable compiled for ASTNode has to be
  executed in running execution context.

This change moves all members previously owned by CallFrame into
ExecutionContext, and makes two exceptions where an executable that does
not have a corresponding execution context saves and restores registers
before running.

Now, all execution state lives in a single entity, which makes it a bit
easier to reason about and opens opportunities for optimizations, such
as moving registers and local variables into a single array.
2024-05-02 07:26:13 +02:00
Timothy Flynn
46b8a3afb7 LibWeb: Move the read bytes into ReadLoopReadRequest's success callback
The callback is already specified to take the bytes by value. No need to
copy the bytes here.
2024-05-01 21:46:45 +02:00
Timothy Flynn
dce05dd273 LibWeb: Revert using a vector to store each chunk in ReadLoopReadRequest
This reverts commit 12cfa08a09.
2024-05-01 21:46:45 +02:00
Timothy Flynn
6a170e7337 LibWeb: Use the ad-hoc read-all-chunks AO in ReadableStreamPipeTo 2024-05-01 21:46:45 +02:00
Timothy Flynn
6c6fb224ec LibWeb: Add an ad-hoc ReadableStreamDefaultReader::read_all_chunks AO
The ReadableStreamPipeTo AO requires reading all chunks from a stream.
There actually isn't an AO defined to do that, so the "read all bytes"
implementation was changed to provide each chunk in a vector in commit
12cfa08a09.

This change makes reading all bytes a bit more uncomfortable in normal
use cases, as we now have to manually join the vector we receive. This
can also cause churn with huge allocations.

So instead, let's just provide an ad-hoc callback to receive each chunk
as they arrive.
2024-05-01 21:46:45 +02:00
Jamie Mansfield
f5799f7d2c LibWeb/Fetch: Append the Fetch metadata headers 2024-05-01 12:57:35 +02:00
Jamie Mansfield
e52f444329 LibWeb/Fetch: Implement the "set the Sec-Fetch-User header" AO 2024-05-01 12:57:35 +02:00
Jamie Mansfield
1ff90aa3e0 LibWeb/Fetch: Implement the "set the Sec-Fetch-Site header" AO 2024-05-01 12:57:35 +02:00
Jamie Mansfield
5eb46a5f01 LibWeb/Fetch: Implement the "set the Sec-Fetch-Mode header" AO 2024-05-01 12:57:35 +02:00