1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00
Commit graph

68984 commits

Author SHA1 Message Date
Andreas Kling
183c847c80 LibJS: Cache PutById to setters in the prototype chain
This is *extremely* common on the web, but barely shows up at all in
JavaScript benchmarks.

A typical example is setting Element.innerHTML on a HTMLDivElement.
HTMLDivElement doesn't have innerHTML, so it has to travel up the
prototype chain until it finds it.

Before this change, we didn't cache this at all, so we had to travel
the prototype chain every time a setter like this was used.

We now use the same mechanism we already had for GetBydId and cache
PutById setter accesses in the prototype chain as well.

1.74x speedup on MicroBench/setter-in-prototype-chain.js
2025-05-05 15:21:43 +02:00
Jelle Raaijmakers
71665fa504 LibWeb: Scale font size by 1.15 for line-height: normal
Browsers such as Chrome and Firefox apply an arbitrary scale to the
current font size if `normal` is used for `line-height`. Firefox uses
1.2 while Chrome uses 1.15. Let's go with the latter for now, it's
relatively easy to change if we ever want to go back on that decision.

This also requires updating the expectations for a lot of layout tests.
The upside of this is that it's a bit easier to compare our layout
results to other browsers', especially Chrome.
2025-05-05 13:15:56 +02:00
Timothy Flynn
01791c5a52 LibJS: Mark sync module evaluation promise as handled
This is a normative change in the ECMA-262 spec. See:
0fb1859

As noted in the PR for this change, this is not actually testable via
either test262 or WPT.
2025-05-05 17:50:18 +12:00
Psychpsyo
7c36a82129 LibWeb: Improve parsing for the CSS contain property
This makes us actually respect the grammar and nets us a couple
extra WPT passes in the parsing section.
2025-05-04 22:24:26 +01:00
Timothy Flynn
1c075d6039 LibWeb: Remove Web::Infra ASCII case conversion methods
We have more optimized versions of these methods in AK.
2025-05-04 15:59:17 +02:00
Psychpsyo
d048ee3155 Meta: Add doctypes to all svg layout tests 2025-05-04 11:23:52 +02:00
Psychpsyo
3fd13485ab Meta: Add doctypes to all table layout tests 2025-05-04 11:23:17 +02:00
Andreas Kling
bf1b754e91 LibJS: Optimize reading known-to-be-initialized var bindings
`var` bindings are never in the temporal dead zone (TDZ), and so we
know accessing them will not throw.

We now take advantage of this by having a specialized environment
binding value getter that doesn't check for exceptional cases.

1.08x speedup on JetStream.
2025-05-04 02:31:18 +02:00
Andreas Kling
ad7c1e147f LibJS: Add SetGlobal bytecode instruction for cached global writes
Before this change, setting a global would end up as SetLexicalBinding.
That instruction always failed to cache the access if the global was a
property of the global object.

1.14x speedup on Octane/earley-boyer.js
2.04x speedup on MicroBench/for-of.js

Note that MicroBench/for-of.js was more of a "set global" benchmark
before this. After this change, it's actually a for..of benchmark. :^)
2025-05-04 01:58:57 +02:00
Sam Atkins
de6df6f403 LibWeb/CSS: Parse and use CSS URL request modifiers 2025-05-03 23:22:40 +01:00
Sam Atkins
09b508d8e8 Tests: Import some URL-related WPT tests 2025-05-03 23:22:40 +01:00
Sam Atkins
a1fb34d7f2 LibWeb/CSS: Alphabetize Enums.json 2025-05-03 23:22:40 +01:00
Andreas Kling
edb5547e37 LibJS: Don't incrementally delete PropertyNameIterator while iterating
We were spending a lot of time removing each property name from the
iterator's underlying HashMap while iterating over it. This wasn't
actually necessary, so let's stop doing it and instead just iterate
over the property names with a stored HashTable iterator.

