77352 Commits

Author SHA1 Message Date
Johan Dahlin
b27c6d68e8 LibWeb: Dedup @font-face fetches by source URL 2026-04-25 17:06:28 +02:00
Johan Dahlin
d90c5b295a LibWeb: Honor text argument of FontFaceSet.load() / .check() 2026-04-25 17:06:28 +02:00
Johan Dahlin
db9c3b88f4 LibIDL: Allow quoted-string defaults with whitespace in IDL parameters
The old parameter-default lexer stopped at any whitespace, making it
impossible to write defaults like `optional CSSOMString text = " "`.
Fall back to `consume_quoted_string()` (capturing quotes) when the
default starts with a quote, so the spec default for
FontFaceSet.load()/.check() can be expressed in IDL.
2026-04-25 17:06:28 +02:00
Johan Dahlin
8c49029bb7 LibGfx+LibWeb: Only trigger @font-face loads from text shaping 2026-04-25 17:06:28 +02:00
Johan Dahlin
acabf765c1 LibWeb+LibGfx: Defer @font-face fetches until a codepoint renders 2026-04-25 17:06:28 +02:00
Johan Dahlin
0de26af387 Tests/LibWeb: Add tests for @font-face load behavior 2026-04-25 17:06:28 +02:00
Aliaksandr Kalenik
f916b3e11f LibWeb: Skip layout update in handle_mousemove when not needed
Only run update_layout() during mousemove handling when the result is
actually consumed, i.e. when the middle-button autoscroll handler or
mouse selection is active. This avoids forcing a synchronous layout
on every mousemove event in the common case.
2026-04-25 15:45:12 +02:00
Aliaksandr Kalenik
4f54b16315 LibWeb: Preserve non-ASCII characters in canvas text preparation
The whitespace-normalization loop in prepare_text() called
StringBuilder::append() on each code point, which resolves to the
`char` overload and truncates non-ASCII characters. measureText("ó")
therefore returned a width of 0, despite fillText painting the glyph.

Use append_code_point() instead, and add a regression test for both
precomposed and decomposed accented text.
2026-04-25 14:54:18 +02:00
Andreas Kling
792a8c3a9c LibWeb: Accept image/avif as a supported image MIME type
The list previously omitted AVIF even though we ship a working
AVIFImageDecoderPlugin, which meant <picture><source type="image/avif">
candidates and image-set(... type("image/avif")) candidates were
unconditionally skipped.
2026-04-25 14:54:10 +02:00
Andreas Kling
0105d56e6c Tests: Add CSS image-set resolution reftest
Cover image-set() candidate selection by resolution for background
images. The tests cover both source-order-independent selection and
calculated resolution descriptors that require layout context.
2026-04-25 14:54:10 +02:00
Andreas Kling
a226d778e6 LibWeb: Visit abstract list-style images
List-style images can now be abstract image values such as image-set(),
not just plain URL images. Visit the stored abstract image directly so
GC-backed resources held by those image values stay reachable.
2026-04-25 14:54:10 +02:00
Andreas Kling
c1fcb7dc3e Tests: Add CSS image-set background reftest
Cover image-set() painting through background-image with URL-backed
SVG candidates. The test verifies that an unsupported type() candidate
is skipped and the supported image/svg+xml candidate is loaded and
painted.
2026-04-25 14:54:10 +02:00
Andreas Kling
61d79a1e47 LibWeb: Parse CSS image-set()
Add an abstract image style value for image-set() and parse both the
standard and -webkit-prefixed spellings through the existing <image>
value path. The parser accepts URL and string image candidates,
optional resolution descriptors, and type() filters.

Track attr-taint through substituted component values so image-set()
candidates using attr()-derived URL-producing tokens are rejected when
resolved for URL-using properties.

Update the relevant WPT baselines now that image-set() parsing is
supported in additional value contexts.
2026-04-25 14:54:10 +02:00
Andreas Kling
30f37d691c LibWeb: Share supported image MIME type list
Extract the file-local is_supported_image_type() helper from
HTMLImageElement into a small standalone translation unit so other
parts of the engine can ask the same question. The next commit reuses
it for the image-set() type() filter.

