Commit graph

34317 commits

Author SHA1 Message Date
Andreas Kling 4ce5aeb312 LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f'
When loading a canned version of reddit.com, we end up parsing many many
shadow tree style sheets of roughly ~170 KiB text each.

None of them have '\r' or '\f', yet we spend 2-3 ms for each sheet just
looping over and reconstructing the text to see if we need to normalize
any newlines.

This patch makes the common case faster in two ways:

- We use TextCodec::Decoder::to_utf8() instead of process()
  This way, we do a one-shot fast validation and conversion to UTF-8,
  instead of using the generic code-point-at-a-time callback API.

- We scan for '\r' and '\f' before filtering, and if neither is present,
  we simply use the unfiltered string.

With these changes, we now spend 0 ms in the filtering function for the
vast majority of style sheets I've seen so far.

(cherry picked from commit dba6216caa71796f25831908035cd9eb0fb54715)
2024-07-21 12:37:05 -04:00
Andreas Kling 457de9e99d LibWeb: Use StringBuilder::append_code_point() over append(Utf32View)
When appending a single Unicode code point, we don't have to go through
the trouble of creating a Utf32View wrapper over it.

(cherry picked from commit 7892ee355df95f6414ab5334d8d997c2c0356a45)
2024-07-21 12:37:05 -04:00
Braydn d131f29ba8 LibJS: Implement CreatePerIterationEnvironment for 'for' statements
Implement for CreatePerIterationEnvironment for 'for' loops per the Ecma
Standard. This ensures each iteration of a 'for' loop has its own
lexical environment so that variables declared in the loop are scoped to
the current iteration.

(cherry picked from commit dbc2f7ed48f00234f5f94a30b06b83842d9cf4dd)
2024-07-21 11:31:13 -04:00
Colin Reeder 8908038f96 LibWeb: Add support for indexed setter of HTMLOptionsCollection
(cherry picked from commit 99824eae142b02c7bce84b9e98d10fc6428f31fe)
2024-07-21 11:29:07 -04:00
BenJilks 456a09e8c7 LibWeb: Propagate margin and offset when computing a box's baseline
When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.

(cherry picked from commit 3c897e7cf3594f02f559599e1bf28747c9edba13)
2024-07-21 11:28:55 -04:00
Diego Frias e4d3b9060a LibWeb: Implement the :has() pseudo-class
See https://drafts.csswg.org/selectors-4/#relational.

(cherry picked from commit f63a945ba0300551417c740e450957f29c9b73d1)
2024-07-21 11:10:11 -04:00
Liav A. 4aec3f4ef9 Kernel+Userland: Simplify loading of an ELF interpreter path
The LibELF validate_program_headers method tried to do too many things
at once, and as a result, we had an awkward return type from it.

To be able to simplify it, we no longer allow passing a StringBuilder*
but instead we require to pass an Optional<Elf_Phdr> by reference so
it could be filled with actual ELF program header that corresponds to
an INTERP header if such found.

As a result, we ensure that only certain implementations that actually
care about the ELF interpreter path will actually try to load it on
their own and if they fail, they can have better diagnostics for an
invalid INTERP header.

This change also fixes a bug that on which we failed to execute an ELF
program if the INTERP header is located outside the first 4KiB page of
the ELF file, as the kernel previously didn't have support for looking
beyond that for that header.
2024-07-21 15:38:52 +02:00
Liav A. ccf3d29afd Utilities: Introduce the watchfs utility
This utility is meant mainly for debugging purposes, to watch regular
files and directories being modified.
2024-07-21 12:15:44 +02:00
Liav A. fdcfa23e01 Userland+Base: Introduce userspace implementation for running containers
Together with a first JSON file for bringing up a fully functional
BuggieBox container, we allow users to take advantage of the kernel
unsharing features that were introduced in earlier commits.
2024-07-21 11:44:23 +02:00
Liav A. aa01f52592 LibCore: Add System methods to handle the unshare syscall family
These 2 methods will be used later by the userspace implementation that
will handle creation of containers.
2024-07-21 11:44:23 +02:00
Liav A. 4370bbb3ad Kernel+Userland: Introduce the copy_mount syscall
This new syscall will be used by the upcoming runc (run-container)
utility.

In addition to that, this syscall allows userspace to neatly copy RAMFS
instances to other places, which was not possible in the past.
2024-07-21 11:44:23 +02:00
Liav A. 816f2efb4e Userland: Always enter jail mode in Browser and Assistant
These programs are capable of running other programs, so we should
restrict them from potentially running SUID programs, which was never a
functionality we supported for those programs anyway.
2024-07-21 11:44:23 +02:00
Liav A. dd59fe35c7 Kernel+Userland: Reduce jails to be a simple boolean flag
The whole concept of Jails was far more complicated than I actually want
it to be, so let's reduce the complexity of how it works from now on.
Please note that we always leaked the attach count of a Jail object in
the fork syscall if it failed midway.
Instead, we should have attach to the jail just before registering the
new Process, so we don't need to worry about unsuccessful Process
creation.

The reduction of complexity in regard to jails means that instead of
relying on jails to provide PID isolation, we could simplify the whole
idea of them to be a simple SetOnce, and let the ProcessList (now called
ScopedProcessList) to be responsible for this type of isolation.

Therefore, we apply the following changes to do so:
- We make the Jail concept no longer a class of its own. Instead, we
  simplify the idea of being jailed to a simple ProtectedValues boolean
  flag. This means that we no longer check of matching jail pointers
  anywhere in the Kernel code.
  To set a process as jailed, a new prctl option was added to set a
  Kernel SetOnce boolean flag (so it cannot change ever again).
- We provide Process & Thread methods to iterate over process lists.
  A process can either iterate on the global process list, or if it's
  attached to a scoped process list, then only over that list.
  This essentially replaces the need of checking the Jail pointer of a
  process when iterating over process lists.
2024-07-21 11:44:23 +02:00
Liav A. 91c87c5b77 Kernel+Userland: Prepare for considering VFSRootContext when mounting
Expose some initial interfaces in the mount-related syscalls to select
the desired VFSRootContext, by specifying the VFSRootContext index
number.

For now there's still no way to create a different VFSRootContext, so
the only valid IDs are -1 (for currently attached VFSRootContext) or 1
for the first userspace VFSRootContext.
2024-07-21 11:44:23 +02:00
mkblumenau 02157e3eaf LibGUI: Improve how SpinBox handles negative numbers
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
Negative numbers now display correctly in SpinBox.
Previously, they displayed as the negative sign only (no number).
Now the user can also type negative numbers into the SpinBox.
2024-07-19 21:20:52 +01:00
circl 94ce662c0a LibWeb: Restore event characteristics of MouseEvents and WheelEvents
These were accidentally no longer set after
2c396b5378fec5f4470e1e1e950806dff8005f08

(cherry picked from commit f20010c1d3a66aaabd5da5a96c578ad013756f99)
2024-07-16 15:04:06 -04:00
Ali Mohammad Pur 68aa4cbb91 LibWasm: Make Absolute/Negate<SignedIntegral> explicitly work mod 2^N
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
Previously we relied on signed overflow, this commit makes the same
behaviour explicit (avoiding UB in the process).

(cherry picked from commit 8c8310f0bddc874a9f7f07c4158f0abc799357d4)
2024-07-16 17:35:43 +02:00
Diego Frias bc5c549e7f LibWasm: Correctly validate v128_load*_lane instructions
(cherry picked from commit 8a0ef17d9a9621ab4bd52dc402c0fbd57944d42c)
2024-07-16 17:35:43 +02:00
Diego Frias a2bb6e1cfc LibWasm: Implement rest of SIMD load/store instructions
Also implement `v128.any_true`.

(cherry picked from commit f5326f1747b9559993cb6f89841de2fc54c10387)
2024-07-16 17:35:43 +02:00
Enver Balalic 34b3015c16 LibWasm: Implement most of iNxM SIMD operations
With this we pass an additional ~2100 tests.
We are left with 7106 WASM fails :).

There's still some test cases in the iNxM tests that fail with
this PR, but they are somewhat weird.

(cherry picked from commit b4acd4fb0b7f4105c7ef673ccc00904114c3c468)

Co-authored-by: Diego Frias <styx5242@gmail.com>
2024-07-16 17:35:43 +02:00
Diego b896f27a45 LibWasm: Fix sign issues in SIMD cmp ops
(cherry picked from commit 1e1dcd89438c5b0b8ad34682de4f1c7c62cbacb9)
2024-07-16 17:35:43 +02:00
Diego Frias 9ae48f6a49 LibWasm: Make SIMD float min/max operations binary ops
They previously acted like comparison operators, which was not correct.

(cherry picked from commit d6acda2047dec0a0ba6eda50039feff816c3e82b)
2024-07-16 17:35:43 +02:00
Diego c3af74f0a2 LibWasm: Validate stack correctly in v128_store*_lane instructions
Previously the validator put a `v128` on the stack, which is not what
the spec defines.

(cherry picked from commit 0d38572d8bd2a276be1b6066b62efd376ddbd4d6)
2024-07-16 17:35:43 +02:00
Diego 59628b5eeb LibWasm: Make memory.grow grow the memory's type
After a `memory.grow`, the type of the memory instance should be
updated so potential memory imports on the boundary are unlinkable.

(cherry picked from commit cdb6e834a1c0eaa6e62a9018026a599916332ab3)
2024-07-16 17:35:43 +02:00
Diego e5a842c78e LibWasm: Fix loop arity for single-type blocktypes
Single-type blocktypes previously gave loop labels an arity of 1, even
though they're shorthand for `[] -> [T]`.

(cherry picked from commit ad6a80144c23f9ccdeeccb123a9de85396524040)
2024-07-16 17:35:43 +02:00
Diego 7df774c473 LibWasm: Implement SIMD bitwise operations
(cherry picked from commit 2ab676860e56216cf0560dac1aafd4e5656ec586)
2024-07-16 17:35:43 +02:00
MacDue cf88838001 LibC: Call pthread key destructors before global destructors
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
Since be2bf05 the ThreadEventQueue is now destroyed via a phread key
destructor, which leads to many other objects being destroyed. A bunch
of these destructors reference globals, but exit() calls destructors
on globals before phread destructors, this bad state leads to the hangs
seen in #24694.

Fixes #24694
2024-07-15 18:50:55 -04:00
Kenneth Myhra 0d9429e383 LibWeb: Implement min option for ReadableStreamBYOBReader.read()
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
When the min option is given the read will only be fulfilled when there
are min or more elements available in the readable byte stream.

When the min option is not given the default value for min is 1.

