Commit graph

5846 commits

Author SHA1 Message Date
Andreas Kling c8270dbe2e LibJS: Rename ScriptFunction => OrdinaryFunctionObject
These are basically what the spec calls "ordinary function objects",
so let's have the name reflect that. :^)
2021-06-27 22:36:04 +02:00
Andreas Kling ba9d5c4d54 LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
Andrew Kaster e389ae3c97 LibJS: Ensure shift values in shift_right are modded by 32
The unsigned shift right implementation was already doing this, but
the spec requires a mod32 of rhs before the shift for the signed shift
right implementation as well. Caught by UBSAN and oss-fuzz.
2021-06-27 22:35:37 +02:00
Andrew Kaster 1f2720ce0d LibJS: Avoid undefined static cast of negative values in to_u32
If the value we get after fmod in Value::to_u32 is negative, UBSAN
complains that -N is out of bounds for u32. An extra static cast to i64
makes it stop complaining. An alternative implementation could add 2^32
if the fmod'd value is negative. Caught by UBSAN and oss-fuzz.
2021-06-27 22:35:37 +02:00
Tom 091628202f WindowServer: Un-tile window if resizing warrants it
Since being tiled means we restrict rendering a window to the screen it
is on (so that we don't "bleed" into an adjacent screen), we need to
untile it if the window either can't fit into the screen, or it is
detached from the screen edges.
2021-06-27 22:35:12 +02:00
Linus Groh d3fc8652c7 LibJS: Add content type check to IntegerIndexedElementSet()
Resolves a FIXME.
2021-06-27 21:01:07 +01:00
Linus Groh e08702a235 LibJS: Add content type check to InitializeTypedArrayFromTypedArray()
Resolves a FIXME.
2021-06-27 21:01:02 +01:00
Linus Groh d7750999b3 LibJS: Implement the TypedArray [[ContentType]] internal slot 2021-06-27 21:01:01 +01:00
Linus Groh 93bae37dd9 LibJS: Add 'is detached' check to InitializeTypedArrayFromTypedArray()
Resolves a FIXME.
2021-06-27 21:01:01 +01:00
Linus Groh 48e7fd52e7 LibJS: Make variables in InitializeTypedArrayFromTypedArray() match spec
This makes it easier to follow the code and compare it to the spec.
2021-06-27 21:01:01 +01:00
Linus Groh abb5a1f05c LibJS: Add missing InitializeTypedArrayFromTypedArray() spec link
Also move the others outside of their functions.
2021-06-27 21:00:57 +01:00
Andreas Kling 67d1b28b97 FileManager: Pass launch origin rects to spawned programs
This makes GUI applications animate their initial window showing up
on screen. :^)
2021-06-27 19:38:11 +02:00
Andreas Kling 6a132d8672 WindowServer+LibGUI: Allow specifying a "launch origin" for new windows
The launch_origin_rect parameter to create_window() specifies where on
screen the window was launched from. It's optional, but if you provide
it, the new window will have a short wireframe animation from the origin
to the initial window frame rect.

GUI::Window looks for the "__libgui_launch_origin_rect" environment
variable. Put your launch origin rect in there with the format
"<x>,<y>,<width>,<height>" and the first GUI::Window shown by the app
will use that as the launch origin rect.

Also it looks pretty neat, although I'm sure we can improve it. :^)
2021-06-27 19:38:11 +02:00
Andreas Kling 75f870a93f WindowServer: Add a more generic mechanism for animations
This patch adds the WindowServer::Animation class, which represents
a simple animation driven by the compositor.

An animation has a length (in milliseconds) and two hooks:

- on_update: called whenever the animation should render something.
- on_stop: called when the animation is finished and/or stopped.

