Commit graph

35618 commits

Author SHA1 Message Date
Karol Kosek
11f82a32d4 LibGUI: Use preferred font line height for item heights in ListView
Previously, changing the font to one with a height greater than 18 meant
that no text was visible in the list items anymore.
2022-03-14 22:29:57 +01:00
Ali Mohammad Pur
d75cf27e02 LibJS: Implement default values for function parameters in BC 2022-03-14 22:28:53 +01:00
Ali Mohammad Pur
0b8d2fb62f LibJS/Bytecode: Replace merged block references before copying them 2022-03-14 22:28:53 +01:00
Simon Wanner
1f9d76c7b8 LibWeb: Invalidate styles after CSSImportRule loads
This replicates the behavior of StyleSheetList::add_sheet, making sure
the rules added by the imported style sheet are applied.
2022-03-14 22:22:53 +01:00
Simon Wanner
1ed5e79478 LibWeb: Fix resolving relative URLs in style sheets
Relative URLs in style sheets should be resolved relative to the
style sheet they're in instead of the document.
2022-03-14 22:22:53 +01:00
Ali Mohammad Pur
a37bee919a LibJS: Use ranges instead of specifying all registers for NewArray
Listing all the registers will lead to the inability to allocate enough
space in one basic block (as there can be an arbitrary number of
registers used), instead switch to specifying the range of registers
used and save a lot of space in the process.
2022-03-14 21:15:27 +03:30
Luke Wilde
e517cb505a LibJS/Bytecode: Make NewArray write directly to indexed properties
This follows how the regular AST interpreter creates arrays, as using
Array::create_from uses create_data_property_or_throw, which will crash
when it encounters an empty value. We require empty values to represent
array holes.
2022-03-14 21:15:27 +03:30
Luke Wilde
750b69540e LibJS/Bytecode: Setup declarative environment for lexical for statements 2022-03-14 21:15:27 +03:30
Luke Wilde
97af7654dd LibJS/Bytecode: Setup declarative environment for catch with variable 2022-03-14 21:15:27 +03:30
Luke Wilde
04774f923f LibJS/Bytecode: Setup lexical environment boundary for with statements
This allows us to properly unwind the object environment for `with` on
a block terminating instruction, e.g. an unconditional throw.
2022-03-14 21:15:27 +03:30
Luke Wilde
9f4cc6435d LibJS/Bytecode: Unwind to closest unwind boundary on Throw
This will leave any lexical/variable environments on the way to the
closest unwind context boundary.

This will not leave the closest unwind context, as we still need the
unwind context to perform the Throw instruction correctly.
2022-03-14 21:15:27 +03:30
Luke Wilde
858bcac4c7 LibJS/Bytecode: Unwind environments before block terminating instruction
When we reach a block terminating instruction (e.g. Break, Throw),
we cannot generate anymore instructions after it. This would not allow
us to leave any lexical/variable environments.

This uses the mechanism introduced in ba9c49 to unwind environments
when we encounter these instructions.
2022-03-14 21:15:27 +03:30
Luke Wilde
ada8880f58 LibJS: Leave unwind context if it has no finalizer when using handler
For example, a try/catch block with no finally. The try block and catch
block do not need to unwind to a finally block, so the unwind context
is no longer needed when we jump to the catch block.

If we threw an exception in a catch block of a try/catch, there will be
no handler or finalizer and the unit would continue on as if nothing
happened.

This would subsequently crash with the  `m_saved_exception.is_null()`
assertion failure when we next call a non-native function.
2022-03-14 21:15:27 +03:30
Luke Wilde
0356239f3e LibJS/Bytecode: Unconditionally end break/continuable scopes
Previously we would only end these scopes if the block was not
terminated. If the block was generated, we would not end the scope
and would generate other bytecode with these scopes still open.

These functions do not generate any code, so they can be used even if
the current block is terminated. The enter and end scope functions are
only used to track where to unwind to when break/continue are used.
2022-03-14 21:15:27 +03:30
Timothy Flynn
27904b1060 LibJS: Add a fast path for creating per-iteration DeclarativeEnvironment
The steps for creating a DeclarativeEnvironment for each iteration of a
for-loop can be done equivalently to the spec without following the spec
directly. For each binding creating in the loop's init expression, we:

    1. Create a new binding in the new environment.
    2. Grab the current value of the binding in the old environment.
    3. Set the value in the new environment to the old value.

