Commit graph

51871 commits

Author SHA1 Message Date
Andreas Kling
55531e5cda LibJS/Bytecode: Use LHS identifier as function name on logical assign
This now creates a function named `x`:

    x ||= function() { }

9 new passes on test262. :^)
2023-06-26 16:07:33 +02:00
Andreas Kling
17ba47558c LibWeb: Make a copy of Document's DocumentObserver set when iterating
The observer callbacks can do all kinds of things, so let's not be in
the middle of iterating the set in case someone decides to mutate it.

Fixes a crash when loading https://lichess.org/
2023-06-26 12:10:33 +02:00
Timothy Flynn
6fb670c1c2 LibJS: Implement Iterator.prototype.find 2023-06-26 10:39:07 +02:00
Timothy Flynn
1f05b0638f LibJS: Implement Iterator.prototype.every 2023-06-26 10:39:07 +02:00
Timothy Flynn
6ac1d5afae LibJS: Implement Iterator.prototype.some 2023-06-26 10:39:07 +02:00
Timothy Flynn
134bb44ca0 LibJS: Implement Iterator.prototype.forEach 2023-06-26 10:39:07 +02:00
Timothy Flynn
35380b2aef LibJS: Implement Iterator.prototype.toArray 2023-06-26 10:39:07 +02:00
Timothy Flynn
acc05480e8 LibJS: Implement Iterator.prototype.reduce 2023-06-26 10:39:07 +02:00
Timothy Flynn
ad42b4ea67 LibJS: Implement Iterator.prototype.flatMap
This prototype is a bit tricky in that we need to maintain the iteration
state of the mapped iterator's inner iterator as we return values to the
caller. To do this, we create a FlatMapIterator helper to perform the
steps that apply to the current iteration state.
2023-06-26 10:39:07 +02:00
Timothy Flynn
67028ee3a3 LibJS: Implement Iterator.prototype.drop 2023-06-26 10:39:07 +02:00
Timothy Flynn
0e2f9f006d LibJS: Implement Iterator.prototype.take 2023-06-26 10:39:07 +02:00
Timothy Flynn
7e0083fb65 LibJS: Rename ErrorType::IntlNumberIsNaN to ErrorType::NumberIsNaN
It will be used outside of the Intl namespace, so give it a less overly
specific name.
2023-06-26 10:39:07 +02:00
Timothy Flynn
deeee65e37 LibJS: Implement Iterator.prototype.filter 2023-06-26 10:39:07 +02:00
Timothy Flynn
3eb2e4e08a LibJS: Implement Iterator.prototype.map
This uses a new Iterator type called IteratorHelper. This does not
implement IteratorHelper.prototype.return as that relies on generator
objects (i.e. the internal slots of JS::GeneratorObject), which are not
hooked up here.
2023-06-26 10:39:07 +02:00
Timothy Flynn
7ff6b472c0 LibJS: Implement Iterator.prototype [ @@toStringTag ] 2023-06-26 10:39:07 +02:00
Timothy Flynn
d9d245faa7 LibJS: Implement Iterator.from and the WrapForValidIteratorPrototype
Iterator.from creates an Iterator from either an existing iterator or
an iterator-like object. In the latter case, it sets the prototype of
the returned iterator to WrapForValidIteratorPrototype to wrap around
the iterator-like object's iteration methods.
2023-06-26 10:39:07 +02:00
Timothy Flynn
5736b53013 LibJS: Add an Iterator constructor and object
The Iterator object cannot be constructed directly but can be subclassed
or created with `Iterator.from` (not implemented here).
2023-06-26 10:39:07 +02:00
Timothy Flynn
428109e709 LibJS: Forward declare IteratorRecord and remove inclusion from VM.h
This drastically reduces the amount of compilation required when
Iterator.h is changed.
2023-06-26 10:39:07 +02:00
Timothy Flynn
4977000fa0 LibJS: Rename JS::Iterator to JS::IteratorRecord
This is in preparation for an upcoming implementation of the Iterator
Helpers proposal. That proposal will require a JS::Object type named
"Iterator", so this rename is to avoid conflicts.
2023-06-26 10:39:07 +02:00
Andrew Kaster
cd2a6767bc AK: Never use assert() when targeting Windows platforms
The Windows CRT definition of assert() is not noreturn, and causes
compile errors when using it as the backing for VERIFY() in debug
configurations of applications like the Jakt compiler.
2023-06-26 05:09:00 +02:00
Luke Wilde
c5f3b3ae02 LibJS/Bytecode: Return the proper result for iteration statements 2023-06-26 04:58:27 +02:00
Luke Wilde
b162c9117e LibJS/Bytecode: Set accumulator to undefined at start of catch blocks
Otherwise we leak the error value through to the result.
2023-06-26 04:58:27 +02:00
Zaggy1024
1789905d4a LibVideo/PlaybackManager: Don't crash when demuxer seek throws an error
`seek_demuxer_to_most_recent_keyframe()` wasn't correctly returning in
cases where an error was thrown by the demuxer. To avoid this, the
function now returns the error, and the playback state handler must act
on it instead, allowing it to exit the seeking state early.
2023-06-25 20:35:37 -04:00
Zaggy1024
b94c132dd1 Tests/LibVideo: Add a test for Matroska files containing CRC32 elements 2023-06-25 20:27:02 -04:00
Zaggy1024
cf1cb04af0 LibVideo/Matroska: Don't choke on files containing CRC32 elements
The EBML specification allows for CRC32 elements to be placed as the
first child element of a master element. However, our parsing of master
elements didn't take that into account, so an error would be thrown.

