Commit Graph

34269 Commits

Author SHA1 Message Date
Karol Kosek
fb5e2670d6 LibWeb: Fix highlighting HTML comments
Commit b193351a99 caused the HTML comments to flash when changing
the text cursor. Also, when double-clicking on a comment, the selection
started from the beginning of the file instead.

The following message was displaying when `TOKENIZER_TRACE_DEBUG`
was enabled:

    (Tokenizer::nth_last_position) Invalid position requested: 4th-last
    of 4. Returning (0-0).

Changing the `nth_last_position` to 3 fixes this. I'm guessing that's
because the parser is at that moment on the second hyphen of the `<!--`
string, so it has to go back only by three characters.
2022-02-14 12:50:44 +03:30
kleines Filmröllchen
704bb361bb LibCore: Allow event loops on other threads to wake up
Because the wake pipe is thread-local, it was previously not possible
to wake an event loop across a thread. Therefore, this commit
rearchitects event loop waking by making the wake function a member of
the event loop itself and having it keep a pointer to its thread's wake
pipe. The global wake() function calls wake on the current thread's
event loop.

This also fixes a bug in BackgroundAction: it should wake the event loop
it was created on, instead of the current thread's event loop.
2022-02-13 23:06:53 +01:00
kleines Filmröllchen
716a3429fa LibCore: Fix event loop stacks on non-main threads
Previously, event loop stacks on non-main threads would always crash
because the condition for "am I the lowest-stacked loop" was still
"am I the main loop", which of course is no longer sensible. A simple
switch to `is_instantiated` fixes this.
2022-02-13 23:06:53 +01:00
brapru
93496af02b LibVT: Fix triple click behavior
When triple clicking a line in the terminal the selection will span the
whole line. However, after dragging down to lines above/below the
selection will stop at the cursor.

Instead, the expected functionality of triple clicking and dragging is
to select the whole line and any whole lines dragged to after the triple
click.

