Commit graph

34540 commits

Author SHA1 Message Date
Diego Frias
5cde327d46 LibWasm: Provide size hint when parsing instructions into a vector
Speeds up spidermonkey.wasm instantiation by around 20ms (280ms -> 260ms)
2024-07-27 08:19:51 +02:00
Aliaksandr Kalenik
1bd0871ed8 LibWeb+LibGfx: Use Skia for text rasterization
The main incentive is much better performance. We could have gone a bit
further in optimizing the Skia painter to blit glyphs produced by LibGfx
more efficiently from the glyph atlas, but eventually, we also want Skia
to improve correctness.

This change does not completely replace LibGfx in text handling. It's
still used at all stages, including layout, up until display list
replaying.
2024-07-27 08:18:54 +02:00
Jamie Mansfield
b7f0241ab5 LibWeb: Use "en" as a fallback when setting preferred languages
This will set the preferred languages to [ "en" ] if an empty list is
provided.
2024-07-27 08:18:16 +02:00
Jamie Mansfield
7b105e1ecf LibWeb: Add a default for the navigator's languages
This will mean that non-Qt frontends don't return an empty array.
2024-07-27 08:18:16 +02:00
Sam Atkins
59778d2b36 LibWeb/CSS: Make CSS Parser::create() infallible
Now that `Tokenizer::tokenize()` just returns a String, there are no
errors to propagate, and we can simplify the user code a bit.
2024-07-26 17:29:20 +02:00
Sam Atkins
89c5f25016 LibWeb/CSS: Remove tiny-oom propagation from CSS Tokenizer 2024-07-26 17:29:20 +02:00
Shannon Booth
22969a8e92 Bindings: Avoid second property index lookup for platform objects
While conceptually is_supported_property_index is a cheap index lookup,
it is not currently cheap for an container such as HTMLAllCollection
that is operating on an uncached collection. Instead - just do the
lookup once. It also happens to look a little nicer to not blindly
dereference an optional.
2024-07-26 14:26:16 +02:00
Shannon Booth
8a5985b87f Bindings: Use is_supported_property_name instead of contains_slow
This uses a faster hashtable lookup in the case of HTMLCollection.

Also port invoke_named_property_setter to FlyString to avoid a
FlyString->String->FlyString conversion that surfaces from this change.
2024-07-26 14:26:16 +02:00
Shannon Booth
9b1af542e7 Bindings: Implement is_supported_property_index in terms of item_value
Greatly simplifying the code :^)
2024-07-26 14:26:16 +02:00
Shannon Booth
c5c1a8fcc7 Bindings: Make item_value return an Optional<JS::Value>
This removes some ambiguity about what the return value should be if
the index is out of range.

Previously, we would sometimes return a JS null, and other times a JS
undefined.

It will also let us fold together the checks for whether an index is a
supported property index, followed by getting the value just afterwards.
2024-07-26 14:26:16 +02:00
Shannon Booth
9b59dc5e8b Bindings: Remove exception handling for named_item_value 2024-07-26 14:26:16 +02:00
Shannon Booth
081c92bf3d Bindings: Remove exception handling for named_item
We don't need this for any case, so just remove it to simplify handling
in PlatformObject.
2024-07-26 14:26:16 +02:00
Andreas Kling
273593afba LibWeb: Don't proceed with Element.click() on disabled form controls
Fixes an infinite reload loop on some of the dom/events/ tests in WPT.
2024-07-26 14:25:04 +02:00
Sam Atkins
696ccc1aa9 LibWeb: Prevent elements with no layout box from modifying counters 2024-07-26 11:04:30 +01:00
Sam Atkins
898e3bd898 Last: LibWeb: Add counter() and counters() functions to content property
These let you format counters' current values as strings for use in
generated content.
2024-07-26 11:04:30 +01:00
Sam Atkins
576a431408 LibWeb: Implement CounterStyleValue
This is `counter(name, style?)` or `counters(name, link, style?)`. The
difference being, `counter()` matches only the nearest level (eg, "1"),
and `counters()` combines all the levels in the tree (eg, "3.4.1").
2024-07-26 11:04:30 +01:00
Sam Atkins
017d6c3314 LibWeb: Implement counter-[increment,reset,set] properties
These control the state of CSS counters.

Parsing code for `reversed(counter-name)` is implemented, but disabled
for now until we are able to resolve values for those.
2024-07-26 11:04:30 +01:00
Sam Atkins
4c42e93853 LibWeb: Format Properties.json 2024-07-26 11:04:30 +01:00
Sam Atkins
ca10fb4129 LibWeb/CSS: Refactor contains_single_none_ident() to actually parse it
The new method is Parser::parse_all_as_single_none_value(), which has a
few advantages:

1. There's no need for user code to manually create a StyleValue.
2. It consumes tokens so that doesn't have to be done manually.
3. Whitespace before or after the `none` is consumed correctly.

