Commit Graph

9103 Commits

Author SHA1 Message Date
Jamie Mansfield
6e3b2ce300 LibWeb/Fetch: Add to_string function for Request::Mode 2024-05-01 12:57:35 +02:00
Jamie Mansfield
3daba8970c LibWeb/Fetch: Add to_string function for Request::Destination 2024-05-01 12:57:35 +02:00
Jamie Mansfield
da8d0d82c0 LibWeb/Fetch: Add "json" destination for JSON modules
This is a change in the Fetch spec.

See:
- https://github.com/whatwg/fetch/commit/49bff76
2024-05-01 12:57:35 +02:00
Andreas Kling
527ad9ac01 LibWeb: Implement XMLHttpRequest.responseURL
This was used on https://twinings.co.uk/ so let's support it :^)
2024-05-01 12:52:03 +02:00
Andreas Kling
34f2cbf202 LibWeb: Honor intrinsic constraints on available space in table widths
When a table's containing block provides min-content or max-content
available space, we now size the table's width accordingly.
2024-05-01 11:13:48 +02:00
Tim Ledbetter
02a8966b61 LibWeb: Serialize empty media rules with a single newline
This deviates from the CSSOM specification but all modern browsers do
this.
2024-05-01 07:21:21 +02:00
Tim Ledbetter
a2cccf9420 LibWeb: Use correct spacing when serializing media features
Previously, there was no space between the media feature name and value.
2024-05-01 07:21:21 +02:00
Timothy Flynn
2d4d16ac37 LibWeb: Remove exceptional return types from infallible stream IDL 2024-04-30 08:14:12 +02:00
Timothy Flynn
572a7bb313 LibWeb: Remove exceptional return types from infallible stream AOs 2024-04-30 08:14:12 +02:00
Timothy Flynn
c29916775e LibWeb: Mark stream AOs as infallible as required by the spec
There were several instances where the spec marks an AO invocation as
infallible, but we were propagating WebIDL::ExceptionOr. These mostly
cannot throw due to knowledge about the values they are provided. By
unwinding these, we can remove a decent amount of exception handling.
2024-04-30 08:14:12 +02:00
Timothy Flynn
3aa6ef8ac0 LibWeb: Use LibJS's is-infinity helper in the enqueue-value-with-size AO 2024-04-30 08:14:12 +02:00
Timothy Flynn
9d5e538247 LibWeb: Mark writable stream abort steps as infallible
These don't throw. We can remove a decent amount of exception handling
by marking them infallible.
2024-04-30 08:14:12 +02:00
Timothy Flynn
fc070c8cbd LibWeb: Mark readable stream cancel/pull/release steps as infallible
These don't throw. We can remove a decent amount of exception handling
by marking them infallible.
2024-04-30 08:14:12 +02:00
Timothy Flynn
13021a0fb9 LibWeb: Remove small OOM error propagation from stream AOs 2024-04-30 08:14:12 +02:00
Timothy Flynn
bbe6b84bd6 LibWeb: Mark most stream callbacks as infallible
There are a number of script-provided stream callbacks for various
stream operations, such as `start`, `pull`, `cancel`, etc. Out of all of
these, only the `start` callback can actually throw. And when it does,
the exception is realized immediately in the corresponding stream
constructor.

All other callbacks have spec text of the form:

    Throwing an exception is treated the same as returning a rejected
    promise.