Previously, the triple line counter would get reset as soon as the whole
line was selected. This patch resets the m_triple_click_timer in the
mouse up event, so that the triple click selecting functionality is
maintained during the entire click event and terminated when the event
is over.
2022-02-13 23:05:39 +01:00
Idan Horowitz
197ebe3433 Kernel: Remove dead code from ThreadSafeWeakPtr
This is a Kernel-only header, so any #ifndef KERNEL code is essentially
dead.
2022-02-13 23:02:57 +01:00
Idan Horowitz
b32cf33a23 Kernel: Remove make_weak_ptr()
New users of WeakPtr in the kernel should use try_make_weak_ptr instead
2022-02-13 23:02:57 +01:00
Idan Horowitz
c8ab7bde3b Kernel: Use try_make_weak_ptr() instead of make_weak_ptr() 2022-02-13 23:02:57 +01:00
Idan Horowitz
98c20b65cc AK+Kernel: Add an OOM-fallible try variant make_weak_ptr()
This will allow us to propagate allocation errors that may be raised by
the construction of the WeakLink.
2022-02-13 23:02:57 +01:00
Idan Horowitz
d6ea6c39a7 AK+Kernel: Rename try_make_weak_ptr to make_weak_ptr_if_nonnull
This matches the likes of the adopt_{own, ref}_if_nonnull family and
also frees up the name to allow us to eventually add OOM-fallible
versions of these functions.
2022-02-13 23:02:57 +01:00
Timothy Flynn
bfe1bd9726 LibSQL: Convert binary SQL operations to be fallible
Now that expression evaluation can use TRY, we can allow binary operator
methods to fail as well. This also fixes a few instances of converting a
Value to a double when we meant to convert to an integer.
2022-02-13 21:30:38 +00:00
Timothy Flynn
b15db851fe LibSQL: Short-circuit single-element tuple comparisons
If a tuple has a single value, perform a comparison using that singular
value. This allows, for example, comparisons of the form "(1) < 4",
where (1) is a single element tuple.
2022-02-13 21:30:38 +00:00
Timothy Flynn
e13c96157c LibSQL: Implement converting float and tuple values to a boolean 2022-02-13 21:30:38 +00:00
Timothy Flynn
8fab99e920 LibSQL: Use absolute value when comparing against floating point epsilon
Otherwise, any value that is less than another value would be considered
about equal by mistake.
2022-02-13 21:30:38 +00:00
Timothy Flynn
e649ff5d31 LibSQL: Return a not-yet-implemented error for unimplemented expressions
Easier to debug than returning a NULL value.
2022-02-13 21:30:38 +00:00
Timothy Flynn
5c90aa357b Base: Restart the SQL server if it crashes
There's a fair amount of VERIFY/TODO calls in LibSQL that will crash the
SQL server if we hit an unimplemented feature or some bug. Restart the
server if this happens to help with debugging / development.
2022-02-13 21:30:38 +00:00
Lenny Maiorani
f2d8c488ec Userland/Applets: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-13 21:27:17 +00:00
Jamie Mansfield
04c5bc5e55 LibJS: Add spec comments to ArrayBuffer.prototype.byteLength 2022-02-13 21:26:15 +00:00
Jamie Mansfield
7aa4c22f6b LibJS: Add spec comments to ArrayBuffer.prototype.slice 2022-02-13 21:26:15 +00:00
Filiph Sandström
8b7987be86 LibGfx: Allow changing the default font path 2022-02-13 21:25:59 +00:00
electrikmilk
62102e3130 Base+HexEditor: Add icons 2022-02-13 21:24:46 +00:00
electrikmilk
adf6be45fb Base+Calculator: Add icons
Adds icons for Pi and Euler's Constant to the Constants menu.
2022-02-13 22:09:18 +01:00
electrikmilk
9e81f60a2f Base: Flip elephant's feet around in PHP file icon
I noticed that the elephant's feet in this icon look like they are
backwards. Slight oversight on my part.
2022-02-13 22:08:14 +01:00
electrikmilk
861efc520e Base: Add C file type icon
Add 16x16 and 32x32 file icons for C files.
2022-02-13 22:07:12 +01:00
u9g
7b223fa51a Base: Add Spreadsheet alias to shellrc 2022-02-14 00:01:35 +03:30
electrikmilk
91d27bd484 Magnifier: Add missing icons
Add icons for 'Next Frame' and 'Previous Frame'.
2022-02-13 15:17:09 -05:00
Andrew Kaster
b4a7d148b1 Kernel: Expose maximum argument limit in sysconf
Move the definitions for maximum argument and environment size to
Process.h from execve.cpp. This allows sysconf(_SC_ARG_MAX) to return
the actual argument maximum of 128 KiB to userspace.
2022-02-13 22:06:54 +02:00
Max Wipfli
b0df096298 Kernel/VFS: Add FIXMEs about error codes leaking data from veiled paths
Error codes can leak information about veiled paths, if the path
resolution fails with e.g. EACCESS.

This is non-trivial to fix, as there is a group of error codes we want
to propagate to the caller, such as ENOMEM.
2022-02-13 21:58:26 +02:00
Max Wipfli
f3cf1b33d7 Tests: Add test for LibC mkdir() 2022-02-13 21:58:26 +02:00
Max Wipfli
e8f491b01d Kernel/VFS: Validate paths against process veil in mkdir()
VirtualFileSystem::mkdir() relies on resolve_path() returning an error,
since it is only interested in the out_parent passed as a pointer. Since
resolve_path_without_veil returns an error, no process veil validation
is done by resolve_path() in that case. Due to this problem, mkdir()
should use resolve_path_without_veil() and then manually validate if the
parent directory of the to-be-created directory is unveiled with 'c'
permissions.

This fixes a bug where the mkdir syscall would not respect the process
veil at all.
2022-02-13 21:58:26 +02:00
Max Wipfli
8c7010f282 Kernel/VFS: Clear out_parent if path is veiled
Previously, VirtualFileSystem::resolve_path() could return a non-null
RefPtr<Custody>* out_parent even if the function errored because the
path has been veiled.

If code relies on recieving the parent custody even if the path is
veiled, it should just call resolve_path_without_veil and do the veil
validation manually. This is because it could be that the parent is
unveiled but the child isn't or the other way round.
2022-02-13 21:58:26 +02:00
Filiph Sandström
3ebb3d9d52 LibCore: Add Darwin anon_create support 2022-02-13 17:54:34 +00:00
Timothy Flynn
7e63f0eb32 LibWeb: Update TestHTMLTokenizer's expected token hash
The output of the tokenizer changed in commit:
b193351a99.
2022-02-13 17:37:33 +00:00
Joaquim Monteiro
3243091c0d LibTLS: Add SHA-384 as supported certificate signing algorithm 2022-02-13 21:02:58 +03:30
Brian Gianforcaro
d386d3946a Toolchain: Fix QEMU build with latest gcc by disabling -fcf-protection
I noticed after upgrading my machine that the QEMU is no longer building
due to GCC enabling `-fcf-protection` by default, even for targets that
don't support it.

