Commit graph

68640 commits

Author SHA1 Message Date
Andreas Kling
2462a6b0fa LibJS: Use Value::to_byte_string() in fewer places 2025-03-28 12:31:40 -04:00
Andreas Kling
c71772126f LibJS: Remove ByteString internals from PrimitiveString
PrimitiveString is now internally either UTF-8, UTF-16, or both.
We no longer convert them to/from ByteString anywhere, nor does VM have
a ByteString cache.
2025-03-28 12:31:40 -04:00
Timothy Flynn
f05b0bfd5f LibWeb+LibWebView+WebContent: Convert about:settings to a WebUI
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-03-28 07:31:10 -04:00
Timothy Flynn
c75e40180c LibWeb+LibWebView+WebContent: Convert about:processes to a WebUI 2025-03-28 07:31:10 -04:00
Timothy Flynn
41aeb9e63a LibWeb+LibWebView+WebContent: Introduce a WebUI framework
When we build internal pages (e.g. about:settings), there is currently
quite a lot of boilerplate needed to communicate between the browser and
the page. This includes creating IDL for the page and the IPC for every
message sent between the processes.

These internal pages are also special in that they have privileged
access to and control over the browser process.

The framework introduced here serves to ease the setup of new internal
pages and to reduce the access that WebContent processes have to the
browser process. WebUI pages can send requests to the browser process
via a `ladybird.sendMessage` API. Responses from the browser are passed
through a WebUIMessage event. So, for example, an internal page may:

    ladybird.sendMessage("getDataFor", { id: 123 });

    document.addEventListener("WebUIMessage", event => {
        if (event.name === "gotData") {
            console.assert(event.data.id === 123);
        }
    });

To handle these messages, we set up a new IPC connection between the
browser and WebContent processes. This connection is torn down when
the user navigates away from the internal page.
2025-03-28 07:31:10 -04:00
Lucien Fiorini
f72d87931f LibJS: Reduce Mov instructions by using preferred destinations 2025-03-28 11:21:12 +00:00
Lucien Fiorini
5707076b9e LibJS: Optimize away Mov instructions when the source is the destination 2025-03-28 11:21:12 +00:00
Sam Atkins
192cae17ee LibWeb/DOM: Update step 4 of load_document()
Corresponds to 2ab779b8e8

We don't implement most of what that touches, so the only actual change
is a couple of words added here.
2025-03-28 11:18:57 +00:00
Glenn Skrzypczak
a73cd88f0c LibWeb/CSS: Implement 'background-blend-mode'
This implements the 'background-blend-mode' CSS property.
2025-03-28 09:41:06 +00:00
Glenn Skrzypczak
1898643ba4 LibWeb/Painting: Add SaveLayer command
This adds a command for saving the current layer of the canvas.
This is useful for painting content onto a blank background in
isolation and later compositing it onto the canvas.
2025-03-28 09:41:06 +00:00
Glenn Skrzypczak
3e56e9e65d Tests: Import URLs surrounded by single quotes
This updates the regex for CSS URLs in the WPT import script to
correctly match URLs surrounded by single quotes.
2025-03-28 09:41:06 +00:00
Sam Atkins
09b8f73e11 LibWeb/CSS: Implement UnicodeRangeStyleValue
This is preparation for storing at-rule descriptors as style values.
2025-03-28 09:15:02 +00:00
Sam Atkins
e0a03147c6 LibGfx: Make UnicodeRange comparable 2025-03-28 09:15:02 +00:00
Sam Atkins
ef3a2bf907 LibWeb/CSS: Move functions for detecting var()/attr() into Token types
This makes them accessible outside of PropertyParsing.cpp (which will be
useful if/when descriptors can include them). I've also renamed them to
use the correct term: "arbitrary substitution function".
2025-03-28 09:15:02 +00:00
Aliaksandr Kalenik
732a5cdc12 LibWeb: Respect min/max-content available size in auto width calculation
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
...for block level boxes. Otherwise we end up resolving auto width as
zero during intrinsic layout, which leads to incorrectly applied
max-width constraint.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/4123
2025-03-28 02:13:41 +00:00
Jelle Raaijmakers
2794ed0c73 CI: Do not cancel in-progress JS artifact builds
It might be useful to have these artifacts, even for older commits. As
an added bonus, this causes the JS benchmarks to run as well giving us
more datapoints.
2025-03-27 23:58:21 +00:00
Luke Wilde
c7d25301d3 LibWeb: Implement the LegacyUnforgeable attribute
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This fixes the frame-ancestors WPT tests from crashing when an iframe
is blocked from loading. This is because it would get an undefined
location.href from the cross-origin iframe, which causes a crash as it
expects it to be there.
2025-03-27 23:50:35 +00:00
Tim Ledbetter
7853b757c2 LibWeb: Lower the baseline of text with veritcal-align: sub
This lowers the baseline of the given text by one fifth of the parent's
font size.
2025-03-27 23:30:57 +00:00
Tim Ledbetter
6fbbbc9b81 LibWeb: Raise the baseline of text with veritcal-align: super
This raises the baseline of the given text by one third of the parent's
font size.
2025-03-27 23:30:57 +00:00
Aliaksandr Kalenik
fc45121b70 LibWeb: Size box as normal if it has aspect ratio but auto sizes
Otherwise we apply `calculate_stretch_fit_width()` instead of
calculating width based on the content inside the box, like other
browsers do.
2025-03-27 23:13:57 +00:00
Jelle Raaijmakers
006f276cab LibWeb: Copy IDBDatabase object stores through Vector(ReadonlySpan)
Prevents a crash because `ReadonlySpan.copy_to()` was trying to copy to
an empty vector.