This can be replaced by initializing the bindings vector in the new
environment directly with the bindings in the old environment (but only
copying the bindings of the init statement).
2022-03-14 16:33:15 +01:00
Timothy Flynn
f37fbcf516 LibJS: Preallocate the list returned from CreateListFromArrayLike
This list has up to 10,000 elements in some test262 tests, so let's
avoid frequent allocation bumps.
2022-03-14 16:33:15 +01:00
Timothy Flynn
c12cfe83b7 AK: Allow creating a Vector from any Span of the same underlying type
This allows, for example, to create a Vector from a subset of another
Vector.
2022-03-14 16:33:15 +01:00
Timothy Flynn
5bb00a75f5 CI: Do not "always" run GitHub Actions workflows
This way, if a branch is force-pushed in an open PR, running workflows
can be canceled.

https://docs.github.com/en/actions/learn-github-actions/expressions#always

"Always - Causes the step to always execute, and returns true, even when
canceled"
2022-03-14 10:27:19 -04:00
Sahan Fernando
683de841e5 Kernel: Sandbox each GPU3DDevice file description into own host context 2022-03-14 17:38:18 +03:30
Arif Orhun Uzun
fe7d801dd9 SpaceAnalyzer: Fix the crash caused by double click
With #12480, Breadcrumbbar's on_focus_change() uses
on_click(). In SpaceAnalyzer, double clicking triggers the
TreeWidgetMap's on_path_change(), which triggers Breadcrumbbar's
on_focus_change(), which also triggers the TreeWidgetMap's
on_path_change() again. This resulted in use-after-free of
Breadcrumbbar, thus resulted in the crash. Not updating the
TreeWidgetMap's viewpoint recursively solves the issue.
2022-03-14 07:40:22 -04:00
Brian Gianforcaro
01bd3c5563 LibC: Expose AK::timing_safe_compare via timingsafe_memcmp(..)
Ports / other userland often needs such an implementation to function.
Lets expose `AK::timing_safe_compare` under the same name used used in
OpenBSD / FreeBSD / Solaris and other projects.
2022-03-13 19:08:58 -07:00
Brian Gianforcaro
0a5321b3f9 LibCrypto: Use AK::timing_safe_compare to validate sensitive data
Addresses one FIXME in GCM, and another similar issue in EMSA_PSS.
We should be using constant time memory comparisons in all of our
crypto code.
2022-03-13 19:08:58 -07:00
Brian Gianforcaro
3ab2b90744 LibCore: Use timing_safe_compare to compare password hash values
This is not strictly required, as we are comparing hashes, not the
password it self. However given this is generic code that could be
used anywhere in the system, it seems prudent to be cautious and
make sure we don't inadvertently leak any information about the hash
via timing attacks in future usages of `LibCore::Account`.

Reported-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2022-03-13 19:08:58 -07:00
Brian Gianforcaro
390666b9fa AK: Add naive implementations of AK::timing_safe_compare
For security critical code we need to have some way of performing
constant time buffer comparisons.
2022-03-13 19:08:58 -07:00
Brian Gianforcaro
02b2f2787a Tests: Rename AK/TestMemMem.cpp to AK/TestMemory.cpp
Rename to create a new generic test group for the AK memory APIs.
2022-03-13 19:08:58 -07:00
Idan Horowitz
c575710e5e LibWeb: Use inline script tag source line as javascript line offset
This makes JS exception line numbers meaningful for inline script tags.
2022-03-14 00:25:33 +01:00
Luke Wilde
47d0d9fd65 Ports: Update curl to 7.82.0 2022-03-13 22:58:21 +01:00
Luke Wilde
47ec3dbf45 Ports: Update zstd to 1.5.2 2022-03-13 22:58:21 +01:00
Ben Maxwell
e435710f7c Base: Add syntax/code styling to Cupertino theme
This makes code readable in Hack Studio.

