Commit graph

3512 commits

Author SHA1 Message Date
Andrew Kaster
7aa0165fe7 LibWeb: Deduplicate attributes when emitting start and end tags
Some checks are pending
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.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-22.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-22.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
The HTML tokenizer specification says that we're supposed to do this
when leaving the Attribute name or when emitting the token, as
appropriate.

Hopefully 'as appropriate' can mean only when emitting the token, as
that's the easiest place to insert this logic without complicating the
tokenizer any more.
2024-10-01 11:04:28 +02:00
Jelle Raaijmakers
233b4f2ca8 LibMedia+everywhere: Remove superfluous and unused audio code
We had numerous NiH-based implementations of audio formats and metadata
that we now no longer need because we either don't make use of the code,
or we replaced its implementation by FFmpeg.
2024-09-30 18:48:12 +02:00
Jelle Raaijmakers
57783eff24 LibMedia: Convert OggLoader into generic FFmpegLoader
This loader supports whatever format libavformat and libavcodec can
handle. Currently only seekable streams are supported, and we still have
some limitations as to the number of channels and sample format.

Plays all non-streaming audio files at:

  https://tools.woolyss.com/html5-audio-video-tester/
2024-09-30 18:48:12 +02:00
Gingeh
de588a97c0 LibRegex: Only search start of line if pattern begins with ^ 2024-09-30 12:28:22 +02:00
Aliaksandr Kalenik
814fa0682a LibWeb: Delete public constructor of FontFaceSet
The IDL definition in the spec does not have a public constructor, and
our test that relies on it was failing to run in other browsers.
2024-09-30 08:07:59 +02:00
Timothy Flynn
ee7b90b789 LibWeb: Disable worker-crypto test for now
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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 times out on macOS CI.
2024-09-29 16:51:52 -04:00
Timothy Flynn
dd5a0361f2 LibWeb: Dispatch click events using the correct button/buttons
We were generating click events always using the primary mouse button
instead of the provided button, and with the buttons field set to that
provided button.
2024-09-29 19:30:27 +02:00
Andreas Kling
f1be662f68 LibWeb: Always blockify the root element
This is what the spec tells us to do:

    The root element’s display type is always blockified,
    and its principal box always establishes an independent
    formatting context.

    Additionally, a display of contents computes to block
    on the root element.

Spec link: https://drafts.csswg.org/css-display/#root

Fixes #1562
2024-09-29 11:46:13 +02:00
Sam Atkins
1d8867d9ae LibWeb/CSS: Parse and propagate the font-language-override property 2024-09-28 14:42:26 +02:00
Sam Atkins
4a67b28600 LibWeb/CSS: Make font-stretch a legacy alias for new font-width
CSS Fonts level 4 renames font-stretch to font-width, with font-stretch
being left as a legacy alias. Unfortunately the other specs have not yet
been updated, so both terms are used in different places.
2024-09-28 14:42:26 +02:00
Aliaksandr Kalenik
3a5e78780e LibWeb: Implement "The percentage height calculation quirk" in BFC
See https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk

Basically, it means that in quirks mode, percentage height needs to be
resolved against nearest ancestor in the containing block chain that
does not have height=auto.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/365
2024-09-28 14:41:26 +02:00
Aliaksandr Kalenik
9098e39a43 LibWeb: Resolve not auto height before child box layout in BFC
It's possible to resolve box's height without doing inner layout, when
computed value is not auto. Doing that fixes height resolution, when box
with percentage height has containing block with percentage height.

Before:
- resolve used width
- layout box's content
- resolve height