The included patch came from the QEMU development list, but hasn't be
included in any patch releases at the time of writing.
https://lore.kernel.org/all/20220208211937.79580-1-vineetg@rivosinc.com/

Until QEMU patches, lets fix it on our end by patching before we build.
2022-02-13 17:11:53 +00:00
Ali Mohammad Pur
b760a1a4ba Ports: Update the citron patches after upstreaming a few
This also switches to checking out a specific commit instead of just the
master HEAD, as the port linter requires a hash (which is imo pointless
in this case), and we can't provide a stable hash for the master branch
HEAD.
2022-02-13 19:03:43 +03:30
Andreas Kling
4b412e8fee Revert "LibJS: Get rid of unnecessary work from canonical_numeric_index_string"
This reverts commit 3a184f7841.

This broke a number of test262 tests under "TypedArrayConstructors".
The issue is that the CanonicalNumericIndexString AO should not fail
for inputs like "1.1", despite them not being integral indices.
2022-02-13 16:01:32 +01:00
MacDue
b193351a99 LibWeb: Fix off-by-one in HTMLTokenizer::restore_to()
The difference should be between m_utf8_iterator and the
the new position, if m_prev_utf8_iterator is used one fewer
source position is popped than required.

This issue was not apparent on most pages since restore_to
used for tokens such  <!doctype> that are normally
followed by a newline that resets the column to zero,
but it can be seen on pages with minified HTML.
2022-02-13 14:51:09 +00:00
Ali Mohammad Pur
62ad33af93 Tests: Wrap test-bytecode-js source in an IIFE
Putting everything in the global scope will lead to mayhem and failing
tests with an actually correct implementation of scoping :^)
Also adds in a tiny debug log of the exception, otherwise we'd be
staring at failing tests with no info on what failed.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
1bbfaf8627 LibJS: More properly implement scoping rules in bytecode codegen
Now we emit CreateVariable and SetVariable with the appropriate
initialization/environment modes, much closer to the spec.
This makes a whole lot of things like let/const variables, function
and variable hoisting and some other things work :^)
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
c7e6b65fd2 LibJS: Implement ClassExpression::generate_bytecode()
...and use that in ClassDeclaration::generate_bytecode().
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
75aa900b83 LibJS: Make ASTNode::generate_bytecode() fallible
Instead of crashing on the spot, return a descriptive error that will
eventually continue its days as a javascript "InternalError" exception.
This should make random crashes with BC less likely.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
3a5f7cb524 LibJS: Don't emit a LeaveUnwindContext after a successful handler
The handler already comes with a nice and shiny FinishUnwind, doubling
up will leave two contexts instead.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
d7c207beb9 LibJS: Implement the NewClass opcode 2022-02-13 14:41:33 +00:00
Linus Groh
8b27917603 LibJS/Tests: Rename snake_case identifiers in string-basic.js 2022-02-13 14:33:46 +00:00
Linus Groh
b126a8b697 LibJS: Correct receiver value in GetValue's [[Get]] call 2022-02-13 14:30:26 +00:00
Linus Groh
5e2d059508 LibJS: Add spec comments to more Reference AOs 2022-02-13 14:30:03 +00:00
Andreas Kling
88e7d44cc4 LibJS+LibLine: Run clang-format 2022-02-13 14:55:23 +01:00
Andreas Kling
92e0378dbd LibJS: Always inline Lexer::current_code_point()
This gives a ~1% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
50a446a5d1 LibJS: Make more use of Token::flystring_value()
This patch makes check_identifier_name_for_assignment_validity()
take a FlyString instead of a StringView. We then exploit this by
passing FlyString in more places via flystring_value().

This gives a ~1% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
0cb0979990 LibJS: Add Token::flystring_value() to produce FlyString directly
When parsing identifiers, we ultimately want to sink the token string
into a FlyString anyway, and since Token may have a FlyString already
inside it, this allows us to bypass the costly FlyString(StringView).

This gives a ~3% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00