The list is still hard-coded; deriving it from the registered image
decoders remains a FIXME.
2026-04-25 14:54:10 +02:00
Andreas Kling
9a275155c9 Tests: Import CSS image-set parsing WPT
Import the CSS Images image-set parsing WPT with the current
expectations so parser support can be landed against a focused baseline.
2026-04-25 14:54:10 +02:00
Tim Ledbetter
30f8e7f80c LibWeb: Include non-auto cross margins in auto-margin resolution
When resolving cross-axis auto margins on a flex item, the outer cross
size calculation omitted all cross-axis margins. We now include
non-auto margins as part of the outer cross size treating auto margins
as zero.
2026-04-25 14:46:12 +02:00
Sam Atkins
2ed3868012 Meta: Replace GenerateCSSPropertyID with a python generator
We don't match the C++ output byte-for-byte here, because the key
iteration order is different. So I've taken the opportunity to tidy up
some whitespace too.
2026-04-25 12:02:49 +02:00
Sam Atkins
3580e2506c Meta: Replace GenerateCSSStyleProperties with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
d3d124b1d8 Meta: Replace GenerateCSSNumericFactoryMethods with a python generator
Adds a new `invoke_py_idl_generator` CMake helper for python scripts
that also produce an IDL file.
2026-04-25 12:02:49 +02:00
Sam Atkins
399341c3de Meta: Replace GenerateCSSPseudoElement with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
353846fe79 Meta: Replace GenerateCSSMathFunctions with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
143f1bc34d Meta: Replace GenerateCSSDescriptors with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
5fbf6f6801 Meta: Replace GenerateCSSUnits with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f2ead8b520 Meta: Replace GenerateCSSMediaFeatureID with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
91022151d6 Meta: Replace GenerateCSSPseudoClass with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f7898d2c8b Meta: Replace GenerateCSSTransformFunctions with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f9dc467cae Meta: Replace GenerateCSSKeyword with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f6a3ff388b Meta: Replace GenerateCSSEnvironmentVariable with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
4de5f3056b Meta: Replace GenerateCSSEnums with a python generator 2026-04-25 12:02:49 +02:00
Andreas Kling
b629914428 LibWeb: Make TransferArrayBuffer zero-copy
Move owned ArrayBuffer storage directly when transferring stream
buffers instead of copying the bytes before detaching the source.
WebAssembly memory continues to copy because its ArrayBuffer wraps
externally-owned storage.

Preserve the abrupt completion from DetachArrayBuffer before moving
storage so non-transferable buffers, such as WebAssembly.Memory-backed
views, still surface TypeError through stream operations instead of
aborting.

This saves ~130ms of main thread time when loading a YouTube video
on my Linux computer. :^)
2026-04-25 10:53:51 +02:00
Tim Ledbetter
59bf30f17f LibWeb: Add AVIF and WebP to the Accept header for images
This matches the behavior of other engines. Some CDNs that do content
negotiation will fall back to non alpha-preserving formats if these
values are not present.
2026-04-25 08:49:04 +02:00
Tim Ledbetter
49834ef782 Tests: Add test server endpoint that records the last request's headers 2026-04-25 08:49:04 +02:00
Tim Ledbetter
eef11001ec LibWeb: Avoid ref-count churn when diffing computed styles 2026-04-25 08:47:47 +02:00
Luke Wilde
5d38e37a53 UI/AppKit: Add missing AutocompleteRowModel text field initializer 2026-04-25 08:47:15 +02:00
Andreas Kling
c66cab7e6b AK: Hide tentative HashTable bucket from iterators across ensure()
HashMap<_, GC::Ref<_>>::ensure() crashed under UBSan whenever the
initialization callback triggered a GC: lookup_for_writing() stamped
the target bucket as used and added it to the ordered list before the
callback ran, so the marking visitor walked the map, read the
uninitialized slot, and failed the returns_nonnull check in GC::Ref.

Split bucket reservation into two phases. lookup_for_writing() now
hands back the target in the Free state (not in the ordered list,
m_size unchanged); callers placement-new the value and then commit via
commit_inserted_bucket(). The Robin Hood displacement loop still
stamps the slot internally and un-stamps before returning, so probing
is unchanged and the whole operation remains a single hash and a
single probe.
2026-04-25 06:21:36 +02:00
Yayoi-cs
0b9636fadf LibJS: Only cache TypedArray data pointers for owned buffers
WebAssembly.Memory-backed ArrayBuffers wrap external
ByteBuffer storage. When that memory grows,
ByteBuffer::try_resize() may realloc the backing storage while
old fixed-length buffer objects remain reachable from JS.

TypedArrayBase cached m_data for all fixed-length buffers, and
the asm interpreter fast path dereferenced that cached pointer
directly. For wasm memory views this could leave a stale
pointer behind across grow().

Restrict cached typed-array data pointers to fixed-length
ArrayBuffers that own stable ByteBuffer storage.
External/unowned buffers, including WebAssembly.Memory
buffers, now keep m_data == nullptr and fall back to code that
re-derives buffer().data() on each access.