This patch also ports the window minimization animation to this new
mechanism. :^)
2021-06-27 19:38:11 +02:00
Gunnar Beutner f285241cb8 Kernel: Rename Thread::tss to Thread::regs and add x86_64 support
We're using software context switches so calling this struct tss is
somewhat misleading.
2021-06-27 15:46:42 +02:00
Gunnar Beutner 233ef26e4d Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegisters 2021-06-27 15:46:42 +02:00
Ali Mohammad Pur fd72597999 LibWeb: Make ExceptionOr capable of holding all error types in the spec
The WebIDL spec specifies a few "simple" exception types in addition to
the DOMException type, let's support all of those.
This allows functions returning ExceptionOr<T> to throw regular
javascript exceptions (as limited by the webidl spec) by returning a
`DOM::SimpleException { DOM::SimpleExceptionType::T, "error message" }`
which is pretty damn cool :^)
2021-06-27 12:49:49 +01:00
Andreas Kling dff3439ad0 Profiler: Cache the timeline histograms instead of recomputing on paint
There was an aggressive amount of work happening on every paint. :^)
2021-06-27 12:05:28 +02:00
Tom a9906cfcd1 WindowServer: Try to auto-add unconfigured framebuffer devices
This will try to auto-add framebuffer devices that haven't been
explicitly configured to the right-hand side.
2021-06-27 09:46:27 +02:00
Tom 38af4c29e6 WindowServer: Coalesce flushing buffers into one ioctl() call
We regularily need to flush many rectangles, so instead of making many
expensive ioctl() calls to the framebuffer driver, collect the
rectangles and only make one call. And if we have too many rectangles
then it may be cheaper to just update the entire region, in which case
we simply convert them all into a union and just flush that one
rectangle instead.
2021-06-27 09:46:27 +02:00
Tom 708f27ca0e WindowServer: Use relative coordinates when flushing screen dirty rects
The framebuffer device expects coordinates relative to itself.
2021-06-27 09:46:27 +02:00
Tom c12cbb96ce WindowServer: Fix geometry label not updating if it isn't moving
This fixes a regression where the geometry label isn't updating even
though the window geometry had changed because the geometry label's
location isn't changing.
2021-06-27 09:37:07 +02:00
Andreas Kling f61a9f2dc5 LibJS: Don't extend arguments object to match the parameter count
The `arguments` object should only have the *arguments* as numeric
properties, not the *parameters*.

Given this function:

    function foo(a, b) {
        return arguments.length;
    }

Calling foo() with no arguments now correctly returns 0 instead of 2.
2021-06-27 00:37:07 +02:00
Andreas Kling beb43f673e AK: Undo bogus Variant::downcast() rename
I accidentally renamed these to verify_cast() when doing the global
AK::downcast() rename.
2021-06-26 21:27:58 +02:00
Linus Groh 337ad6d15c LibJS: Implement the GetMethod() abstract operation as a Value method
This was a standalone function previously (get_method()), but instead of
passing a Value to it, we can just make it a method.

Also add spec step comments and fix the receiver value by using GetV().
2021-06-26 19:24:35 +01:00
Linus Groh 31f5797e89 LibJS: Implement the GetV() abstract operation
Like Get(), but with any value instead of an object - it's calling
ToObject() for us and passes the value to [[Get]]() as the receiver.

This will be used in GetMethod() (and a couple of other places, which
can be updated over time).

I also tried something new here: adding the three steps from the spec as
inline comments :^)
2021-06-26 19:17:28 +01:00
Linus Groh dbda5a9a4c LibJS: Move install_error_cause() from Object to Error
This is only used by Error and its subclasses, so it doesn't need to be
available to all objects.
2021-06-26 19:06:55 +01:00
davidot a63cc2c6b9 LibJS: Skip tests which broke with reversion of f102b563
These tests are correct as other engines pass them but are now broken
2021-06-26 18:16:53 +01:00
davidot 83dd0164b2 Revert "LibJS: Fix this_value in native setters and getters"
This reverts commit f102b563
The reverted to behavior is not correct for example with a double proxy
But this change lead to problems with DOMNodes
2021-06-26 18:16:53 +01:00
davidot 19f505d320 LibJS: Fix propagation of setters and getters from prototypes
If we define a property with just a setter/getter (not both) we must:
- take the previous getter/setter if defined on the actual object
- overwrite the other to nullptr if it is from a prototype
2021-06-26 18:16:53 +01:00
davidot b1441a47b1 LibJS: Allow setting the length of an object with prototype Array
Before this it would always go through the native setter thus
 modifying the array but now you can set length to anything
