Commit graph

70447 commits

Author SHA1 Message Date
Psychpsyo
93ae57114d LibWeb: Stop clipping the root element's background 2025-07-04 16:18:57 +01:00
Tim Ledbetter
5413716802 LibWeb: Don't crash when setting offscreen canvas size to 0
Previously, this would crash because `Gfx::Bitmap` can't have a zero
size.
2025-07-04 16:10:38 +01:00
Rocco Corsi
f882c446cb Documentation: Update missing distribution packages for building
Ubuntu missing: python3-venv
Fedora missing: git
Manjaro OK
OpenSUSE missing: git and libpulse-devel
2025-07-04 15:58:36 +01:00
Gingeh
1b7323fc2d LibWeb: Interpolate legacy colors in sRGB 2025-07-04 15:28:08 +01:00
Aliaksandr Kalenik
c18314b942 LibWeb+LibGfx: Replace BackingStore with PaintingSurface
Now, when Skia backend context is available by the time backing stores
are allocated, there is no need to have a separate BackingStore class.

This allows us to get rid of BackingStore -> PaintingSurface cache.
2025-07-04 16:12:47 +02:00
Aliaksandr Kalenik
082053d781 LibWeb+WebContent+WebWorker: Move backing store allocation in Navigable
Making navigables responsible for backing store allocation will allow us
to have separate backing stores for iframes and run paint updates for
them independently, which is a step toward isolating them into separate
processes.

Another nice side effect is that now Skia backend context is ready by
the time backing stores are allocated, so we will be able to get rid of
BackingStore class in the upcoming changes and allocate PaintingSurface
directly.
2025-07-04 16:12:47 +02:00
Aliaksandr Kalenik
b73525ba0e LibWeb+WebContent: Delete unused "has focus" flag from paint config 2025-07-04 16:12:47 +02:00
Timothy Flynn
418409aa6f AK: Fix usage of constexpr within Utf16View and related utilities
* Error and ErrorOr are not themelves constexpr, so a function returning
  these types cannot be constexpr.

* The UDL was trying to call Utf16View::validate, which is not constexpr
  itself. The compiler will actually already raise an error if a UTF-16
  literal is invalid, so let's just avoid the call altogether.
2025-07-05 01:25:22 +12:00
Callum Law
778759517e LibWeb: Support calcs which resolve to numbers as hue values in colors
Gains us 5 new WPT tests.
2025-07-04 13:18:55 +01:00
Callum Law
9ab7c5d08d LibWeb: Support relative lengths in calc color values
Gains us ~40 WPT tests.
2025-07-04 13:18:55 +01:00
Callum Law
62d138ebf7 LibWeb: Allow passing a resolution context to CSSStyleValue::to_color
This will be used for resolving any calculated style values within the
various `CSSColorValue` sub-classes.

No functionality changes.
2025-07-04 13:18:55 +01:00
Callum Law
b468923372 LibWeb: Allow creating Length::ResolutionContext with provided root
Previously we could not create a `Length::ResolutionContext` using the
`for_layout_node` method if the provided node's document did not have a
layout node.

We now provide a workaround for this in the case that the
provided layout is that root layout node.

This is useful for instance if we want to create a length resolution
context when calling `NodeWithStyle::apply_style` on the root node.
2025-07-04 13:18:55 +01:00
Ryan Liptak
1fd0bf9feb LibWeb: Add simple named character reference test to TestHTMLTokenizer 2025-07-04 11:57:19 +02:00
Ryan Liptak
7096a2892e LibWeb/HTML: Use lookahead when possible for named character references
When there is an active insertion point, it's necessary to tokenize
code-point-by-code-point to handle the case of document.write being
used to insert a named character reference one code point at a time.

However, when there is no insertion point defined, looking ahead at the
input and doing the matching all-at-once is more efficient since it
allows:

- Avoiding the work done in next_code_point between each code point
  being matched (leading to better CPU cache usage in theory)
- Skipping ahead to the end of the match all at once, which does less
  work overall than the equivalent number of next_code_point calls
  (that is, skip(N) does less work than next_code_point called N times)

