Commit Graph

23145 Commits

Author SHA1 Message Date
Sergey Bugaev
8fee93d868 LibC: Add futex_wait() and futex_wake() helpers
These are convinient wrappers over the most used futex operations.
futex_wait() also does some smarts for timeout and clock handling.

Use the new futex_wait() instead of a similar private helper in
LibPthread.
2021-07-05 20:26:01 +02:00
Daniel Bertalan
a482a3e609 AK: Declare operators new and delete as global functions
This fixes a build issue introduced in 23d66fe, where the compiler
statically detected that that mismatching new and delete operators were
used.

Clang generates a warning for this, for the reasons described in the
comment in `AK/kmalloc.cpp`, but GCC does not.

Besides moving the allocator functions into a `.cpp` file, declarations
in `AK/kmalloc.cpp` were reordered to have imports at the top, in order
to make the code more readable.
2021-07-05 20:23:42 +02:00
Andreas Kling
27fecf57bd LibGUI: Don't fire visibility-tracking timers in non-visible widgets
We were already avoiding firing timers within non-visible *windows*.
This patch extends the mechanism to support timers within non-visible
*widgets*.
2021-07-05 20:03:31 +02:00
kleines Filmröllchen
9f1f3c6f37 Piano: Use AudioServer instead of /dev/audio for audio
Piano is an old application that predates AudioServer. For this reason,
it was architected to directly talk to the soundcard via the /dev/audio
device. This caused multiple problems including simultaneous playback
issues, no ability to change volume/mute for Piano and more.

This change moves Piano to use AudioServer like any well-behaved audio
application :^) The track processing and IPC communication is moved to
the main thread because IPC doesn't like multi-threading. For this, the
new AudioPlayerLoop class is utilized that should evolve into the
DSP->AudioServer interface in the future.

Because Piano's CPU utilization has gotten so low (about 3-6%), the UI
update loop is switched back to render at exactly 60fps.

This is an important commit on the road to #6528.
2021-07-05 19:33:55 +02:00
kleines Filmröllchen
9d00db618d LibAudio: Add ClientConnection::async_enqueue()
async_enqueue() is a wrapper over the async_enqueue_buffer() call
to AudioServer. This allows users to asyncronously enqueue audio
samples, when the program requires non-blocking audio streaming.

This also makes ClientConnection use east-const everywhere.
2021-07-05 19:33:55 +02:00
kleines Filmröllchen
c8ced9f11d LibAudio: Improve latency on audio queue failures
We don't know what is a good time to wait after an audio buffer fails to
be processed by AudioServer. However, it seems like decreasing the wait
time to 10ms after such a failure should improve latency and has not
caused issues in my testing. After all, 10ms is quite some time in audio
sample magnitudes.
2021-07-05 19:33:55 +02:00
Tom
96155009dd WindowServer: Fix crash removing modal windows
Calling Window::is_modal requires the window to be on a window stack,
so we need to check this before removing it from the window stack.
2021-07-05 19:31:48 +02:00
Linus Groh
598842c5b7 LibJS: Fix bogus target.[[OwnPropertyKeys]]() call in Proxy 2021-07-05 18:19:45 +01:00
Linus Groh
34c28b981a LibJS: Add a missing exception check in Object.assign() 2021-07-05 18:19:45 +01:00
Linus Groh
2e94fa25d0 LibJS: Add spec step comments to Object.assign() 2021-07-05 18:19:45 +01:00
Linus Groh
4f2af65836 LibJS: Add spec step comments to Object.hasOwn() 2021-07-05 18:19:45 +01:00
Idan Horowitz
8195c31965 LibJS: Remove the non-standard get_own_property_descriptor helper 2021-07-05 18:19:39 +01:00
Max Wipfli
8a295299f3 Kernel: Fix regression in VFS::symlink
The create_child method should be called with basename, not the full
linkpath.
2021-07-05 19:12:31 +02:00
Max Wipfli
502436f9fc Kernel: Stricter path checking in validate_path_against_process_veil
This change enforces that paths passed to
VFS::validate_path_against_process_veil are absolute and do not contain
any '..' or '.' parts. We should VERIFY here instead of returning EINVAL
since the code that calls this should resolve non-canonical paths before
calling this function.
2021-07-05 18:51:21 +02:00
Max Wipfli
82c25aad01 Kernel: Use the static LexicalPath::basename(String) in VFS
This is just for improved code clarity, and shouldn't change anything
else.
2021-07-05 18:51:21 +02:00
Max Wipfli
3c0272126e Kernel: Don't allocate Strings unnecessarily in process veil validation
Previously, Custody::absolute_path() was called for every call to
validate_path_against_process_veil(). For processes that don't have a
veil, the path is not used by the function. This means that it is
unnecessarily generated. This introduces an overload to
validate_path_against_process_veil(), which takes a Custody const& and
only generates the absolute path if it there is actually a veil and it
is thus needed.