2021-06-26 18:16:53 +01:00
davidot b38fb418f8 LibJS: Don't remove non-configurable items in Array when setting length 2021-06-26 18:16:53 +01:00
davidot c7aaf40a35 LibJS: Make Array.prototype.lastIndexOf slightly more spec compliant 2021-06-26 18:16:53 +01:00
Andreas Kling 9683b10aec LibJS: Make sure this in the global environment is the global object
Fixes regressed with 0f9038b732.
2021-06-26 17:06:36 +02:00
Andreas Kling 49018553d3 LibJS+LibCrypto: Allow '_' as a numeric literal separator :^)
This patch adds support for the NumericLiteralSeparator concept from
the ECMAScript grammar.
2021-06-26 16:30:35 +02:00
Andreas Kling 527c639c1f LibJS: Fix spelling mistake in one of the syntax error descriptions 2021-06-26 16:25:11 +02:00
Luke a1f3e711c0 LibJS: Add %TypedArray%.prototype.entries 2021-06-26 13:32:53 +01:00
Luke a6324481e1 LibJS: Add %TypedArray%.prototype.values 2021-06-26 13:32:53 +01:00
Luke fb43b778ab LibJS: Add %TypedArray%.prototype.keys 2021-06-26 13:32:53 +01:00
Luke 293974c1cb LibJS: Add TypedArray support to ArrayIterator
ArrayIteratorPrototype::next seems to implement CreateArrayIterator,
which is an issue for a separate PR.
2021-06-26 13:32:53 +01:00
Andreas Kling ee4fc97038 LibJS: Align ObjectEnvironmentRecord member names with the spec
In the spec, object environments have a [[BindingObject]], so let's
call it the same thing in our implementation.
2021-06-26 10:39:16 +02:00
Andreas Kling 0f9038b732 LibJS: Remove unnecessary GlobalObject& member on global environment
We already store the GlobalObject& in a base class, so no need to also
store it in the subclass. :^)
2021-06-26 10:34:55 +02:00
Andreas Kling 6d7d8f3db9 LibJS: Create new object earlier in VM::construct()
Also make use of OrdinaryCreateFromConstructor() instead of setting
the prototype manually.

This fixes 2 function tests in test262. :^)
2021-06-26 00:04:54 +02:00
Linus Groh a59ba0e21f LibJS: Change PropertyName(i32) => template<Integral T> PropertyName(T)
Negative numeric properties are not a thing (and we even VERIFY()'d this
in the constructor). It still allows using types with a negative range
for now as we have various places using int for example (without
actually needing the negative range, but that's a different story).

u32 is the internal type of `m_number` already, so this now allows us to
leverage the full u32 range for numeric properties.
2021-06-25 22:01:23 +01:00
Linus Groh f4867572b7 LibJS: Change PropertyName(Symbol*) => PropertyName(Symbol&)
Requires a bunch of find-and-replace updates across LibJS, but
constructing a PropertyName from a nullptr Symbol* should not be
possible - let's enforce this at the compiler level instead of using
VERIFY() (and already dereference Symbol pointers at the call site).
2021-06-25 22:01:23 +01:00
Andreas Kling d436d6d565 LibJS: Rename ScriptFunction::m_parent_scope => m_environment
This is for the [[Environment]] slot so let's have a matching name. :^)
2021-06-25 21:22:37 +02:00
Andreas Kling 667bba2410 LibJS: Add the Function.[[ThisMode]] field
This is not a behavioral change in itself, just prep work for future
spec-compliance changes.
2021-06-25 21:15:04 +02:00
Andreas Kling b650d11dd3 LibJS: FunctionEnvironment.[[FunctionObject]] is the *invoked* function
We were setting the wrong [[FunctionObject]] on the environment when
going through ProxyObject and BoundFunction.
2021-06-25 20:38:43 +02:00
Andreas Kling 08d2ea3fac LibJS: Rename the context in Call/Construct ops to "callee context"
This matches what the spec calls them.
2021-06-25 20:38:43 +02:00
Andreas Kling 06787410ad LibJS: Make assertion in BindThisValue mirror the spec exactly :^) 2021-06-25 20:38:43 +02:00