Commit graph

64238 commits

Author SHA1 Message Date
Cameron Youell
958ffad706 AK: Provide more complete definitions for AK_OS_WINDOWS
MSG_NOSIGNAL is a no-op for Windows, so we can define it to 0.

At the same *time*, none of the CLOCK_* macros are defined on
Windows, as clock_gettime does not exist. Put AK_OS_WINDOWS in the
same category of the BSDs for the COARSE versions of those macros.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
Cameron Youell
e1710939ce AK: Implement now_time_from_clock for Windows
Monotonic uses QueryPerformanceCounter, while realtime uses
GetSystemTimeAsFileTime. These should approximate clock_gettime
fairly accurately. The QPC implementation only grabs microseconds,
but if we have actual use cases for nanos, we can bump that up.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
David Smith
e7c209820d LibWeb: Layout all math elements using InternalDummy context
Always create a new formatting context for <math> elements. Previously
that didn't happen if they only had inline children, e.g. mtable.

This fixes a crash in the WPT MathML test
mathml/crashtests/children-with-negative-block-sizes.html
2024-10-16 19:51:36 +02:00
stelar7
4408ea7c9b LibWeb: Handle calculations without a context better 2024-10-16 16:39:47 +02:00
Tim Ledbetter
c0beacbb76 LibWebSocket: Remove some accidentally included debug logic
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
2024-10-16 13:22:30 +01:00
Sam Atkins
6e68e8f3c9 LibWeb/CSS: Insert whitespace between tokens in serialized UnresolvedSV
Otherwise, `margin: var(--foo) var(--bar)` would be wrongly serialized
as `margin: var(--foo)var(--bar)`
2024-10-16 08:34:31 +02:00
Sam Atkins
bf3e6daedb LibWeb/CSS: Preserve whitespace and comments in custom properties
A couple of parts of this:
- Store the source text for Declarations of custom properties.
- Then save that in the UnresolvedStyleValue.
- Serialize UnresolvedStyleValue using the saved source when available -
  that is, for custom properties but not for regular properties that
  include var() or attr().
2024-10-16 08:34:31 +02:00
Sam Atkins
f8995d37a2 LibWeb/CSS: Tokenize comments as whitespace tokens
This is in a weird position where the spec tells us to discard the
comments, but then we have to preserve the original source text which
may include comments. As a compromise, I'm treating each comment as a
whitespace token - comments are functionally equivalent to whitespace
so this should not have any behaviour changes beyond preserving the
original text.
2024-10-16 08:34:31 +02:00
Sam Atkins
ea164124de LibWeb/CSS: Preserve original source text for ComponentValues
This requires a little bit of ad-hoc tracking of start/end Tokens for
Function and SimpleBlock.
2024-10-16 08:34:31 +02:00
Sam Atkins
04939d68f0 LibWeb/CSS: Rename Token::representation() to original_source_text()
This is the term used in the Syntax-3 spec as of right now.
2024-10-16 08:34:31 +02:00
Sam Atkins
301502a3a1 LibWeb: Add coverage test for calc() usage
Ignoring the fact that we should serialize a simplified form of calc()
expressions, the following are wrong:

- grid-auto-columns
- grid-auto-rows
- grid-template-columns
- grid-template-rows
- transform-origin