Instead of erroring out, the `parse_master_element()` function will now
skip CRC32 elements that are found as the first child of a master
element. If it is found after the first child, that will be considered
an error.

Void elements will also be skipped by `parse_master_element()`.

Since the `parse_cluster()` function has to seek the stream back to the
cluster's first child in order to allow cues' positions to be used
correctly, `parse_master_element()` had to be changed to return the
first element position, since the callback is not invoked for CRC32
elements. This means that the parameter used to communicate the element
position to the child element parsing function is unused, so that is
removed.
2023-06-25 20:27:02 -04:00
Andreas Kling
a4a1d1b84a LibJS/Bytecode: Transfer object expression property names to functions
2 new passes on test262. :^)
2023-06-25 20:39:29 +02:00
Andreas Kling
ad15a1e3e2 LibJS/Bytecode: Don't assert on eval() without arguments
3 new passes on test262. :^)
2023-06-25 19:41:53 +02:00
Andreas Kling
ceb5199225 LibJS/Bytecode: Don't clobber accumulator in Put/Delete instructions
The fact that side effects clobbers the accumulator isn't just annoying
inside the instruction handler, but also really counter-intuitive in
the bytecode program itself.

17 new passes on test262. :^)
2023-06-25 19:14:30 +02:00
Andreas Kling
8450948458 LibJS: Make class definition evaluation work in bytecode mode
Instead of assuming that there's an active AST interpreter, this code
now takes VM& everywhere and invokes the appropriate interpreter.

92 new passes on test262. :^)
2023-06-25 18:28:44 +02:00
Andreas Kling
66936a0d61 LibJS/Bytecode: Fix non-string keys not being excluded in rest object
By converting the excluded names to PropertyKey before filtering, we
ensure that non-string keys get excluded as needed.

