Commit graph

189 commits

Author SHA1 Message Date
Timothy Flynn
64abc6101d LibWeb+WebWorker: Use IPC mechanics for structured serialization
Our structured serialization implementation had its own bespoke encoder
and decoder to serialize JS values. It also used a u32 buffer under the
hood, which made using its structures a bit awkward. We had previously
worked around its data structures in transferable streams, which nested
transfers of MessagePort instances. We basically had to add hooks into
the MessagePort to route to the correct transfer receiving steps, and
we could not invoke the correct AOs directly as the spec dictates.

We now use IPC mechanics to encode and decode data. This works because,
although we are encoding JS values, we are only ultimately encoding
primitive and basic AK types. The resulting data structures actually
enforce that we implement transferable streams exactly as the spec is
worded (I had planned to do that in a separate commit, but the fallout
of this patch actually required that change).
2025-07-18 10:09:02 -04:00
Timothy Flynn
7fad8c333d LibWeb: Use forward-declarations of structured serialized types
This reduces the rebuilt targets when touching StructuredSerialize.h
from ~1200 to ~400. The remaining are due to generated IPC headers.
2025-07-18 10:09:02 -04:00
Luke Wilde
8e999bca62 LibWeb/CSP: Implement the style-src-attr directive
Some checks are pending
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-07-18 11:58:04 +12:00
Luke Wilde
574b736156 LibWeb/CSP: Implement the style-src-elem directive 2025-07-18 11:58:04 +12:00
Luke Wilde
8b0b3b186f LibWeb/CSP: Implement the style-src directive 2025-07-18 11:58:04 +12:00
Sam Atkins
6b53454b68 LibWeb/SVG: Move path data into Path.{h,cpp}
More things need this than just the `<path>` element, so let's avoid
having to include `SVGPathElement.h` in places that don't need it.

Minor changes at the same time:
- Wrap it in a Path class
- Specify underlying type for PathInstructionType
- Make a couple of free functions into methods
- Give PathInstruction an operator==

No functionality changes.
2025-07-17 13:59:23 -04:00
Aliaksandr Kalenik
b0ef7f4427 LibWeb: Defer invalidation sets processing until update_style()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This change converts `Node::invalidate_style()` (invalidation sets
overload) from eagerly doing tree traversal that marks elements affected
by invalidation set to instead adding "pending invalidation sets" into
`StyleInvalidator`, processing of which is deferred until the next
`update_style()`. By doing that we sometimes substantially reduce amount
of work done performing tree traversal that marks elements for style
recalculation.

Improves performance on Discord, were according to my measurements we
were previously spending 20% of time in style invalidation, but now it's
down to <1%.
2025-07-17 00:43:26 +02:00
Aliaksandr Kalenik
8cbe27b2f9 LibWeb: Move perform_pending_style_invalidations() in StyleInvalidator
This change introduces StyleInvalidator as a preparation for upcoming
change that will make `perform_pending_style_invalidations()` take care
of pending invalidation sets.
2025-07-17 00:43:26 +02:00
Sam Atkins
0a5e8c2865 LibWeb/CSS: Implement "parse with a <syntax>"
Uses the SyntaxNode tree to parse a list of ComponentValues into some
kind of StyleValue.
2025-07-16 14:47:45 +01:00
Sam Atkins
ded2207762 LibWeb/CSS: Parse the CSS <syntax> type into a tree
`<syntax>` is a limited subset of the "value definition syntax" used in
CSS specs. It's used for `@property`'s `syntax` descriptor, and for the
`type()` function in `attr()`.
2025-07-16 14:47:45 +01:00
Shannon Booth
15657ec4c3 LibWeb: Include or declare missing definitions for PseudoElement.h
clangd was loudly complaining about this file.
2025-07-15 13:54:17 +01:00
Aliaksandr Kalenik
7e333cdcf7 LibWeb: Separate device pixel conversion helpers from PaintContext
In the upcoming change, device pixel conversion of ClipFrame will
happen during display list replay, where PaintContext is not available,
so let’s move it out of PaintContext.
2025-07-14 15:48:28 +02:00
Luke Wilde
f50f23b19f LibWeb/CSP: Implement the script-src-attr directive 2025-07-12 13:06:33 +12:00
Luke Wilde
f382bccc3d LibWeb/CSP: Implement the script-src-elem directive 2025-07-12 13:06:33 +12:00
Aliaksandr Kalenik
410e82c9fd LibWeb: Rearrange code such that a lot less files include Command.h
Some checks failed
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
With this change number of recompiled files after modification of
`Command.h` goes down from >1000 to <100.
2025-07-11 17:37:27 +02:00
Luke Wilde
0cff47828d LibWeb/CSP: Implement the script-src directive 2025-07-09 15:52:54 -06:00
Lucien Fiorini
5d85959f5f LibWeb/SVG: Add FEGaussianBlurElement 2025-07-09 18:07:12 +01:00
Lucien Fiorini
f8b12614df LibWeb/SVG: Add FEBlendElement 2025-07-09 18:07:12 +01:00
Lucien Fiorini
d3684a36b0 LibWeb/SVG: Add FEFloodElement 2025-07-09 18:07:12 +01:00
Sam Atkins
b6032b0fcd LibWeb/CSS: Reimplement var()/attr() as arbitrary substitution functions
"Arbitrary substitution functions" are a family of functions that
includes var() and attr(). All of them resolve to an arbitrary set of
component values that are not known at parse-time, so they have to be
substituted at computed-value time.