Generated in part with this python script (though I've since iterated on
the output repeatedly so it's quite different):

```py
import json
properties_file = open("./Userland/Libraries/LibWeb/CSS/Properties.json")
properties = json.load(properties_file)
for (key, value) in properties.items():
    if not 'valid-types' in value:
        continue
    if 'longhands' in value:
        continue
    valid_types = value['valid-types']
    for type_string in valid_types:
        name, *suffix = type_string.split(None, 1)
        match name:
            case 'integer' | 'number':
                print(f'{key}: calc(2 * var(--n));')
            case 'angle':
                print(f'{key}: calc(2deg * var(--n));')
            case 'flex':
                print(f'{key}: calc(2fr * var(--n));')
            case 'frequency':
                print(f'{key}: calc(2hz * var(--n));')
            case 'length':
                print(f'{key}: calc(2px * var(--n));')
            case 'percentage':
                print(f'{key}: calc(2% * var(--n));')
            case 'resolution':
                print(f'{key}: calc(2x * var(--n));')
            case 'time':
                print(f'{key}: calc(2s * var(--n));')
```
2024-10-16 08:34:02 +02:00
Sam Atkins
7c2680b7ef LibWeb/CSS: Serialize empty grid-template-* values correctly
Previously we would serialize these as the empty string. eg, this:

```
<div style="grid-auto-columns: auto"></div>
```

would have a computed `grid-auto-columns` value of ``.
2024-10-16 08:34:02 +02:00
Sam Atkins
69d064697a LibWeb/CSS: Handle calculated integers when expanding unresolved values
In order to know whether `calc(2.5)` is a number or an integer, we have
to see what the property will accept. So, add that knowledge to
`Parser::expand_unresolved_values()`.

This makes `counter-increment: foo calc(2 * var(--n));` work correctly,
in a test I'm working on.
2024-10-16 08:34:02 +02:00
Sam Atkins
aeed4921c4 LibWeb: Indent the CSS dumps correctly
Selectors and at-rules both made assumptions about their indentation
level, which made it difficult to read the dump output. It'll become
even worse once rules can be further nested within each other, so let's
fix it now. :^)
2024-10-16 08:32:29 +02:00
Sam Atkins
5cc75d4de4 LibWeb: Remove tiny-OOM handling from dump code 2024-10-16 08:32:29 +02:00
Tim Ledbetter
ebe1dc6dcd LibWebSocket: Send closing frame when server begins a closing handshake 2024-10-16 08:31:49 +02:00
Tim Ledbetter
0b365061d1 LibWebSocket: Ensure connection is failed on invalid opening handshake 2024-10-16 08:31:49 +02:00
Andrew Kaster
9d0ce4df0f LibWeb: Add support for parsing comments in the Swift HTML tokenizer 2024-10-16 08:31:42 +02:00
Andrew Kaster
36a8ad9157 LibGfx: Move FontDatabase internals to SystemFontProvider interface
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 will be the first step is making better use of system libraries
like fontconfig and CoreText to load system fonts for use by the UI
process and the CSS style computer.
2024-10-15 15:09:16 -06:00
Galvin
e8ff9b6eb4 UI/AppKit: Fix tab title icon and text layout
Make the tab title icon and text vertical center
2024-10-15 11:44:26 -04:00
Sam Atkins
81596b4145 LibWeb/CSS: Stop invalidating style when setting an animation's effect
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 reverts 6d25bf3aac

Invalidating the style here means that transitions can cause an element
to leave style computation with its "needs style update" flag set to
true. This then causes a VERIFY to fail in the TreeBuilder.

This invalidation does not otherwise seem to have any effect. The
original commit suggests this was to fix a bug, but it's not clear what
bug that was. If it reappears, we can try to solve the issue in a
different way.
2024-10-15 08:43:26 -04:00
Benjamin Bjerken
63d9ed9d8c LibWeb: Fix CloseWatcher constructor for detached iframes
This fixes the last subtest in /close-watcher/frame-removal.html :)
2024-10-15 08:41:54 -04:00
Jelle Raaijmakers
14b2e5849d LibWeb: Add barebones BaseAudioContext.decodeAudioData()
Implement just enough steps to get https://zty.pe/ working! :^)
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
7b76438d57 LibWeb: Accept JS::HeapFunction when queuing a media element task
This opens up the possibility of easier memory management in future
changes.
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
177e5210e0 LibWeb: Move 'queue a media element task' to BaseAudioContext
We need these steps to be available for the yet to be implemented
`BaseAudioContext.decodeAudioData()`.
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
273a46cc76 LibWeb: Remove unused include from AudioBuffer 2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
3df3977ca5 LibWeb: Correct AudioBuffer spec link 2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
0b9d55b676 Meta: Reuse built-in JS types list for IDL to C++ generation
This opens up the code path for the `ArrayBuffer` type, which can now be
used as a method argument.
2024-10-15 10:02:15 +02:00
justus2510
7a92b47a35 LibWeb: Make FileReader fire progress event
Fixes wpt/FileAPI/reading-data-section/filereader_events.any.html :)
2024-10-15 08:42:37 +02:00
Timothy Flynn
c0102aa818 LibJS: Support date strings of the form "Wed Apr 17 2019 23:08:53""
Seen on https://www.skaping.com/valloire/galibier.
2024-10-15 08:25:32 +02:00
Andrew Kaster
a3157c8c69 LibWasm: Reject indirect calls to external function references
Some checks failed
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
Build Dev Container Image / build (push) Has been cancelled
This fixes a test in the WebAssembly spec test suite that was
added in 924c1f816d
2024-10-14 18:14:18 -06:00
Andrew Kaster
c4f7361a5b Meta: Add a vcpkg cache to the devcontainer
This also means that the prebuilt devcontainer will have a populated
vcpkg binary cache, speeding up the first build by a lot.
2024-10-14 15:55:23 -06:00
Andrew Kaster
8e716daa3d CMake: Allow developers to append VCPKG_BINARY_SOURCES
This enables adding extra binary caches, which will be useful for
devcontainers.
2024-10-14 15:55:23 -06:00
John Diamond
5c35807878 Documentation: Suggest installing clang-format version 18 precisely 2024-10-14 15:54:53 -06:00
John Diamond
8f45f59df3 Meta: Warn before attempting to use clang-format 19
The clang-format version released with llvm 19 will format many files
differently than clang-format-18.

