Commit graph

26330 commits

Author SHA1 Message Date
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
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 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
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
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
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
kleines Filmröllchen e0dce41ddf AudioServer: Add a hack to make audio "just work" on HDA for now
This should be fixed properly, but we have decided that a quick hack is
fine so that audio "just works" for most people.
2023-06-25 00:16:44 +02:00
kleines Filmröllchen 03fac609ee AudioServer+Userland: Separate audio IPC into normal client and manager
This is a sensible separation of concerns that mirrors the WindowServer
IPC split. On the one hand, there is the "normal" audio interface, used
for clients that play audio, which is the primary service of
AudioServer. On the other hand, there is the management interface,
which, like the WindowManager endpoint, provides higher-level control
over clients and the server itself.

The reasoning for this split are manifold, as mentioned we are mirroring
the WindowServer split. Another indication to the sensibility of the
split is that no single audio client used the APIs of both interfaces.
Also, useless audio queues are no longer created for managing clients
(since those don't even exist, just like there's no window backing
bitmap for window managing clients), eliminating any bugs that may occur
there as they have in the past.

Implementation-wise, we just move all the APIs and implementations from
the old AudioServer into the AudioManagerServer (and respective clients,
of course). There is one point of duplication, namely the hardware
sample rate. This will be fixed in combination with per-client sample
rate, eliminating client-side resampling and the related update bugs.
For now, we keep one legacy API to simplify the transition.

The new AudioManagerServer also gains a hardware sample rate change
callback to have exact symmetry on the main server parameters (getter,
setter, and callback).
2023-06-25 00:16:44 +02:00
Valtteri Koskivuori c3f5b514c8 WindowServer: Yank out window frame opacity
This facility was added in 15a1d9a, but isn't being used for anything.
It wasn't even hooked up to LibGUI for applications to use.
Relevant use-cases, such as the most prominent one in `AnalogClock`, use
`GUI::Window::set_frameless()` instead.
2023-06-24 23:45:27 +02:00
Valtteri Koskivuori 6931a5a0a8 WindowServer+LibGUI: Yank out window-global opacity
From what I can tell, this facility was added to WSWindow/GWindow in
2019 in 9b71307. I only found a single place in the codebase still using
this facility: `WindowServer::Menu::start_activation_animation()`. A
subtle fade-out animation that happens when a menu item is selected, and
the menu disappears.
I think our compositing facilities have improved enough to make this
facility redundant. The remaining use mentioned above was ported to just
directly blit the fade-out animation instead of requesting it from
WindowServer.
2023-06-24 23:45:27 +02:00
Andreas Kling 4fd71e3c3a LibJS/Bytecode: Support destructuring in try..catch
112 new passes in test262.
2023-06-24 21:10:07 +02:00
MacDue 3d755a57b6 LibGfx: Ensure last subpath is closed by Path::close_all_subpaths() 2023-06-24 19:31:30 +02:00
MacDue 6b40271b95 LibWeb: Close all subpaths when filling SVG paths 2023-06-24 19:31:30 +02:00
Shannon Booth f2881f4662 headless-browser: Use Diff::write_normal to output hunks
Saving a bunch of code :^)

The "Hunk:" text is preserved as there is no real need for the browser
test harness to be producing valid patch files.
2023-06-24 18:34:08 +02:00
Shannon Booth 2b56aefaed diff: Use Diff::write_normal to output hunks
Saving a bunch of code :^)
2023-06-24 18:34:08 +02:00
Shannon Booth 7afff80e71 LibDiff: Add Diff::write_normal for outputting normal hunks
In order to extract duplicated code between browser and the diff
utility.
2023-06-24 18:34:08 +02:00
Shannon Booth 312de21498 diff: Remove "Hunk:" text from output
While this is a useful piece of information it means that diff is
producing hunks that are not of a valid normal diff format. This breaks
the ability to redirect the output of diff to a file to generate a
patch.
2023-06-24 18:34:08 +02:00
Aliaksandr Kalenik 331f6a9e60 LibJS: Invalidate cached environment coordinate after delete in global
Fixes the bug in interpreter when cached environment coordinate is not
invalidated after `delete` operator usage on global `this`.
2023-06-24 18:33:44 +02:00
Andreas Kling 06ac768c8b LibJS/Bytecode: Add some basic codegen for ExportStatement
This is by no means complete, but at least a bunch of test-js and
test262 tests start working. :^)
2023-06-24 17:13:30 +02:00
Andreas Kling 5d79431859 LibJS/Bytecode: Actually generate & run bytecode for SourceTextModule 2023-06-24 17:13:30 +02:00
Andreas Kling 8a5e71256d LibJS/Bytecode: Add codegen for ImportCall
Also moved most of the AST ImportCall::execute() into a helper so we can
share the code.
2023-06-24 17:13:30 +02:00
Andreas Kling eb9298b54e LibJS/Bytecode: Support destructuring function parameters
To reduce code duplication, I've added new VM::execute_ast_node()
helper that handles bytecode compilation if needed.