In my benchmarking, this provides a small performance boost (fewer
instructions, fewer cpu cycles, fewer branch misses) essentially for
free.
2025-07-04 11:11:19 +02:00
ayeteadoe
f737ec2570 CMake: Rename SERENITY_* helper variables to LADYBIRD_*
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-07-03 23:19:41 +02:00
ayeteadoe
d897bfae91 CMake: Rename all_generated target to better convey intent 2025-07-03 23:19:41 +02:00
ayeteadoe
25f5936dee CMake: Rename serenity_* helper functions/macros to ladybird_* 2025-07-03 23:19:41 +02:00
ayeteadoe
100b204a68 CMake: Move lagom target creation helper functions into Meta/CMake 2025-07-03 23:19:41 +02:00
Tim Ledbetter
cb4a5eca2e Meta: Add formatter to PropertyID code generator 2025-07-03 21:17:16 +01:00
Jelle Raaijmakers
c03210e858 LibWeb: Dump PaintableBox dimensions for inline layout nodes
We were only dumping a PaintableBox' dimensions if its layout node was a
Layout::Box as well, causing us to not dump the dimensions of paintables
for inline nodes in the paintable tree.
2025-07-03 22:16:48 +02:00
Aliaksandr Kalenik
5874b7a76f LibWeb: Skip update_associated_selection() when there's no selection
This change fixes at least two issues:
- `update_associated_selection()` is responsible for selectionchange
  dispatch, and we were incorrectly dispatching this event on ranges
  that were not associated with a selection.
- `Range::get_client_rects()` was using `update_associated_selection()`
  to refresh the selection state in the paintable tree for the current
  range, but since a range might not be associated with a selection,
  this could make the painted selection reflect the state of an
  arbitrary range instead of the actual selection range.

Fixes a bug on Discord where any text typed into the message input would
get selected.
2025-07-03 22:16:39 +02:00
Timothy Flynn
69074a3841 AK: Avoid double allocations when converting UTF-16 LE/BE to UTF-8
We can form the UTF-8 string in-place.
2025-07-03 11:45:23 -04:00
Timothy Flynn
62d9a84b8d AK+Everywhere: Replace custom number parsers with fast_float
Some checks failed
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
Our floating point number parser was based on the fast_float library:
https://github.com/fastfloat/fast_float

However, our implementation only supports 8-bit characters. To support
UTF-16, we will need to be able to convert char16_t-based strings to
numbers as well. This works out-of-the-box with fast_float.

We can also use fast_float for integer parsing.
2025-07-03 09:51:56 -04:00
Timothy Flynn
9fc3e72db2 AK+Everywhere: Allow lonely UTF-16 surrogates by default
By definition, the web allows lonely surrogates by default. Let's have
our string APIs reflect this, so we don't have to pass an allow option
all over the place.
2025-07-03 09:51:56 -04:00
Timothy Flynn
86b1c78c1a AK+Everywhere: Prepare Utf16View for integration with a UTF-16 string
To prepare for an upcoming Utf16String, this migrates Utf16View to store
its data as a char16_t. Most function definitions are moved inline and
made constexpr.

This also adds a UDL to construct a Utf16View from a string literal:

    auto string = u"hello"sv;

This let's us remove the NTTP Utf16View constructor, as we have found
that such constructors bloat binary size quite a bit.
2025-07-03 09:51:56 -04:00
Timothy Flynn
c17b067e1d AK: Completely remove endianness from Utf16View APIs
These were mostly removed in 7628ddfaf7.
This removes the few remaining cases, as no callers are providing any
non-host endianness. This is just to prevent weird API dissymmetry
between Utf16View and an upcoming Utf16String.
2025-07-03 09:51:56 -04:00
Timothy Flynn
a0eb47e2fc AK: Add hash traits for Utf16View
This is based on the hash in JS::Utf16StringImpl::compute_hash.
2025-07-03 09:51:56 -04:00
Timothy Flynn
2abc955ca9 AK: Allow treating UTF-16 views with lonely surrogates as valid
Much of the web requires us to allow lonely surrogates in UTF-16 data.
The default behavior to disallow such code units has not been changed
here - that will be changed in an upcoming commit.
2025-07-03 09:51:56 -04:00
Timothy Flynn
d978a582a0 AK: Add a Utf16View ASCII validator 2025-07-03 09:51:56 -04:00
Timothy Flynn
35a1832d08 Tests/AK: Rename TestUtf16 / TestUtf8 to TestUtf16View / TestUtf8View
These are the files they actually test, so let's rename them to avoid
confusion with an upcoming Utf16String test.
2025-07-03 09:51:56 -04:00
Timothy Flynn
d38b2194ea AK: Remove errant did_destroy_fly_string_data declaration
This declaration is in the AK namespace. The real declaration is in
StringData.h, in the AK::Detail namespace. as is its implementation
in FlyString.cpp. So the declaration removed here was actually unused.

