Commit graph

34282 commits

Author SHA1 Message Date
Shannon Booth 0ce3726d49 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.

(cherry picked from commit a51095f705c5a6bce2c291e8b51ac90182c63419)
2024-07-28 20:21:18 -04:00
Shannon Booth ff5358d9b8 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.

(cherry picked from commit 5eb80b8697d458ea2b70112a995e066f64b37ca6)
2024-07-28 20:21:18 -04:00
simonkrauter d314a5a887 LibWeb: Rename HTMLInputElement members related to range shadow tree
Choose a better name for private members which were added in
https://github.com/LadybirdBrowser/ladybird/pull/513

(cherry picked from commit b1d7a27468e5dca58039c79a455c9f8ac1b80680)
2024-07-28 17:35:10 -04:00
Andreas Kling eed8a503bd LibWeb+RequestServer: Let RequestServer set HTTP Accept-Encoding header
Ultimately it's RequestServer who knows which kind of encodings it can
handle and decompress, so let's have it set the Accept-Encoding.

(cherry picked from commit 2c918b540db2efcef4751084592ae1cf3be0999f)
2024-07-28 17:34:44 -04:00
Jamie Mansfield 9bbf50b755 LibWeb: Stub BroadcastChannel interface
This is enough to get the 1Password login page to load :^)

(cherry picked from commit d4a7cfb68fddbcfaaaddbd7f159c502c869281bf)
2024-07-28 16:44:35 -04:00
Jamie Mansfield 3a508ecf27 LibWeb: Implement HTMLMarqueeElement.trueSpeed
(cherry picked from commit 1f1276ffb10e0403e8880ff229e84be8f07f0d90)
2024-07-28 16:44:22 -04:00
Jamie Mansfield 47df84b14d LibWeb: Implement HTMLMarqueeElement.scrollDelay
(cherry picked from commit a917f8124cbf1aece0a8a623d4ce47a2464115b6)
2024-07-28 16:44:22 -04:00
Jamie Mansfield 43efbdd4b3 LibWeb: Implement HTMLMarqueeElement.scrollAmount
(cherry picked from commit 2a408ecfbc4b8cbc788230aa06fa30d32721922c)
2024-07-28 16:44:22 -04:00
Jamie Mansfield 5c9e947ebc LibWeb: Implement HTMLFrameElement.noResize
(cherry picked from commit 66528a17cb60c44d8cb946785b19d92a125c923a)
2024-07-28 16:44:22 -04:00
Jamie Mansfield 4b6801c13d LibWeb: Implement HTMLFrameElement.marginWidth
(cherry picked from commit e363e8918901ac33ceecc088f30c66797c069c8c)
2024-07-28 16:44:22 -04:00
Jamie Mansfield 0fa1f703d6 LibWeb: Implement HTMLFrameElement.marginHeight
(cherry picked from commit 4edc946aed6c2bceca4f8bfe9dca799d2cfe4743)
2024-07-28 16:44:22 -04:00
Braydn 2e8c178a03 LibWeb: Add Web Worker Origin Inheritance
Fetch requests from web workers fail CORS checks because the origin is
not inherited from the outside settings. Ensure web worker origin is
correctly inherited from outside settings

(cherry picked from commit 24adb1c4526fe29bbc332780272251be1635cf05)
2024-07-28 16:44:11 -04:00
Sam Atkins c90492a50c 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.

(cherry picked from commit 59778d2b365476ecb5b50218dae4457493ee7bf7)
2024-07-28 16:44:00 -04:00
Sam Atkins 83178e11a5 LibWeb/CSS: Remove tiny-oom propagation from CSS Tokenizer
(cherry picked from commit 89c5f25016e3486ae9104c1ecbda9e1341573377)
2024-07-28 16:44:00 -04:00
Tim Ledbetter f1cfe231af LibWeb: Perform DOMTokenList token validation in the correct order
(cherry picked from commit 0127190dcf7fd0ee27a935cf1f3f5c74b77c0fc9)
2024-07-28 14:13:20 -04:00
Tim Ledbetter a88effd0fe LibWeb: Follow the specification steps to serialize a DOMTokenList
This ensures that calling `element.classList.toString()` always
produces the correct value.

(cherry picked from commit ec1f7779cb16223dab0ef9f7bf875c3f7b5724a9)
2024-07-28 14:13:20 -04:00
Tim Ledbetter 66280e96e9 LibWeb: Update Element class list is when class attribute is removed
(cherry picked from commit 21e21abeed122b8b9ebd1bb98ad2201d7edae4f7)
2024-07-28 14:13:20 -04:00
Tim Ledbetter a439fe0d5b 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.

(cherry picked from commit 5a796629c61221261c1856e19dd829973e6158f0)
2024-07-28 14:13:11 -04:00
Shannon Booth 303e13046a 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.

(cherry picked from commit 22969a8e929eae00a45989acae99eb5a97269358)
2024-07-28 14:12:04 -04:00
Shannon Booth 9203a8d46b 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.