918 new passes on test262. :^)
2023-06-24 08:38:54 +02:00
Andreas Kling b3a3c53007 LibJS: Fix bad indentation when dumping FunctionNode AST nodes 2023-06-24 08:38:54 +02:00
Zaggy1024 c760713650 LibWeb: Prioritize video duration when loading video element media
Previously, an audio loader could succeed for an HTMLVideoElement that
contains a video file, which caused the duration to be set to the bogus
duration of the audio loader instead of the correct duration from the
video container. Instead of setting the duration based on audio always,
set it to the video duration if we are creating a video element.
2023-06-24 06:20:06 +02:00
Xexxa e3a0f84ffb Browser: Change "Same Origin" to "Same-Origin" 2023-06-24 06:19:39 +02:00
Luke Wilde 95d619943e LibJS/Bytecode: Support private identifiers in optional chaining
Fixes 4 test262 tests :^)
2023-06-23 21:05:18 +02:00
Timothy Flynn 8b668da9d5 LibRegex: Bail parsing class set characters upon early EOF
Otherwise, we reach a skip() invocation at the end of this function,
which crashes due to EOF. Caught by test262.
2023-06-23 20:22:45 +02:00
Timothy Flynn 32502fceed LibJS: Update spec numbers/steps for RegExp unicode sets flag proposal
This proposal has been merged into the main ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/26b2369
2023-06-23 20:22:45 +02:00
Timothy Flynn 9407e05a3c LibJS: Update RegExp spec numbers to match re-ordering within the spec
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/abee2e6
https://github.com/tc39/ecma262/commit/77256bf
2023-06-23 20:22:45 +02:00
Andreas Kling 99b23fe2ad LibJS/Bytecode: Emit GetPrivateById for private member expressions
This makes it possible to call private member functions.

347 new passes on test262. :^)
2023-06-23 17:51:04 +02:00
Aliaksandr Kalenik 934cb601c2 LibWeb: Implement "destroy the child navigable" on navigable containers
Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-06-23 17:24:32 +02:00
Andi Gallo 55f1a70577 LibWeb: Fix style updates for table box nodes
On style update, we have to preserve the invariant established when we
built the layout tree - some properties are applied to the table wrapper
and the table box values are reset to their initial values.

This also ensures that the containing block of a table box is always a
table wrapper, which isn't the case if we set absolute position on the
box instead of the wrapper.

Fixes #19452.
2023-06-23 16:40:19 +02:00
Andi Gallo e28578363a LibWeb: Get initial values for table box from CSS::InitialValues 2023-06-23 16:40:19 +02:00
Andreas Kling 406e3ed849 LibWeb: Implement getting the container document of a navigable
Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2023-06-23 16:20:29 +02:00
Aliaksandr Kalenik d85bdd3ac5 LibWeb: Add API for finding NavigableContainer by content navigable
This is only needed because currently spec doesn't explicitly define
that navigable should have a pointer to associated container and when
this pointer should be set.
2023-06-23 16:20:29 +02:00
Andreas Kling 85a3a1c085 LibJS/Bytecode: Add codegen for "named evaluation if anonymous function"
This gives anonymous functions the name from the LHS they are being
assigned to.