(cherry picked from commit 907dc84c1e8c3c236ade581f46dabdb144915c1d)
2024-07-15 09:05:07 -04:00
Nico Weber ceb956c170 animation: Add a switch for controlling the webp color cache size 2024-07-15 08:47:34 -04:00
Nico Weber e9329eefe6 LibGfx/WebPWriter: Add support for writing color cache symbols
Lossless WebP allows having a 1-bit to 11-bit addressed
"color cache", where pixels are inserted into a content-addressed
cache of size `1 << color_cache_bits`. Pixels in the color
cache can be addressed using their index. This can be used
to refer to literal pixels using a single color_cache_bits
large symbol, instead of up to 4 symbols for GBRA.

We default to always using a color cache with 6 bits, unless
the input image already uses only a single channel already
(either as-is, or if we write a color indexing transform).

Due to this change, the size of the first prefix group
changes from being known at compile time (256 + 24)
to being known at runtime (256 + 24 + color_cache_size).
Change a few Array<>s to Vector<>s to make this work.

    sunset_retro.png (876K):
        1.6M -> 1.4M, 29.1 ms ± 0.9 ms -> 31.7 ms ± 0.9 ms

From 83% larger than the input file to 60% larger (12.5% smaller),
for a 9% slowdown.

The two gifs I usually test with don't change: Files using the
color _index_ transform (i.e. that have < 256 colors) don't
use the color _cache_ in our encoder.
2024-07-15 08:47:34 -04:00
Luke Warlow e8bcd3842d LibWeb: Implement support for scrollbar-gutter
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
This property is now correctly parsed.

Ladybird always uses overlay scrollbars so this property does nothing.

(cherry picked from commit 662317726549cd2dde4c7902b99f0b83397a3396)
2024-07-14 20:44:46 -04:00
Andreas Kling c75b68c5a4 LibWeb: Add null check in Document::ancestor_navigables()
The spec doesn't explicitly forbid calling this when the document
doesn't have a node navigable, so let's handle that situation gracefully
by just returning an empty list of ancestors.

I hit this VERIFY somewhere on the web, but I don't know how to
reproduce it.
2024-07-14 20:37:22 -04:00
circl c7de605e4b LibWeb/ResourceLoader: Report file: errors as "network errors"
This triggers the generated error page which is more informative.

(cherry picked from commit 91e3ef6dbf411edb6497342ac89817c8487ce6d8)
2024-07-14 19:57:14 -04:00
circl b15cbceec6 LibWeb/ResourceLoader: Call error callback if resource: load fails
(cherry picked from commit e35b055192cf611519204389fc91917b91233d95)
2024-07-14 19:57:14 -04:00
circl 8998afc9c3 LibWeb/Fetch: Pass error from ResourceLoader into network_error
(cherry picked from commit 4e6eb35520def1b1488af6a800b03c007e56b9dd)
2024-07-14 19:57:14 -04:00
circl 5a5c6afd2d LibWeb: Pass network error message to generated error page
(cherry picked from commit b83e82c32cf82d2b9d21271322a4a9161357f081)
2024-07-14 19:57:14 -04:00
Diego Frias 4c0fcb7ae3 LibWebView: Trim whitespace when sanitizing file paths
Previously, the presence of surrounding whitespace would give file paths
the `https` schema instead of the `file` schema, making navigation
unsuccessful.

(cherry picked from commit ff7ca5c48c316e07b1bf631b2d7ed14c358dfa42)
2024-07-14 19:34:49 -04:00
Bastiaan van der Plaat 6ab28fd568 LibWeb/CSS: Serialize transform scale percentage values as numbers
(cherry picked from commit c81a640f3ed424b11830fbe9777f1a267240577f)
2024-07-14 19:34:39 -04:00
BenJilks 2e95c03ca6 LibWeb: Change flex remaining space distribution to include gap
Some checks are pending
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
The remaining space is in addition to, not of in place of the
main gap.

(cherry picked from commit 47aee289d87add9784a2d722cb529774cdfb54e2)
2024-07-14 18:12:55 -04:00
Jamie Mansfield 0d09539fd2 LibWeb: Add FIXMEs for missing SVGGeometryElement attributes
(cherry picked from commit 772d64aca25719d8790ce324ea2ce7fd59d3203c)
2024-07-14 18:12:26 -04:00
Jamie Mansfield 05d90afa65 LibWeb: Add FIXMEs for missing SVGElement attributes
(cherry picked from commit c9f3a7ddbfaedd957c5bd5a50616d4ac7532d154)
2024-07-14 18:12:26 -04:00
Jamie Mansfield c14af45628 LibWeb: Implement SVGElement.className
(cherry picked from commit 9d1ea4c7e013629d432a4c3559a5919462fd4c71)
2024-07-14 18:12:26 -04:00
Jamie Mansfield b96e9c130b LibWeb: SVGElement includes GlobalEventHandlers
This fixes many tests on
wpt/html/webappapis/scripting/events/event-handler-all-global-events.html

(cherry picked from commit 59f74b909ba161a143fb4cd5cbaf6dcf6734d240)
2024-07-14 18:12:26 -04:00
Jamie Mansfield 8ce8639ed8 LibWeb: Implement MessageEvent.initMessageEvent
This fixes wpt/html/webappapis/scripting/events/messageevent-constructor.https.html

(cherry picked from commit ffb3a28684b1b4c028af93aa6d7d9194f002d503)
2024-07-14 18:12:26 -04:00
Tim Ledbetter 4b00926a66 LibWeb: Update Range::set_base_and_extent() to the latest spec text
This allows it to work with content inside shadow roots.

(cherry picked from commit 34741d09c6e69bd7cd8450668facd552cd69d21b)
2024-07-14 16:46:23 -04:00
Tim Ledbetter 35ce74aa9b LibWeb: Don't update selection if start and end node roots differ
This allows selection to work within shadow roots and prevents the
selection being cleared if the mouse moves outside of the current
document or shadow root.

(cherry picked from commit e5d1261640a71a672c5cd19910f5f6288e65ed04)
2024-07-14 16:46:23 -04:00
Colin Reeder bf0a7667a0 LibWeb: Handle inline-start and inline-end as float values
Should resolve #449 for LTR languages at least

(cherry picked from commit d427344f39581cd7789280949eb6d102b39218a3)
2024-07-14 16:45:48 -04:00
Jamie Mansfield 6e9f9b5efc LibWeb: Implement EmbedderPolicy struct
(cherry picked from commit 190a41971569ad90c26662d7e7e850a61c55c8dd)
2024-07-14 16:45:35 -04:00
Tim Ledbetter fe5ccd3e0c LibWeb: Add styling for disabled button elements
(cherry picked from commit c92222dcae6bf641fc7da4fb568b0bb640ceb7e4)
2024-07-14 16:45:21 -04:00
Tim Ledbetter 7d71a5483c LibWeb: Don't dispatch click events to disabled FormAssociatedElements
Disabled FormAssociatedElements also no longer receive focus when
clicked.

(cherry picked from commit e18501f67fb0361a10392bc626e6c43f26f1e9cc)
2024-07-14 16:45:21 -04:00
Timothy Flynn 3f8b94b131 LibJS: Update specification steps for the Set Methods proposal
It is now Stage 4 and has been merged into the main ECMA-262 spec:
https://github.com/tc39/ecma262/commit/a78d504

(cherry picked from commit 2dbd71d54ba20b3700d3f98001a1cf0ec4adbe25)
2024-07-14 16:45:08 -04:00
Timothy Flynn 0bbf42bca7 LibJS: Introduce the CanonicalizeKeyedCollectionKey AO
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/30257dd

(cherry picked from commit 55b4ef79157f299e68163824d8d03dfab31dd3d6)
2024-07-14 16:45:08 -04:00
Jamie Mansfield 1d2fa89d9f LibWeb: Implement HTMLMediaElement.textTracks
(cherry picked from commit 65be928d4e18108146645e177b586a3d9117aebc)
2024-07-14 14:01:30 -04:00
Jamie Mansfield a09b52e40f LibWeb/HTML: Implement TextTrackList IDL interface
(cherry picked from commit ecad28657a0941c99870bdb72f3a6f09b6db6ee3)
2024-07-14 14:01:30 -04:00
Jamie Mansfield 894567cb44 LibWeb: Implement TextTrack.id
(cherry picked from commit ba8e77df1690e9ce00c4903b65adbc19fbda25ed)
2024-07-14 14:01:30 -04:00
Jamie Mansfield c8cd40fa21 LibWeb: Allow TrackEvent track to be a TextTrack
Fixes two FIXMEs :^)

(cherry picked from commit ab91a616b8e8bdd32c195adb2f081ba07fba2ac4)
2024-07-14 14:01:30 -04:00
simonkrauter 5838244afc LibWeb: Use correct default value for <input type=range>
Previously the input element was displayed with value 0, when no value
was set in the HTML. Now it uses `value_sanitization_algorithm()`, which
will calculate the default value.
In `value_sanitization_algorithm()` there was a logical mistake/typo.
The comment from the spec says "unless the maximum is less than the
minimum".
The added layout test would fail without the code changes.
Fixes #520

(cherry picked from commit 191531b7b18d2edf97dc7bf88a9c19903eeae2d5)
2024-07-14 14:01:21 -04:00
Tim Ledbetter 497fc7476d LibWeb: Remove m_src_is_set field from HTMLScriptElement
Now that we pass an `old_value` parameter to `attribute_changed` it is
no longer necessary to store the current attribute state in
`HTMLScriptElement`.

(cherry picked from commit aa4e18fca50b261eabd5672a3f1163b4ac7ef50b)
2024-07-14 14:01:11 -04:00
Tim Ledbetter df796fef1a LibWeb: Pass the old attribute value to Element::attribute_changed()
(cherry picked from commit a552bda8d96d3c8a16f02dca5d1b37483dd5a634)
2024-07-14 14:01:11 -04:00
Kenneth Myhra 55b214ba95 LibWeb: Align transform_stream_error_writable_and_unblock_write w/ spec
This aligns AO transform_stream_error_writable_and_unblock_write() with
the spec.

No functional change is introduced by this amendment.

(cherry picked from commit 24bed027b2db59935da185d3bd490718ccb37baa)
2024-07-14 14:00:45 -04:00
Andreas Kling 5e481950f8 LibJS: Make GetById and GetByValue avoid get_identifier() in common case
We now defer looking up the various identifiers by IdentifierTableIndex
until the last moment. This allows us to avoid the retrieval in common
cases like when a property access is cached.

Knocks a ~12% item off the profile on https://ventrella.com/Clusters/

