Commit graph

18182 commits

Author SHA1 Message Date
davidot
3b1c3e574f LibJS: Handle empty named export
This is an export which looks like `export {} from "module"`, and
although it doesn't have any real export entries it should still add
"module" to the required modules to load.
2022-09-02 02:07:37 +01:00
davidot
f75c51b097 LibJS: Allow full ModuleExportName in namespace
This means we should accept a string after 'export * as '.
2022-09-02 02:07:37 +01:00
demostanis
68c6161f25 LibMarkdown: Add newline and remove ANSI escape after code blocks
Also make clang-tidy happy by making line a const&
2022-09-01 23:36:23 +00:00
Timothy Slater
5064b581ee LibGUI: Disable increment/decrement buttons on SpinBox based on value
When the value for a SpinBox equals the max, disable the increment
button. Functionally, clicking the button doesn't do anything because
the set_value() clamps the value to min/max and updates the textbox.
However it is still nice to indicate to the user that they've reached
the max. Same goes for minimum value and the decrement button.
2022-09-01 17:47:49 +01:00
Timothy Slater
e43e412fc8 LibGUI: Improve SpinBox usability
Previously the value of the SpinBox is re-evaluated after every change
to the TextBox control. This leads to very unintuitive behavior such as
the user deleting the contents of the box and it having no
visible effect. This happens because the TextBox no longer has a valid
number and so gets reset to the current m_value of the SpinBox.

By defering the update of to the SpinBox value until focus leaves the
control we provide a much more intuitive experience with the text box.
We do still validate when a user types something that it parses to an
int. If it does not we delete the most recent character. This in effect
prevents non-numeric numbers from being entered.

Upon losing focus the value will be checked. If empty we set the SpinBox
value to the minimum allowed value.
2022-09-01 17:47:49 +01:00
Karol Kosek
5478409025 LibGfx: Fallback to a default scaled bitmap if the upscaled one failed
This makes cursors in a 2x Display Scale without a special upscaled
version (such as a Hand cursor) display the 1x version instead.
2022-09-01 14:27:07 +01:00
Timothy Slater
f2da577e77 PixelPaint: Change repeated code into a loop for Wand Select Tool 2022-08-31 18:19:46 +01:00
Karol Kosek
a0ef00cab2 LibGUI: Don't accept drag events in AbstractView if it's not editable
With a new DragCopy cursor icon being used on accepted events, this
caused a 'false assumption' that everything can be dropped into
AbstractView.

This will now only happen if the View is editable, which still isn't
perfect, but at least the Settings app will no longer change cursors.
Also note that we won't get "drag move" events as the comment below
says, which disables automatic scrolling when dragging an element.
2022-08-31 17:29:44 +01:00
Karol Kosek
1d9ec8bd56 LibVT: Accept supported drag enter events 2022-08-31 17:29:44 +01:00
Karol Kosek
f1aa03b779 WindowServer: Place drag and drop overlay at the cursor position
... instead of in the center of the cursor bitmap.

It doesn't make much of a difference, as the default cursor hotspot is
center. But since now we switch between a normal Drag cursor and
DragCopy one that has set hotspot, this caused the overlay to shake.
2022-08-31 17:29:44 +01:00
Karol Kosek
d4aff36875 WindowServer: Include window frames when sending drag events
Previously, the cursor would use a default cursor on window frames such
as the title bar and menu bar, which was not quite correct as drop
events were still handled there.
2022-08-31 17:29:44 +01:00
Karol Kosek
2e244fc85b WindowServer+LibGUI: Change cursor icon if DragEnter event was accepted 2022-08-31 17:29:44 +01:00
Karol Kosek
e5674d9666 Base+WindowServer+LibGfx: Add new DragCopy Cursor
The purpose of this cursor is to indicate if a current dragged object
(file, Spreadsheet cell) can be dropped onto a widget.
2022-08-31 17:29:44 +01:00
Timothy Slater
25ac38cac1 PixelPaint: Make erase_selection work for non-rectangular selections
Layer::erase_selection used to erase the entire bounding box of the
selection. With the add/subtract merge modes for the selection tool it
is possible to create selections which are not rectangular. This leads
to deleting pixels that were not selected.

This change adjusts the erase behavior to walk the selection rect and
check if a pixel is selected or not before deleting.
2022-08-31 16:59:22 +01:00
Jelle Raaijmakers
a373542f4c Profiler: Display correctly rounded percentages as '#.##%' 2022-08-31 16:57:40 +01:00
Timothy Slater
fcf86b07a5 PixelPaint: Add Wand Select Tool
Wand Selection tool uses similar logic to the Bucket Tool. Flood filling
and threshold calculations to determine the affected area just in this
case we do not set the pixels of the selected area, instead we use
those pixels to alter the selection mask.

In the future we can probably abstract out the shared flood logic so
both tools can share the code.
2022-08-31 16:30:23 +02:00
Timothy Slater
066c5acee1 PixelPaint: Change BucketTool flood fill algorithm
This resolves some cases where the existing filling algorithm could get
stuck in a recursion loop and evenutally overflow the stack.
2022-08-31 16:26:09 +02:00
Timothy Slater
0506f4eef8 PixelPaint: Account for alpha in color distance calculation
This fixes an issue where BucketTool would consider "black"
and "transparent" the same color.
2022-08-31 16:26:09 +02:00
Hendiadyoin1
21ae882cfd LibJS: Implement SuperCall for the Bytecode-VM 2022-08-31 15:22:36 +01:00
Hendiadyoin1
25be67299e LibJS: Use builder.join in to_string_impl()s where applicable 2022-08-31 15:22:36 +01:00
Skye Sprung
4370e8f80a HackStudio: Warn of unsaved changes before making a new project
Before, the warning dialog would be opened after the NewProjectDialog,
leading to focus-fighting by the two windows. This fixes that and makes
the action more consistent with the standard serenity way of handling
unsaved changes by asking before the NewProjectDialog is brought up.
The way this is achieved avoids having to rewrite open_project as well.
2022-08-31 15:21:03 +01:00
Skye Sprung
a7b7003376 HackStudio: Fix crash when opening or creating with open empty file
This commit fixes a crash that would occur due to an unnamed file being
automatically saved via EditorWrapper::save(). Now, we throw up a
FilePicker::get_save_filepath.
2022-08-31 15:21:03 +01:00
Crax97
7d544344ca PixelPaint: Add point_position_to_preferred_cell to RectangleSelectTool
Specializing point_position_to_preferred_cell for the
RectangleSelectTool as it selects a new cells with a rounding
behavior instead of a flooring behavior
2022-08-31 12:20:55 +02:00
Crax97
3d756e89c8 PixelPaint: Ask the current tool for the preferred pixel location
When handling mouse events, different tools may want to interact
with a different pixel in the image for the same input position.
2022-08-31 12:20:55 +02:00
Crax97
c9fb380490 PixelPaint: Execute mousemove_event early return check before
This is done to allow querying the current active tool inside the
event_with_pan_and_scale_applied and event_adjusted_for_layer
functions without risking a null pointer dereference
2022-08-31 12:20:55 +02:00
Crax97
3037f5b183 PixelPaint: Add point_position_to_preferred_cell method to Tool
This method is used to point a position at the preferred pixel of
the image. Certain tools may want to specify a different preferred
pixel for the same input position.
2022-08-31 12:20:55 +02:00
Crax97
059a9c71a0 LibGfx: Add Point::to_ceiled method for getting a ceiled Point 2022-08-31 12:20:55 +02:00
Adam Jakubek
aa466723eb FileManager: Navigate to parent dir when current location is removed
When the location currently displayed in FileManager is removed, find
the nearest existing parent path and open it in the window.
Without the fix, the FileManager window remained in the deleted
directory.

Changing the path in 'DirectoryView' object will automatically update
other components in the FileManager (breadcrumb bar, directory tree
view).
2022-08-31 10:32:41 +01:00
Adam Jakubek
f7e6593910 LibGUI: Fix assertion when handling removal of FileSystemModel's root
This commit fixes FileSystemModel behaviour when the root path of the
model has been deleted.
In this case, the model index resolved for the root path is invalid and
passing it to 'begin_delete_rows' would trigger assertion failure.