This change presents the existing warning shown for incorrect
clang-format versions to those with versions greater than 18.

Fixes issue #1750
2024-10-14 15:54:53 -06:00
Andrew Kaster
10a2cc3781 Tests: Use Swift.String extension instead of manual conversion
This fixes a build error with Swift 6.0 on macOS.
2024-10-14 16:55:09 -04:00
Shannon Booth
329e9ed820 LibWeb: Fix spec typo in inner_navigate_event_firing_algorithm
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
2024-10-14 20:49:03 +02:00
Shannon Booth
dc9861174b LibWeb: Fire traversable event during "apply the history step"
These steps were recently clarified by Andrew in:

https://github.com/whatwg/html/commit/12b0d582
2024-10-14 20:49:03 +02:00
Shannon Booth
bd3ffcdabb LibWeb: Simplify populate_session_history_entry_document conditional 2024-10-14 20:49:03 +02:00
Shannon Booth
41f574155d LibWeb: Factor out AO for 'try to scroll to the fragment'
I had made a stab at implementing this to determine whether it could
assist in fixing an issue where scroll_to_the_fragment was not getting
called at the appropriate time. It did not fix that issue, and actually
ended up breaking one of our in tree tests. In the meantime, factor out
this method into a standalone function.
2024-10-14 20:49:03 +02:00
Andreas Kling
279d229f71 LibWeb: Remove unnecessary use of TRY_OR_THROW_OOM in XMLHttpRequest 2024-10-14 20:47:35 +02:00
Andreas Kling
fa1c5a3e85 LibWeb: Make XMLHttpRequests functions related to MimeType infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
600cb5ccba LibWeb: Make MimeSniff::Resource::sniff() infallible
Everyone was already using this API as if it were infallible anyway.
2024-10-14 20:47:35 +02:00
Andreas Kling
5c20bc2afc LibWeb: Make MimeSniff::MimeType::parse() infallible
It already returns an empty Optional for failures, so there's no need to
wrap it in an ErrorOr as well.
2024-10-14 20:47:35 +02:00
Andreas Kling
88e7688940 LibWeb: Make more MimeSniff::MimeType APIs infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
9a8db40a23 LibWeb: Make MimeSniff::MimeType::create() infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
073bcfd386 AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
2024-10-14 20:47:35 +02:00
Andreas Kling
dd419b5a8d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.
2024-10-14 20:47:35 +02:00
Edward Banner
03569fc509 LibWeb: Fix table overflow issues
- Include vertical border spacing in row group offset calculation so
  that they are axis-aligned with child row/cell elements. This makes it
  so there isn't horizontal and vertical overflow caused by child
  row/cell elements.
- Include horizontal border spacing in tr width calculations. This makes
  it so tr elements don't have overflow anymore when there are multiple
  columns.
- Apply vertical caption offset to row group top offset.
- Don't double-count top padding when calculating vertical offset for
  tr and row groups.
2024-10-14 17:30:17 +01:00
Jelle Raaijmakers
70b3936188 LibMedia: Handle EOF as end of stream in FFmpegLoader
We were dealing with EOF by returning a generic I/O error, but
Audio::Loader requires us to return empty chunks at the end of stream.
2024-10-14 11:59:23 -04:00