Commit graph

73123 commits

Author SHA1 Message Date
Callum Law
2f0cd9f739 LibWeb: Add Time::from_style_value
This method takes a `TimeStyleValue`, `PercentageStyleValue` or
fully-simplified `CalculatedStyleValue` with a numeric type of time, as
well as a percentage basis and produces the equivalent `Time` value.

This saves us having to reimplement this logic in multiple places
2025-11-23 09:43:24 +01:00
Timothy Flynn
165afd8ad1 test-web: Do not clear the WebContent crash handler between tests
Clearing the callback opens a window for the WebContent process to crash
while we do not have a callback set. In practice, we see this with ASAN
crashes, where the crash occurs after we've already signaled that the
test has completed.

We now set the crash handler once during init. This required moving the
clearing of other callbacks to the test completion handler (we were
clearing these callbacks in several different ways anyways, so now we
will at least be consistent).
2025-11-22 14:09:11 +01:00
ayeteadoe
59c963f98f Meta+LibGfx: Remove fontconfig dependency on Windows
Previously when launching a UI process and/or a WebContent process on
Windows, the following message would be output to the console:

Fontconfig error: Cannot load default config file: No such file: (null)

Apparently on Windows, you have to provide a font .conf file to
fontconfig explicitly. Since we are not doing that, the default fonts
that are backed off to are not ideal.

Similar to how we aren't using fontconfig on Android, Windows also has
native font infrastructure in terms of both a collection of System
installed fonts as well as skia support for font managers that use
native Windows APIs. With that, we can remove the usage of fontconfig
entirely and improve the fonts used on websites like ladybird.org or
google.com.
2025-11-22 07:51:55 -05:00
ayeteadoe
4fb1ba0193 LibCore: Remove unused NotifierActivationEvent fd() and type() methods
In 11b8bbe one thing that was claimed was that we now properly set the
Notifier's actual fd on the NotifierActivationEvent. It turns out that
claim was false because a crucial step was forgotten: actually set the
m_notifier_fd when registering. Despite that mistake, it ultimately was
irrelevant as the methods on NotifierActivationEvent are currently
unused code. We were posting the event to the correct Notifier receiver
so the on_activation was still getting invoked.

Given they are unused, NotifierActivationEvent can be defined the same
way as TimerEvent is, where we just pass the event type enum to the
Event base class. Additionally, NotificationType can be moved to
the Notifier header as this enum is now always used in the context of
creating or using a Notifier instance.
2025-11-22 09:47:25 +01:00
Zaggy1024
c34b5a544e LibMedia: Set Matroska "complex" tracks' types based on the codec
The spec indicates that the codec defines how to interpret the data,
so use our CodecIDs to determine the track type.
2025-11-21 16:51:58 -06:00
Psychpsyo
f0e6bfbc9f LibWeb: Reimport transitioncancel-003.html to make it less flaky 2025-11-21 18:42:36 +01:00
Jelle Raaijmakers
b3c186ce64 LibWeb: Add spec steps to prescan a byte stream algorithm
Fix up the implementation as we go. Also change `ByteBuffer const&` into
`ReadonlyBytes` everywhere, so we don't accidentally copy bytes.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
f52632d48a LibWeb: Skip right amount of characters during encoding detection
When detecting an element's opening tag, the spec asks us to skip ahead
to the first whitespace or end chevron character before trying to read
attributes. Instead, we were always skipping 2 positions ahead and then
ignoring all whitespace characters and slashes, which was clearly wrong.

Theoretically this could have caused some weird behaviors if part of the
opening tag matched an expected attribute name, but it's very unlikely
to see that in the wild.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
4bcf988e46 LibWeb: Use FlyString attribute name comparisons in encoding detection
Prevent some unnecessary work by performing pointer comparisons.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
4ebbbdfef1 LibWeb: Advance position at attribute end quote in encoding detection
This did not cause any immediate issues except generating instances of
`Attr` with useless values which caused some unnecessary work during
encoding detection.
2025-11-21 17:43:08 +01:00
Zaggy1024
40d1f42418 LibMedia: Keep data providers' ThreadDatas alive in deferred_invoke
We need strong references to the thread data in order to prevent a UAF
when, for example, a seek starts as GC is destroying a media element.
2025-11-21 10:28:01 -06:00
Zaggy1024
eaf1564d1b LibMedia: Use u32 instead of uint to parse FFmpeg version numbers
This was breaking the build on Windows, apparently we don't have uint
there.
2025-11-21 09:32:54 -06:00
Sam Atkins
e691f0e10f LibWeb/DOM: Stop adding duplicates to the agent's signal_slots
We use a Vector for this, but its spec definition is an ordered set.
That means we need to ensure we don't add duplicates. This fixes issues
where we would send slotchange events multiple times to the same
HTMLSlotElement.
2025-11-21 16:19:57 +01:00
Sam Atkins
6e17503423 LibWeb: Add and remove MutationObservers at specified times
In the current spec, MutationObservers are explicitly added to the
pending mutation observers list, and they are removed when that list is
cleared in the "notify mutation observers" microtask.