Fixes #4127.
2025-03-27 23:13:32 +00:00
Andreas Kling
f5dd776b11 LibJS: Remove some irrelevant hash lookups in ESFO constructor
If we don't have parameter expressions, we don't need to collect
metadata about whether instantiated var names collide with parameter
names or function names, as these flags are only used in the parameter
code path.
2025-03-27 23:12:04 +00:00
Andreas Kling
c037bda455 LibJS: Use a premade shape for normal function objects
This avoids going through all the shape transitions when setting up the
most common form of ESFO.

This is extremely hot on Uber Eats, and this provides some relief.
2025-03-27 23:12:04 +00:00
Oliver Medhurst
60fd406903 LibWeb: Fix inside list style overriding content offset
Previously, if a horizontal margin was set on a list-item and
it was list-style-position: inside, it would effectively remove
that margin.
2025-03-27 23:10:09 +00:00
Oliver Medhurst
b272bb3373 LibWeb: Fix ::marker placement in tree
Fixes ::marker (pseudo-element) placement in the tree for list-items.

Previously:
- ::before
- content
- ::marker
- ::after

Now (matches Firefox, afaik per-spec):
- ::marker
- ::before
- content
- ::after
2025-03-27 23:10:09 +00:00
Manuel Zahariev
bc8f8676cc LibWebView: Additional unit tests for sanitized_url
Covers:
- single word search
- public domain suffixes, registered TLDs
- localhost
- url including words or search for url and words
2025-03-27 18:30:08 -04:00
Manuel Zahariev
9e7436a096 LibWebView: Better integration of sanitize_url with search
With search enabled:
- For a single word that does not look like a url: search (a
reported bug).
- If no suffix or a suffix that is not recognized: search.