Instead of deleting all children rows one by one, we simply invalidate
the whole model.
2022-08-31 10:32:41 +01:00
Timothy Flynn
c477425b9b LibJS: Create DurationFormat's ListFormat object with type and style
This is a normative change in the Intl.DurationFormat spec. See:
https://github.com/tc39/proposal-intl-duration-format/commit/1304e4b
2022-08-30 14:26:11 -04:00
Timothy Flynn
127b28c940 LibJS: Use numeric style if the previous style was numeric or 2-digit
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/3a46ee3
2022-08-30 14:26:11 -04:00
Timothy Flynn
cab1cce522 LibJS: Update DurationFormat AO text to align with ECMA-402 and Temporal
These are editorial changes in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/71b291b
https://github.com/tc39/proposal-intl-duration-format/commit/d0cc6fa
https://github.com/tc39/proposal-intl-duration-format/commit/d4b35bb
2022-08-30 14:26:11 -04:00
Timothy Flynn
a86b840c64 LibJS: Rename DurationFormat's DurationSign to DurationRecordSign
This is an editorial change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/f947239
2022-08-30 14:26:11 -04:00
Timothy Flynn
f8c51fec1d LibJS: Align ToDurationRecord with ToTemporalDurationRecord
This is an editorial change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/527ea58
2022-08-30 14:26:11 -04:00
Timothy Flynn
a28ff92106 LibJS: Mark PartitionDurationFormatPattern as infallible
This is an editorial change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/cea3b68
2022-08-30 14:26:11 -04:00
Timothy Flynn
aabd06722f LibJS: Change GetDurationUnitOptions to require a string for prevStyle
This is an editoral change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/62ee645
2022-08-30 14:26:11 -04:00
Timothy Flynn
1778462d97 LibJS: Resolve FIXMEs in DurationFormat's PartitionDurationFormatPattern
These are normative changes in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/e2e18d1
https://github.com/tc39/proposal-intl-duration-format/commit/f1e8ed3
https://github.com/tc39/proposal-intl-duration-format/commit/2ed31b8
https://github.com/tc39/proposal-intl-duration-format/commit/2d51d64
https://github.com/tc39/proposal-intl-duration-format/commit/64cc5db
https://github.com/tc39/proposal-intl-duration-format/commit/a1d7876
https://github.com/tc39/proposal-intl-duration-format/commit/47a3a69
https://github.com/tc39/proposal-intl-duration-format/commit/3e9358e
https://github.com/tc39/proposal-intl-duration-format/commit/f4ecb46
https://github.com/tc39/proposal-intl-duration-format/commit/b454c8c
2022-08-30 14:26:11 -04:00
Timothy Flynn
d57b92da09 LibJS: Default to "short" for DurationFormat's style option
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/b289494
2022-08-30 14:26:11 -04:00
Timothy Flynn
765d016670 LibJS: Default to 0 for DurationFormat's fractionalDigits option
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/ac7e184
2022-08-30 14:26:11 -04:00
Timothy Flynn
2fb332da7b LibJS: Update spec steps to validate DurationFormat's numberingSystem
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/63a9202
2022-08-30 14:26:11 -04:00
thankyouverycool
cce9172cd4 Applications+DevTools: Remove fixed sizes from Splitters
And adjust some GML properties. Since a808cfa, splitters grow
opportunistically. Setting them to fixed sizes now quite literally
fixes them in place. Fixes immovable splitters missed in the
aforementioned commit.
2022-08-30 16:28:44 +01:00
Linus Groh
6cedb1b9d9 LibJS: Implement $262.evalScript() according to the given algorithm
test262's INTERPRETING.md specifies the exact steps for this function,
so let's shuffle some things around and add "spec" comments.

Most importantly this now returns the result of the evaluated script,
which at least one test relies on:
https://github.com/tc39/test262/blob/main/test/built-ins/Proxy/revocable/tco-fn-realm.js
2022-08-30 12:00:04 +01:00
Linus Groh
69415f0608 LibJS: Make string_to_bigint() a standalone function
This now matches the newly added string_to_number().
2022-08-30 10:30:54 +01:00
Linus Groh
15e3a99250 LibJS: Trim non-ASCII whitespace as well in StringToBigInt
This was never caught since the original implementation AFAICT, and
isn't being covered by test262 either:
https://github.com/tc39/test262/issues/1354
2022-08-30 10:30:43 +01:00
Linus Groh
c88c33dc22 LibJS: Trim non-ASCII whitespace as well in StringToNumber
This regressed in f4b3bb5.
2022-08-30 10:20:45 +01:00
Slappy826
f4b3bb519f LibJS: Handle non-decimal integer literals in Value::to_number
Implements support for parsing binary and octal literals, and fixes
instances where a hex literal is parsed in ways the spec doesn't
allow.
2022-08-30 01:00:48 +01:00
davidot
123cdfa1f1 LibJS: Properly initialize the global object for $262.createRealm 2022-08-29 22:44:35 +01:00
Timothy Flynn
48cb15283a LibRegex: Explicitly check if a character falls into a table-based range
Previously, for a regex such as /[a-sy-z]/i, we would incorrectly think
the character "u" fell into the range "a-s" because neither of the
conditions "u > s && U > s" or "u < a && U < a" would be true, resulting
in the lookup falling back to assuming the character is in the range.

Instead, first explicitly check if the character falls into the range,
rather than checking if it falls outside the range. If the explicit
checks fail, then we know the character is outside the range.
2022-08-29 16:34:47 -04:00
djwisdom
27f5a18ce6 HexEditor: Add Help->Manual entry in Menu 2022-08-29 09:25:29 +01:00
Andreas Kling
35c9aa7c05 LibJS: Hide all the constructors!
Now that the GC allocator is able to invoke Cell subclass constructors
directly via friendship, we no longer need to keep them public. :^)
2022-08-29 03:24:54 +02:00
Andreas Kling
d54ba587f3 LibJS: Make Heap a friend of everyone who uses JS_CELL
This will allow Heap to invoke non-public constructors when allocating
new cells.
2022-08-29 03:24:54 +02:00
Andreas Kling
49fd92d92a LibJS: Make JS_OBJECT and JS_ENVIRONMENT forward to JS_CELL 2022-08-29 03:24:54 +02:00
Andreas Kling
6e973ce69b LibJS: Add JS_CELL macro and use it in all JS::Cell subclasses
This is similar to what we already had with JS_OBJECT (and also
JS_ENVIRONMENT) but sits at the top of the Cell inheritance hierarchy.
2022-08-29 03:24:54 +02:00
Jelle Raaijmakers
94f016b363 LibGL+LibGPU+LibSoftGPU: Report texture env add extension
The Quake 3 port makes use of this extension to determine a more
efficient multitexturing strategy. Since LibSoftGPU supports it, let's
report the extension in LibGL. :^)
2022-08-28 23:45:43 +01:00
Linus Groh
d53a369e7f LibJS: Implement ShadowRealmConstructor::construct() closer to spec
Defer creation of the global object to Realm::set_global_object(), and
use the newly added set_default_global_bindings() AO as intended.
2022-08-28 19:34:10 +01:00
Linus Groh
040e3abb1d LibJS: Implement SetDefaultGlobalBindings as a standalone function
Instead of hardcoding all the property definitions in GlobalObject's
initialize() function, make it the standalone AO it is supposed to be
that can then be used by other global objects that don't inherit from
JS::GlobalObject.
2022-08-28 19:34:10 +01:00
Linus Groh
e3804e6426 LibJS: Move construction of GlobalObject native functions to Intrinsics
This will later allow global objects not inheriting from the regular
JS::GlobalObject to pull in these functions without having to implement
them from scratch. The primary use case here is, again, a wrapper-less
HTML::Window in LibWeb :^)

Allocating these upfront now allows us to get rid of two hacks:

- The GlobalObject assigning Intrinsics private members after finishing
  its initialization
- The GlobalObject defining the parseInt and parseFloat properties of
  the NumberConstructor object, as they are supposed to be identical
  with the global functions of the same name
2022-08-28 19:34:10 +01:00
Linus Groh
52543fc771 LibJS+LibWeb: Let Realm store a plain Object for [[GlobalObject]]
This removes the requirement of having a global object that actually
inherits from JS::GlobalObject, which is now a perfectly valid scenario.