This solves some issues with slotchange events.

As noted, we delay actually emptying the list of pending mutation
observers until after we're finished with the "clone", because we can't
actually copy or move the intrusive list. As far as I am aware, this
should not affect behaviour because only one microtask can run at once.
2025-11-21 16:19:57 +01:00
Timothy Flynn
37f49d5f6d LibJS: Use nanoseconds to normalize values in IsValidDuration
This is an editorial change in the Temporal proposal. See:
68004cc
a6043aa
1962c8b

Note that we were already performing this calculation using nanoseconds.
2025-11-21 13:52:55 +01:00
Timothy Flynn
8feabc3158 LibJS: Re-order infallible operations in GetDifferenceSettings
This is an editorial change in the Temporal proposal. See:
c11021a
2025-11-21 13:52:55 +01:00
Psychpsyo
2db3796fd3 LibWeb: Implement CSS perspective-origin 2025-11-21 11:14:28 +00:00
Psychpsyo
27e4793c5d LibWeb: Make ObjectPosition more reusable 2025-11-21 11:14:28 +00:00
Psychpsyo
ada3810779 LibWeb: Rename transform_box_rect() to transform_reference_box()
This is closer to its name in the spec.
2025-11-21 11:14:28 +00:00
Sam Atkins
9a1352fc17 LibWeb/CSS: Support calculated angles in conic-gradient() 2025-11-21 11:36:28 +01:00
Zaggy1024
e72080b15f LibMedia: Adjust Matroska seeking based on SeekPreRoll
This is important for seeking Opus tracks, as Opus needs to decode a
certain amount of input data before its output converges. Without this,
audio after a seek can sound muffled briefly.
2025-11-21 11:02:44 +01:00
Zaggy1024
31c751ee92 LibMedia: Handle buggy FFmpeg WebM muxing in Matroska::Reader 2025-11-21 11:02:44 +01:00
Zaggy1024
653a3452df LibMedia: Move conversion of Matroska codecs to CodecID to a new file
This function is needed in Matroska::Reader to check for Opus in the
next commit.
2025-11-21 11:02:44 +01:00
Zaggy1024
dcc2359eac LibMedia: Clamp Matroska cluster timestamps when casting them 2025-11-21 11:02:44 +01:00
Zaggy1024
f899d49e18 LibMedia: Make Matroska's get_element_id_size function static
...to silence a warning.
2025-11-21 11:02:44 +01:00
Zaggy1024
180f2a07f1 LibMedia: Read the Matroska SamplingFrequency element 2025-11-21 11:02:44 +01:00
Zaggy1024
364b422ae0 LibMedia: Store Matroska audio and video track info more safely
We don't need to put these in a union, it's not gonna save us much
space. The reader also may find both audio and video elements, in which
case this code would produce undefined behavior.

Also, with this change, we can use the default values from the spec.
2025-11-21 11:02:44 +01:00
Zaggy1024
b59f0501b8 LibMedia: Use String instead of ByteString in Matroska::Document 2025-11-21 11:02:44 +01:00
Estefania
8f15565967 LibWeb: Add stub implementation for Navigator.getBattery()
Adds a stub that returns a cached rejected promise with a
not yet implemented error. This converts
battery-status/battery-promise-window.https.html from timeout
to pass. Full implementation still needed.
2025-11-21 10:53:01 +01:00
Andreas Kling
e7388646bb LibJS: Remove unused InstructionStreamIterator::source_range() 2025-11-21 09:46:03 +01:00
Andreas Kling
f37063e2a1 LibJS: Stop worrying about Instruction destructors
By adding static_asserts to prove that all of our generated instruction
classes are trivially destructible, we can confidently remove the
destructor walk in BasicBlock and save ourselves some unnecessary work.
2025-11-21 09:46:03 +01:00
Andreas Kling
370b81f1b7 LibJS: Remove unused "Dump" instruction 2025-11-21 09:46:03 +01:00
Andreas Kling
003589db2d LibJS: Generate C++ bytecode instruction classes from a definition file
This commit adds a new Bytecode.def file that describes all the LibJS
bytecode instructions.

From this, we are able to generate the full declarations for all C++
bytecode instruction classes, as well as their serialization code.

Note that some of the bytecode compiler was updated since instructions
no longer have default constructor arguments.

The big immediate benefit here is that we lose a couple thousand lines
of hand-written C++ code. Going forward, this also allows us to do more
tooling for the bytecode VM, now that we have an authoritative
description of its instructions.

Key things to know about:

- Instructions can inherit from one another. At the moment, everything
  simply inherits from the base "Instruction".

- @terminator means the instruction terminates a basic block.

- @nothrow means the instruction cannot throw. This affects how the
  interpreter interacts with it.

- Variable-length instructions are automatically supported. Just put an
  array of something as the last field of the instruction.