It does mean we create and then discard a `none` StyleValue in a couple
of places, namely parsing for `grid-*` properties. We may or may not
want to migrate those to returning the IdentifierStyleValue instead.
2024-07-26 11:04:30 +01:00
Sam Atkins
6f2f91d1f5 LibWeb: Stop computing content in NodeWithStyle::apply_style()
This seems to have been required when pseudo-elements were first
implemented, but has since become unused. It's also awkward because we
don't have access to the DOM Element and its CountersSet at this point.
So, let's remove it.

For reference, Chrome&Firefox both return the computed value for
`content: counter(foo)` as `counter(foo)`, not as the computed string.
So not computing it here seems like the intended behaviour.
2024-07-26 11:04:30 +01:00
Sam Atkins
708f49d906 LibWeb: Give DOM Elements a CountersSet
This represents each element's set of CSS counters.
https://drafts.csswg.org/css-lists-3/#css-counters-set

Counters are resolved while building the tree. Most elements will not
have any counters to keep track of, so as an optimization, we don't
create a CountersSet object until the element actually needs one.

In order to properly support counters on pseudo-elements, the
CountersSet needs to go somewhere else. However, my experiments with
placing it on the Layout::Node kept hitting a wall. For now, this is
fairly simple at least.
2024-07-26 11:04:30 +01:00
Kenneth Myhra
a744a9ebe7 LibWeb: Append fetch record to client's fetch group when request is a
...subresource.
2024-07-26 10:22:17 +02:00
Kenneth Myhra
e36607bdba LibWeb: Add spec link to fetch group concept 2024-07-26 10:22:17 +02:00
Kemal Zebari
c5f1e47883 LibWeb: Implement Blob::bytes()
Implements https://w3c.github.io/FileAPI/#dom-blob-bytes.
2024-07-26 10:21:32 +02:00
Timur Sultanov
ad7b2b7c26 LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec
2024-07-26 09:15:39 +01:00
Timur Sultanov
9d4f3c938f LibWeb: Improve HTMLOptionElement spec compliance
Implement ask_for_a_reset() function
2024-07-26 09:15:39 +01:00
Timur Sultanov
f4102b1dc9 LibWeb: Implement selectedness algorithm
Implement selectedness setting algorithm in HTMLSelectElement
2024-07-26 09:15:39 +01:00
doctortheemh
9cbb3fac12 LibWeb: Parse fill and stroke values
Use the CSS color data type using the CSS parser.
2024-07-26 09:14:09 +01:00
Jamie Mansfield
793248aec9 LibWeb/HTML: Implement HTMLMediaElement.addTextTrack
Removes some noise from the console when browsing bbc.co.uk :^)
2024-07-26 09:30:19 +02:00
Jamie Mansfield
ff08c2f735 LibWeb/HTML: Add readiness state to TextTrack 2024-07-26 09:30:19 +02:00
Jamie Mansfield
4b16f1df05 LibWeb/HTML: Implement TextTrack.mode 2024-07-26 09:30:19 +02:00
Tim Ledbetter
ea2bb52962 LibWeb: Make DocumentType::node_name() return DocumentType::name()
This aligns our implementation with the specification.
2024-07-26 07:19:23 +02:00
sideshowbarker
cdb9081a86 LibWebView: Emit “submit an issue” suggestion when Ladybird crashes 2024-07-25 18:37:02 -06:00
Andrew Kaster
cdffc4238a WebContent: Ignore GC for page client member of BackingStoreManager
This is very non-ideal, but the use of a reference for this member is
technically ok in its current usage as a member of the PageClient
itself.
2024-07-25 18:35:57 -06:00
Andrew Kaster
b73bd76571 LibWeb: Visit the DataTransfer member of DragEvent 2024-07-25 18:35:57 -06:00
Andrew Kaster
f314f58fca LibJS+ClangPlugins: Add escape hatch for GCPtr checks 2024-07-25 18:35:57 -06:00
Andrew Kaster
88176d4be2 LibThreading: Guard closing the background thread on the thread existing
This prevents a crash in ImageDecoder when it's closed before any
image decoding requests have been made.
2024-07-25 20:55:31 +01:00
Andreas Kling
de2b9eebe6 LibWeb: Inherit CSS variables across shadow boundaries
This fixes a bunch of issues on https://wpt.fyi/
2024-07-25 21:38:32 +02:00
Tim Schumacher
cf6929fef3 Meta: Guard everything that installs headers with an option 2024-07-25 13:25:09 -06:00
Andreas Kling
d49ae5af32 LibWeb: Make offsetTop and offsetLeft behave more like other browsers
We now follow the rules from the spec more closely, along with an
unspecified quirk for when the offsetParent is a non-positioned body
element. (Spec bug linked in a comment.)

This fixes a whole bunch of css-flexbox tests on WPT, which already had
correct layout, but the reported metrics from JS API were wrong.
2024-07-25 18:52:04 +02:00
Timur Sultanov
afb2e063b7 LibWeb: Set the first added <option> element under <select> as selected 2024-07-25 16:58:12 +02:00
Timur Sultanov
d1a7caa35d LibWeb: Use queue_a_task() function to queue an element task
Remove direct usage of task_queue() and use a helper function instead
2024-07-25 16:58:12 +02:00
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