1.10x speedup on MicroBench/for-in-indexed-properties.js
2025-05-03 22:00:51 +02:00
Andreas Kling
c8edd37741 Meta: Add Shannon Booth to maintainers list :^) 2025-05-03 20:58:23 +02:00
Andreas Kling
570d1e8811 LibJS: Use PrimitiveString more instead of Utf16String in String code
This avoids a whole lot of unnecessary roundtrips from UTF8 <=> UTF16.
2025-05-03 20:01:20 +02:00
Andreas Kling
98fef16972 LibJS: Use PrimitiveString more instead of Utf16String in RegExp code
PrimitiveString has an internal UTF-16 string cache anyway, and so this
actually avoids repeatedly converting between UTF-8 and UTF-16.
2025-05-03 20:01:20 +02:00
Jess
897c83cbcb Docs: Link the external Nix devshell 2025-05-03 16:40:50 +01:00
Andreas Kling
7c26354563 LibJS: Avoid Value->PropertyKey->Value roundtrip in for..in iteration
Before this change, we would call [[OwnPropertyKeys]] on the target
objects, then convert the returned keys from Value into PropertyKey.
Then, when actually iterating, we'd convert them back into Value again.
This was particularly costly for numeric property keys, since we had
to go through string-from-number construction.

Now, we simply keep the original values returned by [[OwnPropertyKeys]]
around and use them for the enumeration.

1.09x speedup on MicroBench/for-in-indexed-properties.js
1.01x speedup on MicroBench/for-in-named-properties.js
2025-05-03 17:33:54 +02:00
Andreas Kling
11ece7de10 LibGC: Add GC::RootHashMap<...> template container
This is a GC-aware wrapper around AK::HashMap. Entry values are treated
as GC roots, much like the GC::RootVector we already had.

We also provide GC::OrderedRootHashMap as a convenience.
2025-05-03 17:33:54 +02:00
Andreas Kling
a453da2906 AK: Allow specifying HashSetExistingEntryBehavior in HashMap::set() 2025-05-03 17:33:54 +02:00
Timothy Flynn
8a80ff7b3b AK+LibJS: Use simdutf for all base64 operations
We were previously unable to use simdutf for base64 decoding operations
other than "loose". Upstream has added support for the "strict" and
"stop-before-partial" operations, so let's make use of them!
2025-05-03 11:21:10 -04:00
Timothy Flynn
e04545979f Meta: Update simdutf to version 7.0.0 2025-05-03 11:21:10 -04:00
Timothy Flynn
6b6dd9c998 Meta: Update vcpkg baseline 2025-05-03 11:21:10 -04:00
Shannon Booth
e476d21ed0 LibJS: Add and use PrimitiveString::length_in_utf16_code_units
I was investigating an optimization in this area, and while it
didn't seem to have a noticable improvement, it still seems
useful to apply this change.
2025-05-03 16:18:47 +02:00
Sam Atkins
560317b3d0 LibWeb/CSS: Update spec comment in calc() simplification algorithm
This was corrected in 8bcf3ada9e
2025-05-03 14:54:33 +01:00
Sam Atkins
1cb1526178 LibWeb/CSS: Remove document-URL hack from create_a_style_sheet()
We no longer need this, because we don't complete URLs during parsing,
and the location is set elsewhere when needed.
2025-05-03 12:01:43 +01:00
Sam Atkins
bc1d323ba0 LibWeb/CSS: Remove URL parameter to the CSS Parser
We no longer complete any URLs during parsing.
2025-05-03 12:01:43 +01:00
Sam Atkins
9e2e796f2d LibWeb/CSS: Use CSS::URL for font-fetching
ParsedFontFace and FontLoader now both keep track of which
CSSStyleSheet (if any) was the source of the font-face, so the URLs can
be completed correctly.
2025-05-03 12:01:43 +01:00
Sam Atkins
14fb567a0f LibWeb/CSS: Stop overwriting style sheet location after construction 2025-05-03 12:01:43 +01:00
Sam Atkins
981ede900a LibWeb/DOM: Create style element style sheets with document's base URL
This is the simplest fix I could find that resolves a buggy interaction
between this and the CSS fetch algorithms, which also doesn't regress
anything. (As far as I can tell.)
2025-05-03 12:01:43 +01:00
Sam Atkins
7a4854732a LibWeb/CSS: Make CSS::URL formattable 2025-05-03 12:01:43 +01:00
Sam Atkins
efad6e96aa LibWeb/CSS: Set CSSFontFaceDescriptors' parent rule 2025-05-03 12:01:43 +01:00
Sam Atkins
ffc01626f7 LibWeb/CSS: Load fonts using fetch
Convert FontLoader to use fetch_a_style_resource(). ResourceLoader used
to keep its downloaded data around for us, but fetch doesn't, so we use
Gfx::Typeface::try_load_from_temporary_memory() so that the font has a
permanent copy of that data.
2025-05-03 12:01:43 +01:00
Sam Atkins
1967d5bc75 LibGfx: Add a helper for constructing a TTF font from temporary bytes
Once we switch from ResourceLoader to Fetch, nobody is going to be
holding onto the downloaded data, so we need to make a permanent copy
of it.
2025-05-03 12:01:43 +01:00
Sam Atkins
f76f8dcce1 LibWeb/CSS: Return the FetchController from fetch_a_style_resource() 2025-05-03 12:01:43 +01:00
Sam Atkins
6b762331df LibGfx: Rename WOFF[2]::try_load_from_externally_owned_memory()
Typeface::try_load_from_externally_owned_memory() relies on that
external owner keeping the memory around. However, neither WOFF nor
WOFF2 do so - they both create separate ByteBuffers to hold the TTF
data. So, rename them to make it clearer that they don't have any
requirements on the byte owner.
2025-05-03 12:01:43 +01:00
Tim Ledbetter
23009779e1 LibWeb: Interpolate font-style values correctly
These are interpolated by computed value, except a value of `normal` is
treated as `oblique 0deg`.
2025-05-03 12:05:22 +02:00
Tim Ledbetter
c0f9b11070 LibWeb: Parse oblique font-style with an angle value 2025-05-03 12:05:22 +02:00
Andreas Kling
e537e426c1 LibJS: Teach for..in iterator to use IteratorNextUnpack optimization
Even though this code was already optimized to re-use a single result
object, returning { value, done } directly in output parameters still
provides a substantial speedup.