Add regressions for both the original shared-memory grow case
and the second-grow stale-view case.
2026-04-25 06:11:18 +02:00
Tim Ledbetter
5d69c6d2b7 LibWeb: Filter by font width before weight in font matching
Implement the width filtering step of the font matching algorithm.
Without it, system font providers that group all widths under one
family could return a condensed variant for font-width: normal,
producing visibly narrower text.
2026-04-24 20:19:38 +02:00
Tim Ledbetter
2ff967fd6f LibWeb: Track declared font width on @font-face rules 2026-04-24 20:19:38 +02:00
Tim Ledbetter
5cefb14707 LibWeb: Switch font to loading in FontFace::load()
FontFace.load() set the face's status to "loading" but never switched
the containing FontFaceSets to "loading" or appended to their
`[[LoadingFonts]]` lists. The load-completion handler then found
`[[LoadingFonts]]` already empty and fired switch-to-loaded after the
first face finished, resolving `document.fonts.ready` while faces in
the same set were potentially still loading.
2026-04-24 20:19:38 +02:00
Timothy Flynn
fdbdb0ecd2 LibWebView+UI: Show an error page when we cannot sanitize a URL
Previously, if search was disabled, entering non-URL text would just
silently drop the search query (and on Qt, we would reload the current
URL). We now detect that the query did not result in a navigation and
load an error page instead, which directs the user to enable search.
2026-04-24 20:17:23 +02:00
Timothy Flynn
83eda625d5 LibWebView: Remove new tab page URL from sanitize_urls API
This used to come from UI-specific settings (e.g. QSettings). But it's
stored in LibWebView now, so we don't need callers to provide it.
2026-04-24 20:17:23 +02:00
Shannon Booth
cc6e048bd6 LibWeb+LibIDL: Remove support for #import directives during parsing
These no longer serve any purpose now that we run the IDLGenerator
on all of these files at once.
2026-04-24 20:08:29 +02:00
Shannon Booth
ba741994dd LibIDL: Resolve parsed interfaces post parsing
Move partial interface, partial namespace, mixin, typedef, and overload
finalization into a context-wide post-parse resolve step.

This lets BindingsGenerator parse all declared IDL files first and then
finalize the shared IDL context before generating bindings.
2026-04-24 20:08:29 +02:00
Shannon Booth
a153732a64 LibWeb: Parse support IDL files when generating bindings
Teach the bindings build to pass support IDL files alongside the regular
binding IDLs so BindingsGenerator parses the full declared IDL set into
a shared context.

Keep idl_files.cmake as the source of truth for parsed support IDLs, and
let Interface::will_generate_code() decide which parsed interfaces emit
generated bindings.
2026-04-24 20:08:29 +02:00
Shannon Booth
5f3812ecca LibIDL: Drop unused imported module state
Semantic IDL lookups no longer rely on imported modules, so stop storing
that state on Interface and Module.

import directives are still resolved during parsing for now, but the
parsed imported-module lists are no longer needed.
2026-04-24 20:08:29 +02:00
Shannon Booth
0e55b0f87e LibWeb/Bindings: Derive includes from IDL references
Stop using imported modules to decide which binding headers to include.
Instead, collect dependencies from referenced interfaces, dictionaries,
enumerations, callbacks, and nested IDL types in the parsed context.
2026-04-24 20:08:29 +02:00
Shannon Booth
535b8f5b9b LibWeb/Bindings: Qualify generated C++ type names
Derive C++ namespaces from each IDL module's location and use those
qualified names when generating binding code.

Also Teach dictionaries their owning IDL module path so dictionary C++
types can be qualified the same way as interfaces. This removes the need
for the generated `using namespace Web::*` hack and the hard-coded
namespace list.

Also fix DOMURL.idl to refer to the IDL interface name `URL`, not the
C++ implementation name `DOMURL`.
2026-04-24 20:08:29 +02:00
Shannon Booth
4178ec0af4 LibWeb/WebGL: Remove Extensions interface
No other third layer folder in LibWeb has its own namespace which
makes this a special case for the IDLGenerator when determining
namespaces. Instead of adding a special case, simply remove the
namespace.
2026-04-24 20:08:29 +02:00
Shannon Booth
83427086fa LibWeb/Bindings: Use IDL context to determine 'is platform object' 2026-04-24 20:08:29 +02:00
Shannon Booth
83f4e03045 LibWeb/Bindings: Batch BindingsGenerator over all IDL files
Teach BindingsGenerator to parse and generate bindings for the full
LibWeb IDL set in one invocation, and collapse the CMake bindings
rules from one custom command per IDL file to a single batched codegen
step.

This has the downsides of:
 * Any single IDL change now reruns the whole bindings generator
 * Per-IDL parallelism at the custom-command level is lost

However, I still feel that this is a worthy trade off as:
 * Generated files are written with write_if_changed(), so rebuilds
   of generated files should not be significantly impacted.
 * It is not a common task to be modifying IDL files
 * Most importantly, giving the IDL generator full knowledge of _all_
   IDL will allow for some simplifications of the bindings generator as
   it has knowledge of all types.
2026-04-24 20:08:29 +02:00