And indeed this is internally handled by the streams spec. Thus all of
those callbacks can be specified as returning only a promise, rather
than a WebIDL::ExceptionOr<Promise>.
2024-04-30 08:14:12 +02:00
Timothy Flynn
ffb48ccd81 LibWeb: Ensure TransformStream's transform/flush callbacks do not throw
Unlike what the comments here currently indicate, these callbacks do
only return a Promise, and thus cannot throw.
2024-04-30 08:14:12 +02:00
Timothy Flynn
60ea803b2a LibWeb: Fix typo in mass copy-pasted comment in stream AOs 2024-04-30 08:14:12 +02:00
Timothy Flynn
9e8ff45962 LibWeb: Fix invalid spec link on the TransformStream constructor 2024-04-30 08:14:12 +02:00
Aliaksandr Kalenik
9275743626 LibWeb: Verify in runtime that stacking context is not painted twice
Duplicated stacking context painting is easy to introduce because of
a bit complicated traversal order and very painful to debug.
2024-04-29 20:32:14 +02:00
Aliaksandr Kalenik
9bc0552a80 LibWeb: Fix paint recording to stop visiting stacking context twice
...if its box is positioned and has z-index=0.
2024-04-29 17:26:13 +02:00
Tim Ledbetter
b9f0ea2178 LibWeb: Evaluate media rules for adopted style sheets
Previously, media rules were not evaluated for adopted style sheets.
2024-04-29 08:10:38 +02:00
Tim Ledbetter
f4e0c5395a LibWeb: Don't apply disabled adopted style sheets to the document
Previously, we would apply any adopted style sheet to the document if
its alternate flag was not set. This meant that all adopted style
sheets would be applied, since constructed style sheets never have this
flag set.
2024-04-29 08:10:38 +02:00
Tim Ledbetter
84193f2746 LibWeb: Align StyleSheet title getter with the specification
The CSSOM specification says that StyleSheet.title should return null
if the title field is empty.
2024-04-29 08:10:38 +02:00
Aliaksandr Kalenik
7bea2b68f4 LibWeb: Paint non-positioned SC with z-index=0 in paint_descendants()
Fixes the bug when non-positioned boxes that establish a stacking
context and have z-index=0 are ignored during paint commands recording.
2024-04-28 22:28:18 +02:00
Aliaksandr Kalenik
15f69ffbba LibWeb: Use cached absolute rect and transform in refresh_clip_state()
Changes compute_absolute_padding_rect_with_css_transform_applied() to
use cached absolute rect and CSS transform instead of doing expensive
containing block chain traversal.

Reduces refresh_clip_state() from 4% to 2% in Discord profiles.
2024-04-28 17:47:03 +02:00
Timothy Flynn
34b446ab34 LibWeb: Assign the Content-Type fetch response header as appropriate
The condition here was inverted.
2024-04-28 12:32:04 +02:00
Timothy Flynn
b04ef436fa LibWeb: Remove OOM propagation from Fetch::Response 2024-04-28 12:32:04 +02:00
Timothy Flynn
790589ceb0 LibWeb: Remove OOM propagation from Fetch::Request 2024-04-28 12:32:04 +02:00
Timothy Flynn
d12c560859 LibWeb: Remove OOM propagation from Fetch::Headers 2024-04-28 12:32:04 +02:00
Timothy Flynn
d327fa8135 LibWeb: Remove OOM propagation from Fetch::BodyInit 2024-04-28 12:32:04 +02:00
Timothy Flynn
3e991a55fa LibWeb: Remove OOM propagation from Fetch::Body 2024-04-28 12:32:04 +02:00
Shannon Booth
bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
Aliaksandr Kalenik
b1205f0aa1 LibWeb: Skip unnecessary sample corner and blit corner commands
Before this change we were recording and executing sample/blit commands
for each painting phase, even if there are no painting commands
in-between sample and blit that produce result visible on a canvas.

This change adds an optimization pass that goes through recorded
painting commands list and marks sample and blit commands that could
be skipped.