This patch results in a speed up of Assistant's file system cache
building by around 16 percent.
2021-07-05 18:51:21 +02:00
Idan Horowitz
557424a141 LibJS: Remove usage of define_native_property in OrdinaryFunctionObject
The length & name properties are supposed to be normal data properties.
2021-07-05 17:26:31 +01:00
Tom
b2e6088bff LibThreading: Fix BackgroundAction result use-after-free
We need to move the result out of the BackgroundAction object before
posting the completion callback as there is a chance the
BackgroundAction instance gets freed before the event loop runs our
callback.

Fixes #7641
2021-07-05 18:11:58 +02:00
Gunnar Beutner
8aafbd917a Kernel: Fix incorrect indentation
Looks like a tab and some other things snuck in. :)
2021-07-05 17:12:56 +02:00
davidot
f998cc156f LibJS: Remove PropertyName::to_value since it is not used anymore :^) 2021-07-05 16:04:52 +01:00
davidot
ce59e49e27 LibJS: Use a custom property_name_to_value method instead of to_value 2021-07-05 16:04:52 +01:00
davidot
721238f41c LibJS: Use the direct formatter of PropertyName instead of via to_value 2021-07-05 16:04:52 +01:00
davidot
c52d515028 LibJS: Make AbstractOperations::canonical_num... take a PropertyName
This allows us to hide the fact that it could be a number and means we
no longer need to check for this optimization in string and typedarray
2021-07-05 16:04:52 +01:00
Hendiadyoin1
9b7e48c6bd Kernel: Replace raw asm functions with naked ones 2021-07-05 16:40:00 +02:00
Idan Horowitz
c830de4983 LibWeb: Replace usage of native properties with accessors in Window
This is required by the WebIDL specification.
2021-07-05 14:40:49 +01:00
Idan Horowitz
4fdf4bfbd0 LibWeb: Replace usage of native properties with accessors in Navigator
This is required by the WebIDL specification.
2021-07-05 14:40:49 +01:00
Idan Horowitz
6468a2bf21 LibWeb: Replace usage of native properties with accessors in Location
This is required by the WebIDL specification.
2021-07-05 14:40:49 +01:00
Linus Groh
073071c634 LibJS: Fix Promise constructor reject function argument
If calling the executor function throws an exception, the return value
of `vm.call()` will be an empty value, which we then passed as an
argument to the reject function, which is incorrect - what it actually
needs is the exception value. This stems from a misunderstanding of the
spec I had at the time of implementing this - in their case, the
exception value is part of the completion record returned by Call().