With the upcoming removal of wrapper objects in LibWeb, the HTML::Window
object will inherit from DOM::EventTarget, which means it cannot also
inherit from JS::GlobalObject.
2022-08-28 16:36:56 +01:00
Linus Groh
72730422bb LibJS: Remove Shape::global_object() and Object::global_object()
Same reason as in commit 275dea9.
2022-08-28 16:36:56 +01:00
Linus Groh
4f436bd323 LibJS: Let NewGlobalEnvironment take a plain Object
The object is passed directly to NewObjectEnvironment, which has no
requirement for this being a JS::GlobalObject. This is needed for the
next change, which will make Realm store a plain Object as for the
global object as well.
2022-08-28 16:36:56 +01:00
Linus Groh
cfa5885855 LibJS: Turn initialize_global_object() into a regular initialize()
There's nothing special about global object initialization anymore, this
can just work the same way as for any other object now.
2022-08-28 16:36:56 +01:00
Linus Groh
867ad03995 LibJS: Move Console ownership from GlobalObject to ConsoleObject
GlobalObject is now a regular object with no special properties :^)
2022-08-28 16:36:56 +01:00
Linus Groh
78eca3ae64 LibJS: Move ConsoleObject construction from GlobalObject to Intrinsics
This will allow us to move the underlying console from GlobalObject to
ConsoleObject without still having to do a 'console' property lookup on
the GlobalObject.
2022-08-28 16:36:56 +01:00
Linus Groh
d35f53c344 LibJS: Remove Console's reliance on GlobalObject
This was not being used for anything meaningful, just store a reference
to the VM directly.
2022-08-28 16:36:56 +01:00
thankyouverycool
1dd9086e1a WindowServer: Remove misbehavior conditions for modals
This was too restrictive and there are already UI elements that rely
on this behavior. Now Blocking modals will preempt interaction with
all windows in their modal chain except those descending from them.
Fixes crashing in FilePicker when permission is denied.
2022-08-28 16:04:35 +01:00
thankyouverycool
b2b68a7551 WindowServer: Continue processing ongoing resizes after tiling
Just like tiling behavior during ongoing moves, now resizing
does not finish until a MouseUp event, letting you drag out of
undesired tile states. Resize tiling only works with vertical
and horizontal cursors now to cut down on unintentional tiling
from the corners.
2022-08-28 16:04:35 +01:00
thankyouverycool
38e13772e0 LibGUI: Make CommandPalette and EmojiInputDialog passive modals
Now they can be dismissed by clicking anywhere outside themselves,
including on their parent windows. This is a better default for
them since they don't have title bars to flash, and it's more
consistent with other frameless windows in the system.
2022-08-28 16:04:35 +01:00
Kenneth Myhra
54435dea59 LibC: Add stubs for 'removexattr()' and friends
This add stubs for 'removexattr()', 'lremovexattr()', and
'fremovexattr()'.

These are needed by GLib version 2.73.3.
2022-08-28 15:42:14 +01:00
Andreas Krohn
8aca5ab3b3 PixelPaint: Cropping to content with moved layers was broken
When cropping to content with a layer not positioned at 0,0 the moved
layers content disappeared and the layers position was not updated
according to the crop offset.

There's probably an easier/more efficient way, but for my testcase this
improves the behavior.
2022-08-28 11:22:42 +01:00
Kevin Meyer
6e006be9e6 PixelPaint: Fix const correctness of Selection::in_interactive_selection 2022-08-28 10:14:18 +01:00
davidot
ba5bcb67a5 LibWeb: Implement the HostEnsureCanAddPrivateElement JS hook
Also added a local test for ensuring this behavior since it is unique to
browsers. Since we don't actually use WindowProxy anywhere yet we just
test on location for now.
2022-08-27 20:33:27 +01:00
davidot
cd763de280 LibJS+LibUnicode: Move some constant arrays to a separate header
Since LibUnicode depends on this data it used to include
Intl/AbstractOperations which in turn includes a number of other LibJS
headers. By moving this to its own header with minimal includes we can
save on rebuilding LibUnicode for unrelated LibJS header changes.
2022-08-27 10:55:44 -04:00
Linus Groh
dfb7588d30 LibJS: Remove GlobalObject::{set_,}associated_realm() 2022-08-27 11:29:10 +01:00
Linus Groh
61bd9fef7d LibJS+LibWeb: Remove last uses of GlobalObject::associated_realm() 2022-08-27 11:29:10 +01:00
Linus Groh
50428ea8d2 LibJS: Move intrinsics to the realm
Intrinsics, i.e. mostly constructor and prototype objects, but also
things like empty and new object shape now live on a new heap-allocated
JS::Intrinsics object, thus completing the long journey of taking all
the magic away from the global object.
This represents the Realm's [[Intrinsics]] slot in the spec and matches
its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of
architecture.

In the majority of cases it should now be possibly to fully allocate a
regular object without the global object existing, and in fact that's
what we do now - the realm is allocated before the global object, and
the intrinsics between both :^)
2022-08-27 11:29:10 +01:00
Jelle Raaijmakers
84c4b66721 LibGL+LibGPU+LibSoftGPU: Implement texture pixel format support
In OpenGL this is called the (base) internal format which is an
expectation expressed by the client for the minimum supported texel
storage format in the GPU for textures.

Since we store everything as RGBA in a `FloatVector4`, the only thing
we do in this patch is remember the expected internal format, and when
we write new texels we fixate the value for the alpha channel to 1 for
two formats that require it.

`PixelConverter` has learned how to transform pixels during transfer to
support this.
2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
6c80d12111 LibGPU+LibSoftGPU: Add PixelFormat::Intensity 2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
e615af886e LibGL: Report color buffer bits instead of texture bits
For `GL_RED_BITS`, `GL_GREEN_BITS`, `GL_BLUE_BITS` and `GL_ALPHA_BITS`
we were reporting the values we use in LibSoftGPU for textures. This
fixes these context parameters to actually report the color buffer
bits.
2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
eb7c3d16fb LibGL+LibGPU+LibSoftGPU: Implement flexible pixel format conversion
A GPU (driver) is now responsible for reading and writing pixels from
and to user data. The client (LibGL) is responsible for specifying how
the user data must be interpreted or written to.

This allows us to centralize all pixel format conversion in one class,
`LibSoftGPU::PixelConverter`. For both the input and output image, it
takes a specification containing the image dimensions, the pixel type
and the selection (basically a clipping rect), and converts the pixels
from the input image to the output image.

Effectively this means we now support almost all OpenGL 1.5 formats,
and all custom logic has disappeared from:
  - `glDrawPixels`
  - `glReadPixels`
  - `glTexImage2D`
  - `glTexSubImage2D`

The new logic is still unoptimized, but on my machine I experienced no
noticeable slowdown. :^)
2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
d7cfdfe633 LibGL: Implement GL_NORMAL_ARRAY_TYPE context parameter
This is used by the Grim/Monkey4 engine in ScummVM.
2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
73f7f4656c LibSoftGPU: Make ownership_token type in Image consistent
This is now the same as defined in `GPU::Image`.
2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
3279c25553 LibGfx: Allow non-const indexing into VectorN 2022-08-27 12:28:05 +02:00
Jelle Raaijmakers
07ae5514ae LibGL: Rename units to all singular 2022-08-27 12:28:05 +02:00
Andreas Kling
e65990f7a3 LibWeb: Treat cyclic percentage max-size as "auto" on the flex container
This allows things like `max-width: 100%` to work on flex containers
whose containing blocks themselves have automatic width.
2022-08-27 12:19:37 +02:00
Linus Groh
92295b9584 LibWeb: Remove one remaining use of JS::InvalidCharacterError 2022-08-26 23:19:15 +01:00
Linus Groh
adc5ac35b7 LibJS: Remove InvalidCharacterError
This a Web API and not part of ECMA-262. Never has been.
2022-08-26 22:26:03 +01:00
davidot
6989f304bc LibJS: Remove now unnecessary i32 casts when constructing BigIntegers 2022-08-26 19:18:26 +01:00
davidot
791855deab LibCrypto+LibJS: Remove the create_from methods from BigInteger
Instead we just use a specific constructor. With this set of
constructors using curly braces for constructing is highly recommended.
As then it will not do too many implicit conversions which could lead to
unexpected loss of data or calling the much slower double constructor.