- The m_length field is magical. If present, it will be populated with
  the full length of the instruction. This is used for variable-length
  instructions.
2025-11-21 09:46:03 +01:00
Andreas Kling
84443e1de6 Meta: Add ability for code generator to output one extra header 2025-11-21 09:46:03 +01:00
Callum Law
408bbead31 LibWeb: Don't mangle inherited properties when updating animated style 2025-11-21 09:24:53 +01:00
stasoid
01f6f33236 Meta: Compile for the native architecture of the host system on Windows
when ENABLE_CI_BASELINE_CPU is OFF
2025-11-21 09:10:28 +01:00
Timothy Flynn
4470f94129 RequestServer: Store a couple of data hashes in disk cache entries
We currently have a FIXME to validate cached data with a crc32. But this
is sort of a non-starter, because we never actually have the cached data
in-memory - we transfer it to the WebContent process via system calls,
and it never reaches userspace in RequestServer.

Chrome makes a bit of an educated gamble here. They assume cosmic bit
blips are extremely unlikely, thus the cached data does not get verified
with a hash. Instead, they store non-cryptographic hashes of some select
fields, and they validate just those hashes.

Here, we store a hash of the cache key in the cache header, and a hash
of the cache header in the cache footer. With these validations, along
with other validations already in-place, we can be reasonably sure we
are not sending corrupt data to the WebContent process.
2025-11-21 08:48:42 +01:00
Timothy Flynn
3663e12585 RequestServer: Do not request partial content for failed cache reads
This effectively reverts 9b8f6b8108.

I misunderstood what Chrome was doing here - they will issue a range
request only for what they call "sparse" cache entries. These entries
are basically used to cache partial large file, e.g. a multi-gigabyte
video. If they hit a legitimate read error, they will fail the request
with a ERR_CACHE_READ_FAILURE status.

We will now (again) fail with a network error when a cache read fails.
2025-11-21 08:48:42 +01:00
Timothy Flynn
4fddd6a681 RequestServer: Do not log disk cache version mismatches on first-run
Particularly on test runs, this is just noise.
2025-11-21 08:48:42 +01:00
Aliaksandr Kalenik
2a18b6b802 LibWeb: Prevent default on pointerdown/mousedown should skip focus steps
Fixes a bug in the ChatGPT model dropdown where clicking it immediately
closes the menu because focus is being stolen.
2025-11-21 08:30:32 +01:00
Ali Mohammad Pur
d5d37abfa5 AK+LibRegex: Only set node metadata on Trie::ensure_child if missing
a290034a81 passed an empty vector to this,
which caused nodes that appeared multiple times to reset the trie
metadata...which broke the optimisation.

This patchset makes the function take a 'provide missing metadata'
function instead, and only invokes it when the node is missing rather
than unconditionally setting the metadata on all nodes.
2025-11-21 02:46:33 +01:00
Jelle Raaijmakers
2c5beeabe3 LibWeb: Improve support for SVG text positioning attributes
Previously, we only supported very basic numbers and a single level of
text positioning support in the `x`, `y`, `dx` and `dy` attributes in
`<text>` and `<tspan>` SVG elements.

This improves our support for them in the following ways:

  * Any `length-percentage` or `number` type value is accepted;
  * Nested `<text>` and `<tspan>` use the 'current text position'
    concept to determine where the next text run should go;
  * We expose the attributes' values through the API.

Though we still do not support:

  * Applying the `rotate` attribute;
  * Applying transformations on a per-character basis.
  * Proper horizontal and vertical glyph advancing (we just use the path
    bounding box for now).
2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
527a293047 LibWeb: Implement SVGAnimatedLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
797e6dd4eb LibWeb: Implement SVGLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
832e953c67 LibWeb: Use is_ascii_digit() in SVG attribute parsing 2025-11-20 23:15:24 +01:00
Hendiadyoin1
bcd01da91d AK: Use Deducing this for OptionalBase
This is taken from and akin to
https://github.com/SerenityOS/serenity/pull/25894
2025-11-20 16:27:07 +01:00
Sam Atkins
fd4888e800 LibWeb/Layout: Honor hanging and each-line in text-indent 2025-11-20 16:02:40 +01:00
Sam Atkins
c4b9e7eadf LibWeb: Parse and propagate extended text-indent property values
CSS Text 3 gives `text-indent` a couple of optional keywords to control
which lines are affected. This commit parses them, but doesn't yet do
anything with them.
2025-11-20 16:02:40 +01:00
Sam Atkins
eea1d4e1d2 test-web: Report which file has missing match/mismatch metadata
This makes it easier to figure out what's causing the assertion failure.
2025-11-20 16:02:40 +01:00
Sam Atkins
0e8f3a4648 Tests: Import ahem font for ref tests
A few tests were trying to use ahem.css but failed because the path was
invalid and the font wasn't imported.
2025-11-20 16:02:40 +01:00