This error was previously masked as we would use a fallback
(`value_or(js_undefined())` for the empty value argument, but that was
removed in 57f7e6e.

Fixes #8447.
2021-07-05 14:14:54 +01:00
Linus Groh
fe9dc47320 LibJS: Make FunctionObject's m_home_object an Object*, not Value
As the name implies (and the spec confirms), this is only ever going to
be an object or "nothing", or "undefined" in the spec. By taking this
literally and updating a check to check for `is_undefined()`, we
introduced a bug - the value was still initialized as an empty value.
Instead, use a pointer to an Object - either we have one, or we don't.

Fixes #8448.
2021-07-05 13:53:30 +01:00
Linus Groh
83f3f396ad LibWeb: Use JS_DECLARE_NATIVE_FUNCTION for WebAssembly accessors 2021-07-05 12:43:24 +01:00
Linus Groh
b5da876817 LibWeb: Make WebAssembly.Memory.prototype.buffer an accessor property 2021-07-05 12:33:29 +01:00
Linus Groh
b73b6fbd4c LibWeb: Make WebAssembly.Instance.prototype.exports an accessor property 2021-07-05 12:33:08 +01:00
Linus Groh
79d8326370 LibWeb: Use "WebAssembly.Foo" in exception error messages
Not just "Foo" or "WebAssemblyFoo". This is how it's accessed from the
outside (JS).
Also fix one case of "not an" => "not a".
2021-07-05 12:32:51 +01:00
Idan Horowitz
d713a84851 LibJS: Stop masking non-RangeError exceptions in TypedArray creation
Non-RangeError exceptions can be thrown by user implementations of
valueOf (which are called by to_index), and the specification
disallows changing the type of the thrown error.
2021-07-05 12:16:24 +01:00
Idan Horowitz
3b81a7420e LibJS: Use the GetMethod AO for creating a TypedArray from an iterable 2021-07-05 12:16:24 +01:00
Idan Horowitz
086b6f11c4 LibJS: Enforce a 2GB "Excessive Length" limit for TypedArrays 2021-07-05 12:16:24 +01:00
Idan Horowitz
56335dab6c LibJS: Use the GetPrototypeFromConstructor AO for TypedArrays creation 2021-07-05 12:16:24 +01:00
Luke
9cae827f07 LibWeb: Implement Node.contains
Used by Web Components Polyfills.
2021-07-05 12:39:46 +02:00
Luke
a826df773e LibWeb: Make WrapperGenerator generate nullable wrapper types
Previously it was not doing so, and some code relied on this not being
the case.

In particular, set_caption, set_t_head and set_t_foot in
HTMLTableElement relied on this. This commit is not here to fix this,
so I added an assertion to make it equivalent to a reference for now.
2021-07-05 12:39:46 +02:00
Luke
62c015dc96 LibWeb: Implement the adoption steps for <template> elements
While I'm here with the cloning steps, let's implement this too.
2021-07-05 12:39:46 +02:00
Luke
a7fa757dd1 LibWeb: Implement the cloning steps for <template> elements 2021-07-05 12:39:46 +02:00
Luke
5897bc5c1f LibWeb: Make adopted_from no longer take a const Document reference
Nodes implementing the adoption steps can modify the passed in
document, for example HTMLTemplateElement does so to adopt it's
contents into the new document.
2021-07-05 12:39:46 +02:00
Luke
f3f2170ac6 LibWeb: Add the cloning steps in clone_node
This will be used in HTMLTemplateElement later to clone template
contents.

This makes the clone functions non-const in the process, as the cloning
steps can have side effects.
2021-07-05 12:39:46 +02:00
Luke
e4ae1cdd1f LibWeb: Use the element factory in clone_node
It was directly creating a new Element object instead of creating the
appropriate element.

For example, document.body.cloneNode(true) would return an Element
instead of an HTMLBodyElement.
2021-07-05 12:39:46 +02:00
Luke
5430bc8963 LibWeb: Make clone_node capable of cloning document fragments
Used by Web Components Polyfills.
2021-07-05 12:39:46 +02:00
Luke
f7ad8c0f94 LibWeb: Add DOMParser
This allows you to invoke the HTML document parser and retrieve a
document as though it was loaded as a web page, minus any scripting
ability.

This does not currently support XML parsing.

This is used by YouTube (or more accurately, Web Components Polyfills)
to polyfill templates.
2021-07-05 12:39:46 +02:00
Luke
0ea50d44bf LibWeb: Check if scripting is disabled before running script
This is not a full check, it's just enough to prevent script execution
in DOMParser.
2021-07-05 12:39:46 +02:00
stelar7
ce314c54bd JsonParser: Bring parser more to spec 2021-07-05 12:36:19 +02:00
Tom
31a2f10927 LibGfx: Fix classic theme frame transparency check
We shouldn't use the title stripe or title shadow colors to determine
whether the frame itself is going to have alpha channels or not. This
caused e.g. the classic theme's window frame to be rendered as
transparency just because the stripe color had an alpha channel of 0.
2021-07-05 12:29:14 +02:00
Gunnar Beutner
8c14488106 Kernel: Get rid of of some of the duplicate kernel base address macros 2021-07-05 12:28:45 +02:00