(cherry picked from commit 509c10d14db0f2e2ce2b89f307d9dd360b855eb5,
amended to mark the two `throw_null_or_undefined_property_get` functions
static, as -Wmissing-declarations pointed out on CI)
2024-07-14 14:00:35 -04:00
Andreas Kling eba2a5b0f9 LibJS: Move CommonImplementations.h into Interpreter.cpp
Now that the Interpreter is the only user of these functions, we might
as well keep them in Interpreter.cpp which makes CLion less confused.

(cherry picked from commit ae0cfe4f2d260bfd804364c17f28494e3e8964c9)
2024-07-14 14:00:35 -04:00
simonkrauter 7b353a3a55 LibWeb: Define width for -webkit-slider-runnable-track
Fixes LadybirdBrowser/ladybird#512

(cherry picked from commit b5e80db2259448bc0b3dc48d88f53e8d1880987e)
2024-07-14 06:57:50 -04:00
Tim Ledbetter 1506f72219 LibWeb: Populate filename in WindowOrWorkerGlobalScope.reportError()
Previously, when `WindowOrWorkerGlobalScope.reportError()` was called
the `filename` property of the dispatched error event was blank. It is
now populated with the full path of the active script.

(cherry picked from commit 34b987366449313c96a73ec1d70e88e60f2c4510)
2024-07-14 06:57:29 -04:00
Jamie Mansfield 9d7267ba76 LibWeb: Add missing edge visit for TextTrack in HTMLTrackElement
(cherry picked from commit 0a3082ef05e8e7a963d3a208acd6efee0ff5c848)
2024-07-14 06:57:14 -04:00
Jamie Mansfield 0a1146c67a LibWeb/HTML: Stub TextTrack IDL interface
(cherry picked from commit 67e3ac8916d7354c8485b4bbe9c4162392e0e99c)
2024-07-14 06:57:14 -04:00
rmg-x 435bbb53f8 LibWeb: Ensure normal line-height on HTMLInputElement
Previously, setting CSS `line-height: 0` on an `input` element would
result in no text being displayed.

Other browsers handle this by setting the minimum height to the
"normal" value for single line inputs.

(cherry picked from commit 629068c2a7eb02db37ffb4fe8d536306ee71e156)
2024-07-14 06:56:56 -04:00
rmg-x 7507357496 LibWeb: Add method HTMLInputElement::is_single_line()
(cherry picked from commit b36a78a798bf9cac60ff13e003b0a1c94a716817)
2024-07-14 06:56:56 -04:00
rmg-x c30d2197bc LibWeb: Remove StyleProperties::compute_line_height(Layout::Node)
This method was unused and a FIXME remained for combining it with
another, similar method.

(cherry picked from commit df7f7268db5edb37b735f30586d774544537e342)
2024-07-14 06:56:56 -04:00
simonkrauter 8884386b4e LibWeb: Harmonize look of range input element
Previously the entire slider track was colored.
Now only the lower part of the slider track (left side of the thumb) is
colored.
Chrome and Firefox do the same.

(cherry picked from commit 7766909415312b971252f8c7750b0a1873fd5ba0)
2024-07-14 06:56:43 -04:00
⭐caitp⭐ bf6d966a30 LibWeb: Pass event_init to base class constructor in FocusEvent
This fixes some WPT failures caused by the "view" parameter not being
initialized from the property bag.

(cherry picked from commit 932a7d4d819fac9d0acfe4184574488dd69f94ec)
2024-07-14 06:56:30 -04:00
⭐caitp⭐ 6bc28e1f0b LibWeb: Remove set_event_characteristics()
These methods were overriding properties specified by the EventInit
property bags in the constructor for WheelEvent and MouseEvent.

They appear to be legacy code and no longer relevant, as they would have
been used for ensuring natively dispatched events had the correct
properties --- This is now done in separate create methods, such as
MouseEvent::create_from_platform_event.

This fixes a couple WPT failures (e.g. in
/dom/events/Event-subclasses-constructors.html)

(cherry picked from commit 2c396b5378fec5f4470e1e1e950806dff8005f08)
2024-07-14 06:56:16 -04:00
Tim Ledbetter fe03f6b6a7 LibWeb: Implement Node.normalize()
This method puts the given node and all of its sub-tree into a
normalized form. A normalized sub-tree has no empty text nodes and no
adjacent text nodes.

(cherry picked from commit 0a0651f34ea927a0ca44dc5d2c7786f3dcf8da25)
2024-07-14 06:55:54 -04:00
BenJilks aec3ab77ef LibWeb: When solving abspos lengths, use min max constrained height
Solving using the unconstrained height, when solving for bottom, would
either leave a gap over overflow its container.

(cherry picked from commit bee42160c5e2cdb949e6057f029391ee7e0fa9fa)
2024-07-13 22:52:34 -04:00
Maciej 1e41585416 LibWeb: Implement HTML DragEvent class
This just defines the class, drag events aren't actually fired yet.

(cherry picked from commit 65d8d205ee5d7ef356da58f8238e610949773683)
2024-07-13 22:52:06 -04:00
Andreas Kling 17c1a20f9b LibWeb: Don't fire resize event until document actually resizes once
The first time Document learns its viewport size, we now suppress firing
of the resize event.

This fixes an issue on multiple websites that were not expecting resize
events to fire so early in the loading process.

(cherry picked from commit 4e7558c88b7a993686bb3dc173731e677efe5e26)
2024-07-13 22:03:32 -04:00
Andreas Kling 4aeaea515b LibJS: Cache environment index for global declarative bindings
This allows global `let` and `const` variable accesses to be cached
by the GetGlobal instruction, and works even when the access is in a
different translation unit from the declaration.

Knocks a ~10% item off the profile on https://ventrella.com/Clusters/

(cherry picked from commit 9448c957c136e62b374a0f8998d1d51906e59fb5)
2024-07-13 22:03:22 -04:00
Caitlin Potter a263b007ff LibWeb: Legacy Platform Objects don't force [[Configurable]]
Per https://github.com/whatwg/webidl/commit/3fb6ab4dbc6a42517c84acf0909,
this step in the spec didn't reflect the reality in mainstream browsers.
This change fixes a failure in WPT/dom/collections/

(cherry picked from commit fac82119dff6f8063490698934ddd4243970eea3)
2024-07-13 21:53:20 -04:00
Maciej 6673dcc960 LibWeb: Prepare script when src is set the first time
From https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:
When a script element el that is not parser-inserted experiences one
of the events listed in the following list, the user agent must
immediately prepare the script element el:
- [...]
- The script element is connected and has a src attribute set where
  previously the element had no such attribute.

(cherry picked from commit d890be6e0f7db08ab39ba546cb3421b50b687cda)
2024-07-13 21:52:51 -04:00
Luke Warlow 85b5be0a20 LibWeb: Implement :modal pseudo class
Adds the :modal pseudo class which matches dialogs opened with
showModal().

(cherry picked from commit 63a5ff70e5f3bee10839415885a158e304719fec)
2024-07-13 21:52:41 -04:00
Gingeh d532331f34 LibWeb/CSS: Support hwb, oklab and oklch color functions
(cherry picked from commit e8d32bab58d9ffb183ee71ee6516d49556db136b,
manually amended to fix the two diags mentioned in
https://github.com/LadybirdBrowser/ladybird/pull/385#issuecomment-2227126447
)
2024-07-13 21:43:38 -04:00
Gingeh 052ff6e141 LibWeb/CSS: Split parse_rgb_or_hsl_color into separate functions
(cherry picked from commit 490a36bab18873db632496e594152b68cd2b8ca3)
2024-07-13 21:43:38 -04:00
Tim Ledbetter fdac183bff LibWeb: Invalidate input element style on focus change
The style of input and textarea elements is now invalidated when focus
is changed to a new element. This ensures any `:focus` selectors are
applied correctly.

(cherry picked from commit 572324d47b99bcfbc5db5ff6aef0d6c4eb15ce4c)
2024-07-13 21:41:18 -04:00
simonkrauter 74408dae20 LibWeb: Use system colors for input type range and progress as default
Instead of using fixed arbitrary colors for the background of the bar,
AccentColor and Background are now used.

(cherry picked from commit 062a266574a24fe13f2a77401b97f833c3cdd099)
2024-07-13 21:40:59 -04:00
Natsuki Ikeguchi fceb6e021f LibWeb: Add initial implementation of global.reportError()
(cherry picked from commit ccb3a2f7add22105a92ca997b67bbe02ec65b535)
2024-07-13 21:40:50 -04:00
rmg-x 7204d5b843 LibWeb: Add response status check when loading fallback favicon
If a favicon image response status was not ok,
we would still attempt to decode the received body data.

(cherry picked from commit 7f04ceb4f6889921ba055ce87476762b9eba262e)
2024-07-13 18:23:14 -04:00
rmg-x 30856ab527 LibWeb: Add response status check in SharedImageRequest::fetch_image
If an image response status was not ok, we would still pass the received
body data to ImageDecoder which is not correct.

(cherry picked from commit 8085e3eb2655ba412fd803a38c4e58d1dc3b3c3b)
2024-07-13 18:23:14 -04:00
Aziz Berkay Yesilyurt 32f513fc1c LibWeb/HTML: Update Text Input Styling
So that it is closer to the spec.
https://www.w3.org/TR/css-ui-4/#input-rules

(cherry picked from commit 13cd653d1ccf9ef486f4622e350614361e275a0c)
2024-07-13 18:22:56 -04:00
Arthur Hartwig Carlsson fd35cb2730 LibWeb: Don't insert out-of-flow elements into block pseudo elements
Like 1132c858e9, out-of-flow elements such
as float elements would get inserted into block level `::before` and
`::after` pseudo-element nodes when they should instead be inserted as a
sibling to the pseudo element. This change fixes that.

This fixes a few layout issues on the swedish tax agency website
(skatteverket.se). :^)

(cherry picked from commit 9ed2669fc801a3475c9f383ae7221b6a2b1a7fa5)
2024-07-13 18:22:38 -04:00
Arthur Hartwig Carlsson f11f4927c2 LibWeb: Refactor out-of-flow and in-flow into functions
The concept of out-of-flow and in-flow elements is used in a few places
in the layout code. This change refactors these concepts into functions.

(cherry picked from commit 196922ae5b44044cbf7baaf28fbfedba1b3d11f3)
2024-07-13 18:22:38 -04:00
Tim Ledbetter 1149e8a0e9 LibWeb/CSS: Use serif for font and font-family initial property values
These properties previously used sans-serif for their initial values.

(cherry picked from commit 0a1fc7ee132840c4e888967ecdd70e698d2ead33)
2024-07-13 18:22:23 -04:00
Tim Ledbetter b511ecee44 LibWeb/CSS: Set initial value of color property to canvastext
Previously the non-standard value `-libweb-palette-base-text` was used.

