Commit graph

65276 commits

Author SHA1 Message Date
Tim Ledbetter
7fe110225b LibWeb: Use correct specifier to pad font language override value 2024-11-18 17:38:03 -05:00
Aliaksandr Kalenik
96a35767b6 LibWeb: Implement mask-image CSS property support
Implemented by reusing AddMask display list item that was initially
added for `background-clip` property.

Progress on flashlight effect on https://null.com/games/athena-crisis
2024-11-18 22:58:58 +01:00
Andrew Kaster
7b7bb60393 CMake: Store the CMake sauce to add no-as-needed libraries to cache
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
This was causing issues for my Ubuntu 24.04 build when building
the Distribution preset, so just stash this constant config in
the CMake cache to not worry about it anymore.
2024-11-18 14:19:24 -07:00
Andreas Kling
e28e4f6700 LibWeb: Update handling of "once" event listeners now that spec is fixed
https://github.com/whatwg/dom/issues/1323 was fixed, and the solution
ended up slightly different from what we had, so let's follow the spec.
2024-11-18 20:20:57 +01:00
Aliaksandr Kalenik
9f541c363d LibWeb: Allow stacking context to only be created by PaintableBox
For a while we used the wider Paintable type for stacking context,
because it was allowed to be created by InlinePaintable and
PaintableBox. Now, when InlinePaintable type is gone, we can use more
specific PaintableBox type for a stacking context.
2024-11-18 20:07:30 +01:00
Pavel Shliak
ed80e929e5 LibGfx: Sync to_skia_color_type 2024-11-18 19:17:51 +01:00
Shannon Booth
66530086a4 LibWeb: Add MediaSourceExtensions events
Some checks are pending
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (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
Continuing the boilerplate for these interfaces.
2024-11-18 10:58:21 +00:00
Lucien Fiorini
ff791a63fc LibJS: Add fast paths for get and set on float typed arrays 2024-11-18 09:12:05 +01:00
Psychpsyo
3856dd946b LibWeb: Prevent checkboxes from firing change events when losing focus
This is because toggling the checkbox is committing the value.
2024-11-18 09:04:11 +01:00
Andrew Kaster
c898ee90cf js: Don't destroy the JS VM on shutdown
This avoids a crash in the fully static distribution build, due to
static init order fiasco.
2024-11-18 08:23:08 +01:00
rmg-x
8d511b2f7b RequestServer: Clear "Content-Type" header when one isn't provided
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
libcurl will automatically set the Content-Type header when using the
CURLOPT_POSTFIELDS option to "application/x-www-form-urlencoded".

See: https://curl.se/libcurl/c/CURLOPT_POSTFIELDS.html

The following WPT cases now pass (8 tests):
http://wpt.live/xhr/send-blob-with-no-mime-type.html
2024-11-18 02:03:11 +01:00
Andreas Kling
3e8c8b185e LibWeb: Use WindowProxy instead of Window in UI Events IDL
I believe this is an error in the UI Events spec, and it should be
updated to match the HTML spec (which uses WindowProxy everywhere).

This fixes a bunch of issues already covered by existing WPT tests.

Spec bug: https://github.com/w3c/uievents/issues/388

Note that WebKit has been using WindowProxy instead of Window in
UI Events IDL since 2018:
816158b4aa
2024-11-17 23:47:24 +01:00
Timothy Flynn
5bcba896c2 LibWeb: Implement the DecompressionStream interface 2024-11-17 22:37:45 +01:00
Timothy Flynn
638a8aecad LibWeb: Implement the CompressionStream interface 2024-11-17 22:37:45 +01:00
Timothy Flynn
c0da3e356a LibWeb: Add a couple ad-hoc BufferSource AOs
These helpers will be used by CompressionStream/DecompressionStream.
2024-11-17 22:37:45 +01:00
Timothy Flynn
35ba7c7e00 LibWeb: Add the IDL for the GenericTransformStream mixin 2024-11-17 22:37:45 +01:00
Timothy Flynn
5a2260a0bc LibWeb: Return the readable stream error directly instead of as a string
This error is not a string object, it's e.g. a JS::TypeError. This now
matches similar handling of writable stream errors.
2024-11-17 22:37:45 +01:00
Timothy Flynn
fd15910adf LibCompress: Do not verify that zlib & deflate compressors are finished
These compressors will be used by w3c's CompressionStream, which can run
arbitrary JS, and thus never reach their "finish" steps. Let's not crash
the WebContent process if that happens.
2024-11-17 22:37:45 +01:00
Timothy Flynn
355ce72c06 LibCompress: Allow using GzipCompressor in a streaming fashion
GzipCompressor is currently written assuming that it's write_some method
is only called once. When we use this class for LibWeb, we may very well
receive data to compress in small chunks. So this patch makes us write
the gzip header and footer only once, which now resembles the zlib and
deflate compressors.
2024-11-17 22:37:45 +01:00
Timothy Flynn
b11fdea175 LibCompress: Add a forwarding header
Currently, just with the types needed for the w3c Compression spec.
2024-11-17 22:37:45 +01:00
Timothy Flynn
a91af764f6 Utilities: Remove unused compression utilities
Some LibCompress API changes for LibWeb will make these utilities a bit
difficult to keep up to date. Given that these are unused anways, let's
just not bother.
2024-11-17 22:37:45 +01:00
Timothy Flynn
077ae6efa1 headless-browser: Create the expectation directory if it doesn't exist
This is convenient when adding tests to a new folder.
2024-11-17 22:37:45 +01:00
Lucas CHOLLET
6affbf78c2 LibGfx: Adjust matrices for XYZ -> sRGB conversions
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
TL;DR: There are two available sets of coefficients for the conversion
matrices from XYZ to sRGB. We switched from one set to the other, which
is what the WPT tests are expecting.

All RGB color spaces, like display-p3 or rec2020, are defined by their
three color chromacities and a white point. This is also the case for
the video color space Rec. 709, from which the sRGB color space is
derived. The sRGB specification is however a bit different.

In 1996, when formalizing the sRGB spec the authors published a draft
that is still available here [1]. In this document, they also provide
the matrix to convert from the XYZ color space to sRGB. This matrix can
be verified quite easily by using the usual math equations. But hold on,
here come the plot twist: at the time of publication, the spec contained
a different matrix than the one in the draft (the spec is obviously
behind a pay wall, but the numbers are also reported in this official
document [2]). This official matrix, is at a first glance simply a
wrongly rounded version of the one in the draft publication. It however
has some interesting properties: it can be inverted twice (so a
roundtrip) in 8 bits and not suffer from any errors from the
calculations.

So, we are here with two versions of the XYZ -> sRGB matrix, the one
from the spec, which is:
 - better for computations in 8 bits,
 - and official. This is the one that, by authority, we should use.
And a second version, that can be found in the draft, which:
 - makes sense, as directly derived from the chromacities,
 - is publicly available,
 - and (thus?) used in most places.

The old coefficients were the one from the spec, this commit change them
for the one derived from the mathematical formulae. The Python script to
compute these values is available at the end of the commit description.

More details about this subject can be found here [3].

[1] https://www.w3.org/Graphics/Color/sRGB.html
[2] https://color.org/chardata/rgb/sRGB.pdf
[3] https://photosauce.net/blog/post/making-a-minimal-srgb-icc-profile-part-3-choose-your-colors-carefully

The Python script:

```python
# http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html

from numpy.typing import NDArray
import numpy as np

### sRGB
# https://www.w3.org/TR/css-color-4/#predefined-sRGB
srgb_r_chromacity = np.array([0.640, 0.330])
srgb_g_chromacity = np.array([0.300, 0.600])
srgb_b_chromacity = np.array([0.150, 0.060])
##

## White points
white_point_d50 = np.array([0.345700, 0.358500])
white_point_d65 = np.array([0.312700, 0.329000])
#

r_chromacity = srgb_r_chromacity
g_chromacity = srgb_g_chromacity
b_chromacity = srgb_b_chromacity
white_point = white_point_d65

def tristmimulus_vector(chromacity: NDArray) -> NDArray:
    return np.array([
        chromacity[0] /chromacity[1],
        1,
        (1 - chromacity[0] - chromacity[1]) / chromacity[1]
    ])

tristmimulus_matrix = np.hstack((
    tristmimulus_vector(r_chromacity).reshape(3, 1),
    tristmimulus_vector(g_chromacity).reshape(3, 1),
    tristmimulus_vector(b_chromacity).reshape(3, 1),
))

scaling_factors = (np.linalg.inv(tristmimulus_matrix) @
                   tristmimulus_vector(white_point))

M = tristmimulus_matrix * scaling_factors

np.set_printoptions(formatter={'float_kind':'{:.6f}'.format})
xyz_65_to_srgb = np.linalg.inv(M)

# http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
# Let's convert from D50 to D65 using the Bradford method.
m_a = np.array([
    [0.8951000, 0.2664000, -0.1614000],
    [-0.7502000, 1.7135000, 0.0367000],
    [0.0389000, -0.0685000, 1.0296000]
])

cone_response_source = m_a @ tristmimulus_vector(white_point_d50)
cone_response_destination = m_a @ tristmimulus_vector(white_point_d65)

cone_response_ratio = cone_response_destination / cone_response_source
m = np.linalg.inv(m_a) @ np.diagflat(cone_response_ratio) @ m_a

D50_to_D65 = m
xyz_50_to_srgb = xyz_65_to_srgb @ D50_to_D65

print(xyz_50_to_srgb)
print(xyz_65_to_srgb)
```
2024-11-17 22:18:40 +01:00
Shannon Booth
fd0c63b338 LibJS: Align spec comments for ShadowRealm for HostInitializeShadowRealm
The proposed changes have been merged into the proposal with:

https://github.com/tc39/proposal-shadowrealm/commit/f20d02
2024-11-17 22:15:22 +01:00
Psychpsyo
e8c228fb93 LibWeb: Properly escape URL on error page 2024-11-17 22:14:14 +01:00
Shannon Booth
634823d5b4 LibWeb: Implement HTMLIFrameElement.sandbox 2024-11-17 22:12:29 +01:00
Shannon Booth
a4b43cae9a LibWeb: Implement HTMLLinkElement.sizes 2024-11-17 22:12:29 +01:00
Shannon Booth
061ac1f8c7 Tests: Import WPT test for DOMTokenList coverage on attributes 2024-11-17 22:12:29 +01:00
Ali Mohammad Pur
5a4d657a4e LibRegex: Avoid generating ForkJumps when jumping to the next alt block
Fixes #2398.
2024-11-17 20:12:39 +01:00
Shannon Booth
b264d18ad1 LibWeb: Fix missing auxiliary logic for cross document navigation
I noticed this missing check when trying to debug an unrelated issue. I
don't know what it could fix, but this seems like an oversight.
2024-11-17 11:37:43 -05:00
Ali Mohammad Pur
00bc22c332 LibRegex: Don't immediately ignore TempInverse in optimizer
fe46b2c141 added the reset-temp-inverse flag, but set it up so all
tempinverse ops were negated at the start of the next op; this commit
makes it so these flags actually persist for one op and not zero.

Fixes #2296.
2024-11-17 09:03:29 -05:00
Andreas Kling
69c84d3f63 LibWeb: Make sure we don't fire "once" event listeners twice
Spec bug: https://github.com/whatwg/dom/issues/1323
2024-11-17 14:56:35 +01:00
Andreas Kling
aa9ed71ff3 Tests: Import a bunch of WPT tests from /dom/events 2024-11-17 14:56:35 +01:00
Shannon Booth
0339ece565 LibWeb: Add missing initialize call to WritableStreamDefaultController 2024-11-17 08:51:41 -05:00
Shannon Booth
98dadb0ce6 LibWeb: Always return a rejected Promise for functions which throw
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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 were previously throwing an exception if the generated code was
throwing an exception before it hit the implementation of the interface.
Instead, we are meant to catch any exception, and wrap that in a
rejected promise.

For example, this was impacting the fixed test in this commit as an
exception was being thrown when invoking WebIDL::convert_to_int<T>
as the given number was out of range, and the [EnforceRange]
extended attribute decorates that attribute.

This same type of case is seen for a few tests in WPT.
2024-11-16 18:33:58 +01:00
Shannon Booth
8d93cac983 LibWeb: Return GC::Ref for some Stream promise returning functions
These will never return null.
2024-11-16 18:33:58 +01:00
Shannon Booth
ab309dcc58 LibWeb: Change URL parsing sequence for window open steps
This adapts to the latest HTML spec which fixed the issue we had
reported of:

https://github.com/whatwg/html/commit/316b83
2024-11-16 18:22:35 +01:00
sideshowbarker
ed7ec7a0f8 LibWeb: Fix accname computation for all aria-labelledby cases
This change ensures that:

- if an element for which an accessible name otherwise wouldn’t be
  computed is referenced in an aria-labelledby value, the accessible
  name for the element will be computed as expected.

- if an element has both an aria-label value and also an
  aria-labelledby value, the text from the aria-label value gets
  included in the computation of the element’s accessible name.

Otherwise, without this change, some elements with aria-labelledby
values will unexpectedly end up without accessible names, and some
elements with aria-label values will unexpectedly not have that
aria-label value included in the element’s accessible name.
2024-11-16 18:21:37 +01:00
Andreas Kling
13bd52249d LibWeb: Make Selection APIs throw on DocumentType node inputs
This matches the behavior of all major engines, and is covered by
hundreds of subtests in WPT.

Spec PR: https://github.com/w3c/selection-api/pull/342
2024-11-16 14:39:55 +01:00
Jonne Ransijn
c3783cf3bd LibIDL: Fix use-after-free in GenerateWindowOrWorkerInterfaces
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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
`lexical_bases` was storing `StringView`s into `ByteString`s returned
from `LexicalPath::string()` that might no longer exist.
2024-11-16 10:30:14 +01:00
Lucas CHOLLET
63873f3809 LibWeb/CSS: Add support for the rec2020 color space in color()
This color space is often used as a reference in WPT tests, having
support for it makes us pass 15 new tests:
  - css/css-color/rec2020-001.html
  - css/css-color/rec2020-002.html
  - css/css-color/rec2020-003.html
  - css/css-color/rec2020-004.html
  - css/css-color/rec2020-005.html
  - css/css-color/predefined-011.html
  - css/css-color/predefined-012.html
2024-11-16 10:29:46 +01:00
Lucas CHOLLET
2173219eac LibGfx: Fix parameters name of Color::from_linear_srgb
And sort the declarations alphabetically while touching it.
2024-11-16 10:29:46 +01:00
Lucas CHOLLET
0b9c4b8adc LibWeb/CSS: Add support for the prophoto-rgb color space in color()
That makes us pass the following WPT tests:
 - css/css-color/prophoto-rgb-001.html
 - css/css-color/prophoto-rgb-002.html
 - css/css-color/prophoto-rgb-003.html
 - css/css-color/prophoto-rgb-004.html
 - css/css-color/prophoto-rgb-005.html
 - css/css-color/predefined-009.html
 - css/css-color/predefined-010.html
2024-11-16 10:29:46 +01:00
Lucas CHOLLET
596a4e55dd LibWeb/CSS: Add support for the display-p3 color space in color()
This color space is often used as a reference in WPT tests, having
support for it makes us pass 15 new tests:
  - css/css-color/display-p3-001.html
  - css/css-color/display-p3-002.html
  - css/css-color/display-p3-003.html
  - css/css-color/display-p3-004.html
  - css/css-color/display-p3-005.html
  - css/css-color/display-p3-006.html
  - css/css-color/lab-008.html
  - css/css-color/lch-008.html
  - css/css-color/oklab-008.html
  - css/css-color/oklch-008.html
  - css/css-color/predefined-005.html
  - css/css-color/predefined-006.html
  - css/css-color/xyz-005.html
  - css/css-color/xyz-d50-005.html
  - css/css-color/xyz-d65-005.html
2024-11-16 10:29:46 +01:00
Lucas CHOLLET
f949334a9a LibGfx: Use a more explicit formula in Color::from_linear_srgb
NFC. I prefer having the constants expanded, it makes it easier to trace
them back to the initial formula.
2024-11-16 10:29:46 +01:00
Lucas CHOLLET
a59d9a3986 LibWeb/CSS: Add support for the a98-rgb color space in color()
This makes us pass the following WPT tests:
 - css/css-color/a98rgb-001.html
 - css/css-color/a98rgb-002.html
 - css/css-color/a98rgb-003.html
 - css/css-color/a98rgb-004.html
 - css/css-color/predefined-007.html
 - css/css-color/predefined-008.html
2024-11-16 10:29:46 +01:00
Luke Wilde
c0ae3aa884 LibWeb: Add CMake dependencies for GeneratedCSSStyleProperties.idl
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, 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: Andrew Kaster <andrew@ladybird.org>
2024-11-15 16:08:19 -07:00
Jelle Raaijmakers
e5d71a6c82 LibWeb: Apply the paint transformation in SVGGradientElement
In commit 1b82cb43c2 I accidentally
removed the paint transformation altogether. The result was that
zoomed-in SVGs, or SVG elements with a transformation applied could have
their gradient coordinates misplaced significantly.

This was also exposed in the `svg-text-effects` test by way of a slight
visual difference. Add a new test that very clearly exposes the fixed
issue by rotating the gradient coordinates by 45 degrees.
2024-11-15 23:21:13 +01:00
Jelle Raaijmakers
e21b5cab32 LibWeb: Change Array<T,Size> to Array in DisplayListPlayerSkia
No functional changes.
2024-11-15 23:21:13 +01:00
Nico Weber
ae7ee22aea LibWeb: Don't copy url when calling determine_the_origin() in Navigable
In #1537, determine_the_origin() changed to take
`Optional<URL::URL> const&` as first parameter, but it's passed
`Web::Fetch::Infrastructure::Response::url()`, which returns
`Optional<URL::URL const&>`. Ladybird does not have
SerenityOS/serenity#22870 (yet?), so this mismatch silently creates
a copy.

Change determine_the_origin() to take `Optional<URL::URL const&>`
instead. No behavior change, saves a copy, and is probably what
was originally intended.
2024-11-15 23:19:40 +01:00