Commit graph

64527 commits

Author SHA1 Message Date
Jelle Raaijmakers
4c189166f4 LibWeb: Implement indexed property support for HTML::Storage
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
We only supported named properties on Storage, and as a result
`localStorage[0]` would be disconnected from the Storage's backing map.

Fixes at least 20 subtests in WPT in /webstorage.
2024-10-18 23:10:22 +02:00
Timothy Flynn
999c591e83 LibCore: Remove unused Core::System wrappers
As efforts to begin porting to Windows is underway, doing so should be a
bit less daunting if we clean up syscall wrappers that aren't used.

Note: While this removes Serenity-only wrappers, it leaves the Serenity
implementations of used wrappers in place for now, to not needlessly
complicate merging between the two orgs.
2024-10-18 18:16:18 +02:00
Timothy Flynn
1ce10d6b39 Utilities: Remove no-op calls to unveil and pledge 2024-10-18 18:16:18 +02:00
Jelle Raaijmakers
8419a5f60f LibGfx: Remove unused, deprecated code 2024-10-18 18:12:45 +02:00
Aliaksandr Kalenik
11e10d0532 LibWeb: Add missing flex-start and flex-end in to_alignment [GFC]
Fixes crashing on https://tweakers.net/
2024-10-18 18:11:46 +02:00
Edward Banner
912511a152 LibWeb: Use containing block to compute scrollable overflow
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
Instead of using child boxes to compute scrollable overflow for the box,
we use descendants which have the box as their containing block.
2024-10-18 15:26:42 +02:00
Aliaksandr Kalenik
de238328eb LibWeb: Accept paintable instead of layout node in resolve_background() 2024-10-18 14:59:41 +02:00
Aliaksandr Kalenik
78d8989ea4 LibWeb: Accept paintable instead of layout node in paint_background()
After InlinePaintable is gone it's possible to make this function accept
a PaintableBox instead of more broad
Layout::NodeWithStyleAndBoxModelMetrics type.
2024-10-18 14:59:41 +02:00
Timothy Flynn
048b51eb54 WebContent: Add a JS visitor to WebDriver's IPC connection
We've added a few JS::Handle members to this class over time. Let's
avoid creating a new GC root for each of these, and explicitly add a
visitation method.
2024-10-18 09:45:04 +02:00
Timothy Flynn
022e2b8a94 LibWeb+WebContent: Rename the WebDriver get-known-element AO
The underlying concept is the same, but this method was renamed in the
spec to drop the word "connected".
2024-10-18 09:45:04 +02:00
Timothy Flynn
a96a762305 LibWeb+WebContent: Use NNGCPtr in WebDriver code where appropriate
Some of this code is older than widespread use of GCPtr. These functions
returning raw pointers has been a point of confusion at times, so lets
just indicate that they are non-null.
2024-10-18 09:45:04 +02:00
Totto16
93954dcd9a Meta: Replace deprecated pre-commit stage name
Also set minimum_pre_commit_version to 3.2.0
as this stage name is supported since then
2024-10-18 09:40:59 +02:00
Jelle Raaijmakers
2a98f2a12d LibWeb: Implement AudioListener
This exposes BaseAudioContext.listener, which is a container for
parameters related to the configuration of an actual "listener" in 3D
space.
2024-10-18 09:39:04 +02:00
Timothy Flynn
eeee6ba3f5 LibWeb: Visit the MessagePort's associated Worker target
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
Without this, a worker can be GC'd in a very simple script such as:

    const worker = new Worker("script.js");
    worker.onmessage = () => {};

Where script.js attempts to post a message back to the parent window.

When the Worker is GC'd, the IPC connection from the WebContent process
to the WebWorker process is closed. When this occurs, the WebWorker will
exit() from LibIPC, and any message from the worker to its parent does
not have a chance to run.
2024-10-17 16:34:32 -04:00
Timothy Flynn
ba1b26cdc2 LibWeb: Disentangle associated MessagePorts when a document is destroyed 2024-10-17 16:34:32 -04:00
Timothy Flynn
d44dd756b3 LibWeb: Reset MessagePort's worker event target when it is disentangled 2024-10-17 16:34:32 -04:00
Timothy Flynn
83be2606db LibWeb: Update spec steps for destroying a DOM document
This just updates our copied spec steps - new steps are not implemented
here. This is mostly just to highlight new steps we are missing around
MessagePorts.

No behavior change, but this does resolve an outstanding FIXME around
spec step ordering.
2024-10-17 16:34:32 -04:00
Timothy Flynn
32a22c49e3 LibWeb: Move StructuredSerializeOptions to its own header
This largely reduces the number of files needed to be compiled when we
change the MessagePort header.
2024-10-17 16:34:32 -04:00
Timothy Flynn
5ed702e211 LibWeb: Sort the forwarding header 2024-10-17 16:34:32 -04:00
Andreas Kling
3c5819a6d2 LibJS: Allow GetById to cache getters
1.25x speed-up on this microbenchmark:

    let o = { get x() { return 1; } };
    for (let i = 0; i < 10_000_000; ++i)
        o.x;

I looked into this because I noticed getter invocation when profiling
long-running WPT tests. We already had the mechanism for non-getter
properties, and the change to support getters turned out to be trivial.
2024-10-17 22:06:16 +02:00
Sam Atkins
e4245dc39e LibWeb/CSS: Process style properties from CSSNestedDeclarations rules
These are created when a style rule has properties listed after another
rule. For example:

```css

.test {
  --a: 1;
  --b: 1;
  --c: 1;

  .thing {
    /* ... */
  }

  /* These are after a rule (.thing) so they're wrapped in a
     CSSNestedDeclarations: */
  --d: 1;
  --e: 1;
  --f: 1;
}
```