171 new passes on test262. :^)
2023-06-23 16:09:33 +02:00
Shannon Booth a975fca42e LibWeb: Implement size attribute of ByteLengthQueuingStrategy
Co-authored-by: Matthew Olsson <mattco@serenityos.org>
2023-06-23 13:27:29 +02:00
Shannon Booth 49689e5d8e LibWeb: Implement size attribute of CountQueuingStrategy
Co-authored-by: Matthew Olsson <mattco@serenityos.org>
2023-06-23 13:27:29 +02:00
Shannon Booth 6d93692bc5 LibWeb: Add IDL definition for 'Function'
This is used in ByteLengthQueuingStrategy and CountQueuingStrategy
in the Streams spec.
2023-06-23 13:27:29 +02:00
Shannon Booth 4f217947b3 LibWeb: Implement QueuingStrategy for Web::Streams::ReadableStream 2023-06-23 13:27:29 +02:00
Andreas Kling e5c7d8407b LibJS/Bytecode: Support private class fields
This is accomplished with two new instructions:
- GetPrivateById
- PutPrivateById

Looks like 1616 new passes on test262. :^)
2023-06-23 08:53:10 +02:00
Andreas Kling 467ea86179 LibJS: Use bytecode for generator function default parameters
Otherwise there's a mismatch between which interpreter we use.
This fixes a regression in the AST interpreter score on test262.
2023-06-23 08:09:50 +02:00
Tim Ledbetter 702054dcbc wc: Add -L option to show the length of the longest line
If more than one file is specified on the command line and the `-L`
option is used, the totals field will show the longest line
encountered; it is not a sum like the other values.
2023-06-23 06:24:33 +02:00
Andi Gallo 8e52d1125d LibWeb: Take specified height into account for automatic table height
Track table grid height stretched to the specified height and use it to
set the final box height in TFC.

Fixes #19563.
2023-06-23 06:24:08 +02:00
Aliaksandr Kalenik 04a5196a5d LibWeb: Add fast_is<T>() for SVGUseElement
is<SVGUseElement> quite hot in profiles
2023-06-23 06:23:42 +02:00
Tim Ledbetter e259c3b38a dirname: Add support for multiple paths 2023-06-22 17:26:51 -04:00
Tim Ledbetter 828caf12a6 dirname: Add -z option for null terminated output 2023-06-22 17:26:51 -04:00
Tim Ledbetter c1c35f4f59 mkdir: Add -v option to print a message for each created directory 2023-06-22 22:35:30 +02:00
Tim Ledbetter 925ea4e854 mkdir: Replace LibC function calls with LibCore equivalents 2023-06-22 22:35:30 +02:00
Jelle Raaijmakers 56da2c5db6 aconv: Remove usage of ancient Core::DeprecatedFile
That'll teach me for merging without waiting for CI :^)
2023-06-22 21:53:00 +02:00
kleines Filmröllchen 57b3858fbc Utilities: Add aconv for converting between audio formats
The intention for this utility is to eventually become a general-purpose
multimedia conversion tool like ffmpeg (except probably not with as many
supported formats, stream mappings and filters). For now, we can not
write any video format so the added complexity is not necessary at the
moment.
2023-06-22 21:45:54 +02:00
kleines Filmröllchen de17cd018e LibAudio: Add accessor to "real" PCM sample format of loader 2023-06-22 21:45:54 +02:00
kleines Filmröllchen cd2e890304 LibAudio: Handle all integer PCM sample formats "correctly" in WavWriter
WavWriter needs a TON of modernization work, but for now this commit
just tackles two FIXMEs by converting samples correctly into all
supported integer PCM formats. The supported formats are only signed
16-bit and unsigned 8-bit for now, but can be expanded later. At least
we don't produce horrible speaker-destroying noise when writing any
other format.
2023-06-22 21:45:54 +02:00
Lucas CHOLLET d00a563462 LibGfx/PortableFormat: Write directly to the bitmap
No need to copy the data first to a Vector and then to the Bitmap. We
can skip this unnecessary step.
2023-06-22 21:32:45 +02:00
Daniel d8c1150f6b LibWeb: Respect "no-store" directive in cache-control header 2023-06-22 21:24:23 +02:00
Andreas Kling cd08515957 LibJS/Bytecode: Support named evaluation of anonymous functions 2023-06-22 21:16:17 +02:00
Andreas Kling f4fe9f09a1 LibJS/Bytecode: Perform ShadowRealm evaluations in bytecode when enabled 2023-06-22 21:16:17 +02:00
Andreas Kling 6537ed8fff LibJS/Bytecode: Simplify Bytecode::Interpreter lifetime model
The JS::VM now owns the one Bytecode::Interpreter. We no longer have
multiple bytecode interpreters, and there is no concept of a "current"
bytecode interpreter.