(cherry picked from commit 8a5985b87f618120ce891bfbe87786381654af25)
2024-07-28 14:12:04 -04:00
Shannon Booth 1ffbd29683 Bindings: Implement is_supported_property_index in terms of item_value
Greatly simplifying the code :^)

(cherry picked from commit 9b1af542e7a718d110786551a1a18914cc386a2d)
2024-07-28 14:12:04 -04:00
Shannon Booth 930725ce8d 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.

(cherry picked from commit c5c1a8fcc78af986e5dd1a1f0bef1223e458ed37)
2024-07-28 14:12:04 -04:00
Shannon Booth daa4dc63f5 Bindings: Remove exception handling for named_item_value
(cherry picked from commit 9b59dc5e8b88d311089e57fe134a1377a39242cb)
2024-07-28 14:12:04 -04:00
Shannon Booth 7bcb02822e Bindings: Remove exception handling for named_item
We don't need this for any case, so just remove it to simplify handling
in PlatformObject.

(cherry picked from commit 081c92bf3dc66773887243718cf41011289ac55e)
2024-07-28 14:12:04 -04:00
Andreas Kling 91bca10aa3 LibWeb: Only inject "User-Agent"/"Accept" headers when they're missing
...otherwise we send out HTTP requests with duplicates of these headers.

(cherry picked from commit 847243b7065b80739fdd4d015bc6559b0581bb66)
2024-07-28 14:11:20 -04:00
Sam Atkins fc6c6573b1 LibWeb: Prevent elements with no layout box from modifying counters
(cherry picked from commit 696ccc1aa992fdd7e22a44571d8be7d89738261d)
2024-07-28 13:31:02 -04:00
Sam Atkins 6ab5a043e6 Last: LibWeb: Add counter() and counters() functions to content property
These let you format counters' current values as strings for use in
generated content.

(cherry picked from commit 898e3bd89878ddb87df06e056031673dc770be2b)
2024-07-28 13:31:02 -04:00
Sam Atkins 07fe3e57c6 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").

(cherry picked from commit 576a4314084e5c3b839006da00dddb16e58b3503)
2024-07-28 13:31:02 -04:00
Sam Atkins 1bc896fa60 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.

(cherry picked from commit 017d6c3314d57d4e351764f328c1d25dbc9d033a)
2024-07-28 13:31:02 -04:00
Sam Atkins 491b2632df LibWeb: Format Properties.json
(cherry picked from commit 4c42e93853541db2a2f87179e3bb1688811655d0)
2024-07-28 13:31:02 -04:00
Sam Atkins bab7f225c6 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.

(cherry picked from commit ca10fb412947f6b6080326573418bfa8a3759c12)
2024-07-28 13:31:02 -04:00
Sam Atkins b2333ad4cf 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.

(cherry picked from commit 6f2f91d1f50130b6060ccfb1af1faaa890e81618)
2024-07-28 13:31:02 -04:00
Sam Atkins e06d74c314 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.

(cherry picked from commit 708f49d906389f8875f006894e2aacf2305834bf)
2024-07-28 13:31:02 -04:00
Jamie Mansfield b1ebaee65f LibWeb/DOM: Check if name is valid in Element.toggleAttribute
This resolves a test in https://wpt.live/dom/nodes/attributes.html.

(cherry picked from commit f774d75f890e89a8483e5c7459de4fd96ce1b479)
2024-07-28 13:17:47 -04:00
Ali Mohammad Pur ed5c5de25a Utilities/js: Make it possible to exit via two consecutive ^C's
Apparently this is common in the js repl world.
Fixes #743.

(cherry picked from commit d3f089dc268931e670ea6a00ac8bcb06ed9822e6)
2024-07-28 13:06:44 -04:00
Sam Atkins c847487f30 LibWeb: Reserve enough space for span>1 columns in BorderConflictFinder
This code previously only allocated enough space in
m_col_elements_by_index for 1 slot per column, meaning that columns
with a span > 1 would write off the end of it.

(cherry picked from commit 9e32c9329acd89d73eeff3494a5e728077962513)
2024-07-28 13:00:11 -04:00
Sam Atkins 1ea6e6c395 LibWeb: Correct logic for removing end nodes from HTMLOptionsCollection
This test case would previously crash.

Found with domato.

(cherry picked from commit 0cec68ea996623ee652900986c7232c8d538a209)
2024-07-28 13:00:11 -04:00
Timur Sultanov 9e36f7c86c LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec

(cherry picked from commit ad7b2b7c26c343504be32b9da8961e4fb5df3e86)
2024-07-28 12:59:58 -04:00
Timur Sultanov 54afd8bdc9 LibWeb: Improve HTMLOptionElement spec compliance
Implement ask_for_a_reset() function

(cherry picked from commit 9d4f3c938fd182d5cd195beefb1adf4d1bde376b)
2024-07-28 12:59:58 -04:00
Timur Sultanov 8344a54408 LibWeb: Implement selectedness algorithm
Implement selectedness setting algorithm in HTMLSelectElement

(cherry picked from commit f4102b1dc99c9bb1ec012106d28a35e03a6faea3)
2024-07-28 12:59:58 -04:00
Nico Weber 6ab69b1cc1 LibGfx/WebPWriterLossless: Use predictor transform
...for images that don't use a color indexing transform.