Reduces sample and blit corners executing from 17% to 8% on Discord.
2024-04-27 21:06:16 +02:00
Aliaksandr Kalenik
776951b7ff LibWeb: Cache combined CSS transform on pre-paint phase
Makes 5% of `compute_combined_css_transform()` in Discord profiles gone.
2024-04-27 16:00:26 +02:00
Aliaksandr Kalenik
cd07249482 LibWeb/Painting: Add ClippableAndScrollable mixin
Moves code that was duplicated across PaintableBox and InlinePaintable
into separate class.
2024-04-27 16:00:26 +02:00
Shannon Booth
91efa1d568 LibWeb: Add skeleton for OfflineAudioContext
Implement enough to construct the object itself, with most parts stubbed
out.
2024-04-27 07:11:02 +02:00
Shannon Booth
d27b70ae24 LibWeb: Add HTML event 'complete' 2024-04-27 07:11:02 +02:00
Aliaksandr Kalenik
613cd6104d LibWeb: Support masking of SVGForeignObjectPaintable 2024-04-27 07:10:20 +02:00
Aliaksandr Kalenik
7d05fe84bc LibWeb: Add layout node and paintable for SVGForeignObjectElement
Introduces separate layout and paintable type for foreign element.
It is necessary to inherit SVGForeignObjectPaintable from SVGMaskable
in upcoming changes.
2024-04-27 07:10:20 +02:00
Aliaksandr Kalenik
acd5369774 LibWeb: Separate svg mask calculation into SVGMaskable
Preparation work before adding support for SVGForeignObjectElement
masking.

Having a mixin makes possible sharing mask calculation between
SVGForeignObjectElement's paintable and SVGGraphicsPaintable.

Both has to support masking:
- PaintableWithLines (from SVGForeignObjectElement) -> PaintableBox
- SVGGraphicsPaintable -> SVGPaintable -> PaintableBox

After this change it will be possible to introduce a new paintable type
for foreignObject that inherits from both PaintableWithLines and
SVGMaskable.
2024-04-27 07:10:20 +02:00
Timothy Flynn
c9a461ee75 LibWeb: Remove OOM propagation from Fetch::Infrastructure::HTTP 2024-04-27 07:08:14 +02:00
Timothy Flynn
1ffda6a805 LibWeb: Propagate OOM in Body::fully_read() through its error callback
Fetched bodies can be on the order of gigabytes, so rather than crashing
when we hit OOM here, we can simply invoke the error callback with a DOM
exception. We use "UnknownError" here as the spec directly supports this
for OOM errors:

    UnknownError: The operation failed for an unknown transient reason
                  (e.g. out of memory).

This is still an ad-hoc implementation. We should be using streams, and
we do have the AOs available to do so. But they need to be massaged to
be compatible with callers of Body::fully_read. And once we do use
streams, this function will become infallible - so making it infallible
here is at least a step in the right direction.
2024-04-27 07:08:14 +02:00
Timothy Flynn
ec5988d56b LibWeb: Mark the task in the success steps of reading a body as mutable
Otherwise, the `move(bytes_copy)` in the body of the steps does not
actually act as a `move`.
2024-04-27 07:08:14 +02:00
Timothy Flynn
5f51a11618 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Responses 2024-04-27 07:08:14 +02:00
Timothy Flynn
5a4f13dcd4 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Requests 2024-04-27 07:08:14 +02:00
Timothy Flynn
b3032befe0 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Methods 2024-04-27 07:08:14 +02:00
Timothy Flynn
c79f46fe6f LibWeb: Remove OOM propagation from Fetch::Infrastructure::Headers 2024-04-27 07:08:14 +02:00
Tim Ledbetter
dda730c46b LibWeb: Exclude [Global] interfaces from legacy platform object method
Previously, [Global] interfaces were not excluded from the
`internal_own_property_keys()` call. This caused a crash when iterating
over the properties of the Window object.
2024-04-26 20:02:21 +02:00
Andreas Kling
ff9ae5ff40 LibWeb: Bring document & browsing context creation in line with spec
We had drifted away from the spec steps a little bit here. This patch
brings us back in line and knocks off some FIXMEs in the process.
2024-04-26 20:01:58 +02:00
Andreas Kling
a5c62b953f LibWeb: Take care of some FIXMEs in auxiliary browsing context creation 2024-04-26 20:01:58 +02:00