(cherry picked from commit 58589d6250696c86b3816efb979536e0633dafca)
2024-07-13 18:22:23 -04:00
simonkrauter 3df0082bb1 LibWeb: Correct HTMLMeterElement color selection
The logic of the comment "the region between the high boundary and the
maximum value must be treated as the optimum region" is correct.
However, the code below covered only two cases, the optimum case was
missing.
Fixes #473

(cherry picked from commit a676bd97a745cd7a4b33bb779e00ec68cb1d3c7c)
2024-07-13 18:22:04 -04:00
Keith Cirkel 83b113298a LibWeb: Add customElements.getName
(cherry picked from commit 8d593bcfeb96a3058abeec7bb772579e0c33fcb2)
2024-07-13 18:21:45 -04:00
Andreas Kling 4781543e2c LibWeb: Ensure EC on stack when resolving/rejecting image decode promise
Fixes #419

(cherry picked from commit 9c80326053356ddeb986df275a19468c16a8469a)
2024-07-13 17:37:57 -04:00
Jacob Wischnat 5cf467c86d LibMedia: Support videos with BT470BG color matrix
(cherry picked from commit 7a03ef45c2fa7f416a26955593fda34c4521f123)
2024-07-13 17:37:23 -04:00
Nico Weber 1a663078ed LibGfx/WebPLoader: Use transparent black as animation background color
This matches libwebp (see ZeroFillCanvas() call in
libwebp/src/demux/anim_decode.c:355 and ZeroFillFrameRect() call
in line 435, but in WebPAnimDecoderGetNext()) and makes files
written e.g. by asesprite look correct -- even though the old
behavior is also spec-compliant and arguably makes more sense.
Now nothing looks at the background color stored in the file.

See PR for an example image where it makes a visible difference.
2024-07-12 19:01:07 -04:00
Liav A. a5bc15355d DeviceDeviceMapper: Remove hardcoded list of pluggable once devices
Instead, simplify things by allowing the user to specify a specific
device entry in the configuration file, by specifying a minor number.

The first example of such device is the /dev/beep, as it resides on the
"generic" device node family (as it has a major number of 1).

However, because it can be skipped (if the user disables the beep device
through a kernel commandline option), we can't just create it blindly.
Therefore, when iterating on the configuration file the DeviceMapper
code detects the entry has a specific minor number of 10, and creates
a special DeviceNodeMatch (with a specific minor number being included).
When an event from /dev/devctl that notifies on the existence of the
/dev/beep device arrives, we find this specific match and don't create
an actual DeviceNodeFamily object, but rather blindly create a device
node.Mapper: Remove the concept of pluggable once devices
2024-07-12 18:44:49 -04:00
Liav A. f8851b9cf2 DeviceMapper: Don't hardcode a list of device node families
Instead, let the user define them through a configuration file which can
be written with the assistance of /sys/kernel/chardev_major_allocs and
/sys/kernel/blockdev_major_allocs files.
2024-07-12 18:44:49 -04:00
Dan Klishch 9bbadf7362 LibCrypto: Remove FIXMEs regarding possible optimizations in SHA{1,256}
These do not bring any noticeable (>0.5%) performance improvements.
2024-07-12 18:30:07 -04:00
Dan Klishch 16a251140a LibCrypto: Use static function pointer to choose SHA256 SIMD kernel
See previous commit for rationale.
2024-07-12 18:30:07 -04:00
Dan Klishch 645a220f3b LibCrypto: Use static member function pointer to choose SHA1 SIMD kernel
It turns out we cannot use function multi-versioning with "sha" feature
or even just plain ifunc resolvers without preprocessor guards. So,
instead of feeding ifdef-soup monster, we just use static member
function pointer.

Moving the kernel into the SHA1 class makes it possible to not pass
class members as parameters to it. This, however, requires us to
disambiguate different target "clones" of the kernel using some kind
of template.
2024-07-12 18:30:07 -04:00
Dan Klishch dbe37edde0 LibCrypto: Use AK::detect_cpu_features in ifunc resolvers
Note: AVX target clone does not bring any significant (>0.5%)
performance change.
2024-07-12 18:30:07 -04:00
Dan Klishch 225d9a2c1a AK: Introduce AK_CAN_CODEGEN_FOR_<FEATURE> macros
These replace `#if ARCH(...)` macros that were added to conditionally
include different hand-vectorized SIMD-implementations.
2024-07-12 18:30:07 -04:00
Dan Klishch f257271dcf LibCrypto: Deduplicate repeating attributes for lambdas with a macro
This also removes `[[gnu::target("sse4.2")]]` from nested functions:
since we don't explicitly use any of the SSE4.2 intrinsics there, the
said target is unneeded. Note that this won't prevent compiler from
choosing SSE4.2 intrinsics as the affected functions are always inlined
into `transform_impl_sha1` that has `[[gnu::target("sse4.2")]]`.
2024-07-12 18:30:07 -04:00
Dan Klishch 56b7f9e404 Meta: Globally disable -Wpsabi
This warning is triggered when one accepts or returns vectors from a
function (that is not marked with [[gnu::target(...)]]) which would have
been otherwise passed in register if the current translation unit had
been compiled with more permissive flags wrt instruction selection (i.
e. if one adds -mavx2 to cmdline). This will never be a problem for us
since we (a) never use different instruction selection options across
ABI boundaries; (b) most of the affected functions are actually
TU-local.

Moreover, even if we somehow properly annotated all of the SIMD helpers,
calling them across ABI (or target) boundaries would still be very
dangerous because of inconsistent and bogus handling of
[[gnu::target(...)]] across compilers. See
https://github.com/llvm/llvm-project/issues/64706 and
https://www.reddit.com/r/cpp/comments/17qowl2/comment/k8j2odi .
2024-07-12 18:30:07 -04:00
Alec Murphy 84d66ac538 LibGUI: Add alt shortcut for make_quit_action
This patch adds the common Ctrl-W shortcut to make_quit_action as an
alternate shortcut by default.

The shortcut can be disabled in programs using this key binding for a
different purpose, e.g. closing tabs, or instances where the "close
window" concept would not be applicable, such as CatDog.

To the best of my knowledge, I have disabled the shortcut for any
existing programs in the system where the aforementioned examples or any
additional conflicts would apply.
2024-07-12 09:54:28 -04:00
MacDue e8fe2f4ffe LibPDF: Use draw_rect() to show debug clipping rects
Using the path rasterizer here is much slower than simply drawing four
lines. This also more accurately shows the (real) clip as the bounding
box is truncated to an int before adding it as a clip rect.

Fixes #23056
2024-07-12 09:47:51 -04:00
PerrinJS f30dc92a1e cat: Add the -n line numbering feature
Adds the -n line numbering feature with the same formatting as gnu's cat
function.
2024-07-12 08:48:24 -04:00
Alec Murphy 1dca789d0f Calendar: Sort Events by start DateTime
This PR allows Calendar to display Events in chronological order.
2024-07-11 07:51:45 +01:00
circl 3961002ffd LibWeb: Use viewport position for did_enter_tooltip_area
This now matches the behavior of did_request_link_context_menu and
friends. Previously the coordinates relative to the page rather than
viewport were sent to the chrome.

(cherry picked from commit 990cf9b4e9476d15494a9538614762119d759b2d)
2024-07-10 09:20:15 -04:00
Diego 5e8dba07a6 LibWasm: Give names to functions exported to JS via ref.func
https://webassembly.github.io/spec/js-api/index.html#name-of-the-webassembly-function
(cherry picked from commit e8fd8982f82e91f97b24523f3ee60eef774990dd)
2024-07-10 01:10:12 +02:00
Diego f5a27dda1d LibWasm: Error when parsed section lengths are invalidated
(cherry picked from commit afd8d90f3237e0cffaabb05becbff16f8c8fdd25)
2024-07-10 01:10:12 +02:00
Diego 3bec014c53 LibWasm: Remove Wasm::ValueType::Kind::Null* variants
As far as I know, they're not in the spec and don't serve any purposes
in the internals of LibWasm.

(cherry picked from commit 5382fbb6171555264e29872029330e1373b39671)
2024-07-10 01:10:12 +02:00
Diego 29ae76925f LibWasm: Fix comparisons between 0.0 and -0.0
According to the spec, -0.0 < 0.0.

(cherry picked from commit 31c7e98a4a46c2d0ef93c5fca47d64d05b96449f)
2024-07-10 01:10:12 +02:00
Diego 3ed4cac2a5 LibWasm: Fix some floating-point conversion issues
NaN bit patterns are now (hopefully) preserved. `static_cast` does not
preserve the bit pattern of a given NaN, so ideally we'd use some other
sort of cast and avoid `static_cast` altogether, but that's a large
change for this commit. For now, this fixes the issues found in spec
tests.

