Commit Graph

60 Commits

Author SHA1 Message Date
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
thankyouverycool
f457e43885 Assistant+CommandPalette: Use FrameShape::Window for main widgets 2022-02-25 19:38:23 +01:00
Lenny Maiorani
f0d2489254 Applications: Port Assistant to LibMain 2022-02-09 21:01:52 +00:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
Rummskartoffel
a610d9a3d1 Assistant: Fix crash in FileProvider background thread upon exit
If the Threading::BackgroundAction for filesystem indexing in
FileProvider hadn't finished by the time the main thread exited, it
would still try to access the FileProvider object that lived in the main
thread, thereby causing a segfault and crashing. This commit prevents
FileProvider from being destroyed while the background thread is still
running by giving the background thread a strong reference to its
FileProvider.
2022-01-15 21:45:03 +01:00
Rummskartoffel
ada1d4906e Assistant: Make Provider ref-counted 2022-01-15 21:45:03 +01:00
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
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
Sam Atkins
d2024f04bd Userland: Cast unused BackgroundAction::construct() results to void
User code does not need to keep this alive, so casting to void is safe.
But maybe a bit weird.
2021-12-05 15:31:03 +01:00
Ben Wiederhake
465af4c4d4 Applications: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
59619572d6 LibThreading: Remove redundant method 2021-11-02 11:07:26 +01:00
Karol Kosek
d40c36a16e Assistant: Fix adding sequential bonus in Fuzzy Match
It was comparing if they both had the same index position (which was
always false).
2021-10-25 13:00:32 +02:00
Karol Kosek
5e10cd364b Assistant: Save match all match points in Fuzzy Match
From what I think, the array should consist of point indexes that have
been matched instead of just the last one.

For example, these are the array contents after searching 'file' for
'File Manager':
- Before: [ 3 ]
- Now: [ 0, 1, 2, 3 ]

Besides that, this greatly improves the scoring logic, as it can now
calculate bonuses.

Closes: #8310
2021-10-25 13:00:32 +02:00
Karol Kosek
e7eccf3de2 Assistant: Simplify the logic of calculating bonus points
This does not change the results, but makes the code clearer.
2021-10-25 13:00:32 +02:00
Karol Kosek
ee17614e34 Assistant: Move score calculation logic to separate function 2021-10-25 13:00:32 +02:00
Karol Kosek
5ddd1555bc Assistant: Make strings const referenced
Found by clazy.
2021-10-25 13:00:32 +02:00
Brian Gianforcaro
ea2d68d14b Assistant: Zero initialize fuzzy match array
SonarCloud flagged the read of the matches array as a potential garbage
read. I don't believe the case it flagged was possible to reach due to
how the code is structured, however we should really just be zero
initializing these stack arrays.
2021-09-28 10:58:09 +02:00
Brian Gianforcaro
9a1181f748 Assistant: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Ben Wiederhake
2f38cad987 Assistant: Fix lockfile logic
Previously, Assistant was able to re-execute itself due to a quirk in
the global cursor tracking logic, it seems.

Now it has become necessary to explicitly drop the lockfile before
activating the new Assistant instance.

Alternatively, this has always been a latent bug that only now has
become more likely.
2021-09-08 10:53:49 +02:00
Ben Wiederhake
dbc8465c20 Assistant: Remove unnecessary global cursor tracking 2021-09-08 10:53:49 +02:00
Andreas Kling
769f777098 Assistant: Use HashMap::ensure() in Database::did_receive_results() 2021-09-04 20:30:56 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
Carlos César Neves Enumo
51b3fb5532 Assistant: Bundle UI updates to avoid flickering
While typing, we get the results from each provider asynchronously.

Previously, we were updating the UI for each result size,
which was causing a lot of flickering.