(This was confusing while implementing a UTF-16 flyweight string.)
2025-07-03 09:51:56 -04:00
Timothy Flynn
5720d626ce AK: Extract some StringBase helpers for use in an outside class 2025-07-03 09:51:56 -04:00
Timothy Flynn
66006d3812 AK+LibJS: Extract some UTF-16 helpers for use in an outside class
An upcoming Utf16String will need access to these helpers. Let's make
them publicly available.
2025-07-03 09:51:56 -04:00
Timothy Flynn
b6dc5050d2 AK: Define a formatter for char16_t 2025-07-03 09:51:56 -04:00
Aliaksandr Kalenik
2618956b6f LibWeb: Delete unused Range::inverted() 2025-07-03 15:00:49 +02:00
Aliaksandr Kalenik
481ab338b4 LibWeb: Delete unused Range::normalized() 2025-07-03 15:00:49 +02:00
Aliaksandr Kalenik
bc8870d019 LibWeb: Make recompute_selection_states() go faster
...by avoiding `is_before()` call on every loop iteration in step 5.

This change makes switching channels on Discord go a lot faster.
2025-07-03 13:48:18 +02:00
Shannon Booth
c63e77142a Tests/LibWeb: Import webstorage symbol-props WPT test
I noticed a subtest in this test failing along with every
other browser. After investigation, the failure was due
to testing the previous specification before:

3fb6ab4

So this imports the now adjusted WPT test as of:

bb3f032
2025-07-03 12:45:31 +01:00
Sam Atkins
994bbcaa75 LibWeb/Painting: Don't paint invisible paintables
This check technically isn't necessary in
`SVGForeignObjectPaintable::paint()` because
`PaintableWithLines::paint(context, phase);` does the check already, but
I've added it there anyway to save some debugging time if someone does
add more code there. :^)
2025-07-03 12:39:05 +02:00
Tim Ledbetter
6ee91c4189 LibWeb: Use correct previous word location when moving selection offset
Previously, this incorrect offset could cause a crash when moving the
selection to the previous word.
2025-07-03 10:28:38 +01:00
Jelle Raaijmakers
1eb581815a Tests: Unskip selection-over-multiple-code-units.html test
The flake was reproducible by running the entire LibWeb test suite over
and over again with sanitizers enabled. By making the test async and run
at window `load` time instead of document `DOMContentLoaded` time, I've
not been able to reproduce the issue locally.

Ideally I was able to find the underlying cause for this bug, but for
now I'd rather run this regression test.
2025-07-03 10:27:39 +01:00
Tim Ledbetter
923deb0c01 LibWeb: Parse border-image shorthand property 2025-07-03 10:19:44 +01:00
Tim Ledbetter
c0390f759c LibWeb: Parse the border-image-repeat property 2025-07-03 10:19:44 +01:00
Tim Ledbetter
98e63e3dd5 LibWeb: Parse the border-image-outset property 2025-07-03 10:19:44 +01:00
Tim Ledbetter
245905b833 LibWeb: Parse the border-image-slice property 2025-07-03 10:19:44 +01:00
Tim Ledbetter
70c2621634 LibWeb: Parse the border-image-source property 2025-07-03 10:19:44 +01:00
Chase Knowlden
ac22e71184 LibWeb: Make offset for HTML style and script elements one after 2025-07-03 10:11:11 +01:00
Sam Atkins
ffd5503dcb LibWeb/DOM: Serialize pseudo-elements in the correct order
Make Element responsible for serializing all its children, so it can put
them in order.
2025-07-03 09:56:56 +01:00
Sam Atkins
4df472988c LibWeb/DOM: Only list pseudo-elements that actually exist
This stops `::before` and `::after` nodes showing up for every single
element in the inspector tree. Unfortunately there's no way for us to
detect that one of these doesn't exist in layout but has *some* style
specified for it, but that seems like a rare use case.
2025-07-03 09:56:56 +01:00
Sam Atkins
140a099fe6 LibDevTools: Remove use-after-move in actor_for_node() 2025-07-03 09:56:56 +01:00