In general:
- Respect the user's choice if they specified a scheme.
- Respect localhost and registered TLDs.
- As before, add file:// to filesystem files that exist.
2025-03-27 18:30:08 -04:00
Andreas Kling
5ea45da15f LibJS: Store NewObject result directly in preferred dst if possible
This avoids a Mov after every object literal.
2025-03-27 19:50:13 +00:00
Andreas Kling
900f209b34 LibJS: Make Optional<Operand> use less space
Shrink these down from 12 bytes to 8 bytes, which helps make many
bytecode instructions smaller.
2025-03-27 19:50:13 +00:00
Andreas Kling
a29d820f87 LibJS: Make Optional<IdentifierTableIndex> use less space
We can use the index's invalid state to signal an empty optional.
This makes Optional<IdentifierTableIndex> 4 bytes instead of 8,
shrinking every bytecode instruction that uses these.
2025-03-27 19:50:13 +00:00
Andreas Kling
904beef6d2 LibJS: Put newly instantiated functions into locals more efficiently
- Don't allocate a separate register, store directly into the local.
- Mark the local as initialized to avoid emitting TDZ checks.
2025-03-27 19:50:13 +00:00
Andreas Kling
6c70dc5f09 LibJS: Create FunctionParameters earlier in the parser
This avoids making multiple copies of the Vector<FunctionParameter> in
the parser.
2025-03-27 19:50:13 +00:00
Tim Ledbetter
d67a95c37e Tests: Remove print statement from crash test
Print statements aren't necessary in crash tests and will cause a
Javascript error when used.
2025-03-27 19:30:41 +00:00
Luke Wilde
42bc83a9d0 LibWebView+WebWorker: Attach an image decoder to worker instances
The createImageBitmap API can programmatically decode arbitrary images
from JS, and it's exposed in Workers, so they need an ImageDecoder
instance.
2025-03-27 17:47:27 +00:00
Jelle Raaijmakers
15103d172c LibWeb: Apply remaining vertical float clearance to next block level box
Whenever we generate line boxes, we might end up with a residual
vertical float clearance by way of having a `<br>` with `clear: ..` set.
Set the Y offset of the next block level box to place by this vertical
clearance.

Relates to #4058.
2025-03-27 17:21:56 +00:00
Ali Mohammad Pur
a83145c751 AK: Don't assert things about active union members in StringBase
This involves yeeting the 'invalid' union member as it was not really
checked against properly anyway; now the 'invalid' state is simply
StringData*{nullptr}, which was assumed to not exist previously.

Note that this is still accessing inactive union members, but is
promising to the compiler that they're fine where they are (the provided
debug macro AK_STRINGBASE_VERIFY_LAUNDER_DEBUG makes the
would-be-UB-if-not-for-launder ops verify that the operation is correct)

Should fix the GCC build.
2025-03-27 15:58:57 +00:00
Ali Mohammad Pur
c39eddaef8 Revert "AK: Don't try to free(UINTPTR_MAX) in StringData::delete()"
This reverts commit 693fe76d1c.
2025-03-27 15:58:57 +00:00
stelar7
209d05fcb4 LibWeb/IDB: Implement IDBDatabase::deleteObjectStore 2025-03-27 15:47:16 +00:00
stelar7
b11276e5c4 LibWeb/IDB: Implement IDBDatabase::objectStoreNames 2025-03-27 15:47:16 +00:00
stelar7
1ad9b3ee6e LibWeb/IDB: Implement create_a_sorted_name_list 2025-03-27 15:47:16 +00:00
stelar7
3879391fa6 LibWeb/IDB: Implement IDBObjectStore::name 2025-03-27 15:47:16 +00:00
stelar7
2e02b62126 LibWeb/IDB: Implement IDBObjectStore::autoIncrement 2025-03-27 15:47:16 +00:00
stelar7
b0453e044d LibWeb/IDB: Implement IDBObjectStore::transaction 2025-03-27 15:47:16 +00:00
stelar7
594ba28c35 LibWeb/IDB: Implement IDBObjectStore::keyPath 2025-03-27 15:47:16 +00:00
stelar7
1057c88fdd LibWeb/IDB: Implement IDBDatabase::createObjectStore 2025-03-27 15:47:16 +00:00
stelar7
3c5578cc87 LibWeb/IDB: Add internal ObjectStore type 2025-03-27 15:47:16 +00:00
stelar7
0979a154fd LibWeb/IDB: Implement is_valid_key_path 2025-03-27 15:47:16 +00:00
stelar7
c276c212a0 LibWeb/IDB: Implement KeyGenerator 2025-03-27 15:47:16 +00:00
Andreas Kling
8af5f25dd0 LibJS: Use a premade shape for normal function object prototypes
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This avoids one shape allocation per function instantiation.
2025-03-27 15:00:43 +00:00
Andreas Kling
dba1798de7 LibJS: Make StringOrSymbol::as_string() return a const reference
No need to copy the FlyString here, we can avoid the ref count churn.
2025-03-27 15:00:43 +00:00