After:
- resolve used width
- resolve height if treated as not auto
- layout box's content
- resolve height if treated as auto
2024-09-27 20:25:25 +02:00
Sam Atkins
fdcece2e88 LibWeb/CSS: Implement legacy name aliases for properties
When a property is a "legacy name alias", any time it is used in CSS or
via the CSSOM its aliased name is used instead.
(See https://drafts.csswg.org/css-cascade-5/#legacy-name-alias)

This means we only care about the alias when parsing a string as a
PropertyID - and we can just return the PropertyID it is an alias for.
No need for a distinct PropertyID for it, and no need for LibWeb to
care about it at all.

Previously, we had a bunch of these properties, which misused our code
for "logical aliases", some of which I've discovered were not even
fully implemented. But with this change, all that code can go away, and
making a legacy alias is just a case of putting it in the JSON. This
also shrinks `StyleProperties` as it doesn't need to contain data for
these aliases, and removes a whole load of `-webkit-*` spam from the
style inspector.
2024-09-27 17:16:23 +01:00
Tim Ledbetter
579a289d3d LibWeb: Fire error event when script has an execution error
We now use the "report an exception" AO when a script has an execution
error. This has mostly replaced the older "report the exception" AO in
various specifications. Using this newer AO ensures that
`window.onerror` is invoked when a script has an execution error.
2024-09-27 07:02:20 -04:00
Timothy Flynn
7b3b608caf AK: Do not coerce i64 and u64 values to i32 and u32
First, this isn't actually helpful, as we no longer store 32-bit values
in JsonValue. They are stored as 64-bit values anyways.

But more imporatantly, there was a bug here when trying to coerce an i64
to an i32. All negative values were cast to an i32, without checking if
the value is below NumericLimits<i32>::min.
2024-09-27 09:46:55 +01:00
Andreas Kling
795471ce31 LibWeb: Render CSS and SVG masks on the GPU if possible
Some checks are pending
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.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-22.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-22.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 converting images to alpha masks on the CPU, we now delegate
that work to the GPU if possible, by way of SkSL shaders.

This noticeably speeds up https://vercel.com/ which has a ton of SVG
masking going on. The old implementation used 15% of CPU time when
loading the page, this one uses basically none.
2024-09-26 16:30:50 +02:00
Andreas Kling
ef9208047d LibJS: Don't infinite loop on unknown console.log formatting specifiers 2024-09-26 10:14:09 +02:00
Sam Atkins
bea47a2554 LibWeb/CSS: Correct behavior of revert inside a @layer
`revert` is supposed to revert to the previous cascade origin, but we
previously had it reverting to the previous layer. To support both,
track them separately during the cascade.

As part of this, we make `set_property_expanding_shorthands()` fall back
to `initial` if it can't find a previous value to revert to. Previously
we would just shrug and do nothing if that happened, which only works
if the value you want to revert to is whatever is currently in `style`.
That's no longer the case, because `revert` should skip over any layer
styles that have been applied since the previous origin.
2024-09-26 08:08:38 +02:00
Jamie Mansfield
973f774e56 LibWeb/WebVTT: Implement VTTCue idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
1a012f279a LibWeb/WebVTT: Implement VTTRegion idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
cfec88feb3 LibWeb/HTML: Implement TextTrackCueList idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
0b2449d8d2 LibWeb/HTML: Implement TextTrackCue idl interface 2024-09-24 23:48:56 +01:00
Andreas Kling
9765a733d0 LibWeb: Don't extrapolate transition properties for unknown properties
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
If we don't recognize a given transition-property value as a known CSS
property (one that we know about, not necessarily an invalid one),
we should not extrapolate the other transition-foo values for it.

Fixes #1480
2024-09-24 21:53:43 +02:00
Timothy Flynn
8472b2b1fb LibThreading: Remove the thread pool
The thread pool test is currently flakey and takes over 2 minutes to run
on CI. It also currently has no users now that RequestServer uses curl,
so let's just remove it for now. If we need it in the future, we can
revive it from git history.
2024-09-22 14:07:16 -04:00
Andreas Kling
e40ad73ae7 LibWeb: Allow setting shorthand CSS properties via CSSStyleDeclaration
We now expand shorthands into their respective longhand values when
assigning to a shorthand named property on a CSSStyleDeclaration.

We also make sure that shorthands can be round-tripped by correctly
routing named property access through the getPropertyValue() AO,
and expanding it to handle shorthands as well.

A lot of WPT tests for CSS parsing rely on these mechanisms and should
now start working. :^)

