Commit graph

34498 commits

Author SHA1 Message Date
Timur Sultanov
93b6334966 LibWeb: Schedule Microtasks on Microtask queue 2024-07-25 16:58:12 +02:00
Tim Ledbetter
3802d9ccc4 LibWeb: Calculate length for all CharacterData type nodes correctly
We now ensure that `Node::is_character_data()` returns true for all
nodes of type character data.

Previously, calling `Node::length()` on `CDataSection` or
`ProcessingInstruction` nodes would return an incorrect value.
2024-07-25 15:57:21 +01:00
Tim Ledbetter
f8b1e96e2b LibWeb: Assert that cloned node is not null before returning
This makes potential issues easier to track down.
2024-07-25 15:57:21 +01:00
Tim Ledbetter
72ed62a560 LibWeb: Don't crash when cloning a CDATASection node 2024-07-25 15:57:21 +01:00
paaspaas00
cdfc7a92f7 LibWeb: Fix typo "rtr" -> "rtl" 2024-07-25 14:51:26 +01:00
Andreas Kling
007c292af3 LibWeb: Execute the correct script in XMLDocumentBuilder::element_end()
We were mistakenly executing the current node's script instead of the
document's pending parsing-blocking script.

This caused ~1000 WPT tests to time out, since we never ended up firing
a load event for XHTML pages that load multiple external scripts.
2024-07-25 15:05:28 +02:00
Andreas Kling
b011d47b86 LibCore: Guess MIME type of .xhtml files to be application/xhtml+xml 2024-07-25 15:05:28 +02:00
Aliaksandr Kalenik
61da1236e7 LibWeb: Add a very basic glyph texture cache in Skia painter
This prevents repeated uploading of the same glyph textures into
GPU-memory.
2024-07-25 14:33:33 +02:00
Aliaksandr Kalenik
67d68eac64 LibWeb: Save "background-clip: text" mask as a nested display list
Before this change, "background-clip: text" was implemented by saving a
Vector<Gfx::Path> of all glyphs needed to paint a mask for the
background. The issue with this approach was that once glyphs were
extracted into vector paths, the glyph rasterization cache could no
longer be utilized.

With this change, all text required for mask painting is saved in a
nested display list and rasterized as a regular text.
2024-07-25 14:33:33 +02:00
Aliaksandr Kalenik
50ab5642cc LibWeb: Make DisplayList ref-counted
This change is a preparation for the upcoming changes where display
list will be nested and the same display could be owned by multiple
display list items.
2024-07-25 14:33:33 +02:00
Aliaksandr Kalenik
e8b7c88881 LibWeb: Move display list command dispatch into player
With this change display list player will be able to recurse into
executing another display list, without having to construct new display
list player. It is going to be useful in the upcoming changes to paint
a mask from a display list owned by a command.
2024-07-25 14:33:33 +02:00
Tim Ledbetter
5a796629c6 LibWeb: Make document.createElementNS() case-sensitive
Previously, when creating a HTML element with
`document.createElementNS()` we would convert the given local name to
lowercase before deciding which element type to return. We now no
longer perform this lower case conversion, so if an uppercase local
name is provided, an element of type `HTMLUnknownElement` will be
returned. This aligns our implementation with the specification.
2024-07-25 13:12:34 +02:00
Edwin Hoksberg
e5deaa1c07 LibWeb: Implement grid-template function fit-content() 2024-07-25 13:12:26 +02:00
Edwin Hoksberg
de84e6f93a LibWeb: Move css_clamp function to FormattingContext
Since we need it in the FlexFormattingContext and
GridFormatting context now.
2024-07-25 13:12:26 +02:00
Andreas Kling
4d78c66b3d LibWeb: Cache name->element mappings in HTMLCollection
This makes https://wpt.fyi/ load today instead of tomorrow, although
there's a lot of room for improvement still.
2024-07-25 13:12:02 +02:00
Jamie Mansfield
2ca8fd1832 LibWeb: Make preferred languages configurable
This also changes fetch to use the preferred languages for the
Accept-Language header.
2024-07-25 11:38:59 +01:00
Diego Frias
2cfc1873c0 LibWasm: Flatten instructions in one continuous loop during parsing
Instead of multiple loops and multiple vectors, parse Wasm expressions
in a simple loop. This gets us from ~450ms to instantiate spidermonkey
to ~280ms.
2024-07-25 12:16:45 +02:00
Jamie Mansfield
f774d75f89 LibWeb/DOM: Check if name is valid in Element.toggleAttribute
This resolves a test in https://wpt.live/dom/nodes/attributes.html.
2024-07-25 06:46:28 +02:00
Tim Ledbetter
0127190dcf LibWeb: Perform DOMTokenList token validation in the correct order 2024-07-25 06:43:31 +02:00
Tim Ledbetter
ec1f7779cb LibWeb: Follow the specification steps to serialize a DOMTokenList
This ensures that calling `element.classList.toString()` always
produces the correct value.
2024-07-25 06:43:31 +02:00
Tim Ledbetter
21e21abeed LibWeb: Update Element class list is when class attribute is removed 2024-07-25 06:43:31 +02:00
Mohamed amine Bounya
6e77fff698 LibWeb: Bring 'construct_entry_list' closer to specs 2024-07-25 06:42:43 +02:00
Diego Frias
4e8376d07e LibWasm: Remove unused vector methods of the interpreter 2024-07-24 23:23:09 +02:00
Diego Frias
9cc3e7d32d LibWasm: Fix SIMD shuffle and swizzle
`swizzle` had the wrong operands, and the vector masking boolean logic
was incorrect in the internal `shuffle_or_0` implementation. `shuffle`
was previously implemented as a dynamic swizzle, when it uses an
immediate operand for lane indices in the spec.
2024-07-24 23:23:09 +02:00
Diego Frias
d841742c35 LibWasm: Fix SIMD bit shift right
Set the sign in the vector's element type (even though it's a bit
redundant).
2024-07-24 23:23:09 +02:00
Aliaksandr Kalenik
40f9c9f82a LibWeb: Remove optional prepare step from DisplayListPlayer
This was only needed by removed LibGfx painter to ensure capacity of a
vector with border corner clippers.
2024-07-24 17:49:14 +02:00
Aliaksandr Kalenik
54cb888e2f LibWeb: Remove step to prepare bitmap cache in display list player
This was only used by old OpenGL GPU painter.
2024-07-24 17:49:14 +02:00
Aliaksandr Kalenik
a10576d016 LibWeb: Remove step to prepare glyphs texture in display list player
This was only used by old OpenGL GPU painter.
2024-07-24 17:49:14 +02:00
Sam Atkins
6160400ab7 Revert "WebContent: Limit the Console client to the top-level navigable"
This reverts commit 758f4887bc.