Also to ensure we don't feed (Un)SignedBigInteger infinities we throw
RangeError earlier for Durations.
2022-08-26 19:18:26 +01:00
davidot
528891bf69 LibCrypto: Add a constructor to (Un)SignedBigInteger taking a double
For now this will assume that the double given is exactly representable
as an integer, so no NaN, infinity or rounding.
2022-08-26 19:18:26 +01:00
davidot
c87d10365b LibCrypto: Make the constructors of (Un)SignedBigInteger templated
This means it can take any (un)signed word of size at most Word.
This means the constructor can be disambiguated if we were to add a
double constructor :^).

This requires a change in just one test.
2022-08-26 19:18:26 +01:00
davidot
48ac6ba372 LibJS: Use the proper to_double method in NumberConstructor 2022-08-26 19:18:26 +01:00
davidot
77d71a5ffd LibCrypto: Add a rounding mode to UnsignedBigInteger::to_double
This allows using different options for rounding, like IEEE
roundTiesToEven, which is the mode that JS requires.

Also fix that the last word read from the bigint for the mantissa could
be shifted incorrectly leading to incorrect results.
2022-08-26 19:18:26 +01:00
Robbie Vanbrabant
26a3b42a15 LibGUI: Add visual line mode to VimEditingEngine
Applications using the Vim emulation engine now support line-wise text
selection.

We already have support for character-wise text selection, by pressing
`v` from normal mode.

However now can also trigger line-wise text selection by pressing
`shift+v` from normal mode, and then using vertical motion commands
(e.g. `j` or `k`) to expand the selection. This is a standard vim
feature.

In visual line mode the following operations are supported:

  * `escape`: back to normal mode
  * `u`: convert to lowercase
  * `U`: convert to uppercase
  * `~`: toggle case
  * `ctrl+d`: move down by 50% of page height
  * `ctrl+u`: move up by 50% of page height
  * `d` or `x`: delete selection
  * `c`: change selection
  * `y`: copy selection
  * `page up`: move up by 100% of page height
  * `page down`: move down by 100% of page height

Notably I didn't implement pressing `v` to go to regular
(character-wise) visual mode straight from visual line mode. This is
tricky to implement in the current code base, and there's an
alternative, which is to take a detour via normal mode.
2022-08-26 12:50:30 +02:00
martinfalisse
f8e82da4b4 LibWeb: Handle unknown values in grid-template-*
This commit fixes a bug found when passing exotic values in the
grid-template-columns (or grid-template-rows) which are not yet
supported.

The bug seems to have been something like:
grid-template-columns: 0 minmax(0, calc(10px - var(--some-color)));
2022-08-26 12:48:57 +02:00
thankyouverycool
3dd522a109 SpreadSheet: Pass parent window when constructing About action
Fixes About dialog not blocking the app's main window.
2022-08-26 12:48:05 +02:00
thankyouverycool
7b2becad52 FileSystemAccessServer: Set dummy child to WindowMode::Passive
so Dialogs can join the modal chain of the window parenting them.
Fixes apps that use FileSystemAccess to sandbox FilePicker not
respecting its blocking effect.
2022-08-26 12:48:05 +02:00
thankyouverycool
aa045a9fdf WindowServer: Always restore modal chain when clicking a window
Refactors restore helper into move_to_front_and_make_active().
Fixes not bringing all modal children to the front when any modal
child or its modeless parent is clicked.
2022-08-26 12:48:05 +02:00
thankyouverycool
d815f659cc LibGUI+Taskbar+WindowServer: Prevent minimization when blocked
This was intentionally enabled with WindowModes as a new Taskbar
convenience, but on second thought, it doesn't add up visually.

Taskbar buttons show blockers' context menus when available,
which is a bit confusing when the window isn't visible. The
modeless window's disabled context menu options and inactive title
bar also contradict the button. So, this patch reenables the
restriction for now. Blocking modals you don't want to answer to
immediately can still be tucked away on another workspace.
2022-08-26 12:48:05 +02:00
thankyouverycool
18b111b802 WindowServer: Ignore modal blocking if capturing input
This exception is necessary for ComboBoxes used in some blocking
Dialogs. CaptureInput is now the only mode which can spawn from
a blocking modal and it won't accept any children of its own.
2022-08-26 12:48:05 +02:00
Jean Lourenço
bab8bd143f Chess: Highlight piece origin square when dragging piece 2022-08-26 09:53:13 +01:00
Andreas Kling
49deb936be PixelPaint: Make selection changes undoable
Using the Rectangle Select Tool will now generate undo/redo commands
like any other tool. :^)
2022-08-26 01:04:52 +02:00
Andreas Kling
d571159aeb PixelPaint: Move selection from ImageEditor to Image
This is preparation for making selection state undoable.
2022-08-26 01:04:52 +02:00
Andreas Kling
67596d9546 PixelPaint: Move "marching ants" painting logic to ImageEditor
Since this code needs to look at a bunch of ImageEditor state anyway,
it makes more sense for it to live in ImageEditor.
2022-08-26 01:04:52 +02:00
Andreas Kling
e6d860f2fe PixelPaint: Round mouse event coordinates instead of truncating
This makes the rectangle select tool feel a lot better when zoomed in.
2022-08-26 01:04:52 +02:00
Andreas Kling
d32f7112dc LibWeb: Intentionally leak the main thread JS VM
This way we avoid doing an expensive full GC on exit.
2022-08-26 01:04:51 +02:00
Linus Groh
36225c0ae7 LibJS: Allow undefined for calendar in MaybeFormatCalendarAnnotation
This is an editorial change in the Temporal spec.

Now that this is spec'd as either an Object or undefined, we can change
the parameter type from arbitrary JS::Value to JS::Object*.

See: https://github.com/tc39/proposal-temporal/commit/cdfcffd
2022-08-25 23:41:09 +01:00
Linus Groh
741cc08221 LibJS: Use fully spec'd algorithm for ToISOWeekOfYear
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/33b62a3
2022-08-25 23:41:09 +01:00
Linus Groh
b438839fcc LibJS: Reject ambiguous time string even with a calendar
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/5e2afb9
2022-08-25 23:41:09 +01:00
Linus Groh
2cf5f5c278 LibJS: Remove unused nonterminals from the ISO8601 parser
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fe9ef00
2022-08-25 23:41:09 +01:00
Linus Groh
42452a81a2 LibJS: Simplify TimeSpecWithOptionalTimeZoneNotAmbiguous
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/77b0163
2022-08-25 23:41:09 +01:00
Linus Groh
f29c7cab16 LibJS: Remove exception rule from TimeZoneIANAName production
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6a758d6
2022-08-25 23:41:09 +01:00
MacDue
965237efb8 LibWeb: Don't return an opaque origin for file:// URLs
The protocol of the origin is used for checking if the a file://
iframe is allowed to be loaded (a document with a file:// origin
can load other files in iframes).

This used to be the case, but was changed in
6e71e400e6, which broke file:// iframes.
2022-08-26 00:21:10 +02:00
MacDue
8d2c2f7c52 LibWeb: Determine the origin when navigating across documents 2022-08-26 00:21:10 +02:00
Luke Wilde
9643a5c63f LibJS: Accept and ignore calendar annotation in Instant strings
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3cd9669
2022-08-25 23:07:08 +01:00
Luke Wilde
54bb6bf2c0 LibJS: Avoid calling ToString on calendar when calendarName is "never"
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/6122f4e
- https://github.com/tc39/proposal-temporal/commit/cf586bc
2022-08-25 21:11:23 +01:00
Timothy Flynn
6309b8773d LibJS: Guard IntegerIndexedElementSet with receiver check
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/3620f11
2022-08-25 19:50:04 +01:00
Timothy Flynn
a803d9226f LibJS: Always access RegExp flags by its "flags" property
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/35b7eb2