Note that multi-level recursive shorthands like `border` don't work
100% correctly yet. We're going to need a bunch more logic to properly
serialize e.g `border-width` or `border` itself.
2024-09-22 09:45:59 +02:00
Sam Atkins
a1fca1a7f3 LibWeb: Start transitions when affected properties change
Co-authored-by: Matthew Olsson <matthewcolsson@gmail.com>
2024-09-22 06:41:55 +02:00
Aliaksandr Kalenik
91b2cd7d31 LibWeb: Account for x-axis in static position for inline items
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.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-22.04, Linux, Linux-x86_64) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (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
..and delay static position calculation in IFC until trailing
whitespace are removed, because otherwise it's not possible to correctly
calculate x offset.
2024-09-21 20:10:49 +02:00
Aliaksandr Kalenik
19afc5b11b LibWeb: Align to padding edge only auto positioned abspos grid items
Containing block for abspos grid items depends on their grid placement:
- if element has definite grid position, then corresponding grid area
  should be used as a containing block
- if element does not have definite grid position, then padding edge of
  grid container should be used as a containing block

So offset should be adjusted for paddings only for boxes without
definite grid position.
2024-09-21 20:10:49 +02:00
Timothy Flynn
2303142386 LibWeb: Always call document.close after document.write
This ensures the HTML parser completes running if it previously stopped
at an insertion point during a call to `document.write`.
2024-09-21 18:42:17 +02:00
Andreas Kling
a0ed12e839 LibWeb: Always flush character insertions before exiting HTML parser
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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 fixes an issue where document.write() with only text input would
leave all the character data as unflushed text in the parser.

This fixes many of the WPT tests for document.write().
2024-09-21 10:05:48 +02:00
Tim Ledbetter
089139f09d LibWeb: Return a WindowProxy from document.defaultView
This aligns our implementation with the most recent specification steps.
2024-09-21 10:05:34 +02:00
Timothy Flynn
f0105b473b LibWeb: Iterate over text chunks using a grapheme-aware segmenter
Our current text iterator is not aware of multi-code point graphemes.
Instead of simply incrementing an iterator one code point at a time, use
our Unicode grapheme segmenter to break text into fragments.
2024-09-21 08:57:54 +02:00
Andreas Kling
8543b8ad6a LibWeb: Let style elements remember which StyleSheetList they live in
Instead of trying to locate the relevant StyleSheetList on style element
removal from the DOM, we now simply keep a pointer to the list instead.

This fixes an issue where using attachShadow() on an element that had
a declarative shadow DOM would cause any style elements present to use
the wrong StyleSheetList when removing themselves from the tree.
2024-09-21 08:56:01 +02:00
Pavel Panchekha
9075f64cac LibWeb: Change inline float clearance to not reset margin collapsing
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
When a block container has `clear` set and some clearance is applied,
that clearance prevents margins from adjoining and therefore resets
the margin state. But when a floating box has `clear` set, that
clearance only goes between floating boxes so should not reset margin
state. BlockFormattingContexts already do that correctly, and this PR
changes InlineFormattingContext to do the same.

Fixes #1462; adds reduced input from that issue as test.
2024-09-21 01:55:43 +02:00
Andrew Kaster
c77d9a2732 LibWeb: Start implementing serviceWorker.register
This is mostly the fun boilerplate. Actually creating the Job queue
to do the heavy lifting is next.
2024-09-20 22:41:24 +01:00
Andrew Kaster
acd604c5e1 LibWeb: Add a test-only API to spoof the current URL and origin
This is not that easy to use for test developers, as forgetting to set
the url back to its original state after testing your specific API will
cause future navigations to fail in inexplicable ways.
2024-09-20 22:41:24 +01:00
Andrew Kaster
a0c07d1bb2 LibWeb: Add stub of ServiceWorker interface 2024-09-20 22:41:24 +01:00
Annya
75c7dbc5d2 LibWeb: Implement Range's extension method
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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 patch implements `Range::getClientRects` and
`Range::getBoundingClientRect`. Since the rects returned by invoking
getClientRects can be accessed without adding them to the Selection,
`ViewportPaintable::recompute_selection_states` has been updated to
accept a Range as a parameter, rather than acquiring it through the
Document's Selection.

With this change, the following tests now pass:

- wpt[css/cssom-view/range-bounding-client-rect-with-nested-text.html]
- wpt[css/cssom-view/DOMRectList.html]

Note: The test
"css/cssom-view/range-bounding-client-rect-with-display-contents.html"
still fails due to an issue with Element::getClientRects, which will
be addressed in a future commit.
2024-09-20 19:58:20 +02:00
Tim Ledbetter
087fcb84cb LibWeb: Don't crash when resolving grid properties of inline elements
Previously, attempting to get the computed value for a
grid-template-rows or grid-template-columns property would cause a
crash for inline elements.
2024-09-20 08:16:33 +02:00
Aliaksandr Kalenik
15c47dc623 Meta+LibWeb: Update Skia to version 129 2024-09-19 14:07:16 -04:00
Aliaksandr Kalenik
9772afcd29 LibGfx: Remove unused Bitmap::fill() 2024-09-19 06:21:33 +02:00
Aliaksandr Kalenik
f2d3f8bc42 LibGfx: Remove unused Gfx::Bitmap scaling functions 2024-09-19 06:21:33 +02:00
Timothy Flynn
e74d2b1762 LibWeb+LibWebView: Set the default path for invalid cookie Path values
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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 were missing this spec step when parsing the Path attribute.
2024-09-19 00:01:56 +01:00
Timothy Flynn
ba1189cd1c LibWeb: Support cookie Max-Age attributes that exceed i64 limits
Attributes have a max value length of 1024. So we theoretically need to
support values in the range -${"9".repeat(1023)} to ${"9".repeat(1024)}.
These obviously do not fit in an i64, so we were previously failing to
parse the attribute.

We will now cap the parsed value to the numeric limits of an i64, after
ensuring that the attribute value is indeed a number.
2024-09-19 00:01:56 +01:00
Tim Ledbetter
779de840af LibWeb: Don't crash when resolving style of grid template properties
Previously, attempting to get the computed value for a
grid-template-rows or grid-template-columns property would cause a crash
if the element had no associated paintable.
2024-09-18 17:38:20 +01:00
Aliaksandr Kalenik
fa907029ee LibWeb: Print FIXME instead of crashing in abspos SVG element layout
Currently we are crashing in `verify_cast<BlockContainer>(box)` on
attempt to create BFC for SVG box.
2024-09-18 15:50:05 +02:00
Aliaksandr Kalenik
e3e0041c7f Tests/LibWeb: Add layout test for float box with box-sizing=border-box
Adds a test for d6a31d80c0 that was
mistakenly ommited in the first place.
2024-09-18 15:49:40 +02:00
Sam Atkins
eaea80007c Tests: Make rebaseline's build-dir check unambiguous
At least on my Linux machine using zsh, this line was interpreted as

  ( cd "$build_dir" || echo ... ) && exit 1

instead of the intended

  cd "$build_dir" || ( echo ... && exit 1 )

...meaning that it always exited regardless of whether it found the
build dir or not. So, let's make the intended precedence explicit.
2024-09-18 12:41:57 +01:00
Tim Ledbetter
89b6cd3fb1 LibWeb: Expose crypto object to workers
This change moves the `crypto()` getter from `Window` to
`WorkerOrWindowGlobalScope`. This aligns our implementation with the
WebCrypto specification.
2024-09-18 10:09:01 +02:00
Aliaksandr Kalenik
41e37f0079 LibWeb: Use correct resolved type for round() CSS function
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
Function is defined as `round(<rounding-strategy>?, A, B?)`

With this change resolved type is `typeof(resolve(A))`, instead of
`typeof(A)`.

For example `round(up, 20%, 1px)` with 200px percentage basis is now
correctly resolved in 40px instead of 40%.

Progress on https://www.notion.so/ landing page.
2024-09-17 20:02:29 +02:00