This fix creates a small timer to bundle the results
and reduce the number of UI updates per input.
2021-08-15 12:24:57 +02:00
Karol Kosek
64ca51265d Assistant: Quit the application after losing focus
Prior to this change, Assistant would just stay in the background,
unless one pressed an Escape key or launched some app.
2021-08-05 11:43:12 +02:00
Timothy
73c1b1617a Everywhere: Replace most cases of exit() with Application::quit()
Application::quit() is nicer for most cases where exit() is used. Cases
where exit() is used intentionally for early termination are left
intact.
2021-08-03 18:55:52 +02:00
Peter Elliott
bf16591c07 Assistant: Only open one Assistant at once
I found myself accidentally opening two assistants at once with the
Window+Space shortcut. Since only one assistant window is usable at the
same time, I made assistant only spawn 1 instance at most.
2021-07-22 23:34:15 +02:00
LuK1337
35b930112f Assistant: Trim terminal command before displaying or running it 2021-07-19 17:49:14 +02:00
Gunnar Beutner
c7265ee6bd Assistant: Keep the Terminal window open after the command has run 2021-07-16 13:05:55 +02:00
Andreas Kling
b8a204c5b9 LibThreading: Rename Lock => Mutex 2021-07-09 11:15:50 +02:00
Yuval Tasher
b08383c48d Assistant: Compare two chars instead of StringViews of length 1 2021-07-07 15:58:57 +02:00
Andreas Kling
a6f0861c7b Assistant: Add missing <unistd.h> include 2021-07-05 23:30:15 +02:00
Andreas Kling
45a2bc27d5 Assistant: Don't index the /dev directory 2021-07-04 23:15:17 +02:00
Andreas Kling
085da369ff Assistant: Force the window to have a shadow despite being frameless 2021-07-04 23:15:17 +02:00
timre13
55dd568583 Assistant: Show a border around the window 2021-07-04 14:48:54 +02:00
ForLoveOfCats
d73f53d1de Assistant: Prevent window from being minimized 2021-07-04 13:58:56 +02:00
Gunnar Beutner
f52bf15f8d Assistant: Make more of the classes final 2021-07-03 22:38:53 +02:00
Gunnar Beutner
52a3226f6d Assistant: Make the bitmap accessor pure virtual
Assistant looks broken when a result doesn't have an icon.
2021-07-03 22:38:53 +02:00
Gunnar Beutner
6af08f950a Assistant: Add missing bitmap accessor for terminal actions 2021-07-03 22:38:53 +02:00
Edwin Hoksberg
a4b4397a10 Assistant: Skip URL provider if query is empty or provider specific 2021-07-03 22:38:40 +02:00
Andreas Kling
c06f72c264 Assistant: Don't index the /proc and /sys directories
Roughly 20% of indexing time in a fresh install was spent on traversing
these kernel-generated directories. Let's just not. :^)
2021-07-03 22:14:09 +02:00
Andreas Kling
94def5ae9d Assistant: Avoid copying the result vectors when providers finish
Just move() them instead to cut down on the copying. :^)
2021-07-03 22:14:09 +02:00
Andreas Kling
e4199beccc Assistant: Keep the set of providers in a Vector for easy iteration 2021-07-03 22:14:09 +02:00
Andreas Kling
4fce72a967 Assistant: Use fstatat() while building FileProvider path cache
Using fstatat() allows the kernel to do relative path resolution as
opposed to absolute path resolution, which is significantly faster
and allows us to build the path cache sooner. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
801f74362e Assistant: Use StringView more in FileProvider fuzzy matching code
By not allocating new String objects, the fuzzy matcher becomes a lot
faster and more responsive while typing. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
d640031214 Assistant: Use FileIconProvider for FileProvider query results
Instead of showing the default "folder" icon for all file results,
we now show an appropriate icon for the given file. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
513e67e2eb Assistant: Make Result bitmaps virtual/lazy
Result classes now return their bitmap via a virtual Gfx::Bitmap*
getter. This effectively makes bitmap fetching lazier, since only
results that end up on screen actually get asked for their bitmap.

This drastically reduces the amount of work done by the FileProvider
background worker.
2021-07-03 20:03:53 +02:00
Timothy Flynn
27fe2b45e5 Assistant: Convert all Vector<NonnullRefPtr> to NonnullRefPtrVector 2021-07-03 15:41:35 +02:00
Timothy Flynn
d69691a26b Assistant: Add provider to run a command in a terminal
Prefix text with "$" in the Assistant text box to run a command in a
forked terminal. For example, "$ top" or "$ top -s pid".
2021-07-03 15:41:35 +02:00