This commit also replaces the 'highlight' window colour
with one that matches theme (the previous was the default).
2022-03-13 22:57:55 +01:00
Sam Atkins
7535398dbf FileOperation: Port to Core::Stream 2022-03-13 22:38:48 +01:00
Sam Atkins
1925bde3c0 FileManager: Use Core::Stream for FileOperationProgressWidget 2022-03-13 22:38:48 +01:00
Sam Atkins
dc5a318aa9 FileManager: Use TRY in run_file_operation()
The exception is `execvp()` since that has no Core::System wrapper yet.
2022-03-13 22:38:48 +01:00
Lenny Maiorani
6a23dfbc92 LibGfx: Use common class template for PBM/PGM/PPM image loaders
PBM, PGM, and PPM image loaders are mostly common. The only difference
is how the data is read and the associated magic numbers. The magic
numbers are already made common using the loading contexts. Now make
the implementations common via a class template which accepts the
context to disambiguate.
2022-03-13 22:35:20 +01:00
Lenny Maiorani
786b02730c LibGfx: Commonize P[BGP]M file loading contexts
Much of the code in PBM, PGM, and PPM image loaders is common. The
contexts are nearly identical. Instead of writing multiple contexts,
write 1 with a template argument to pass in the details of the given
format.
2022-03-13 22:35:20 +01:00
Lenny Maiorani
5c21f963ff Libraries: Use default constructors/destructors in LibX86
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-03-13 22:34:38 +01:00
Lenny Maiorani
1a59cffb00 Libraries: Use default constructors/destructors in LibWebSocket
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-03-13 22:34:38 +01:00
Lenny Maiorani
8b334248e4 Libraries: Use default constructors/destructors in LibVT
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-03-13 22:34:38 +01:00
Lenny Maiorani
a53c00f1df Libraries: Use default constructors/destructors in LibThreading
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-03-13 22:34:38 +01:00
Lenny Maiorani
7cc6ba16be Libraries: Use default constructors/destructors in LibSyntax
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-03-13 22:34:38 +01:00
Lenny Maiorani
7abb782206 Libraries: Use default constructors/destructors in LibSQL
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-03-13 22:34:38 +01:00
Lenny Maiorani
dd08e84664 Libraries: Use default constructors/destructors in LibMarkdown
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-03-13 22:34:38 +01:00
Lenny Maiorani
103ce2f9e9 Libraries: Use default constructors/destructors in LibLine
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-03-13 22:34:38 +01:00
Lenny Maiorani
dcdc62323d Libraries: Use default constructors/destructors in LibIPC
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-03-13 22:34:38 +01:00
Lenny Maiorani
79aa49d04f Libraries: Use default constructors/destructors in LibHTTP
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-03-13 22:34:38 +01:00
Lenny Maiorani
97fcbdd199 Libraries: Use default constructors/destructors in LibGemini
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-03-13 22:34:38 +01:00
Andreas Kling
c1e6fc67a1 LibWeb: Add a Vector::ensure_capacity() in collect_matching_rules()
Avoid some incremental Vector growth by pre-allocating enough capacity
to cover the case where every single selector matches an element.
2022-03-13 19:55:08 +01:00
Andreas Kling
afc5fade05 LibWeb: Add some fast_is<T> helpers for hot classes on GitHub :^) 2022-03-13 18:09:43 +01:00
Andreas Kling
74fda2a761 LibWeb: Make CSS::property_initial_value() use an Array internally
Since we want to store an initial value for every CSS::PropertyID,
it's pretty silly to use a HashMap when we can use an Array.

This takes the function from ~2.8% when mousing around on GitHub all the
way down to ~0.6%. :^)
2022-03-13 18:09:43 +01:00
Andreas Kling
39389b5704 LibWeb: Don't make deep copy of custom properties for every element
Previously we were making a copy of the full set of custom properties
that applied to a DOM element. This was very costly and dominated the
profile when mousing around on GitHub.

Note that this may break custom properties on pseudo elements a little
bit, and that's something we'll have to look into.
2022-03-13 18:09:43 +01:00
Andreas Kling
f88d65d9cb LibWeb: Cache CSS::Selector's pseudo element at construction time
Computing the pseudo element of a CSS::Selector was very hot when
mousing around on GitHub in Browser. A profile had it at ~10%.
After these changes, it's totally gone from the profile. :^)
2022-03-13 18:09:43 +01:00