Commit graph

8810 commits

Author SHA1 Message Date
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
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
Andreas Kling
7477002e46 LibJS: Keep parsed function parameters in a shared data structure
Instead of making a copy of the Vector<FunctionParameter> from the AST
every time we instantiate an ECMAScriptFunctionObject, we now keep the
parameters in a ref-counted FunctionParameters object.

This reduces memory usage, and also allows us to cache the bytecode
executables for default parameter expressions without recompiling them
for every instantiation. :^)
2025-03-27 15:00:43 +00:00
Aliaksandr Kalenik
634f0c2469 LibWeb: Don't crash if ElementByIdMap already has an element
Let's simply reinsert the element respecting it's new position in the
DOM tree, instead of crashing.

Fixes regression in WPT tests caused by introducion of cache for
getElementById().
2025-03-27 14:44:51 +00:00
Timothy Flynn
9eca5febd1 LibDevTools+LibWebView+WebContent: Report exceptions to DevTools 2025-03-27 14:14:02 +00:00
Timothy Flynn
5d0fbc85e5 LibWebView+WebContent: Remove "styled" JS console IPC hooks
This was used by the built-in Inspector to send HTML-ified JS console
messages to the browser. It is no longer used.
2025-03-27 14:14:02 +00:00
Timothy Flynn
a5f3a60ed5 LibWeb: Report unhandled exceptions to the developer console
This was a spec bug which led to us reporting handled (rather than
unhandled) exceptions.

See: https://github.com/whatwg/html/commit/2d7f50a
2025-03-27 14:14:02 +00:00
Jelle Raaijmakers
683d6b77dd LibWeb: Apply vertical clearance to next line after <br> with clear:
We were introducing a line break and applying vertical clearance to the
inline formatting context, but that vertical clearance only applied to
new floating boxes. We should move the current block offset to the
vertical clearance to make sure the next line box starts beyond the
cleared floats.

There was a layout test for `<br>` with `clear: ..` set, but that test
did not actually do anything - removing the `clear` property would
result in the same layout. Replace that test with something that
actually tests float clearing.

Relates to #4058.
2025-03-27 13:57:59 +00:00
Lucien Fiorini
6b6e13e28c LibJS: Avoid emptying the return value register in try/finally
This works because at the end of the finally chunk, a
ContinuePendingUnwind is generated which copies the saved return value
register into the return value register. In cases where
ContinuePendingUnwind is not generated such as when there is a break
statement in the finally block, the fonction will return undefined which
is consistent with V8 and SpiderMonkey.
2025-03-27 12:18:30 +00:00
Sam Atkins
2b67cb5f98 LibWeb/CSS: Move "serialize a CSS declaration" to Serialize.{h,cpp}
We need this in other places, so make it available for reuse. Also,
update step 4 which now only appends `value` if it contains
non-whitespace.
2025-03-27 11:53:09 +00:00
Sam Atkins
a2c89f585f LibWeb/CSS: Give all style values a visit_edges() method
Having this hidden away in ImageStyleValue meant that
CSSStyleProperties (and anyone else who holds style values) had to know
exactly which types need visiting. This is a footgun waiting to happen,
so make this a virtual method on CSSStyleValue instead.
2025-03-27 11:53:09 +00:00
Jelle Raaijmakers
c4bb74f40b LibWeb: Fix and improve float positioning behavior
Our recent change to get rid of the "move 1px at a time" algorithm in
the float positioning logic introduced the issue that potentially
intersecting float boxes were not evaluated in order anymore. This could
result in float boxes being pushed down further than strictly necessary.

By finding the highest point we can move the floating box to and
repeating the process until we're no longer intersecting any floating
box, we also solve some edge cases like intersecting with very long
floating boxes whose edges lay outside the current box' edges.

This is by no means the most efficient solution, but it is more correct
than what we had until now.

Fixes #4110.
2025-03-27 10:56:13 +00:00
SINF-KEN
32dbd6ab8f UI: Fix new error page 2025-03-27 08:34:38 +00:00
Jelle Raaijmakers
f340f8682b LibWeb: Do not clear float sides for floating boxes with clear: ..
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
We used to always clear the side data after encountering a box with
`clear: ..`, but this is not the right thing to do if that same box also
has `float: ..` set. For example, with `clear: right` and `float: left`
it might be that the next box still wants to clear the right side, and
since the previous box is floating it did not push the next box down far
enough to justify clearing the side data at that point.

This changes the logic to only clear the float side if the clearing box
itself is not floating. We also no longer clear the opposite side after
placing a floating box; that doesn't seem to be necessary anymore.

Fixes #4102.
2025-03-27 00:56:56 +00:00
Aliaksandr Kalenik
e655b77393 LibWeb: Fix scroll offset application for SVG root box
Now we use `before_paint()` and `after_paint()` calls for SVG root box
to make sure that both clip and scroll are applied.

Fixes painting of SVG arrows on www.ubereats.com
2025-03-26 20:12:45 +00:00
SINF-KEN
1a34676046 UI: Style the crash page and update error page image
- Modified the error page
- changed the error/crash page

Co-authored-by: notnotnescap <97590612+nescapp@users.noreply.github.com>
2025-03-26 19:39:24 +00:00
Jelle Raaijmakers
002e79a658 LibWeb: Exclude trailing whitespace from line width when placing floats
When generating line boxes, we place floats simultaneously with the
other items on the same line. The CSS text spec requires us to trim the
whitespace at the end of each line, but we only did so after laying out
all the line boxes.

This changes the way we calculate the current line box width for floats
by subtracting the amount of pixels that the current trailing whitespace
is using.