(cherry picked from commit c882498d4450c4c2e46d77a8ab36afc4eb412c00)
2024-07-10 01:10:12 +02:00
Diego d7d36a28de LibWasm: Validate potentially empty else branch in if instruction
(cherry picked from commit fce8ed15630a4969be7c9761b9b7d3cef0530cc6)
2024-07-10 01:10:12 +02:00
Alec Murphy 648b36f3c5 PixelPaint: Disable Crop to Selection if empty
This PR resolves 2 FIXMEs.
2024-07-08 00:06:17 +01:00
mkblumenau 3caa3da8ac WindowServer: Remove some old TODOs in Window.cpp
These were resolved in 74ae6ac (#1010)
2024-07-07 13:27:12 +02:00
Aliaksandr Kalenik 8cb38da92f LibWeb: Implement scrollbars dragging
(cherry picked from commit 881e97084625184543b93cee235cb0b96ee055ae)
2024-07-07 11:32:25 +02:00
Aliaksandr Kalenik 0d9a9490f0 LibWeb: Remove did_request_scroll_to IPC call
No longer used after moving scrollbar painting into WebContent.

(cherry picked from commit 94eacf6da736f957a5fc22faa552341165aaf1ca)
2024-07-07 11:32:25 +02:00
Aliaksandr Kalenik 5728f22dd8 LibWeb: Remove did_request_scroll IPC call
No longer used after moving scrollbar painting into WebContent.

(cherry picked from commit cc3d95a356ea3769d325c2f7bb73947cb4ba7baa)
2024-07-07 11:32:25 +02:00
Aliaksandr Kalenik 40a570e237 LibWeb+WebContent: Move scrollbar painting into WebContent
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.

Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
  corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.

After:
- Page's scrollbar is painted on WebContent side using the same style as
  currently used for elements with `overflow: scroll` and
  `overflow: auto`. A nice side effects: scrollbars are now painted for
  iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().

(cherry picked from commit 5285e22f2aa09152365179865f135e7bc5d254a5)

Co-authored-by: Jamie Mansfield <jmansfield@cadixdev.org>
Co-authored-by: Nico Weber <thakis@chromium.org>
2024-07-07 11:32:25 +02:00
Aliaksandr Kalenik 17f9b16c46 LibWeb: Propagate scrollbar-width property from root element to viewport
(cherry picked from commit eb909118bfe9d939a1109823b6e0b8736abab138)
2024-07-07 11:32:25 +02:00
Aliaksandr Kalenik 5e288aa0b0 LibWeb: Scroll into viewport from a task in set_focused_element()
This is a hack needed to preserve current behaviour after making set
viewport_rect() being not async in upcoming changes.

For example both handle_mousedown and handle_mouseup should use the same
viewport scroll offset even though handle_mousedown runs focusing steps
that might cause scrolling to focused element:
- handle_mousedown({ 0, 0 })
  - run_focusing_steps()
  - set_focused_element()
  - scroll_into_viewport() changes viewport scroll offset
- handle_mouseup({ 0, 0 })

(cherry picked from commit 50920b05953a6bc2aacb07d291d503052caadf15)
2024-07-07 11:32:25 +02:00
Daniel Bertalan 85b7ce8c2f LibJS: Add missing ValueInlines.h include for Value::to_numeric
When compiling with `-O2 -g1` optimizations (as done in the main
Serenity build), no out-of-line definitions end up emitted for
`Value::to_numeric`, causing files that reference the function but don't
include the definition from `ValueInlines.h` to add an undefined
reference in LibJS.so.
2024-07-07 11:11:02 +02:00
mkblumenau eb1e054d65 LibAudio: Use clamp() in Sample::clip()
Sample::clip() now uses clamp().
2024-07-06 22:24:20 +02:00
Liav A. 60e9f24084 Utilities/init: Remove all-mice device node
We are going to remove this device from the kernel in the next commit,
so prepare for that by not creating a device node.
2024-07-06 21:42:32 +02:00
Liav A. 5cc402e7e2 WindowServer: Add basic support for hotplug events in the EventLoop
Add inode watchers on the /tmp/system/devicemap/family/{mouse,keyboard}/
directories.

Then instruct those watchers to dispatch a refresh call to the vectors
which hold references to these devices.
2024-07-06 21:42:32 +02:00
Liav A. aa2d76cd78 Utilities: Add the lsdev utility
This utility lists all devices' major number allocations, for character
and block devices. It can help the user to figure out the DeviceMapper
service manages spawning of device nodes in /dev and other associated
files under the /tmp/system/devicemap directory.
2024-07-06 21:42:32 +02:00
Liav A. 5292bb3fe0 Utilities/init+DeviceMapper: Add IPC hotplug notifications mechanism
The new mechanism is basically adding or removing symbolic links to
device nodes in /dev. These symbolic links are located in the directory
of /tmp/system/devicemap/nodes/{block,char} which contain subdirectories
for major number allocation, which then hold these symbolic links.

An interested userspace program could then open an inode watcher on the
subdirectories which hold the symbolic link for added or removed links
to indicate hotplug events of insertion or removal of a device.
2024-07-06 21:42:32 +02:00
Liav A. 5e8a0e6217 DeviceMapper: Use DeviceNodeType from Kernel API in all possible cases
Having a separate enum is pointless, and opens the possibility of having
duplicates elsewhere. Therefore, just unify everything under one known
enum.
2024-07-06 21:42:32 +02:00
Liav A. fdff05cc97 Kernel+Userland: Simplify minor number allocation for virtual consoles
There is simply no advantage with putting both virtual console devices
and serial TTY devices on the same major number.

Putting them on separate major numbers greatly simplifies the allocation
mechanism on the DeviceMapper code, because it no longer needs to
calculate offsets of minor numbers, and should start from number 0 to
theoretically infinite amount of device nodes.
2024-07-06 21:42:32 +02:00
Liav A. 08b9766b33 DeviceMapper: Simplify formatting patterns for device paths 2024-07-06 21:42:32 +02:00
Alec Murphy 0f72978fd1 FileManager: Add keyboard shortcut for new window
This patch adds the common Ctrl-N shortcut to FileManager for opening a
new window.
2024-07-05 14:01:01 +02:00
Marek Knápek 37c66c1520 LibCrypto: Implement SHA-256 by using x86 intrinsics
Co-Authored-By: Hendiadyoin1 <leon.a@serenityos.org>
2024-07-05 00:52:30 +02:00
Marek Knápek e01d78d8b6 LibCrypto: Implement SHA-1 by using x86 intrinsics
Co-Authored-By: Hendiadyoin1 <leon.a@serenityos.org>
2024-07-05 00:52:30 +02:00
Hendiadyoin1 cd454a1e3d LibWasm: Use shuffle_or_0 in for vector swizzles and shuffles
Otherwise we'd hit a VERIFY in AK::SIMD::shuffle() when that operand
contains an out-of-range value, the spec tests indicate that a swizzle
with an out-of-range index should return 0.
2024-07-05 00:52:30 +02:00
Hendiadyoin1 2c09d9dcec LibELF/DynamicLoader: Disable UBSAN signature verification for IFUNCs
We currently pretend that these return an ElfAddr, while in actuality
they return a function pointer.
UBSAN may check this and complain about it, so let's just disable it
for that line.
2024-07-05 00:52:30 +02:00
Hendiadyoin1 d5c50750dc LibGfx: Remove unused AK/SIMD.h include in Color.h 2024-07-05 00:52:30 +02:00
Zaggy1024 98c74df103 LibMedia: Move VideoSampleData out of the Video namespace
(cherry picked from commit 3cc11870362934f93dea477efcd767929d238b74)
2024-07-04 22:09:32 +02:00
Zaggy1024 077d63c6f3 LibMedia: Flush the video decoder when seeking
This allows H.264 videos to seek correctly.

(cherry picked from commit 8848ee775befd10cd404f70812b95b0bd3e959d0)
2024-07-04 22:09:32 +02:00
Zaggy1024 7b34152212 LibMedia: Add a function to flush persistent data from video decoders
Any data that sticks around in a decoder, especially frames that
haven't been retrieved, may cause issues for playback.

(cherry picked from commit c128a19903c42d5a66153445c457d41dc7ed30a1)
2024-07-04 22:09:32 +02:00
Zaggy1024 7a34e7d56f LibMedia/Matroska: Handle negative timestamp offsets correctly
The timestamp offset of a block was being converted from i16 to u64, so
negative values would overflow and cause timestamps that fall before
the cluster's timestamp from being close to the minimum representable
i64.

The math is also now done using saturating operations to prevent any
other similar issues from occurring.

(cherry picked from commit ef99e701b7372a409b11a4fa1d1196a76580eb0e)
2024-07-04 22:09:32 +02:00
Zaggy1024 2bfaaa967c LibMedia: Give frame timestamps to video decoders
H.264 in Matroska can have blocks with unordered timestamps. Without
passing these to the decoder when providing data, the decoder will be
unable to reorder the frames to presentation order.

VideoFrame will now include a timestamp that is used by the
PlaybackManager, rather than assuming that it is the same timestamp
returned by the demuxer.

(cherry picked from commit f6a4973578c4692f33283aee1c089afd0cdae508)
2024-07-04 22:09:32 +02:00
Zaggy1024 aa2c318795 LibMedia: Add a TrackEntry getter to Matroska::SampleIterator
This can be used to get the codec private data when that is needed.
2024-07-04 22:09:32 +02:00
Zaggy1024 1dbe715690 LibMedia/Matroska: Make SampleIterator getters const
(cherry picked from commit 32714878ad9e5c15b2e46428bbc7bebfe8fe3029)
2024-07-04 22:09:32 +02:00
Zaggy1024 f57d2acf05 LibMedia: Retrieve codec initialization data from Matroska files
This is necessary to give H.264 decoders the data they need to
initialize, including frame size and profile.

(cherry picked from commit 457a69786b788d3158813156d11e70980f50f7b7)
2024-07-04 22:09:32 +02:00
Zaggy1024 b2668c8c6c LibMedia/Matroska: Move the definition get_codec_id_for_track up
The function is separated from the string-to-enum function it uses, and
the order is also inconsistent with header.

(cherry picked from commit bf1e0fac94e0d8599c0c540c24883ca5f5ea4131)
2024-07-04 22:09:32 +02:00
Zaggy1024 def171b4a8 LibMedia/Matroska: Make track entries ref-counted
These aren't particularly small objects, but we were still copying them
around all over the place. When TrackEntry contains data buffers, they
won't need to be copied as well.

(cherry picked from commit 55fda2068b7334acaba2673c80c01c019aaf7075)
2024-07-04 22:09:32 +02:00
Zaggy1024 2dfa68085a LibMedia: Store YUV planes as byte arrays with no padding for 8-bit
This should halve the size of frames in memory for frames with 8-bit
color components, which is the majority of videos.

Calculation of the size of subsampled planes has also been consolidated
into a struct. There are likely some places that will still need to
change over to this, but it should prevent issues due to differing
handling of rounding/ceiling.

(cherry picked from commit 40fe0cb9d5c40a5ee568a3196bf19452ea8fed2b)
2024-07-04 22:09:32 +02:00
Zaggy1024 1fe34874ca LibMedia: Split output bitmap size assertions to individual lines
Now Clang will stop complaining about DeMorgan's theorem.

(cherry picked from commit b49d3dcf6fbe972a46555d751e998c1e7bd5e4a2)
2024-07-04 22:09:32 +02:00
Zaggy1024 e0f3bc2b32 LibMedia: Remove fixed-point path for BT.2020 matrix coefficients
BT.2020 will mainly be used with bit depths greater than 8, so having
this specialization is mostly pointless until we use fixed-point math
for higher bit depths.

(cherry picked from commit fe2a63d485bc9d494b06a780043eae21adfd6854)
2024-07-04 22:09:32 +02:00
Zaggy1024 a6153cb062 LibMedia: Ensure that buffers passed to SubsampledYUVFrame are moved
(cherry picked from commit 6f8389c48377244e631a4eb1a7423d89033a64bc)
2024-07-04 22:09:32 +02:00
Zaggy1024 d7b24c0c30 LibMedia/Matroska: Actually read out the video color range
Apparently I forgot to put read the value for this field, though this
generally doesn't matter since video bitstreams usually specify CICP as
well.

(cherry picked from commit d3f88b4987730e396bc41c2674edddb53845cb37)
2024-07-04 22:09:32 +02:00
Zaggy1024 9e2abedbf9 LibMedia: Add formatters for CICP and its components
This is often useful for debugging.

(cherry picked from commit a99ff1fcb4ed7636f7c6ab47425f0b2feb2ecbd9)
2024-07-04 22:09:32 +02:00
Zaggy1024 9592f8766f LibMedia: Remove unused includes from VideoSampleData.h
(cherry picked from commit 291c1c3bd0af42e9c94dba4e7f256ba2c2d7a6b8)
2024-07-04 22:09:32 +02:00
Zaggy1024 55173b7b08 LibMedia: Make Media::Sample final using Variant for auxiliary data
We don't need to allocate these little things onto the heap, that's
silly.

(cherry picked from commit 5a6950be8ea0830dd5b810e6a6bd7e2e8326e4df)
2024-07-04 22:09:32 +02:00
Zaggy1024 0a525881b6 LibMedia: Rename LibVideo to LibMedia
This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.

(cherry picked from commit 7c10e1a08d7a109b63c9258578eb98aa9dcc1425)
2024-07-04 22:09:32 +02:00
Dennis Camera 9fa81ae1fb LibCrypto: Use ARM C Language Extensions (ACLE) for CRC32 intrinsics
The __builtin_arm_* intrinsics don't exist on all ARMv8 systems.
Use the standardized ACLE intrinsics, instead.
2024-07-04 15:36:10 +02:00
Nico Weber ab156c5034 animation: Add a flag to disable inter-frame color compression 2024-07-04 10:04:54 +02:00
Nico Weber 4156d69cbe LibGfx/WebPWriter: Opt in WebPAnimationWriter to inter frame compression
No effect on sunset-retro.png since that's not animated.

        wow.gif (nee giphy.gif) (184k):
            1.4M -> 255K
            74.0 ms ± 1.1 ms -> 86.9 ms ± 3.3 ms

    (from 7.6x as big as the gif input to 1.4x as big.
    About 82% smaller, for a 16% slowdown.)

        7z7c.gif (11K):
            8.4K -> 8.6K
            12.9 ms ± 0.5 ms -> 12.7 ms ± 0.5 ms

    (2.4% bigger, so the transform makes things a bit worse for this
    image.)
2024-07-04 10:04:54 +02:00
Nico Weber d0b1598806 LibGfx/AnimationWriter: Compress identical pixels in consecutive frames
AnimationWriter already only stores the smallest rect that contains
changing pixels between two frames. For example, when doing a screen
recording and only the mouse cursor moves, we already only encode
the pixels in the (single) rectangle containing old and new mouse cursor
positions.

Within that rectangle, there can still be many pixels that are identical
over the two frames. When possible, we now replace all identical pixels
with transparent black. This has two advantages:

1. It can reduce the number of colors in the image. In particular,
   for wow.gif (and likely many other gifs), new frames had more
   than 256 colors before, and have fewer than 256 colors after this
   change.

2. Long run of identical pixels compress better.

In some cases, this transform might make things slighly worse,
for example if the input image already consists of long runs of
a single color. We'll now add another color to it (transparent black),
without it helping much. And the decoder now must do some blending,
slowing down decoding a bit.

But most of the time this should be a pretty big win. We can tweak
the heuristic when to do it later.

This transform is possible when:

* The new frame doesn't already have transparent pixels (which are
  different from the old frame)