Besides it being nice to follow the spec closely, this means we'll be
able to implement the others (such as `if()` and `inherit()`) more
easily.

The main omission here is the new "spread syntax", which can be
implemented in the future.
2025-07-09 16:44:20 +01:00
Sam Atkins
9079be850b LibWeb/CSS: Include guaranteed-invalid value in ComponentValue
Treating these like any other ComponentValue means not having to convert
between different types of Vector, and that we will be able to use
TokenStream to parse the "argument grammars" of arbitrary substitution
functions.
2025-07-09 16:44:20 +01:00
Luke Wilde
985a481b5a LibWeb/CSP: Implement the object-src directive
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-07-06 13:40:04 +12:00
Luke Wilde
1b12aa4d8e LibWeb/CSP: Implement the media-src directive 2025-07-06 13:40:04 +12:00
Luke Wilde
5addbcd61b LibWeb/CSP: Implement the manifest-src directive 2025-07-06 13:40:04 +12:00
Luke Wilde
715061fb79 LibWeb/CSP: Implement the img-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
1689353beb LibWeb/CSP: Implement the frame-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
e899438907 LibWeb/CSP: Implement the font-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
959bb5cc18 LibWeb/CSP: Implement the connect-src directive 2025-07-05 21:21:44 +12:00
Sam Atkins
e63d81b36e LibWeb: Add CustomStateSet IDL type 2025-07-04 18:10:28 +01:00
Callum Law
62d138ebf7 LibWeb: Allow passing a resolution context to CSSStyleValue::to_color
This will be used for resolving any calculated style values within the
various `CSSColorValue` sub-classes.