Fixes #4050.
2025-03-26 19:35:38 +00:00
Aliaksandr Kalenik
7cae4fadbc LibWeb: Cache "has size containment" flag in Layout::Box
Allows us to avoid DOM node lookup whenever we need to query natural
size of a box during layout.

Makes 3-4% of `Box::preferred_aspect_ratio()` go away from profiles on
www.nyan.cat
2025-03-26 17:52:02 +00:00
Aliaksandr Kalenik
85e28a29f0 LibWeb: Replace 1px iteration in y_for_float_to_be_inserted_here()
...with a loop through already inserted floating boxes that probes
potential insertion points on their edges.

Makes www.nyan.cat go faster.
2025-03-26 13:51:11 +00:00
Aliaksandr Kalenik
d8ff71fbb5 LibWeb: Delete parent state pointer in LayoutState
It's safe to remove this pointer because intrinsic layout should never
look up a box's state beyond its containing block.

This change affects the expectations of two layout tests, but both
already differ slightly from other browsers, and the difference between
expectations is less than 5px.
2025-03-26 12:08:09 +00:00
Sam Atkins
2d3dea0770 LibWeb/CSS: Update quirks-mode styling for form elements
The current HTML spec uses margin-block-end instead of margin-bottom.
2025-03-26 09:47:45 +00:00
Sam Atkins
b2873d7ed6 LibWeb/CSS: Add new list-style-position quirk
Corresponds to d79381d822

In quirks mode, a `<li>` with no parent list element now has
`list-style-position: inside`.
2025-03-26 09:47:45 +00:00
Aliaksandr Kalenik
8cae20af1b LibWeb: Maintain a mapping for fast lookup in getElementById()
With this change we maintain a data structure that maps ids to
corresponding elements. This allows us to avoid tree traversal in
getElementById() in all cases except ones when lookup happens for
unconnected elements.
2025-03-26 08:36:25 +00:00
Aliaksandr Kalenik
275985ff3d LibWeb: Ignore non-box element while collecting abspos nodes for layout
All abspos boxes are expected to be blockified, so we are certain that
we can ignore non-box elements when collecting abspos nodes for layout.

Fixes a crash caused by an attempt to cast a BreakNode to a Box while
performing abspos layout.
2025-03-26 00:17:53 +00:00
Andreas Kling
d856858015 LibWeb: Cache and reuse inline style for text input shadow trees
Instead of reparsing the style attributes every time we instantiate
the internal shadow tree for a text input element, we now parse them
once (in the internal CSS realm) and reuse them for all elements.

Roughly a ~10% speedup on Speedometer 2.1 :^)
2025-03-25 23:57:00 +00:00
Andreas Kling
ba030f0363 LibWeb: Add an engine-internal CSS realm for internal style parsing
This is used for default UA style right now, and we'll expand its use in
the near future.

Note that this required teaching the CSS parser to handle url()
functions when there's no document URL to resolve them against. If we
don't handle that, namespace rules in UA style don't parse correctly.
2025-03-25 23:57:00 +00:00
Andreas Kling
c12f8b80dc LibJS: Add fast_is<T> helpers for all the primitive wrapper objects
The JS runtime is full of checks for is<NumberObject> and friends.
They were showing up in a Speedometer profile as ~1% spent in
dynamic_cast, and this basically chops that down to nothing.
2025-03-25 23:57:00 +00:00
Andreas Kling
3cc5b1a6a5 LibJS: Do a bit less stuff in PropertyKey::try_coerce_into_number()
The many out-of-line function calls here stood out in a profile.
2025-03-25 23:57:00 +00:00
Jelle Raaijmakers
6a3c3ee291 LibWeb: Coerce NaNs to 0 when escaping top-level calculations 2025-03-25 19:53:36 +00:00
Jelle Raaijmakers
545d151948 LibWeb: Make transform: scale(calc(..)) work
The `transform` property supports transform functions that sometimes
need their `calc(percentage)` values to be converted to a number instead
of a length. Currently this only applies to the `scale*` family of
functions, which are marked as such in `TransformFunctions.json`.

We were not consistently applying the `NumberPercentage` type to these
functions though, and in addition, any `NumberPercentage` value would
not consider calculated values.
2025-03-25 19:53:36 +00:00
Andreas Kling
202cbe7df6 LibJS: Constant-fold unary expressions
!0 and !1 are very common patterns in minified JavaScript, and we should
figure out that they're constants. :^)
2025-03-25 19:14:12 +00:00
Luke Wilde
de892abdba LibWeb: Don't apply DPR or zoom level to screen.{width,height}
Safari and WebKit don't apply these, while Firefox only applies the
zoom level. This fixes https://x.com/ showing the tablet view.
2025-03-25 17:34:41 +00:00
Psychpsyo (Cameron)
c7926b2212 LibWeb: Change while to for loop 2025-03-25 15:50:45 +00:00
stelar7
1844e10cd3 LibWeb/IDB: Correctly check if transaction was aborted
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
The associated databases upgrade transaction could be
null at the time we try to access it here.
2025-03-25 10:50:03 +00:00
stelar7
e8b7447c36 LibWeb/IDB: Abort transaction in database upgrade if needed 2025-03-25 10:50:03 +00:00
stelar7
923927564d LibWeb/IDB: Set the source of a IDBRequest 2025-03-25 10:50:03 +00:00
Aliaksandr Kalenik
090ac66af1 LibWeb: Repeat grid track sizing with minmax where both are not definite
...should be treated as invalid value.
2025-03-25 09:53:04 +00:00