They're treated like a nested style rule with the exact same selectors
as their containing style rule.
2024-10-17 20:55:55 +02:00
Sam Atkins
53f99e51f8 LibWeb/CSS: Parse and use nested style rules
For example, this:

```css
.foo {
  color: red;
  &:hover {
    color: green;
  }
}
```

now has the same effect as this:

```css
.foo {
  color: red;
}
.foo:hover {
  color: green;
}
```

CSSStyleRule now has "absolutized selectors", which are its selectors
with any `&`s resolved. We use these instead of the "real" selectors
when matching them, meaning the style computer doesn't have to know or
care about where the selector appears in the CSS document.
2024-10-17 20:55:55 +02:00
Sam Atkins
74c448d744 LibWeb/CSS: Use SelectorList type instead of Vector<NNRP<Selector>> 2024-10-17 20:55:55 +02:00
Sam Atkins
d935a00413 LibWeb/CSS: Clear CSSRule's cached layer name when it is moved
Through the CSSOM, rules can be moved around, and so anything cached
(for now just the qualified layer name) needs to be recalculated when
that happens. This method is virtual so that other rules will be able
to clear their cached data too.
2024-10-17 20:55:55 +02:00
Sam Atkins
36afff97d1 LibWeb/CSS: Parse nested rules in style blocks
Nested lists of declarations become CSSNestedDeclarations; at-rules are
allowed as long as they are CSSGroupingRules.
2024-10-17 20:55:55 +02:00
Sam Atkins
9c66ab356a LibWeb: Implement CSSNestedDeclarations type
This is basically a list of properties, without a block around it. It'll
be part of CSSStyleRules' contents.
2024-10-17 20:55:55 +02:00
Sam Atkins
5b4d1b5b05 LibWeb/CSS: Parse the & nesting selector 2024-10-17 20:55:55 +02:00
Andreas Kling
55f58eea99 LibWeb: Use the correct document URL in DOMParser.parseFromString()
We were hard-coding "about:blank" as the document URL for parsed HTML
documents, which was definitely not correct.

This fixes a bunch of WPT tests under /domparsing/ :^)
2024-10-17 19:16:08 +02:00
Kostya Farber
323370dfa3 LibWeb: Start implementation of rendering tabs according to tab-size
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-17 15:00:57 +02:00
Jelle Raaijmakers
2df3488840 LibWeb: Implement pending promises in BaseAudioContext
Move the pending promises list from AudioContext to BaseAudioContext and
deal with all remaining FIXMEs.
2024-10-17 08:48:14 -04:00
Jelle Raaijmakers
0310b47a7b Documentation: Remove doc on self-hosted runners
The mentioned runner is no longer in use, and we set up runners managed
by the org nowadays.
2024-10-17 08:16:50 -04:00
Simon König
15d2857a01 LibWeb: Don't crash on encountering display: list-item on pseudo element
On any `display: list-item` Node a CSS pseudo element (`::marker`) needs
to be created. This commit allows the ::maker pseudo element to be
nested within other pseudo elements (e. g. ::before or ::after).

This fixes this WPT test:
http://wpt.live/css/CSS2/generated-content/after-content-display-003.xht
2024-10-17 07:42:59 +01:00
Benjamin Bjerken
0c04bd6676 LibWeb: Add SVGImageElement load and error events
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 resolves all WPT timeouts in html/canvas/element/manual/imagebitmap
We can now run an additional 6 tests and 126 subtests :)

This also adds regression tests for this behavior.
2024-10-16 22:59:28 +01:00
Aliaksandr Kalenik
c097f53875 LibWeb: Remove InlinePaintable
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
It was replaced with PaintableWithLines.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
6a549f6270 LibWeb: Replace InlinePaintable with PaintableWithLines created per line
InlinePaintable was an ad-hoc paintable type required to support the
fragmentation of inline nodes across multiple lines. It existed because
there was no way to associate multiple paintables with a single layout
node. This resulted in a lot of duplicated code between PaintableBox and
InlinePaintable. For example, most of the CSS properties like
background, border, shadows, etc. and hit-testing are almost identical
for both of them. However, the code had to be duplicated to account for
the fact that InlinePaintable creates a box for each line. And we had
quite many places that operate on paintables with a code like:
```
if (box.is_paintable_box()) {
  // do something
} else (box.is_inline_paintable()) {
  // do exactly the same as for paintable box but using InlinePaintable
}
```

This change replaces the usage of `InlinePaintable` with
`PaintableWithLines` created for each line, which is now possible
because we support having multiple paintables per layout node. By doing
that, we remove lots of duplicated code and bring our implementation
closer to the spec.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
c690fb9df3 LibWeb: Rename Layout::Node::paintable() to first_paintable()
Layout node is allowed to have multiple corresponding paintables, so
first_paintable() is more explicit name for getter that returns first
paintable.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
7d22b1c5c8 LibWeb: Allow layout nodes to have multiple paintables
CSS fragmentation implies 1:N relationship between layout nodes and
paintables. This change is a preparation for implementation of inline
fragmentation where InlinePaintable will be replaced with
PaintableWithLines corresponding to each line.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
a6718e5f3b LibWeb: Resolve vertical borders for inline nodes
Preparation for upcoming change where InlinePaintable will no longer be
responsible for doing that.
2024-10-16 20:25:42 +02:00
stasoid
9d15b3bbb7 AK: Fix lld-link : error : undefined symbol: __udivti3 on Windows 2024-10-16 12:15:31 -06:00
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