Note there is a bit of weirdness between the mainline spec and the set
notation proposal as the latter has not been updated with this change.
For now, this implements what the spec PR and other prototypes indicate
how the proposal will behave.
2022-08-25 16:39:45 +01:00
Timothy Flynn
9a1f55afe5 LibJS: Fix spec steps and links for RegExp set notation proposal 2022-08-25 16:39:45 +01:00
Timothy Flynn
6af9bf1a1e LibUnicode: Fix compilation when ENABLE_UNICODE_DATABASE_DOWNLOAD is OFF 2022-08-25 16:20:22 +01:00
martinfalisse
79a630adef LibWeb: Begin formatting the grid
This is a really starter attempt at formatting the grid. It doesn't yet
take into account the computed_values of grid-template-rows, nor the
values in grid-column-start and like CSS properties.

But these changes are a start and make it so the examples in
display-grid.html work.

To be fleshed out further..
2022-08-25 13:47:48 +02:00
martinfalisse
7bb3a8d646 LibWeb: Parse grid-column and grid-row CSS values 2022-08-25 13:47:48 +02:00
martinfalisse
44d08b81b7 LibWeb: Parse grid-column-start and related CSS properties
Parse grid-column-start, end, and the equivalent for rows.
2022-08-25 13:47:48 +02:00
martinfalisse
92a00648b1 LibWeb: Parse grid-template-columns and grid-template-rows
Add functionality to begin parsing grid-template-columns and
grid-template-rows. There are still things to be added, like parsing
functions, but I would say a couple of the major points are already
adressed like length, percentage, and flexible-length.
2022-08-25 13:47:48 +02:00
martinfalisse
c40dd9ee78 LibWeb: Add GridTrackPlacementShorthandStyleValue
Add GridTrackPlacementShorthandStyleValue for the use of grid-column and
grid-row.
2022-08-25 13:47:48 +02:00
martinfalisse
08b832eb69 LibWeb: Add GridTrackPlacementStyleValue
Add GridTrackPlacementStyleValue for the use of CSS properties
grid-column-start, grid-column-end, grid-row-start, grid-row-end.
2022-08-25 13:47:48 +02:00
martinfalisse
0148260b5f LibWeb: Add GridTrackSizeStyleValue
Add GridTrackSizeStyleValue for the use of CSS properties
grid-template-columns, grid-template-rows.
2022-08-25 13:47:48 +02:00
martinfalisse
ca286fc220 LibWeb: Add GridTrackPlacement for grid-[column/row]-[start/end]
Add GridTrackPlacement to use with grid-column-start and related CSS
properties.
2022-08-25 13:47:48 +02:00
martinfalisse
fc36970973 LibWeb: Add GridTrackSize class for grid-template-*
Add GridTrackSize to be used with grid-template-column and
grid-template-row.
2022-08-25 13:47:48 +02:00
martinfalisse
e4c5799026 LibWeb: Add GridFormattingContext 2022-08-25 13:47:48 +02:00
martinfalisse
e4541d83d3 LibWeb: Parse grid display value 2022-08-25 13:47:48 +02:00
MacDue
b609dd7348 Eyes: Add an option to show/hide the window frame
This works the same as in the Cube demo, and now allows enjoying
the eyes without any obstructions :^)

The window frame can now be disabled with the -h/--hide-window
command-line option, or via toggle in the GUI.
2022-08-25 13:42:17 +02:00
faxe1008
21358d8a5f PixelPaint: Reduce verbosity of crop to content feature
This patch reduces the repetitiveness of the crop to content feature
implementation.
2022-08-25 13:38:31 +02:00
thankyouverycool
d5de9bcc51 Applications: Use modeless windows in some apps
Browser, Spreadsheet and Charactermap now open child windows
modelessly.
2022-08-25 13:28:50 +02:00
thankyouverycool
35a230f974 LibGUI+Taskbar+WindowServer: Remove mode and parent methods from Taskbar
Taskbar only needs a modeless parent and the activity state of the
modal chain to update buttons.
2022-08-25 13:28:50 +02:00
thankyouverycool
d54dc22362 WindowServer: Default to Desktop when picking a new active window 2022-08-25 13:28:50 +02:00
thankyouverycool
af706d081c WindowServer: Invalidate new and previous active input window frames
Fixes shared active title bar theming not updating for capturing
modals.
2022-08-25 13:28:50 +02:00
thankyouverycool
6f316d59f4 WindowServer: Restore modal chains from the Taskbar and Switcher
And only show modeless windows in WindowSwitcher.
2022-08-25 13:28:50 +02:00
thankyouverycool
5a0472d8d2 WindowServer: Use nearest modeless window for modal Taskbar rects
Modeless windows are guaranteed Taskbar buttons which lets us
simplify getting the proper taskbar rect for modals.
2022-08-25 13:28:50 +02:00
thankyouverycool
df2f479810 WindowServer: Don't move child windows in unison with their parents
This was a cludge for ComboBox ListView windows when they were first
implemented. The behavior is no longer needed and not very ergonomic
when moving Normal windows around.
2022-08-25 13:28:50 +02:00
thankyouverycool
2b2c317c2d WindowServer: Don't let modals minimize themselves
But do allow them to remain minimizable by a parent. This is a nice
ergonomics fix to allow a parent window to quickly minimize and
restore all its modal children.
2022-08-25 13:28:50 +02:00
thankyouverycool
788b16cbf8 WindowServer: Replace modal stacks with modal chains
And apply modal effects on move_to_front_and_make_active()

Instead of building a vector of windows every time we want to
loop over a group of related modals, simply recurse through
their ancestory. This lineage is now called a modal chain. Modal
chains begin at the first modeless parent, and a new chain
starts at every modeless child. This lets apps spawn child windows
independent of the main window's modal effects, restore state,
and workspace, yet still remain descendants.

Looping through a modal chain is recursive and includes the
modeless window which begins it.
2022-08-25 13:28:50 +02:00
thankyouverycool
4c7f95e2f8 LibGUI+WindowServer+Apps: Replace Accessory Windows
with the CaptureInput WindowMode. This mode will serve the same
function as accessories: redirecting input while allowing parent
windows to remain active.
2022-08-25 13:28:50 +02:00
thankyouverycool
0d4fd4e2a6 LibGfx+LibGUI+WindowServer+Apps+Demos: Replace ToolWindows
with the RenderAbove WindowMode. This mode will ensure child
windows always draw above their parents, even when focus is lost.
RenderAbove modals are automatically themed the same as the old
ToolWindows. Fixes ToolWindows rendering above ALL normal windows,
regardless of parent. We can't rely on WindowType to create these
sort of effects because of WindowManager's strict display hierarchy.
2022-08-25 13:28:50 +02:00
thankyouverycool
589572cfa4 LibGUI+WindowServer: Introduce WindowModes
Previously, Windows only understood blocking modality: Windows were
either modal, i.e., in a blocking state, or not. Windows could also
be set as Accessories or ToolWindows, attributes which technically
applied modes to their parents but were implemented ad hoc. This patch
redefines these modal effects as WindowModes and sets up some helpers.
This will let us simplify a lot of modal logic in the upcoming patches
and make it easier to build new modal effects in the future.

Windows can now set 1 of 5 modes before reification:
-Modeless:	No modal effect; begins a new modal chain
-Passive:	Window joins its modal chain but has no effect
-RenderAbove:	Window renders above its parent
-CaptureInput:	Window captures the active input role from its parent
-Blocking:	Window blocks all interaction with its modal chain

