Commit Graph

151 Commits

Author SHA1 Message Date
Linus Groh
85f0fc2b83 LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}()
and having to check those first, and then making another Optional from
the unwrapped value:

    completion.has_value() ? completion.value() : Optional<Value> {}
    //                       ^^^^^^^^^^^^^^^^^^
    //         Implicit creation of non-empty Optional<Value>

This way we need to unwrap the optional ourselves, but can easily pass
it to something else as well.

This is in anticipation of the AST using completions :^)
2022-01-03 21:50:50 +01:00
martinfalisse
b39aede8fe Spreadsheet: Background fill color after reaching vertical end
When selecting a cell in the spreadsheet that was added
automatically as per the InfinitelyScrollableTableView
implementation, the background color is now filled correctly.

Previously, when navigating horizontally in a spreadsheet, after
a certain point the cells would not have the same background fill
color as the user would have experienced in the previous column
ranges (A-Z).
2022-01-03 22:30:04 +03:30
Timothy Flynn
565a880ce5 Userland: Link directly against LibUnicodeData where needed
This is partially a revert of commits:
    10a8b6d411
    561b67a1ad

Rather than adding the prot_exec pledge requried to use dlopen(), we can
link directly against LibUnicodeData in applications that we know need
that library.

This might make the dlopen() dance a bit unnecessary. The same purpose
might now be fulfilled with weak symbols. That can be revisted next, but
for now, this at least removes the potential security risk of apps like
the Browser having prot_exec privileges.
2021-12-30 14:18:12 +01:00
Timothy Flynn
10a8b6d411 Userland: Add unveil/pledge requisites for dynamic Unicode data loading
Loading libunicodedata.so will require dlopen(), which in turn requires
mmap(). The 'prot_exec' pledge is needed for this.

Further, the .so itself must be unveiled for reading. The "real" path is
unveiled (libunicodedata.so.serenity) as the symlink (libunicodedata.so)
itself cannot be unveiled.
2021-12-21 13:09:49 -08:00
Ali Mohammad Pur
f0709c7a24 LibC+AK: Implement all sorts of wprintf variants 2021-12-21 21:24:36 +03:30
RasmusNylander
fa99125571 Spreadsheet: Handle emptying of cell containing only an '='
Cell::set_data(String new_data) now checks whether the cell is a
formula-cell and the new_data is an empty string. If this is case, it
will no longer simply return and will now instead actually set the
cell's contents to an empty string.

This fixes an error whereupon committing the string "=" to a cell, it
would not be possible to directly delete the cell's contents. Instead,
it first had to be overwritten with another string, which then could be
deleted.

This could probably be done more elegantly. Right now, I believe,
writing the string "=" to a (formula-)cell already containing an
identical string will result in the cell being marked as dirty, even
though nothing actually changed.
2021-12-16 02:44:37 +03:30
Ali Mohammad Pur
5f1a34bba3 Spreadsheet: Avoid using Value.to_string_without_side_effects()
We should use .to_string() and handle the possible exceptions.
This makes the displayed cell contents so much more informative than
'[object Object]' :^)
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
235eb0b1ad Spreadsheet: Replace hacky JS VM configuration with a more correct one
Now we give each sheet its own interpreter and realm, and only make them
share the VM.
This is to prepare for the next commit, which will be refactoring a
bunch of things to propagate exceptions via ThrowCompletionOr<T>.
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
82dde46a30 Spreadsheet: Replace the help button's text with something we can render 2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
91444de2cf Spreadsheet: Reimplement ranges as lazy objects instead of arrays
Doing so makes it possible to talk about theoretically infinite ranges
like "all of column A".
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
892e585e9a Spreadsheet: Don't recreate the global environment on every evaluation
The worksheet's realm does not change, and is not shared, so we can
safely leave the global environment be.
This fixes lexical scoping in the spreadsheet's runtime file.
2021-12-12 14:49:49 +03:30
Ben Wiederhake
13cba5f8b4 Spreadsheet: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Erik Biederstadt
e052d647b7 Spreadsheet: Allow sheet renaming after double clicking on the tabwidget 2021-12-01 00:44:26 +03:30
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Andreas Kling
587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
4a2b718ba2 LibCore: Use ErrorOr<T> for Core::File::copy_file() 2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
FrHun
54605794f9 Applications: Remove border from GroupBox margins 2021-11-03 16:13:19 +01:00
Timothy Flynn
1939c72ecc Spreadsheet: Convert JSIntegration to ThrowCompletionOr 2021-10-31 15:48:36 +01:00
Marco Cutecchia
5f04fb0ece Spreadsheet: Make the 'Help' window accessory 2021-10-31 00:58:05 +03:30
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Andreas Kling
398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Idan Horowitz
aad12b050b LibJS: Convert to_length() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Idan Horowitz
f6a5ff7b00 LibJS: Convert to_i32() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Idan Horowitz
20d990563c LibJS: Convert to_number() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Idan Horowitz
1639ed7e0a LibJS: Convert to_double() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Linus Groh
52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh
4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh
3be26f56db LibJS: Convert has_own_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
Linus Groh
b7e5f08e56 LibJS: Convert Object::get() to ThrowCompletionOr
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
Samuel Bowman
db98ed5ed0 Spreadsheet: Add a toolbar
This commit adds a basic toolbar with the following actions:
Add New Sheet, Open, Save, Cut, Copy, and Paste.
2021-10-01 08:34:59 +03:30
Samuel Bowman
e422bfbe88 Spreadsheet: Store actions in member variables on SpreadsheetWidget
Actions are now stored in member variables so they can be used
throughout SpreadsheetWidget.
2021-10-01 08:34:59 +03:30
Samuel Bowman
d8bac4dbda Spreadsheet: Move menu and action code to initialize_menubar()
Previously, all the code to add menus and actions was in main().
This was messy and didn't allow us to reference the actions from
SpreadsheetWidget, which is needed in order to add a toolbar.