No functionality changes.
2025-07-04 13:18:55 +01:00
Tim Ledbetter
245905b833 LibWeb: Parse the border-image-slice property 2025-07-03 10:19:44 +01:00
Totto16
2ad3ce5d37 LibWeb: Implement basics for OffscreenCanvas
This implements the basic interface, classes and functions for
OffscreenCanvas. Many are still stubbed out and have many FIXMEs in
them, but it is a basic skeleton.
2025-06-30 09:46:21 -06:00
Aliaksandr Kalenik
594194eb60 LibWeb: Skip serialization of implicit grid lines created during layout
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
StyleValues created for grid-template-rows and grid-template-columns by
GFC should not include `-start`/`-end` lines implicitly created by grid
areas.
2025-06-25 20:45:48 +02:00
Aliaksandr Kalenik
af602b2555 LibWeb: Align CSS Grid properties parsing with the specification
Reimplements `grid`, `grid-template`, `grid-template-rows`, and
`grid-template-columns` in a way that uses a separate function for each
grammar rule defined in the specification. This change results in many
additional passing tests from the already imported WPT suite. Most of
the remaining test failures are related to incorrect serialization of
grid properties.
2025-06-21 22:07:08 +02:00
Jelle Raaijmakers
22bda8e5e2 LibWeb: Stub Geolocation API
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-06-21 10:00:29 +02:00
Sam Atkins
498e143687 LibWeb/DOM: Stop including Element.h from AbstractElement.h
We only need the forward declaration here, and this will let us include
AbstractElement from Element.
2025-06-19 12:35:31 +01:00
Sam Atkins
ce380a59c7 LibWeb/DOM: Rename ElementReference to AbstractElement
This isn't some kind of identifier, it's a handle on an actual Element
or PseudoElement.
2025-06-19 12:35:31 +01:00
Sam Atkins
e7c2f0dd52 LibWeb: Make PseudoElement a class in its own right
It's getting a bit large and complicated to be a struct hidden in
DOM::Element.
2025-06-19 12:35:31 +01:00
Timothy Flynn
de34143a4e LibWeb: Do not spin the event loop awaiting text track state changes
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The text track processing model would previously spin forever waiting
for the track URL to change. It would then recursively invoke itself
to handle the new URL, again entering the spin loop. This meant that
tracks could easily cause event loop hangs.

We now have an observer system to be notified when the track state
changes instead. This lets us exit the processing model and move on.
2025-06-12 12:25:23 -04:00
Aliaksandr Kalenik
f53559cb55 LibWeb: Change Storage{Bottle,Bucket,Shelf} to be GC-allocated
In upcoming changes StorageBottle will own pointers to GC-allocated
objects, so it needs to be a GC-allocated object itself to avoid
introducing more GC roots.
2025-06-12 17:04:35 +02:00
Tim Ledbetter
e2d0d8e2b9 LibWeb/CSS: Implement the scrollbar-color property
This allows the user to set the scrollbar thumb and track colors.
2025-06-02 00:17:51 +02:00
Sam Atkins
6e45d8ba6c LibWeb/CSS: Set enum sizes for PropertyID and Keyword
The effect of this is hard to measure, but reducing them from 4 bytes
each to 2 bytes can't hurt. :^)
2025-05-20 10:14:21 +12:00
Sam Atkins
c4bcbff59a LibWeb/CSS: Set enum sizes for media query types
This reduces `MediaFeature` from 112 to 104 bytes.
2025-05-20 10:14:21 +12:00
Sam Atkins
870f24f181 LibWeb/CSS: Add basic implementation of CSSMarginRule
This is a bit under-specced, specifically there's no definition of
CSSMarginDescriptors so I've gone with CSSStyleProperties for now. Gets
us 17 WPT subtests.
2025-05-16 11:01:39 +01:00
Sam Atkins
aaf07ae30d LibWeb: Add basic implementation of @page
This doesn't support selectors, and the only descriptors for now are for
margins.
2025-05-15 09:53:29 +01:00
Sam Atkins
398d2f9981 LibWeb/CSS: Implement pending-substitution value
This is a special value temporarily assigned to longhands when their
shorthand is unresolved, and then later replaced once that is resolved.
2025-05-14 11:46:47 +01:00
Sam Atkins
d1dadd43a1 LibWeb/CSS: Implement guaranteed-invalid value
This is a special value produced when var/attr substitution fails, and
is also the initial value for custom properties.
2025-05-14 11:46:47 +01:00
Timothy Flynn
7280ed6312 Meta: Enforce newlines around namespaces
This has come up several times during code review, so let's just enforce
it using a new clang-format 20 option.
2025-05-14 02:01:59 -06:00
stelar7
296d9d74d8 LibWeb/IDB: Implement IDBCursorWithValue interface 2025-05-13 10:48:40 -06:00
Sam Atkins
0925a32558 LibWeb/CSS: Extract a CSSDescriptors base class
This holds the boilerplate that's needed by any CSSStyleDeclaration
subclass that holds Descriptors. CSSFontFaceDescriptors now only has to
worry about initialization and its own exposed properties.
2025-05-08 16:21:32 +01:00