States like fullscreen and tiling are dynamic and don't alter behavior
in modal chains, so they aren't included.
2022-08-25 13:28:50 +02:00
thankyouverycool
609391b46e WindowServer: Add modeless_ancestor() helper 2022-08-25 13:28:50 +02:00
thankyouverycool
ab517aa21d WindowServer: Remove m_unmaximized_rect from Window
Superceded by m_floating_rect
2022-08-25 13:28:50 +02:00
thankyouverycool
68570e897d LibGfx+WindowServer: Remove set_size_around() from Rect and Window
Superceded by to_floating_cursor_position() as a more accurate way
to reposition windows on untile. Effectively made set_size_around()
dead code, so the remnants can be removed.
2022-08-25 13:28:50 +02:00
thankyouverycool
a1dceb5b97 WindowServer: Remove nudge_into_desktop() from Window
Positioning windows outside visible coordinates is valid if sometimes
curious behavior, but it shouldn't be considered misbehavior by default.
There are multiple ways to recover windows with obscured title bars,
and this function papers over actual resize bugs and is no longer
needed to normalize window size, so let's remove it for now.
2022-08-25 13:28:50 +02:00
thankyouverycool
b180132c87 WindowServer: Fix typo 'reminder' -> 'remainder' in WindowManager 2022-08-25 13:28:50 +02:00
thankyouverycool
24b8301a0e WindowServer: Get taskbar height from TaskbarWindow directly
Fixes incorrect hardcoded heights and a failure to get taskbar
height when tiling on new workspaces.
2022-08-25 13:28:50 +02:00
thankyouverycool
c5dd72ac71 LibGUI: Remember size and position of hidden Windows
And don't reset windowless rects on resize events. Fixes child
windows reappearing at [0,0] and with the wrong dimensions after
being hidden.
2022-08-25 13:28:50 +02:00
thankyouverycool
f833473df0 Apps+Demos+Dialogs: Remove unnecessary minimum window sizes
The new layout system conveniently calculates these for us now.
In the case of Mandelbrot where it needs to be overriden, make
sure to disable obey min widget size first. In EmojiInputDialog's
case, the window needs to be resized instead to center correctly.
2022-08-25 13:28:50 +02:00
thankyouverycool
46d6347035 LibGUI+WindowServer: Initialize minimum window size to zero
And remove unnecessary workarounds to the old limit of {50, 50} and
the cautious but arbitrary limit of {1, 1} for other WindowTypes.
Null rects are already the default when calculating minimum window
size and are the least restrictive but valid value.

Also returns early during minimum size calculations for frameless
windows, and verifies against negative minimum sizes and failure to
disable widget min size before setting a minimum window size. Layout
automatically overrides this setting each relayout otherwise.
2022-08-25 13:28:50 +02:00
davidot
8b8cee3172 LibCrypto: Implement a (mostly) proper to_double for UnsignedBigInteger
SignedBigInteger can immediately use this by just negating the double if
the sign bit is set.
For simple cases (below 2^53) we can just convert via an u64, however
above that we need to extract the top 53 bits and use those as the
mantissa.

This function currently does not behave exactly as the JS spec specifies
however it is much less naive than the previous implementation.
2022-08-24 23:27:17 +01:00
davidot
2290fbc2a0 LibCrypto: Make a VERIFY a static_assert since it only uses constants 2022-08-24 23:27:17 +01:00
davidot
fce2b33758 LibJS: Allow BigInts as destructuring property names
These are simply treated as their numerical value which means that above
2^32 - 1 they are strings.
2022-08-24 23:27:17 +01:00
davidot
e663504df1 LibJS: Fix that leftshift for BigInts did not round down
For negative number this previously rounded towards zero instead of the
intended always rounding down.
2022-08-24 23:27:17 +01:00
davidot
cb49c07fb7 LibJS: Use the new BigInt compare_to_double algorithm :^)
Although this is much more complicated it does not seem to impact
performance that much even when looking only at values in which the
previous casting to i32 was correct.
2022-08-24 23:27:17 +01:00
davidot
b5c00830c2 LibCrypto: Add a way to compare a SignedBigInteger with a double
This supports any double value (except for NaNs) instead of having to
cast the double to some smaller type which doesn't work for very large
values.
2022-08-24 23:27:17 +01:00
James Bellamy
352d6545a9 WindowServer+DisplaySettings: Capitalize display mode dropdown
Every other dropdown in settings is capitalized apart from this one.
This commit fixes that.
2022-08-24 12:17:30 +02:00
electrikmilk
1a9d4ffecf PixelPaint: Add more icons
This adds menu item icons for Add Mask, Flatten Image, Fit Image To
View, and Generic 5x5 Convolution.

This modifies the menu item icon for Swap Colors to make the action more
obvious and improve accessibility.
2022-08-24 12:01:19 +02:00
davidot
a9d2d806b6 LibJS: Use __builtin_isnan in static_assert instead of isnan
For the fuzzer build isnan was not usable in a constexpr context however
__builtin_isnan seems to always be.

Also while we're here add my name to the copyright since I forgot after
the Value rewrite.
2022-08-23 22:30:15 +01:00
Andreas Kling
34a09bbb54 PixelPaint: Add simple "Crop Image to Content" feature
This command finds the smallest non-empty content bounding rect
by looking for the outermost non-transparent pixels in the image,
and then crops the image to that rect.

It's implemented in a pretty naive way, but it's a start. :^)
2022-08-23 22:39:27 +02:00
Andreas Kling
5ded6904d8 PixelPaint: Make the default empty image transparent by default
It was previously white by default, but let's change that. :^)
2022-08-23 22:39:27 +02:00
Andreas Kling
28714deff6 PixelPaint: Avoid division-by-zero in HistogramWidget
This is more of a hack fix than anything else, but let's stop PixelPaint
from infinite-looping in HistogramWidget::paint_event().
2022-08-23 22:39:27 +02:00
Jose Flores
355911c44e SQLStudio: Reset status bar and menu actions when closing a tab 2022-08-23 19:08:26 +01:00
Emily Trau
abc150085f LibC: Add missing sys/cdefs.h include
Some header files use __BEGIN_DECLS without including sys/cdefs.h.
This causes issues for C code that compiles against these headers,
which may occur with Ports.
2022-08-23 19:07:12 +01:00
Ali Mohammad Pur
e70624de9f LibWeb: Don't grow Wasm memory again after initialisation
The constructor grows the memory to the initial size, we don't need to
do that again.
2022-08-23 19:04:18 +01:00
Tim Schumacher
5f99934dce Userland: Consolidate most PATH resolving into a single implementation
We previously had at least three different implementations for resolving
executables in the PATH, all of which had slightly different
characteristics.

Merge those into a single implementation to keep the behaviour
consistent, and maybe to make that implementation more configurable in
the future.
2022-08-23 19:00:04 +01:00
Tim Schumacher
39a3775f48 Userland: Rely on a single authoritative source for the default PATH 2022-08-23 19:00:04 +01:00
Linus Groh
61e18c681b LibWeb: Restore realm retrieval from 'this' in activate_event_handler()
Removing the FIXME'd code in b99cc7d was a bit too eager, and relying on
the main thread VM's current realm only works when JS is being executed.

Restore a simplified version of the old code to determine the realm this
time instead of the global object, following the assumptions already
made in get_current_value_of_event_handler() regarding what kind of
event target 'this' can be.
2022-08-23 17:44:39 +01:00
Linus Groh
987927a596 LibJS: Remove Bytecode::Register::global_object()
This is unused.
2022-08-23 13:58:30 +01:00
Linus Groh
275dea9d98 LibJS: Remove {Bytecode::,}Interpreter::global_object()
The basic idea is that a global object cannot just come out of nowhere,
it must be associated to a realm - so get it from there, if needed.