If you ask for VM::bytecode_interpreter_if_exists(), it will return null
if we're not running the program in "bytecode enabled" mode.

If you ask for VM::bytecode_interpreter(), it will return a bytecode
interpreter in all modes. This is used for situations where even the AST
interpreter switches to bytecode mode (generators, etc.)
2023-06-22 21:16:17 +02:00
Lucas CHOLLET b7c30f3096 image: Support JPEG as an output format 2023-06-22 21:13:04 +02:00
Lucas CHOLLET 226b214142 LibGfx/JPEG: Add a JPEG encoder :^)
This encoder is very naive as it only output SOF0 images and uses
pre-defined Huffman tables.

There is also a small bug with quantization which make using it
over-degrade the quality.
2023-06-22 21:13:04 +02:00
Lucas CHOLLET 503720b574 LibGfx/JPEG: Put generic definitions in a shared header
That file holds information that are used by both a decoder and an
encoder.
2023-06-22 21:13:04 +02:00
Timothy Flynn 3dac2f7e58 LibWeb: Decrease size of the media timeline box a tiny bit
Had this staged and meant to amend 8e3e068d75, as it makes the media
controls look a bit more balanced in size, but forgot to actually
commit.
2023-06-22 14:20:26 -04:00
Timothy Flynn 8e3e068d75 LibWeb: Paint the media timeline above the other media controls
It's a little bit of a battle to fit all of the media controls in the
available width of the media element. We currently cram everything on
one horizontal line. We've made adjustments to be able to fit it all,
but the controls (in particular the media timeline) are rather squished.

This paints the timeline above the other media controls now. This
provides much more granular control over the playback position when
scrubbing, and makes it much more likely for the timeline to render at
all.
2023-06-22 20:05:19 +02:00
Timothy Flynn b306db359a LibWeb: Begin scrubbing the media timeline and volume on mouse-down
This feels a bit more natural than waiting until the first mouse-move
event to begin scrubbing.
2023-06-22 20:05:19 +02:00
Aliaksandr Kalenik 2cbc9a6642 LibWeb: Start fleshing out Navigable::choose_a_navigable()
Equivalent of `choose_a_browsing_context` for navigables.
2023-06-22 18:18:50 +02:00
Aliaksandr Kalenik 473848be0e LibWeb: Do not treat size of abspos items as definite
This fixes the issue when size of abspos items is considered to be
resolvable without performing layout which is not correct in the
scenarious when top/right/bottom/left properties are not auto.
2023-06-22 18:18:04 +02:00
Timothy Flynn 1c991e5582 LibWeb: Add missing invocation to forget a media element's tracks
On bandcamp, this missing invocation would cause a playlist to loop one
single track indefinitely.
2023-06-22 14:58:43 +02:00
Shannon Booth 9cb4bf0683 LibWeb: Implement QueuingStrategy for Web::Streams::WritableStream 2023-06-22 06:58:23 +02:00
Shannon Booth 33f6e5d516 LibWeb: Implement Streams AO ExtractSizeAlgorithm(strategy) 2023-06-22 06:58:23 +02:00
Shannon Booth 060c130c82 LibWeb: Implement SetUpReadableByteStreamControllerFromUnderlyingSource 2023-06-22 06:58:23 +02:00
Shannon Booth 9ea597016a LibWeb: Implement Streams AO ExtractHighWaterMark(strategy, defaultHWM) 2023-06-22 06:58:23 +02:00