1.21x speedup on MicroBench/for-in-indexed-properties.js
2025-05-03 11:43:57 +02:00
Andreas Kling
0ef6444824 LibJS: Replace some use of ByteString with String
1.19x speedup on MicroBench/for-in-indexed-properties.js
2025-05-03 08:08:04 +02:00
Andreas Kling
2ef2e75cdc LibJS: Reduce HashTable rehashing in get_object_property_iterator()
Apply a little ensure_capacity() to avoid excessive rehashing of the
property key table when enumerating a large number of properties.

1.23x speedup on MicroBench/for-in-indexed-properties.js
2025-05-03 08:08:04 +02:00
Timothy Flynn
ea77092100 LibWeb: Begin implementing SharedWorker
Shared workers are essentially just workers that may be accessed from
scripts within the same origin. There are plenty of FIXMEs here (mostly
building on existing worker FIXMEs that are already in place), but this
lets us run the shared worker variants of WPT tests.
2025-05-02 17:48:02 -04:00
Timothy Flynn
469d5ccc4b LibWeb: Add FIXME about Worker's constructor's scriptURL parameter
TrustedScriptURL is its own interface that we haven't implemented yet.
2025-05-02 17:48:02 -04:00
Timothy Flynn
56f047119c LibWeb: Alphabetically sort LibWeb sources
I sorted this list when added shared worker sources, and this is the
fallout.
2025-05-02 17:48:02 -04:00
Timothy Flynn
912009f6b3 LibWeb: Implement navigator.clipboard.read 2025-05-02 17:46:16 -04:00
Timothy Flynn
a4e9a27343 LibWeb: Implement navigator.clipboard.write 2025-05-02 17:46:16 -04:00
Timothy Flynn
a1985e57e7 LibWeb: Implement navigator.clipboard.readText 2025-05-02 17:46:16 -04:00
Timothy Flynn
7f8f72556a headless-browser: Implement a stubbed clipboard API
We currently rely on UI-specific APIs to interact with the system
clipboard from AppKit and Qt. We do not have access to these from
headless-browser.

We should ultimately implement these APIs without relying on the UI as
a middle-man. For now, store a clipboard item so that we may exercise
the clipboard WPT tests.
2025-05-02 17:46:16 -04:00
Timothy Flynn
61c0f67c8c LibWeb+LibWebVew+WebContent+UI: Add IPC to retrieve the system clipboard
We currently have a single IPC to set clipboard data. We will also need
an IPC to retrieve that data from the UI. This defines system clipboard
data in LibWeb to handle this transfer, and adds the IPC to provide it.
2025-05-02 17:46:16 -04:00
Timothy Flynn
5fb5066e89 LibWeb: Initialize plain boolean in ClipboardItem::Representation 2025-05-02 17:46:16 -04:00