This is to enforce the changes from all the previous commits by not
handing out global objects unless you actually have an initialized
realm (either stored somewhere, or the VM's current realm).
2022-08-23 13:58:30 +01:00
Linus Groh
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
e3895e6c80 LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct
realm, usually forwarded from the Object's initialize() function, rather
than using the current realm.
2022-08-23 13:58:30 +01:00
Linus Groh
7c468b5a77 LibJS: Pass Realm to GlobalObject::initialize_global_object()
Global object initialization is tightly coupled to realm creation, so
simply pass it to the function instead of relying on the non-standard
'associated realm' concept, which I'd like to remove later.

This works essentially the same way as regular Object::initialize() now.

Additionally this allows us to forward the realm to GlobalObject's
add_constructor() / initialize_constructor() helpers, so they set the
correct realm on the allocated constructor function object.
2022-08-23 13:58:30 +01:00
Linus Groh
b465f46e00 LibJS: Remove GlobalObject parameter from native functions 2022-08-23 13:58:30 +01:00
Linus Groh
7b990c27a1 LibWeb: Replace GlobalObject with VM in remaining AOs [Part 4/4] 2022-08-23 13:58:30 +01:00
Linus Groh
2d69a3b266 LibWeb: Replace GlobalObject with VM in Window AOs [Part 3/4] 2022-08-23 13:58:30 +01:00
Linus Groh
f8fb985b05 LibWeb: Replace GlobalObject with VM in CrossOrigin AOs [Part 2/4] 2022-08-23 13:58:30 +01:00
Linus Groh
5f1fe4b012 LibWeb: Replace GlobalObject with VM in WebAssembly AOs [Part 1/4] 2022-08-23 13:58:30 +01:00
Linus Groh
40a70461a0 LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
2022-08-23 13:58:30 +01:00
Linus Groh
56b2ae5ac0 LibJS: Replace GlobalObject with VM in remaining AOs [Part 19/19] 2022-08-23 13:58:30 +01:00
Linus Groh
25849f8a6d LibJS: Replace GlobalObject with VM in common AOs [Part 18/19] 2022-08-23 13:58:30 +01:00
Linus Groh
7856886ed5 LibJS: Replace GlobalObject with VM in String AOs [Part 17/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ab6796691f LibJS: Replace GlobalObject with VM in ShadowRealm AOs [Part 16/19] 2022-08-23 13:58:30 +01:00
Linus Groh
d69eaf8be9 LibJS: Replace GlobalObject with VM in Array AOs [Part 15/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f13f3f9fbe LibJS: Replace GlobalObject with VM in Date AOs [Part 14/19] 2022-08-23 13:58:30 +01:00
Linus Groh
9930302efb LibJS: Replace GlobalObject with VM in JSON AOs [Part 13/19] 2022-08-23 13:58:30 +01:00
Linus Groh
90bf33241d LibJS: Replace GlobalObject with VM in Atomics AOs [Part 12/19] 2022-08-23 13:58:30 +01:00
Linus Groh
26366d5930 LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19] 2022-08-23 13:58:30 +01:00
Linus Groh
b037894287 LibJS: Replace GlobalObject with VM in TypedArray AOs [Part 10/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f0b793db74 LibJS: Replace GlobalObject with VM in RegExp AOs [Part 9/19] 2022-08-23 13:58:30 +01:00
Linus Groh
d74f8039eb LibJS: Replace GlobalObject with VM in Promise AOs [Part 8/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ccdfa2320c LibJS: Replace GlobalObject with VM in Iterator AOs [Part 7/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ae9e031f56 LibJS: Replace GlobalObject with VM in Reference AOs [Part 6/19] 2022-08-23 13:58:30 +01:00
Linus Groh
275a7a0c0a LibJS: Replace GlobalObject with VM in Environment AOs [Part 5/19] 2022-08-23 13:58:30 +01:00
Linus Groh
a022e548b8 LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
2022-08-23 13:58:30 +01:00
Linus Groh
f6c4a0f5d0 LibJS: Replace GlobalObject with VM in PrototypeObject AOs [Part 3/19] 2022-08-23 13:58:30 +01:00
Linus Groh
694f66b5ca LibJS: Replace GlobalObject with VM in Temporal AOs [Part 2/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f9705eb2f4 LibJS: Replace GlobalObject with VM in Intl AOs [Part 1/19]
Instead of passing a GlobalObject everywhere, we will simply pass a VM,
from which we can get everything we need: common names, the current
realm, symbols, arguments, the heap, and a few other things.

In some places we already don't actually need a global object and just
do it for consistency - no more `auto& vm = global_object.vm();`!

This will eventually automatically fix the "wrong realm" issue we have
in some places where we (incorrectly) use the global object from the
allocating object, e.g. in call() / construct() implementations. When
only ever a VM is passed around, this issue can't happen :^)

I've decided to split this change into a series of patches that should
keep each commit down do a somewhat manageable size.
2022-08-23 13:58:30 +01:00
Linus Groh
999da617c5 LibJS: Remove GlobalObject from VM::this_value()
This is a continuation of the previous six commits.

The global object is only needed to return it if the execution context
stack is empty, but that doesn't seem like a useful thing to allow in
the first place - if you're not currently executing JS, and the
execution context stack is empty, there is no this value to retrieve.
2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Linus Groh
5398dcc55e LibJS: Remove GlobalObject from execute() and related AST functions
This is a continuation of the previous four commits.

Passing a global object here is largely redundant, we definitely need
the interpreter but can get the VM and (later) current active realm from
there - and also the global object while we still need it, although I'd
like to remove Interpreter::global_object() in the future.

This now matches the bytecode interpreter's execute_impl() functions.
2022-08-23 13:58:30 +01:00
Linus Groh
e992a9f469 LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()
This is a continuation of the previous three commits.

Now that create() receives the allocating realm, we can simply forward
that to allocate(), which accounts for the majority of these changes.
Additionally, we can get rid of the realm_from_global_object() in one
place, with one more remaining in VM::throw_completion().
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits.

As allocating a JS cell already primarily involves a realm instead of a
global object, and we'll need to pass one to the allocate() function
itself eventually (it's bridged via the global object right now), the
create() functions need to receive a realm as well.
The plan is for this to be the highest-level function that actually
receives a realm and passes it around, AOs on an even higher level will
use the "current realm" concept via VM::current_realm() as that's what
the spec assumes; passing around realms (or global objects, for that
matter) on higher AO levels is pointless and unlike for allocating
individual objects, which may happen outside of regular JS execution, we
don't need control over the specific realm that is being used there.
2022-08-23 13:58:30 +01:00
Linus Groh
5dd5896588 LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functions
This is a continuation of the previous commit.

Calling initialize() is the first thing that's done after allocating a
cell on the JS heap - and in the common case of allocating an object,
that's where properties are assigned and intrinsics occasionally
accessed.
Since those are supposed to live on the realm eventually, this is
another step into that direction.
2022-08-23 13:58:30 +01:00
Linus Groh
ecd163bdf1 LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
2022-08-23 13:58:30 +01:00
Linus Groh
4c300cc5e8 LibJS: Fix the prototype of AsyncFunctionDriverWrapper's Promise base 2022-08-23 13:58:30 +01:00
Linus Groh
8ceef031e8 LibWeb: Fix the prototype of a couple of WebAssembly prototype objects
Like any other regular, non-inheriting web platform prototype, the
prototype's prototype should be Object.prototype, not the global object.

Another reason to get rid of "global object (an object) + prototype
object (also an object)"-style APIs for allocation :^)
2022-08-23 13:58:30 +01:00
huttongrabiel
4806567f05 NetworkServer: Use Core::Stream instead of Core::File
As per the FIXME.
2022-08-23 13:37:21 +01:00
Hendiadyoin1
4e9313fa73 PixelPaint: Use Sqrt1_2 constant in EllipseTool instead of 1/1.41
This also demotes the constant to floats instead of doubles, because we
truncate it to int anyways and don't need the extra accuracy.
2022-08-23 13:35:15 +01:00
MacDue
50ab2de10e LibWeb: Remove done TODO and fix typo 2022-08-23 13:27:02 +01:00
MacDue
40ad8b793d LibWeb: Avoid infinite loops in background painting
Previously if `background-size` was 0px in any dimension we would
go into in infinite loop whilst painting.
2022-08-23 13:27:02 +01:00
networkException
2161f20aa6 LibGUI: Call on_segment_change handler from on_{click,focus_change}
The on_segment_change handler introduced in
a00fa793b3 was only getting called by
programmatically setting the segment, not by clicking a button or using
tab navigation.
2022-08-23 12:50:20 +02:00
networkException
c1c11df3b8 LibGUI: Don't call on_segment_change handler if the index did not change
This patch makes the handler's behavior closer to what can be expected
from it's name by not handling set_selected_segment if the segment is
already selected.
2022-08-23 12:50:20 +02:00
kleines Filmröllchen
4355a01455 LibCore: Fix deadlock in SharedSingleProducerCircularQueue
This deadlock would incorrectly change the queue from almost empty to
full on dequeue because someone else could empty the queue after we had
checked its non-emptyness. The test would deadlock on this, which
doesn't happen anymore.
2022-08-23 01:03:10 +02:00
MacDue
698717d102 LibWeb: Resolve double-position linear-gradient() color stops
These just resolve to an extra color stop.
Something like "red 10% 40%"  is just shorthand for "red 10%, red 40%".
2022-08-23 01:02:49 +02:00
MacDue
fa5c2183df LibWeb: Don't regenerate linear gradient data unless size changes
This is an easy check to add and seems like it makes things a
tiny bit smoother.
2022-08-23 01:02:49 +02:00
MacDue
de5d25ee44 LibWeb: Add missing checks to LinearGradientStyleValue::equals() 2022-08-23 01:02:49 +02:00
MacDue
3a1f8d714a LibWeb: Parse double-position linear-gradient() color stops
The only accepted syntax for these seems to be
<color> <length percentage> <length percentage>, no other order.

But that's just gathered from looking at other browsers as though
these are supported by all major browsers, they don't appear in
the W3C spec.
2022-08-23 01:02:49 +02:00
Andreas Kling
ecf85875b5 PixelPaint: Disambiguate layer vs image actions in their names
Instead of having "Flip Horizontally" in both the Image and Layer menus,
we now have "Flip Image Horizontally" and "Flip Layer Horizontally".

This same concept applied to other, similar actions.
2022-08-22 21:55:19 +02:00
Andreas Kling
ac943c60ef PixelPaint: Add actions for flipping and rotating an individual layer 2022-08-22 21:55:19 +02:00
Andreas Kling
4491ef8ae6 PixelPaint: Relayout ImageEditor immediately when image rect changes
This avoids a jarring effect where we'd "snap" the image into place
upon the next resize event.
2022-08-22 21:55:19 +02:00
Andreas Kling
d7cf36ec6c PixelPaint: Create undo items for more editing actions 2022-08-22 21:55:19 +02:00
Andreas Kling
32b73dd4af PixelPaint: Restore image size from snapshots
This will make undoing a resize or rotate operation actually restore the
size of the image as well.
2022-08-22 21:55:19 +02:00
Lucas CHOLLET
d5979516b4 ChessEngine: Don't throw away useful branches from last tree
Computation from last turn might have produced some nodes that are still
accurate. Keeping them should make the engine a bit smarter.
2022-08-22 21:20:41 +02:00
Lucas CHOLLET
351fc0cce2 ChessEngine: Use reduced Board objects in MCTSTree
Monte-Carlo methods are known to intensively create nodes and in our
case each leaf of the tree stores a board. However, for this use case,
we don't need a full board object that also contains game information.

This patch adds a `clone_cleared()` method that return a clone without
game information and uses it when constructing the tree.
It allows the ChessEngine much more possibility before getting out of
memory.
2022-08-22 21:20:41 +02:00
Lucas CHOLLET
5f13a87ce7 ChessEngine: Limit MCTSTree expansion
This method temperate the habit of Monte-Carlo based algorithms to
repeatedly create new nodes.

It was first implemented in `Efficient Selectivity and Backup Operators
in Monte-Carlo Tree Search` by Rémi Coulom.
2022-08-22 21:20:41 +02:00
Sam Atkins
cde4552710 GamesSettings: Add a preview for the current card-game settings :^) 2022-08-22 12:50:41 +02:00
Sam Atkins
deeef8c412 GamesSettings: Add a setting for the card-back image
And also add a couple of images so there's more than one option. :^)

(My yak silhouette isn't very good, so please replace that, artists!)
2022-08-22 12:50:41 +02:00
Sam Atkins
435e53fcfe LibCards: Remove card-back-image scaling
This was giving wonky results with images that do not fill the entire
card - and it's also unnecessary, since the Buggie image we have been
using, and the two I will be adding, are all small enough to not need
scaling anyway. :^)
2022-08-22 12:50:41 +02:00
Sam Atkins
40b1428194 LibCards: Make the card back image configurable
`CardPainter::set_background_image_path()` immediately repaints the card
back and inverted card back bitmaps if they exist, so users just need
to `update()` that part of the screen. This is handled automatically by
`CardGame`, but other users will have to do this manually.
2022-08-22 12:50:41 +02:00
Sam Atkins
7f46d31849 LibCards: Centralise card bitmap creation
Instead of each card being responsible for painting its own bitmaps, we
now have a CardPainter which is responsible for this. It paints a given
card the first time it is requested, and then re-uses that bitmap when
requested in the future. This saves memory for duplicate cards (such as
in Spider where several sets of the same suit are used) or unused ones
(for example, the inverted cards which are only used by Hearts). It
also means we don't throw away bitmaps and then re-create identical
ones when starting a new game.

We get some nice memory savings from this:

|           | Before   | After    | Before (Virtual) | After (Virtual) |
|:----------|---------:|---------:|-----------------:|----------------:|
| Hearts    | 12.2 MiB |  9.3 MiB |         25.1 MiB |        22.2 MiB |
| Spider    | 12.1 MiB | 10.1 MiB |         29.2 MiB |        22.9 MiB |
| Solitaire | 16.4 MiB |  9.0 MiB |         25.0 MiB |        21.9 MiB |

All these measurements taken from x86_64 build, from a fresh launch of
each game after the animation has finished, but without making any
moves. The Hearts value will go up once inverted cards start being
requested.
2022-08-22 12:50:41 +02:00
Sam Atkins
aac2488d5c LibCards+Games: Replace card "value" int with a Rank enum
Because `card->value() == 11` is a lot less clear than `card->rank() ==
Cards::Rank::Queen`, and also safer.

Put this, along with the `Suit` enum, in the `Cards` namespace directly
instead of inside `Cards::Card`. Slightly less typing that way.
2022-08-22 12:50:41 +02:00
Sam Atkins
163a74e3e2 Spider: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
c709dc154f Hearts: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
f9f25271b3 Solitaire: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
c5b7ad6004 LibCards: Add a CardGame base class
For now, the only feature of this is that it sets the background colour
from the `Games::Cards::BackgroundColor` config value. Later, other
card game configuration and shared behaviour can go here, to save
duplicating it in each game.
2022-08-22 12:50:41 +02:00
Sam Atkins
a01c4c50d1 GamesSettings: Introduce a new GamesSettings application :^)
This currently has exactly one setting: The background colour for card
games. My thinking is, it's better to not have a Settings application
for each individual game we include in the system, since most will only
have a small number of settings, all Settings windows have tabs anyway,
and I don't want to flood the Settings app list unnecessarily.

As for having a single setting for all the card games: it's nice when
things match. :^)
2022-08-22 12:50:41 +02:00
Roberto Bampi
1c52ca9693 PixelPaint: Push layer creation onto the undo stack
Before this change, creating a layer, painting something on it and
undoing would delete the layer as well as the paint on it.
2022-08-22 12:49:11 +02:00
Jannis Weis
8fa34b43ce HexEditor: Fix utf16 validation
Previously the utf8_view was validated for the utf16 valude instead
of the utf16_view.
2022-08-22 12:48:47 +02:00
Jannis Weis
32205495e6 LibGUI: Clear selected index of Breadcrumbbar if segment is removed
If the segment corresponding to the selected index is removed the index
is no longer valid.
2022-08-22 12:48:11 +02:00
Jannis Weis
3911758277 FileManager: Disable open_child_directory_action if no child exists 2022-08-22 12:48:11 +02:00
Jannis Weis
8b395ffcc5 FileManager: Respond to all selection changes in the Breadcrumbbar
Use Breadcrumbbars on_segment_change instead of on_segment_click.
This allows us to remove the manual handler invokation in the
open_child_directory_action
2022-08-22 12:48:11 +02:00
Jannis Weis
a00fa793b3 LibGUI: Add on_segment_change handler to Breadcrumbbar
This allows programs to respond to any selection changes of the
Breadcrumbbar, not just ones made by clicking one of the buttons.
2022-08-22 12:48:11 +02:00
Andreas Kling
bf25b0a0b5 PixelPaint: Show more specific Undo/Redo action text
The Undo/Redo actions now tell you what kind of action will be
undone/redone. This is achieved by adding an "action text" field to the
ImageUndoCommand and having everyone who calls did_complete_action()
provide this text.
2022-08-21 20:33:03 +02:00
Andreas Kling
101eb53de5 PixelPaint: Add Tool::tool_name() as a single-point-of-truth
Let the tools know what their names are.
2022-08-21 20:33:01 +02:00
Andreas Kling
c45f99f735 PixelPaint: Make Filter::filter_name() const 2022-08-21 20:19:59 +02:00
Andreas Kling
17687435ca WindowServer: Redraw menu items after client updates them somehow
This fixes an issue where the undo/redo actions in TextEditor only
updated once you hovered over them.
2022-08-21 20:04:33 +02:00