14 new passes on test262. :^)
2023-06-25 18:02:37 +02:00
Andreas Kling
6f0952c358 LibJS/Bytecode: Handle object destructuring to member expression
19 new passes on test262. :^)
2023-06-25 17:00:29 +02:00
Hendiadyoin1
7005a91a1e LibJS: Replace invalid escapes in TemplateLiterals with undefined in BC
Also adds a big FIXME, to outline what is still wrong
2023-06-25 16:41:50 +02:00
Andi Gallo
3a0f7e8eb8 LibWeb: Adjust specified table height
Subtract borders and padding from specified height before comparing to
the used content height.
2023-06-25 15:08:42 +02:00
Andreas Kling
77f1e91e9d LibJS: Make $262.evalScript() work in bytecode mode
29 new passes on test262. :^)
2023-06-25 13:13:19 +02:00
Andreas Kling
1932f7e6b6 LibJS/Bytecode: Transfer binding pattern aliases to function names
60 new passes on test262. :^)
2023-06-25 11:59:51 +02:00
Shannon Booth
55d59636ef LibWeb: Implement Web::URL::url_encode closer to spec 2023-06-25 11:28:32 +02:00
Shannon Booth
799c79cc5a LibWeb: Simplify logic in Web::URL::URLSearchParams::sort 2023-06-25 11:28:32 +02:00
Shannon Booth
e99c0ddb0e LibWeb: Add spec link for Web::URL::url_decode 2023-06-25 11:28:32 +02:00
Shannon Booth
be9fcaf92d AK: Expose URLParser::percent_encode_after_encoding
This function is useful in places outside of the URLParser in LibWeb.
2023-06-25 11:28:32 +02:00
Kenneth Myhra
c445bd3a0c LibWeb: Move WebSocket constructor steps closer to spec 2023-06-25 11:28:18 +02:00
FalseHonesty
110eeb8591 LibWeb: Support calc(...) in box-shadow's values of type Length
The CSS box-shadow property takes 2-4 properties that are `<length>`s,
those being:
  - offset-x
  - offset-y
  - blur-radius
  - spread-radius

Previously these were resolved directly to concrete Lengths at parse
time, but now they will be parsed as LengthStyleValues and/or
CalculatedStyleValues and be stored that way until styles are later
resolved.
2023-06-25 10:27:08 +01:00
Andreas Kling
8873bf5016 LibJS/Bytecode: Use ToString instead of generic add() in ConcatString
This avoids invoking valueOf() on the values, which is observable.

48 new passes on test262. :^)
2023-06-25 11:20:05 +02:00
Liav A
99cc33bce9 Ports: Mark cbonsai package.sh as executable
This should fix a recent CI lint problem.
2023-06-25 09:40:00 +02:00
Andreas Kling
8021048bc9 LibJS/Bytecode: Throw on destructuring object assignment to nullish LHS
24 new passes on test262. :^)
2023-06-25 09:19:53 +02:00
Beckett Normington
4032bfc2fc Ports: Add cbonsai port
This commit modifies the port list and adds the package.sh script
for `cbonsai`.
2023-06-25 08:04:23 +01:00
Andi Gallo
8b34af816e LibWeb: Report border box width for tables in a block
For the containing block, table borders are opaque and have to be
accounted when computing the table width since they use available space.
2023-06-25 08:13:04 +02:00
Andi Gallo
2c4908094c LibWeb: Don't subtract border from used table width
The used width is already a content width, which doesn't include
borders. Border widths should be subtracted from the specified width
instead, since that initially specifies the total width including
borders, for consistent comparison. Also handle table box padding as an
additional fix.
2023-06-25 08:13:04 +02:00
Andreas Kling
1f95a40780 LibJS/Bytecode: Actually exit switch statement's lexical scope
95 new passes on test262. :^)
2023-06-25 08:09:39 +02:00
Lucas CHOLLET
cc1bd2d2d9 LibGfx/JPEG: Use a look-up table for cosine values
This solution is a middle ground between re-computing `cos` every time
and a much more mathematically complicated approach (as we have in the
decoder).

While still being far from optimal it already gives us a 10x
improvement, not that bad :^)

Co-authored-by: Tim Flynn <trflynn89@pm.me>
2023-06-25 00:22:21 +02:00
Sam Atkins
5056668ab2 Meta: Add lint check that ports have an executable package.sh 2023-06-25 00:18:52 +02:00