This commit was causing ASAN to complain about a use-after-poison, see
https://github.com/LadybirdBrowser/ladybird/issues/809
2024-07-24 16:44:52 +01:00
Aliaksandr Kalenik
6ae9b54f11 LibWeb: Remove stacking context painting failure handling
CommandResult was needed by LibGfx display list player that could have
failed to allocate a temporary bitmap for painting a stacking context
with CSS transforms. This is no longer an issue with Skia painter, so
we can delete CommandResult::SkipStackingContext handling path.
2024-07-24 14:57:19 +02:00
sideshowbarker
70e053bbf4 LibWeb: WebIDL::OverloadResolution, minor code streamlining 2024-07-24 11:23:58 +02:00
sideshowbarker
cc7c49e235 LibWeb: WebIDL::OverloadResolution::resolve_overload, add dbgln FIXMEs
Relates to https://github.com/LadybirdBrowser/ladybird/issues/801
2024-07-24 11:23:58 +02:00
Shannon Booth
52ccd69e49 WebAudio: Avoid throwing exception for stubbed AudioNode.connect
This stubs out enough to get https://athenacrisis.com/ far enough to
actually load :^)
2024-07-24 11:14:46 +02:00
Shannon Booth
52be4925bc WebAudio: Avoid throwing exception for stubbed setValueAtTime
Instead, just log an error and continue on gracefully, returning an
instance of ourselves as spec'd.
2024-07-24 11:14:46 +02:00
Shannon Booth
a51095f705 WebAudio: Add stub for AudioDestinationNode.destination
This is called by https://athenacrisis.com/ and passed through to
AudioNode.connect, which expects an AudioNode.

Implement this function enough so that we return an AudioNode so that
AudioNode.connect does not throw a TypeError.
2024-07-24 11:14:46 +02:00
Shannon Booth
5eb80b8697 WebAudio: Add IDL interface for AudioDestinationNode
This is an AudioNode representing the final audio destination and is
what the user will ultimately hear.

This node is used as one of the connecting nodes in athenacrisis.com