* The encoder/decoder can handle frames with transparent pixels

For the latter reason, encoders currently have to opt in to this.
2024-07-04 10:04:54 +02:00
Aliaksandr Kalenik 0130372531 LibWeb: Reschedule HTML event loop processing if navigable needs repaint
This is an attempt to fix the hanging CI on macOS caused by some
screenshot requests being stuck unprocessed. With this change, we at
least make sure that the HTML event loop processing, which triggers
repainting, will happen as long as there are navigables that need to be
repainted.

(cherry picked from commit 72b4d44d07e12cc04bde90872e2f31aaab64aa00)
2024-07-03 10:06:51 +02:00
Ryan Castellucci a2a6bc5348 Documentation: Fix some minor ESL grammar issues
There are a few instances where comments and documentation have minor
grammar issues likely resulting from English being the author's second
language.

This PR fixes several such cases, changing to idiomatic English and
resolving where it is unclear whether the user or program/code is
being referred to.
2024-07-03 00:17:46 +02:00
Andrew Kaster 4103a9cfd2 LibWeb: Use double as the argument for AnimationFrameCallbacks
This avoids an unnecessary lossy conversion for the current time from
double to i32. And avoids an UBSAN failure on macOS that's dependent
on the current uptime.

(cherry picked from commit 55c1b5d1f4d7c82f0a68323260cb2e0f7de2faae,
amended to fix a typo in the commit message)
2024-07-02 14:21:39 +02:00
Bastiaan van der Plaat 52023e38dc LibWeb/Geometry: Make DOMRect doubles unrestricted
(cherry picked from commit bff6c0680aff5862e05c68af03a653f2250328b4)
2024-07-01 23:03:47 +02:00
Tim Ledbetter 077c0319b3 sed: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter c921930593 grep: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter 5070830acc cut: Don't skip final character when using byte or character ranges 2024-07-01 13:46:00 +02:00
Tim Ledbetter f3fbcb28e7 cut: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter 4663b2fee6 comm: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
kleines Filmröllchen 9f0ab281ce AudioServer: Handle missing audio device gracefully
On several platforms, we don't yet have audio
support, so audio devices are missing. Instead of
having AudioServer crash repeatedly, and not
having the ability to open any app that relies on
it, we should instead handle missing devices
gracefully. This implementation is minimal, audio
device hotplugging support and such should be
implemented together with multi-device support.
AudioServer will start up and seem to function
normally without an audio device, but it will
pretend the device has a sample rate of 44.1 kHz
and all audio input is discarded.
2024-07-01 12:47:52 +02:00
Tim Ledbetter d9245bc5ac LibWeb: Implement the HTMLTrackElement.kind attribute
This reflects the HTML `kind` attribute.

(cherry picked from commit bdaa7f0e8ed738ad0bd6e19878f296436fe40377)
2024-07-01 12:45:34 +02:00
Nico Weber 5ff69579a4 LibGfx/WebPWriter: Implement run-length encoding
This implements the start of lossless webp's compression scheme,
which is almost, but not quite, entirely unlike deflate.

The green channel is now green-or-length, and has up to 280
entries, instead of up to 256 before. We now use the 40-entry
distance code (even though it only ever stores 1s now).

Due to this, a few places change to taking spans instead of
Array<256>s.

The spec only has the transform from prefix or distance code
to value. The inverse prefix_decompose() in this patch is
my own invention. I checked with a python script that it's
a true inverse (see PR for the script).

We now look for back-references with a distance of 1, which is
equivalent to run-length encoding. It's fairly fast to compute,
but leaves compression on the table. Full window-based
back references will be in a future PR.

We also still don't do color cache entries yet, but that should
be fairly straightforward to add. (It will make the green channel
larger than 280 entries.)

We still use a single global huffman table for the entire image.
Doing one per tile should be doable with the organization we now
have, and might also be in a future PR.

File sizes, and perf numbers on HEAD before this patch series (see
previous commit for perf comparison to previous commit):

    sunset-retro.png (876K):
        1.7M -> 1.6M,
        25.3 ms ± 0.5 ms -> 27.5 ms ± 0.8 ms

(helps little; from 1.94x as input to 1.83x as large.
About 5% smaller, for about a 10% slowdown.)

    wow.gif (nee giphy.gif) (184k):
        3.9M -> 1.4M
        105.7 ms ± 1.7 ms -> 74.0 ms ± 1.1 ms

(from 21.2x as big as the gif input to 7.6x as big.
About 64% smaller, for a 28% speed _up_.)

    7z7c.gif (11K):
        40K -> 8.4K
        13.9 ms ± 0.6 ms -> 12.9 ms ± 0.5 ms

(from 3.6x as big as the gif input to 0.76x as big :^)
About 79% smaller, for a 7% speed _up_.)
2024-07-01 00:29:39 +02:00
Nico Weber 3f1c562aa3 LibGfx/WebPWriter: Extract can_write_as_simple_code_lengths()
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber f5bbc69e6a LibGfx/WebPWriter: Extract compute_and_write_prefix_code_group()
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber 2627721e0b LibGfx/WebPWriter: Extract bitmap_to_symbols() function
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber 580134241e LibGfx/WebPWriter: Separate symbol generation from statistics collection
We now do this in two passes instead of in one. This is virtually free
performance-wise, and allows nicer factoring.

Perf numbers after this change (see previous commit for perf numbers
before):

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 26.7 ms ± 0.8 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 14.5 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 108.2 ms ± 2.2 ms
2024-07-01 00:29:39 +02:00
Nico Weber 85739def89 LibGfx/WebPWriter: Use symbols for writing image data
No behavior change yet, but this will allow us to emit distance/length
and color cache symbols in addition to literal symbols.

Not super expensive perf-wise. Before:

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 25.3 ms ± 0.5 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 13.9 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 105.7 ms ± 1.7 ms

After:

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 26.1 ms ± 0.6 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 14.4 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 106.5 ms ± 1.9 ms
2024-07-01 00:29:39 +02:00
Nico Weber 7c6176f983 LibCompress: Detemplatize generate_huffman_lengths()
Take Spans instead of Arrays. There's no need to have one copy of this
function for every possible array size passed to it.

Hardcode the inline size of the BinaryHeap to 288 for now. If this
becomes a performance issue in the future, we can make that size
an (optional) template parameter then.

No behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber 59ef7d0d4e LibGfx/WebPLoaderLossless: Add a spec comment 2024-07-01 00:29:39 +02:00
Nico Weber e54fc640f0 LibGfx/WebPWriter: Tweak dbgln_if() output
The writer logging now looks more like the reader logging, making
it easier to spot disagreements.
2024-07-01 00:29:39 +02:00
Ali Mohammad Pur f6c3b33333 LibWasm/WASI: Don't convert enums and u8s into i64
Doing so results in incorrect values being created, ultimately leading
to traps or errors.
2024-06-30 21:55:55 +02:00
Dan Klishch 2360df3ab8 Everywhere: Define even more destructors out of line
You guessed it, this fixes compilation with LLVM trunk.
2024-06-30 08:52:07 +02:00
Dan Klishch c03cca7b2f AK+LibTest: Choose definition of CO_TRY and CO_TRY_OR_FAIL more robustly
There are three compiler bugs that influence this decision:

 - Clang writing to (validly) destroyed coroutine frame with -O0 and
   -fsanitize=null,address under some conditions
   (https://godbolt.org/z/17Efq5Ma5) (AK_COROUTINE_DESTRUCTION_BROKEN);

 - GCC being unable to handle statement expressions in coroutines
   (AK_COROUTINE_STATEMENT_EXPRS_BROKEN);

 - GCC being unable to deduce template type parameter for TryAwaiter
   with nested CO_TRYs (AK_COROUTINE_TYPE_DEDUCTION_BROKEN).

Instead of growing an ifdef soup in AK/Coroutine.h and
LibTest/AsyncTestCase.h, define three macros in AK/Platform.h that
correspond to these bugs and use them accordingly in the said files.
2024-06-29 20:15:05 -06:00
Liav A. 6fc3908818 Utilities/init: Add "drop to emergency shell" functionality
In case the user requests this, init can drop directly to a shell
without trying to spawn SystemServer.

To test this on x86-64, run:
```
Meta/serenity.sh run x86_64 GNU "init_args=emergency"
```

Also, init will drop to emergency shell if mounting filesystems with
`mount -a` failed for some reason.

This functionality can be useful in many cases.
For example, if the user needs to perform a command that must not alter
a corrupted filesystem state, then this mode is useful as the filesystem
should be mounted in read-only mode.
Another example is the ability to get a functioning system in case
SystemServer behaves badly or inconsistently, or the user specified a
wrong fstab entry, so proceeding to boot is probably a bad option.
2024-06-30 00:20:45 +02:00
Liav A. 1e73a584a7 Userland: Move basic system init functionality out of SystemServer
Let's make SystemServer simpler by not involving it with the basic
system initialization sequence.
That initialization sequence can be done in another program that
theoretically can be put in another filesystem.

Co-authored-by: Tim Schumacher <timschumi@gmx.de>
2024-06-30 00:20:45 +02:00
Thomas Voss 96efa81dc6 Utilities/wc: Seek the input file(s) if only -c is passed
If the user only wants to get the byte count of a set of files, then for
each file we can simply seek it to get the byte count instead of
iterating over all the bytes.
2024-06-30 00:17:46 +02:00
Andreas Kling 225108c830 LibWeb: Set the correct prototype for SVGAElement instances
(cherry picked from commit 4db05ecf69bee07a060f2e4513e9d53b6110dcc4)
2024-06-28 23:43:59 +02:00
Luke Warlow cf5b1b7c10 LibWeb: Implement unsafe HTML parsing methods
Both Element's and ShadowRoot's setHTMLUnsafe, and Document's static
parseHTMLUnsafe methods are implemented.

(cherry picked from commit ce8d3d17c4f2fcca8fac0ff4a832c8f50a011fc7)
2024-06-28 10:56:27 +02:00
Edwin Hoksberg e2bf7d1a36 LibWeb: Add attribute list that must always be compared without casing
(cherry picked from commit 2b30414c1d8641eaf4212db69e40a4381005314c)
2024-06-28 10:56:14 +02:00
Luke Warlow 27ffaad882 LibWeb: Implement dialog element's close watcher
Dialog elements now correctly establish a close watcher when
shown modally.

This means modal dialogs now correctly close with an escape key press.

(cherry picked from commit d86a6e1bec858a35935ba6839c154ba2482d33e6)
2024-06-28 10:32:12 +02:00
Luke Warlow 47bc8ecb0e LibWeb: Prevent select.click() opening the dropdown
No other browser allows opening the select element dropdown with the
select.click() function.
This change stops this happening in Ladybird.

(cherry picked from commit 564e546ff0bd78cc7ba770b53377457bf1ef88d6)
2024-06-28 10:31:53 +02:00
Liav A. 972f7581e9 Utilities/nc: Add an option to test a TCP-listening service
Similarly to OpenBSD nc, an option to just connect without transmitting
any actual data is added.

However, we don't allow UDP-mode when testing a remote service, as it
will always succeed and has no technical meaning for the user if they're
not able to view the traffic on the remote machine.
2024-06-28 10:31:23 +02:00
Liav A. dcf7296929 Utilities/nc: Don't use LibC gethostbyname function
Instead, let's use the nicer Core::Socket API and resolve the hostname
this way.
2024-06-28 10:31:23 +02:00
Luke Warlow 1df32b7e1a LibWeb: Add HTMLSelectElement showPicker()
Adds the showPicker() function for select elements.
This doesn't do the check for "being rendered" which is in the spec.

(cherry picked from commit 5098ed6b1f881659dbdab10c74a0e17b362ce7a8)
2024-06-28 00:56:17 +02:00
Luke Warlow 33c315bad0 LibWeb: Implement CloseWatcher API
This implements most of the CloseWatcher API from the html spec.

AbortSignal support is unimplemented.

Integration with dialogs and popovers is also unimplemented.

(cherry picked from commit b216046234560df531e1a32269e5dfa18f8f240c,
manually amended to replace a single `UIEvents::KeyCode::Key_Escape`
with `KeyCode::Key_Escape` in EventHandler.cpp since we don't have
the second commit of https://github.com/LadybirdBrowser/ladybird/pull/86)
2024-06-28 00:55:43 +02:00
Luke Warlow 1739111d17 LibWeb: Refactor DOM parsing APIs
Multiple APIs have moved from the DOM Parsing and Serialization spec to
HTML.

Updates spec URLs and comments.

Delete InnerHTML file:
- Make parse_fragment a member of Element, matching serialize_fragment
on Node.
- Move inner_html_setter inline into Element and ShadowRoot as per the
spec.

Add FIXME to Range.idl for Trusted Types createContextualFragment

(cherry picked from commit 9171c3518358cd2d146ffbd7582e4c1247a1daa7)
2024-06-28 00:55:22 +02:00
Jamie Mansfield d586afbf73 LibWeb: Don't set hashChange for classic history navigate events
See:
- https://github.com/whatwg/html/pull/10393

(cherry picked from commit 4c5fa102a381c3687e677f9b6b13752c2bcea867)
2024-06-28 00:55:02 +02:00
Tim Ledbetter 850859f645 LibWeb: Disallow pasting into non-editable text nodes
(cherry picked from commit 8969f2e34af196e935c57257ef7eec8f00b45d33)
2024-06-27 22:54:03 +02:00
Tim Ledbetter b62c572154 LibWeb: Fire auxclick event on middle click
Previously, no event was fired on middle click. This change also allows
the UI to open a link in a new tab on middle click.

(cherry picked from commit 31d7fa244232c2a2239dbf6017ba9e3dd191ec2e)
2024-06-27 22:53:15 +02:00
Tim Ledbetter 2554d766bc LibWeb: Add Internals.middleClick
This simulates click of the middle mouse button, which is necessary for
testing whether the `auxevent` fires correctly.

(cherry picked from commit 728fca1b1ffd8b472bc8524e5e8ec8443de011a5)
2024-06-27 22:53:15 +02:00
Aliaksandr Kalenik 030ea71dff LibWeb: Use button layout for input elements with button type
(cherry picked from commit b2dcdf009605d50503592789ac14a8406b0d3983)
2024-06-27 19:02:45 +02:00
Aliaksandr Kalenik c6e3c0a339 LibWeb: Create BlockContainer layout node for <input type="button">
...and shadow tree with TextNode for "value" attribute is created.
This means InlineFormattingContext is used, and button's text now
respects CSS text-decoration properties and unicode-ranges.

(cherry picked from commit 8feaecd5c8d02a2fdb989a9a9671e008d1c3a7de)
2024-06-27 19:02:45 +02:00
Ali Mohammad Pur 7b47c57c54 LibWeb/CSS: Avoid capturing structured binding in generic lambda
Apple Clang doesn't like this, rather than waiting for their version of
random-clang-commit-to-call-a-release to catch up with llvm trunk, just
work around the issue.

Fixes #186.

(cherry picked from commit 8c9d3b30cf62016ffb03e425f1e7e3f2461262bf)
2024-06-27 19:02:24 +02:00
Luke Warlow d29cef8d5f LibWebView: Allow data URLs in sanitize_url
Allow navigation to data URLs from browser UI.

(cherry picked from commit 6014727c20ad108e8345e89cba8e9eace3c157b3)
2024-06-27 17:14:22 +02:00
Shannon Booth 4033776fb5 LibWeb: Add stub for ValidityState
This fixes https://html5test.com/ as previously an exception was being
thrown after trying to access this attribute which would then result in
a popup about the test failing (and none of the test results being
shown).

(cherry picked from commit e0bbbc729b6aad04ceff5f67c3e2868b65970047,
manually amended with the output of `git clang-format master`)
2024-06-27 17:13:16 +02:00
Hexeption 928576e0ac LibWeb: Added HTMLLinkElement.as
(cherry picked from commit 2f4668edce2effb38563b9da229d00d3ba5dc508,
manually amended to move `||` at the start of the line to appease
clang-format)
2024-06-27 14:49:29 +02:00
Matthew Olsson 5e4e39d84a LibWeb: Remove TimingFunction in favor of EasingStyleValue::Function
Now that EasingStyleValue is a lot nicer to use, there isn't much reason
to keep TimingFunction around.

(cherry picked from commit 7950992fc21e2428a7f32954bbe893a2b2d58cf7,
manually amended with the output of `git clang-format master`)
2024-06-27 14:49:14 +02:00
Matthew Olsson 6c0859d412 Meta: Remove GenerateCSSEasingFunctions
(cherry picked from commit ac35f76e67f9a393ed5a2e5c8b7e7f56809a2a56)
2024-06-27 14:49:14 +02:00
Matthew Olsson e301c1d038 LibWeb: Parse easing values manually
The values aren't that complex, so it doesn't make much sense to have a
dedicated generator for them. Parsing them manually also allows us to
have much more control over the produced values, so as a result of this
change, EasingStyleValue becomes much more ergonomic.

(cherry picked from commit 667e313731f06fabf2a3f75893c3e8f15a4172be,
manually amended with the output of `git clang-format master`)
2024-06-27 14:49:14 +02:00
Tim Ledbetter 2519dadbb3 LibURL: Convert ASCII only URLs to lowercase during parsing
This fixes an issue where entering EXAMPLE.COM into the URL bar in the
browser would fail to load as expected.

(cherry picked from commit 1a4b042664f8fddbfa70f009c5873b1f8575bf0b)
2024-06-27 14:00:51 +02:00
Tim Ledbetter 7561a48ec6 LibWebView: Don't query public suffix list when sanitizing URLs
Previously, part of the procedure we used to sanitize URLs entered via
the command line would check the host against the public suffix
database. This led to some valid, but not publicly accessible URLs
being treated as invalid.

(cherry picked from commit e9f34c7bd1e72da9a57a721d4ad501e8208cc986)
2024-06-27 14:00:51 +02:00
Matthew Olsson fa46393e27 LibWeb: Do not clamp the output of the cubic bezier timing function
It is fine for timing function to be outside of the range [0, 1]

(cherry picked from commit 7925efda5fbc755b3fff00dcbba301fe4f8bc1c9)
2024-06-27 13:44:46 +02:00
Matthew Olsson ae4c5512af LibWeb: Prevent overrunning loop bounds in cubic bezier calculation
(cherry picked from commit 7f902fa2dc787bd1212d977babf7ea9eedd328f0)
2024-06-27 13:44:46 +02:00
Matthew Olsson 3434572089 LibWeb: Correct observable property access order in KeyframeEffect
Apparently these are supposed to be accessed in alphabetical order

(cherry picked from commit 31618abf151180391720ba527541cca86190cc3e)
2024-06-27 13:44:46 +02:00
Matthew Olsson e8034cb476 LibWeb: Only read enumerable keyframe properties
(cherry picked from commit c85f00e373405623ecd255c36ba63c907b44de86)
2024-06-27 13:44:46 +02:00
Simon Wanner 92600b3171 LibTextCodec: Use generated lookup tables for all single byte decoders
(cherry picked from commit 0ab4722cee11d27da79bb05c1d53693f39938cf6)
2024-06-27 00:27:56 +02:00
Simon Wanner c90963161e LibTextCodec: Fix ISO-8859-1 vs. windows-1252 handling in web contexts
The Encoding specification maps ISO-8859-1 to windows-1252 and expects
the windows-1252 translation table to be used, which differs from
ISO-8859-1 for 0x80-0x9F.

Other contexts expect to get the actual ISO-8859-1 encoding, with 1-to-1
mapping to U+0000-U+00FF, when requesting it.

`decoder_for_exact_name` is introduced, which skips the mapping from
aliases to the encoding name done by `get_standardized_encoding`.

(cherry picked from commit 6b2c4599017f512279cb26c0d3c48aa5a9453007)
2024-06-27 00:27:56 +02:00
Simon Wanner dc2e64c5b0 LibTextCodec: Fix some incorrect encoding aliases
(cherry picked from commit 46d5cf0443a7061bd7a8a9e495c3f3ee54614f1e)
2024-06-27 00:27:56 +02:00
Simon Wanner 328552a269 LibTextCodec: Bring TextCodec::get_standardized_encoding closer to spec
(cherry picked from commit 09f2d79cb10f84dfaedea61264d8a9d91bdfa17c)
2024-06-27 00:27:56 +02:00
Simon Wanner 30609289b5 LibWeb: Bring TextDecoder constructor closer to spec
(cherry picked from commit 987910ad0f9978a9a618d13b3e1d299a81ce4906)
2024-06-27 00:27:56 +02:00
circl 98a5fff68b LibWeb: Restrict fetching file: and resource: URLs to internal pages
They are now blocked on pages which:
- Don't have an opaque origin (should be only user-initiated or about:)
- Aren't other file: pages
- Aren't other resource: pages

(cherry picked from commit 1f3285eb0410ff5c902e148932205d9e4b7fbd9b)
2024-06-26 23:11:35 +02:00
circl 8287790913 LibWeb: Consider resource: URLs to be trustworthy and non-opaque
This makes icons once again load in the directory listings

(cherry picked from commit d14888f31a8378f319efa18028083ff605105101)
2024-06-26 23:11:35 +02:00
Enver Balalic 18d589c520 LibWeb: Implement HTMLImageElement::decode with a few FIXMEs
Implements enough of HTMLImageElement::decode for it to not break
websites and actually load an image :)

(cherry picked from commit 862fc91b2cf9bee9b7f180cdf930c6c99b5dd053)
2024-06-26 23:09:54 +02:00
Andreas Kling 69514c8a18 LibWeb: Improve FIXME message about getComputedStyle() properties
Let's log which property we're trying to look up, since that's the most
interesting part!

(cherry picked from commit f7a83e57554c7a98cda165ea1fa18356a6ee54d9)
2024-06-26 23:07:42 +02:00
Andreas Kling 7cd1114f05 LibWeb: Remove unnecessary FIXME marker for CSSStyleDeclaration.cssFloat
(cherry picked from commit 4c94202e9734099b6e2839f5495b8280eec2ab2f)
2024-06-26 23:07:42 +02:00
Andreas Kling 99851591b5 LibWeb: Make CSSKeyframeRule.parentRule actually point to parent rule
(cherry picked from commit 19fa630fa7e8342673b2aaa23e451f221533f12c)
2024-06-26 23:07:42 +02:00
Andreas Kling ea2876bc6f LibWeb: Implement CSSKeyframesRule.cssRuleList
To make this straightforward, CSSKeyframesRule now uses a CSSRuleList
for internal storage.

(cherry picked from commit 7f2c833a39e150c7372299dcfe4d2d5590ae779f)
2024-06-26 23:07:42 +02:00
Andreas Kling da836c344a LibWeb: Implement CSSStyleDeclaration.parentRule
This readonly attribute returns the containing CSS rule, or null (in the
case of element inline style).

(cherry picked from commit a12d28fd3053638ce6f4215bed2d8d45cda86375)
2024-06-26 23:07:42 +02:00
Diego 0520de42f1 LibWasm: Check source and destination offsets in memory.init
Overflows are no longer possible.

(cherry picked from commit 3b40667413ce0885d10491589207b9556d5161d0)
2024-06-26 22:13:13 +02:00
Diego da3aaac7ea LibWasm: Check exports for valid ref.func targets
(cherry picked from commit 0e705f431eab80635dd24857aaa4606b7907c325)
2024-06-26 22:13:13 +02:00
Diego 145fb50fe0 LibWasm: Ensure that global.get only accesses imports in const exprs
(cherry picked from commit bd97091cbb4fd12cd323cedfa11f4c6f33250958)
2024-06-26 22:13:13 +02:00
Diego f7bebbe5a8 LibWasm: Read indices as LEB128 u32s
Every type of index was previously being read as a size_t.

(cherry picked from commit 20d8ea4db13490b3a63acd1dfefcc1bdbc79deae)
2024-06-26 22:13:13 +02:00
Diego ef9f3fd091 LibWasm: Check data segment offset at correct time during instantiation
The data segment offset should be checked _before_ checking if the
contents of the segment are non-existent.

(cherry picked from commit 78c56d80f90f913e4cbc14c865af308c6af9aeae)
2024-06-26 22:13:13 +02:00
Diego d7413560f8 LibWasm: Report start function traps during instantiation
(cherry picked from commit c2a0c4f58126e9db833e482b7611c3cea18622f6)
2024-06-26 22:13:13 +02:00
Diego a91f00fed7 LibWasm: Improve element validation and instantiation
(cherry picked from commit 3225e6fad2b077a160d682ec3953a9d8fb49ffec)
2024-06-26 22:13:13 +02:00
Diego 9605b0f28d LibWasm: Implement rest of table instructions
(cherry picked from commit 4c3071c7c209c2e53c73862be72c9b493f263e78)
2024-06-26 22:13:13 +02:00
Tim Ledbetter 166130e12d LibWeb: Avoid null dereference when performing mixed content checks
Previously, navigating to or from `about:newtab` caused a crash due to
inadvertent null dereferences when checking whether a request or
response to a request should be blocked as mixed content.

(cherry picked from commit 572ebe00eacd5aaeecc17207c75c6bf2327a3897)
2024-06-26 20:03:57 +02:00
Andrew Kaster 3d467182bc LibWeb: Check for navigable destruction in declarative refresh timer
If the Document's navigable has been destroyed since we started this
timer, or it's no longer the active document of its navigable, we
shouldn't navigate to it.

(cherry picked from commit 7b67fa706fd2dabfda3c72a752ac70d8c95bb060;
amended commit message to say "LibWeb:" instead of "DOM:")
2024-06-26 20:03:34 +02:00
Luke Warlow 39a8974840 LibWeb: Implement stub for ElementInternals
This implements a stub ElementInternals object which implements the
shadowRoot getter only.

Also implement attachInternals function.

(cherry picked from commit a65f1ecc375fa02deeab5d0e7ab4702972ffa72e)
2024-06-26 20:02:46 +02:00
Torstennator 490d61d694 PixelPaint: Fix broken "Color Masking" selection
This change solves a problem where the color selection via mouse click
on the color wheel was computing a wrong hue angle.
2024-06-26 20:02:27 +02:00
Torstennator bb0bfb7944 PixelPaint: Fix Color Masking crash
This change solves a crash where it was possible that the
"Color Masking" could try to access pixel coordinates that where beyond
the boundaries of the image.
2024-06-26 20:02:27 +02:00
Andreas Kling ff49762eb4 LibWebSocket: Use HTTP::HeaderMap in WebSocket code
(cherry picked from commit 0d22e0703f4d668fab78b6e4960dfdc2b607369d)
2024-06-26 18:50:27 +02:00
Tim Ledbetter 36630bf859 LibIDL+LibWeb: Mark [FIXME] interfaces as [[Unimplemented]]
Methods and attributes marked with [FIXME] are now implemented as
direct properties with the value `undefined` and are marked with the
[[Unimplemented]] attribute. This allows accesses to these properties
to be reported, while having no other side-effects.

This fixes an issue where [FIXME] methods broke feature detection on
some sites.

(cherry picked from commit 2f5cf8ac204a58dc2a6f722dd95015c6c2fb7a78)
2024-06-26 16:34:37 +02:00
Tim Ledbetter c98bcd0a10 LibJS: Add the [[Unimplemented]] attribute
Properties marked with the [[Unimplemented]] attribute behave as normal
but invoke the `VM::on_unimplemented_property_access callback` when
they are accessed.

(cherry picked from commit 88d425f32b3b49d5dfa8d86e6e4e2c263cd450d4)
2024-06-26 16:34:37 +02:00
Andreas Kling f72805398b LibWeb: Add the bare minimum to render SVGAElement (<a>)
(cherry picked from commit 85a4cfc59bc901e860ba60c51ad1fc9c0cf4e669)
2024-06-26 14:13:40 +02:00
Andreas Kling 19e4b138af LibWeb: Treat width: {min,max,fit}-content as auto if ratio unresolvable
This appears to match other engines.

(cherry picked from commit ae906ca4974da309c362e61ce7b6b393b8c4aed1)
2024-06-26 14:13:40 +02:00
Andreas Kling 97edca4e4e LibWeb: Fix overeager fallback to stretch-fit width for some flex items
If a flex item has a preferred aspect ratio and the flex basis is not
definite, we were falling back to using stretch-fit for the main size,
since that appeared to match other browsers.

However, we missed the case where we actually have a definite cross size
through which the preferred aspect ratio can be naturally resolved.

(cherry picked from commit db1faef786dbd1722bbe6a1f4a5616f3069bdb6a)
2024-06-26 14:13:40 +02:00