Commit graph

65203 commits

Author SHA1 Message Date
stasoid
69f5f40617 AK: Add static bool LexicalPath::is_absolute_path(StringView path); 2024-11-19 14:35:52 -07:00
stasoid
a828a0e158 LibCore/System: Port getcwd, stat, rmdir, unlink to Windows 2024-11-19 14:35:52 -07:00
Andrew Kaster
4b4a6991e3 Tests: Use ABI entry point for swift-testing tests
Avoid the unstable SwiftPM entry point in favor of the stable ABI entry
point.
2024-11-19 14:32:11 -07:00
Andrew Kaster
fca6fd0b85 LibGC: Add Swift bindings to the GC heap
This includes a protocol for creating LibGC Heap allocated Swift
objects. Pay no attention to the Unmanaged shenanigans, they are
all behind the curtain.
2024-11-19 14:32:11 -07:00
Andrew Kaster
829391e714 LibGC: Add a ForeignCell class for ownership of non-C++ objects
This will allow us to use the GC to manage the lifetime of objects
that are not C++ objects, such as Swift objects. In the future we
could expand this cursed FFI to other languages as well.
2024-11-19 14:32:11 -07:00
Andrew Kaster
726f2cfb11 LibGC: Expose deferred state publicly, annotate DeferGC for Swift
While we don't want arbitrary callers deferring GC, we do want
deferral to be available to the Swift. In order for Swift to
understand the RAII nature of DeferGC, we need to mark it as
non-copyable.
2024-11-19 14:32:11 -07:00
Andrew Kaster
32cf4d1e29 AK: Add missing swift/bridging empty defines for non-Swift compilers 2024-11-19 14:32:11 -07:00
Andrew Kaster
d5fb48a6f5 LibGC: Add missing Types.h to forwarding header
The forwarding header was not including any other headers, but still
relied on a definition of size_t.
2024-11-19 14:32:11 -07:00
Andrew Kaster
458167935c AK: Add an extension to construct an AK.String from a Swift.String 2024-11-19 14:32:11 -07:00
Andrew Kaster
a95f761cb4 AK: Include missing StdLibExtras from NeverDestroyed 2024-11-19 14:32:11 -07:00
Pavel Shliak
6033349574 LibWeb: Do not crash when Radial Gradient height is 0 2024-11-19 22:31:51 +01:00
Pavel Shliak
ed409eacf5 LibGfx: Remove unused Bitmap loaders 2024-11-19 21:48:45 +01:00
Andreas Kling
6ffc7ea36d LibWeb: Make Node::is_text() return true for CDATASection nodes
CDATASection inherits from Text, and so it was incorrect for them to
claim not to be Text nodes.

This fixes at least two WPT subtests. :^)

It also exposed a bug in the DOM Parsing and Serialization spec,
where we're not told how to serialize CDATASection nodes.

Spec bug: https://github.com/w3c/DOM-Parsing/issues/38
2024-11-19 19:24:37 +00:00
Andreas Kling
564dc0a434 LibWeb: Use correct factory function when cloning a Document node
Cloning an XMLDocument should produce a new XMLDocument. Same for
HTMLDocument.

This fixes at least one WPT test, which we're also importing. :^)
2024-11-19 19:24:37 +00:00
Aliaksandr Kalenik
24a6fd3d76 Tests/LibWeb: Rebaseline WebAnimations/misc/steps-serialization.html
Fixes failing test introduced by
b342758dbf
2024-11-19 16:13:38 +01:00
Aliaksandr Kalenik
c47d19d05a LibWeb: Update LegendBox and FieldSetBox to use GC namespace
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
Fixes broken build.
2024-11-19 14:51:42 +01:00
Kostya Farber
a820308a02 LibWeb: Add layout objects for fieldset and legend
Add the boilerplate code for the layout objects that represent the
`<fieldset>` and `<legend>` elements. Using these, we can make progress
towards laying out these two elements per the spec at
https://html.spec.whatwg.org/multipage/rendering.html#the-fieldset-and-legend-elements.
2024-11-19 14:31:03 +01:00
Pavel Shliak
b342758dbf LibWeb: Fix extra validation for EasingStyleValue intervals 2024-11-19 14:10:53 +01:00
Psychpsyo
801499f13e LibWeb: Fix crash from text inside SVG 2024-11-19 13:41:15 +01:00
Valtteri Koskivuori
135daeb8bb LibCompress: Don't assume zlib header is available right away
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
Instead of checking the header in ZlibDecompressor::create(), we now
check it in read_some() when it is called for the first time. This
resolves a FIXME in the new DecompressionStream implementation.
2024-11-18 19:55:46 -05:00
Timothy Flynn
be09893fa7 AK+LibJS: Don't use Temporal for console.time() and console.timeLog()
We don't need nanosecond precision here anyways, as we only display
millisecond resolution.

This uses our simple duration formatter from AK, which is updated to
accept a Duration here. This method did not have any users after the
move from Serenity.
2024-11-18 17:46:41 -05:00
Timothy Flynn
8bd394f349 LibJS: Use an Intl prototype for a Function.prototype.toString test
The Temporal.TimeZone object no longer exists in the Temporal spec.
2024-11-18 17:46:41 -05:00
Timothy Flynn
ed76e1ed4b LibJS: Use Date for timing test-js tests
Stop relying on Temporal, at least temporarily. The classes used here
will soon be removed (until they are implemented again from scratch).
2024-11-18 17:46:41 -05:00
Timothy Flynn
dd6acfecd4 LibJS: Don't use Temporal to parse UTC offset strings
The production for these strings has been removed from Temporal. This
implements a separate parser in accordance with the Date spec.
2024-11-18 17:46:41 -05:00
Timothy Flynn
f88826691c LibJS: Remove usage of obsolete Duration record from Intl.DurationFormat
The Duration record no longer exists in Temporal. Implement it according
to the DurationFormat spec to prepare for its removal from our Temporal
implementation.

We also implement the DurationSign AO here as well, as the Temporal
implementation will now require a Temporal.Duration JS object.
2024-11-18 17:46:41 -05:00
Timothy Flynn
59e0b7ccb7 LibJS: Remove unused Temporal inclusion from Intl 2024-11-18 17:46:41 -05:00
Pavel Shliak
8cd514d83c LibWeb: Correct serialization of steps() easing functions 2024-11-18 17:39:03 -05:00
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