For now, write the predictor transform unconditionally, and predict
every pixel as its left neighbor (that is, use predictor 1 everywhere).

This will grow a better heuristic in time, and eventually we might want
to use more than 1 of the 13 different predictor modes. But on average,
doing this unconditionally is better than not doing it unconditionally.
(Also, it's possible to disable this transform using `image`'s
`--webp-allowed-transforms` flag.)

Using the same benchmark as in #24819, this reduces the total size
of the test images further, from 88M to 69M (21.6%). It does increase
runtime for compressing all these images from about 4.4s to 4.7s,
a 6.8% slowdown.

For the usual test image (no effect on the two animations, which use
the color indexing transform):

    sunset_retro.png (876K):
        1.2M -> 730K, 31.4 ms ± 0.8 ms -> 31.4 ms ± 0.7 ms

From 37% larger than the input to 16% _smaller_ than the input :^)
(A 39% size reduction for this image.)

Compressing sunset_retro.png with zopflipng produces a 820K image,
so we're smaller even than what the best PNG encoder can do with
this image.

It's not a win for all images: For example, the size of
qoi_benchmark_suite/screenshot_web/sublime.png goes from 1.0M to 1.5M,
a fairly dramatic size increase. Hopefully we can get that back in
the future with better heuristics. (The input sublime.png is 1.3M,
and sublime.png encoded using our QOI encoder creates a 1.6M file,
so the 1.5M isn't atrocious, even though it's much bigger than the
size without the predictor transform.)

Our WebP Lossless writer currently now has a similar feature set
to our QOI writer: RLE, color cache, left prediction, and
subtract green is somewhat similar to QOI's luma chunk. The WebP
writer also writes huffman trees, which QOI doesn't do. For most
images, the WebP writer creates smaller files than the QOI writer,
while being about 50% slower. The WebP writer also writes smaller
files than Serenity OS's png writer, while being ~40x as fast
(for sunset_retro, ~30ms instead of ~1.3s; 730K output instead of
999K).

Only doing RLE and using a single predictor for the entire image is
similar to what fpng is doing (...but fpng uses the T predictor always).

We still don't write a meta prefix image to keep the huffman trees
flatter, we still don't do full LZ77 backward matches, and we still
don't write color transforms. But the writer has now enough features
to be in usable shape. It's now Serenity OS's best-compressing lossless
image writer.

The test_webp_color_indexing_transform_single_channel test uses a
linear horizontal gradient, which the predictor transform compresses
so well that encoded_data_without_color_indexing ends up being
smaller than the color indexed file. Just disable the predictor
transform in that test for now.
2024-07-28 12:35:41 -04:00
Andreas Kling 94c1066f68 LibWeb: Inherit CSS variables across shadow boundaries
This fixes a bunch of issues on https://wpt.fyi/

(cherry picked from commit de2b9eebe6012e321c85cdae0ca14b4be40de624)
2024-07-28 07:33:15 -04:00
Jamie Mansfield a28019e98b LibWeb/HTML: Implement HTMLMediaElement.addTextTrack
Removes some noise from the console when browsing bbc.co.uk :^)

(cherry picked from commit 793248aec977d4b15006d6e55a960da2e115a734,
amended to s/UIEvents::KeyCode/KeyCode/ to resolve cherry-pick conflict)
2024-07-28 07:32:58 -04:00
Jamie Mansfield 62caf51004 LibWeb/HTML: Add readiness state to TextTrack
(cherry picked from commit ff08c2f735e938c8280089eca690fd5e65d017c1)
2024-07-28 07:32:58 -04:00
Jamie Mansfield b24f6bc13b LibWeb/HTML: Implement TextTrack.mode
(cherry picked from commit 4b16f1df05208e3ae15e4b2d2096e50045597252)
2024-07-28 07:32:58 -04:00
doctortheemh 5d1beff35f LibWeb: Parse fill and stroke values
Use the CSS color data type using the CSS parser.

(cherry picked from commit 9cbb3fac123d0ce12bc1d0127d22ed26417dffd7)
2024-07-28 07:32:47 -04:00
Tim Ledbetter 8c56eb0743 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.

(cherry picked from commit 3802d9ccc4ea4428b82c6d584c3667c040cb46c7)
2024-07-28 07:32:31 -04:00
Tim Ledbetter 25325e7ce9 LibWeb: Assert that cloned node is not null before returning
This makes potential issues easier to track down.

(cherry picked from commit f8b1e96e2be0682e67f574f8a723e51cea9642a9)
2024-07-28 07:32:31 -04:00
Tim Ledbetter 6a6c0ae791 LibWeb: Don't crash when cloning a CDATASection node
(cherry picked from commit 72ed62a560c654370e6a3583bc8bd078732f44db)
2024-07-28 07:32:31 -04:00
Andreas Kling a8a5463d33 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.

(cherry picked from commit d49ae5af32044cb83bc14073b92676a1662c3bc1)
2024-07-28 07:32:17 -04:00