Add a placeholder for the interface without anything backing it for now.
2024-07-24 11:14:46 +02:00
Andreas Kling
9a7e6158af LibJS: Fix crash in bytecode generator on https://twinings.co.uk/
If the current block has already been terminated, we should just skip
creating a per-iteration environment.
2024-07-24 11:13:53 +02:00
Aliaksandr Kalenik
c5afe70f77 LibWeb: Add optimized painting command for repeated background
With this change, instead of recording a display list item for each
instance of a repeated background, a new DrawRepeatedImmutableBitmap
type is used. This allows the painter to use optimized repeated image
painting and, when the GPU backend is used, avoid re-uploading the image
texture for each repetition.

Some screenshot tests are affected, but there are no visible
regressions.

https://null.com/games/chainstaff works a lof faster with this change.
2024-07-24 11:13:04 +02:00
Andreas Kling
4c326fc5f6 LibWeb: Implement :host and :host(<compound-selector>) selector matching
The :host family of pseudo class selectors select the shadow host
element when matching against a rule from within the element's shadow
tree.

This is a bit convoluted due to the fact that the document-level
StyleComputer keeps track of *all* style rules, and not just the
document-level ones.

In the future, we should refactor style storage so that shadow roots
have their own style scope, and we can simplify a lot of this.
2024-07-23 18:03:46 +02:00
Andreas Kling
274c46a3c9 LibWeb: Don't infer descendant combinator for <compound-selector>
This fixes an issue where :host(foo) would parse as if "foo" was the
on the right side of a descendant combinator.

Not testable yet, but will be in the next commit.
2024-07-23 18:03:46 +02:00
Timothy Flynn
758f4887bc WebContent: Limit the Console client to the top-level navigable client
We don't want to set the intrinsic Console object's client to non-top-
level clients, created for e.g. SVG elements or subframes. We also want
to make sure the Console client is updated if the top-level document has
changed.
2024-07-23 18:00:27 +02:00
Sam Atkins
64d45afd8a LibWeb: Check CanvasTextDrawingStyles.font assignment is valid
Checking that the string parsed for the `font` property is not enough,
the spec also wants to rule out CSS-wide keywords like `inherit`. The
simplest way to do so is to check if it's a ShorthandStyleValue, which
also rules out use of `var()`; this matches other browsers' behaviour.

The newly-added test would previously crash, and now doesn't. :^)
2024-07-23 18:00:12 +02:00
simonkrauter
54066ec5a4 LibWeb: Use absolute padding box to calculate max scroll offset
In `PaintableBox::set_scroll_offset()` the scrollport size was measured
by `content_size()` instead of `absolute_padding_box_rect()`.

Fixes #788
2024-07-23 17:59:17 +02:00
Andreas Kling
14beda00c9 LibJS: Rename Value::typeof() to Value::typeof_()
This to avoid clashing with the GCC typeof extension, which apparently
confuses clang-format.
2024-07-23 11:47:37 +02:00
Andreas Kling
d0b11af387 LibJS: Make typeof a lot faster by caching all possible results
The typeof operator has a very small set of possible resulting strings,
so let's make it much faster by caching those strings on the VM.

~8x speed-up on this microbenchmark:

    for (let i = 0; i < 10_000_000; ++i) {
        typeof i;
    }
2024-07-23 11:47:37 +02:00
Andreas Kling
3b7534b362 LibWeb: Use correct scope when removing style sheet inside a shadow tree
Before this change, removing a style element from inside a shadow tree
would cause it to be unregistered with the document-level list of sheets
instead of the shadow-root-level list.

This would eventually lead to a verification failure if someone tried to
update the text contents of that style element, since it was still in
the shadow-root-level list, but now with a null owner element.

Fixes a crash on https://www.swedbank.se/
2024-07-23 11:12:18 +02:00
Andreas Kling
ebacb921da LibWeb: Verify something was removed in StyleSheetList::remove_sheet()
This would have saved me an hour of debugging, so putting it here for
the next person. :^)
2024-07-23 11:12:18 +02:00
Jamie Mansfield
835986de7b LibWeb/WebGL: Stub missing properties in WebGLRenderingContextBase 2024-07-23 09:04:57 +02:00
Timothy Flynn
d58a8b5146 LibWebView+UI: Raise the chrome process open file limit
The default limit (at least on Linux) causes us to run out of file
descriptors at around 15 tabs. Increase this limit to 8k. This is a
rather arbitrary number, but matches the limit set by Chrome.
2024-07-23 09:04:42 +02:00
Timothy Flynn
4451b4fda0 LibCore: Log errors from pipe2 when creating an event loop 2024-07-23 09:04:42 +02:00