This commit moves the menu and action adding code to method on
SpreadsheetWidget called initialize_menubar() which is based upon
applications such as TextEditor which have identically named methods
doing the same thing.

In additon, clipboard_action(), previouly a lambda in main(), has also
been made into a method on SpreadsheetWidget since it would otherwise
be destroyed when it goes out of scope. (This was previously avoided by
declaring the lambda in main() so it's always in scope.)
2021-10-01 08:34:59 +03:30
davidot
0f5fe3b70e SpreadSheet: Fix that non first sheets could not access global functions
Because we declare the functions in runtime.js we need the correct
global object to be setup otherwise they cannot be accessed when
switching to the SheetGlobalObject.
2021-09-30 15:37:56 +01:00
davidot
5611285312 SpreadSheet: Fix that the js integration abused global objects
Before this commit it only allocated the global object so when it wanted
to lookup 'thisSheet' it could not find it in the global environment.
We now hotswap the global object everytime a cell evaluated.

This also fixes that SheetGlobalObject did not have an
internal_has_property meaning 'A0' could not be referenced unless it was
via a member lookup (this.A0). This was already broken before the
bindings refactoring.

The correct behavior of realms in spreadsheet is not completely clear
since what is shared between sheets is not very well defined.

The reason that just setting the SheetGlobalObject as the
global_this_value is not enough is because ECMAScript does not check the
global_this_value for members when resolving a reference in the global
environment.
2021-09-30 08:16:32 +01:00
Linus Groh
e5409c6ead LibJS: Convert internal_set() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
6c2b974db2 LibJS: Convert internal_get() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Idan Horowitz
ab594e5f2f LibJS: Convert Value::invoke and VM::call to ThrowCompletionOr 2021-09-23 23:59:13 +03:00
Timothy Flynn
9def17d4cb Spreadsheet: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Andreas Kling
d42d655853 LibJS+LibWeb+Spreadsheet: Upcall visit_edges() via Base typedef
Let's use Base::visit_edges() when calling the base class, to prevent
accidentally skipping over anyone in the inheritance chain.
2021-09-11 14:10:11 +02:00
Ben Wiederhake
4ef9a1ba48 Spreadsheet: Avoid making StringView of temporary ByteBuffer 2021-09-11 13:22:51 +03:00
Andreas Kling
6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Ali Mohammad Pur
97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Daniel Bertalan
d7b6cc6421 Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other
pointer in the constructors and move assignment operators. This meant
that some operations that would require explicit casting on raw pointers
were done implicitly, such as:
- downcasting a base class to a derived class (e.g. `Kernel::Inode` =>
  `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp),
- casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>`
  in LibIMAP/Client.cpp)

This, of course, allows gross violations of the type system, and makes
the need to type-check less obvious before downcasting. Luckily, while
adding the `static_ptr_cast`s, only two truly incorrect usages were
found; in the other instances, our casts just needed to be made
explicit.
2021-09-03 23:20:23 +02:00
Karol Kosek
8dbb996200 Spreadsheet: Implement begin() and end() 2021-08-31 16:43:18 +02:00
Karol Kosek
f56e240981 Spreadsheet: Add RowIterator::index() 2021-08-31 16:43:18 +02:00