Commit graph

23351 commits

Author SHA1 Message Date
Daniel Bertalan 714bd011e1 Everywhere: Use the correct literal suffixes
When performing arithmetic with long doubles/floats, we want to avoid
floating point promotion and narrowing.
2021-07-08 10:11:00 +02:00
Daniel Bertalan b76ad3db90 IPCCompiler+WindowServer: Fix deleted function warning
It might be the case that we are passing non-movable/non-copyable things
through IPC. In this case, Clang will emit a warning as it can't
generate the requested default move/copy ctor for the IPC message.

To fix this, we use a `#pragma` to make the compiler silently ignore our
request.

The same was the case with the three-way comparison in `Screen`. Since
we don't use the three-way comparison operator anywhere else in our
codebase, we simply use the `==` operator instead.
2021-07-08 10:11:00 +02:00
Daniel Bertalan f14a4994b0 Everywhere: Don't promote float to double where not needed
The `float => double => float` round trip seen in a couple of places
might pessimize the code. Even if it's truncated to an int in the end,
it's weird not to use the functions with the `f` suffixes when working
with single precision floats.
2021-07-08 10:11:00 +02:00
Daniel Bertalan 01a0aa6e0b HackStudio: Do not check NonnullRefPtr for null value 2021-07-08 10:11:00 +02:00
Daniel Bertalan 949ea9cb4a Kernel: Use range-for wherever possible 2021-07-08 10:11:00 +02:00
Daniel Bertalan c6fafd3e90 AK+Userland: Add generic AK::abs() function and use it
Previously, in LibGFX's `Point` class, calculated distances were passed
to the integer `abs` function, even if the stored type was a float. This
caused the value to unexpectedly be truncated. Luckily, this API was not
used with floating point types, but that can change in the future, so
why not fix it now :^)

Since we are in C++, we can use function overloading to make things
easy, and to automatically use the right version.

This is even better than the LibC/LibM functions, as using a bit of
hackery, they are able to be constant-evaluated. They use compiler
intrinsics, so they do not depend on external code and the compiler can
emit the most optimized code by default.

Since we aren't using the C++ standard library's trick of importing
everything into the `AK` namespace, this `abs` function cannot be
exported to the global namespace, as the names would clash.
2021-07-08 10:11:00 +02:00
Daniel Bertalan 62f84e94c8 AK+Kernel: Fix perfect forwarding constructors shadowing others
If a non-const lvalue reference is passed to these constructors, the
converting constructor will be selected instead of the desired copy/move
constructor.

Since I needed to touch `KResultOr` anyway, I made the forwarding
converting constructor use `forward<U>` instead of `move`. This meant
that previously, if a lvalue was passed to it, a move operation took
place even if no `move()` was called on it. Member initializers and
if-else statements have been changed to match our current coding style.
2021-07-08 10:11:00 +02:00
Daniel Bertalan a2e0291172 WindowServer: Don't use old GNU-style designator
Since we use C++20, we can move to the new standardized designated
initializer syntax.
2021-07-08 10:11:00 +02:00
Daniel Bertalan ca06fd658d Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
Daniel Bertalan 5f7f063919 Everywhere: Mark debug-only functions [[maybe_unused]]
These functions are only used from within `dbgln_if` calls, so in
certain build configurations, they go unused. Similarly to variables, we
now signal to the compiler that we understand that these are not always
in use.
2021-07-08 10:11:00 +02:00
Andrew January 5598f63d0f WindowServer: Make descending into submenu make the submenu current
This fixes a bug with menu keyboard navigation. If you pressed the right
arrow to enter a submenu, then the left arrow to exit the submenu, then
right and left again it would leave no menu item selected.

Because descending into the submenu wasn't making it the current menu,
when you press the left arrow it couldn't find the "current menu" in the
stack, so didn't know what menu to pop back to.

It was an accident that it worked the first time you navigated into the
menu. Selecting the parent item also opened the submenu, and opening
an already open menu sets it as the current menu. After closing the
submenu with the left arrow, it is no longer already open, so it wasn't
getting set as the current menu.
2021-07-08 09:13:24 +02:00
Idan Horowitz eeb4c1eec9 LibJS: Reorder and add missing name & length properties to Built-ins
The specification dicatates that each built-in will have a length and
name property. (defined in that order)
2021-07-08 01:45:15 +01:00
Linus Groh 7e4b0681e1 LibJS: Implement Date.prototype.toTemporalInstant() 2021-07-08 01:25:49 +01:00
Linus Groh cc64efac44 LibJS: Split out NumberToBigInt from the BigInt constructor
This is supposed to be its own AO, but since it was only used in one
place, we inlined it. Now that it's also being used in the Temporal
proposal (Date.prototype.toTemporalInstant() specifically), it makes
sense to have it as a standalone function.
A small difference is that we now construct the SignedBigInteger without
casting to i32 but instead take the (known to be integral) double and
cast it to i64. Not perfect, but slightly better.
Also clean up the BigInt constructor a bit while we're here and sprinkle
some spec comments.
2021-07-08 01:25:49 +01:00
Linus Groh 3e8574a9a8 LibCrypto: Add missing implementation of SBI::multiplied_by(USBI)
This only had a declaration and was creating linker errors when used.
Easily fixed!
2021-07-08 01:25:49 +01:00
Andreas Kling f48e581eac WindowServer: When "flash flush" enabled, flash transparent rects green 2021-07-08 01:22:21 +02:00
Andreas Kling 32654b340a LibCore: Remove overly informal language in ArgsParser error message 2021-07-08 01:17:06 +02:00
Andreas Kling 432ab47053 WindowServer: Allow partial repaints in window frame & menubars
Before this change, invalidating any rect in a WindowFrame would cause
the entire window (including frame & drop shadow) to get invalidated,
leading to copious amounts of overdraw when mousing over menubars,
titlebars, and window buttons.

We now simply allow the partial frame invalidations through to the
window's dirty rects collection and the compositor takes care of it.
2021-07-08 01:17:06 +02:00
Andrew January cad62230f6 WindowServer: Close submenus when hovering over separators
ec6debb changed item_index_at to return -1 when hovering over a
separator. The intent was to not send the separator to clients for
MenuItemEntered.

However, this had the unintented consequence of not closing the submenu
when you hover over a separator. Submenus ignore when the item index is
-1 in order to leave the menu open when you move the mouse outside. This
ends up leaving the submenu open without the highlight to show what menu
item the submenu belongs to.

A slightly less severe consequence is that pressing the up or down arrow
key in such a situation would now go the top or bottom of the menu
rather than the item above or below the separator.

We now push the special casing of separators into set_hovered_index so
that the rest of the code behaves as it did before ec6debb.
2021-07-08 01:17:02 +02:00
Ralf Donau 6113fe4747 Kernel: Pledge promises accessible via /proc/PID/pledge 2021-07-08 01:16:26 +02:00
Timothy Flynn 35a2ba8ed8 LibJS: Implement RegExp.prototype [ @@search ]
String.prototype.search is already implemented, but relies on the well-
known Symbol.search, which was not implemented.
2021-07-08 00:01:20 +01:00
Timothy Flynn aaf5339fae LibJS: Do not downcast from Object to RegExpObject unless needed
Several test262 tests rely on creating phony RegExp objects that do not
have the internal slots used to test for a valid RegExp object. To allow
these tests to run (and because the spec doesn't require real RegExp
objects in these methods), do not attempt to downcast where it isn't
needed.
2021-07-08 00:01:20 +01:00
Timothy Flynn ce2651a320 LibJS: Remove RegExp 'do_match' helper
This was previously used as a wrapper for Regex::match when that method
was invoked by multiple RegExp.prototype implementations. But now all
implementations go through the RegExpExec abstraction, so this helper
is not needed. Remove it to discourage its usage.

Also update a comment about using dynamic properties for lastIndex; this
is no longer a FIXME.
2021-07-08 00:01:20 +01:00
Timothy Flynn 2d0589f93c LibJS: Implement global RegExp.prototype.match
Also rename the 'rx' variable to 'regexp_object' to match other RegExp
methods.
2021-07-08 00:01:20 +01:00
Timothy Flynn b6b5adb47d LibJS: Implement RegExp.prototype.match with RegExpExec abstraction 2021-07-08 00:01:20 +01:00
Timothy Flynn ec898a3370 LibJS: Implement RegExp.prototype.replace with RegExpExec abstraction
Also rename the 'rx' variable to 'regexp_object' to match other RegExp
methods.
2021-07-08 00:01:20 +01:00
Timothy Flynn 6c53475143 LibJS: Implement RegExp.prototype.test with RegExpExec abstraction 2021-07-08 00:01:20 +01:00
Timothy Flynn a90d5cb622 LibJS: Extract RegExp.prototype.exec to RegExpExec and RegExpBuiltinExec
The RegExp specification dictates that the internal implementation of
RegExp.prototype.exec must go through the RegExpBuiltinExec abstraction.

Note there is currently no functional difference in this commit. However
this now allows other RegExp.prototype methods to use RegExpExec rather
than calling RegExp.prototype.exec. Then, if JavaScript in the wild has
overwritten exec, RegExpExec has some protections to defer to
RegExpBuiltinExec.
2021-07-08 00:01:20 +01:00
Hendi 0dc4e722e6 LibJS: Make FunctionExpression more spec-compliant 2021-07-07 23:31:51 +01:00
Aziz Berkay Yesilyurt 0da1353c80 Userland: Keep ImageViewer window size the same while zooming in
ImageViewer window kept growing while zooming in, which causes out of
memory error and crashes the application. Now, only the image content
is rescaled and the window size is preserved.

We also open the display window as the same size as the image, which may
cause a similar issue for very large image files. This is prevented by
limiting the maximum window size to be the screen size.
2021-07-08 00:21:31 +02:00
Andreas Kling c0e20252da LibGUI: Don't repaint disabled scrollbars when mousing over them 2021-07-07 23:57:21 +02:00
Andreas Kling b027466f41 WindowServer+wsctl: Add a simple utility for toggling "flash flush"
You can now put the WindowServer into "flash flush" mode by doing:

$ wsctl -f 1

To disable it, somewhat obviously:

$ wsctl -f 0
2021-07-07 22:56:46 +02:00
Andreas Kling 6032b2cb2b WindowServer: When "flash flush" is enabled, stretch flash to 10 ms
Previously, this mode would flash flush/repaint rects in yellow for
however it long it took for the compositor to replace the yellow with
the final image instead.

Now we usleep() for 10 ms when flashing, so you get a chance to see
the yellow. This immediately makes "flash flush" mode super useful. :^)
2021-07-07 22:56:46 +02:00
Idan Horowitz 795786387b LibJS: Remove the NativeProperty mechanism from LibJS
These were an ad-hoc way to implement special behaviour when reading or
writing to specific object properties. Because these were effectively
replaced by the abillity to override the internal methods of Object,
they are no longer needed.
2021-07-07 21:47:22 +01:00
Idan Horowitz 306d59276a LibJS: Stop using a native property for RegExp's lastIndex property
This is not a functional change, the exposed (incorrect) behaviour is
the same as it was before, this simply removes the last user of
NativeProperties, allowing us to remove them completely from LibJS.
2021-07-07 21:47:22 +01:00
Daniel Bertalan 64b1740913 LibELF: Fix syscall regions for .text segments with a non-zero offset
Previously, we assumed that the `.text` segment was loaded at vaddr 0 in
all dynamic libraries, so we used the dynamic object's base address with
`msyscall`. This did not work with the LLVM toolchain, as it likes to
shuffle these segments around.

This now also handles the case when there are multiple text segments for
some reason correctly.
2021-07-07 22:26:53 +02:00
Daniel Bertalan d30dbf47f5 Kernel: Map non-page-aligned text segments correctly
`.text` segments with non-aligned offsets had their lengths applied to
the first page's base address. This meant that in some cases the last
PAGE_SIZE - 1 bytes weren't mapped. Previously, it did not cause any
problems as the GNU ld insists on aligning everything; but that's not
the case with the LLVM toolchain.
2021-07-07 22:26:53 +02:00
davidot ae8c4618b7 LibJS: Use as_object instead of as_array in flatten_into_array
Since is_array does not guarantee that it is<Array> we must use
as_object here.
2021-07-07 21:24:26 +01:00
davidot 4846c4a94e LibJS: Fix types and small spec discrepancy in ArrayPrototype::fill 2021-07-07 21:24:26 +01:00
davidot 6c47b77998 LibJS: Fix types and small spec discrepancy in ArrayPrototype::splice 2021-07-07 21:24:26 +01:00
davidot 7a41c758c0 LibJS: Fix types and small spec discrepancy in ArrayPrototype::includes 2021-07-07 21:24:26 +01:00
davidot cb44fc528b LibJS: Add a way of constructing PropertyName with values above 2**32-1
This is often needed in ArrayPrototype when getting items with indices
above 2**32-1 is possible since length is at most 2**53-1.
This also fixes a number of these cases in ArrayPrototype where the type
was not big enough to hold the potential values.
2021-07-07 21:24:26 +01:00
davidot a70033481d LibJS: Fix that length was sometimes cast to [ui]32
Since array-like objects can have much larger lengths even a u32 is not
sufficient.
2021-07-07 21:24:26 +01:00
davidot 7310713d11 LibJS: Remove fast array paths in ArrayPrototype::{pop, push}
Unfortunately this fast path leads to problems if Array.prototype is
changed. We probably need to find out some way to optimize these methods
by detecting changes to the prototype or other mechanisms.
2021-07-07 21:24:26 +01:00
Liav A 2900c8cf09 Documentation: Add simple troubleshooting guide
In this guide, we explain two boot errors that can occur and what can be
done to solve them.
2021-07-07 22:18:36 +02:00
Liav A cc98871383 Kernel: Print if image has become too large again
Instead of just disabling interrupts and halting when entering the C++
section, just halt with a printed message indicating the error.
2021-07-07 22:18:36 +02:00
Tom a95b726fd8 Kernel: Fix race causing modifying a Process to fail with a panic
The ProtectedDataMutationScope cannot blindly assume that there is only
exactly one thread at a time that may want to unprotect the Process.
Most of the time the big lock guaranteed this, but there are some cases
such as finalization (among others) where this is not necessarily
guaranteed.

This fixes random panics due to access violations when the
ProtectedDataMutationScope protects the Process instance while another
is still modifying it.

Fixes #8512
2021-07-07 21:57:01 +02:00
Tom 942bb976e2 Kernel: Add AtomicEdgeAction class
This class acts like a combined ref-count as well as a spin-lock
(only when adding the first or removing the last reference), allowing
to run a specific action atomically when adding the first or dropping
the last reference.
2021-07-07 21:57:01 +02:00
Linus Groh 116f1c5c56 Ports: Update Python to 3.9.6
Released on 2021-06-28.
https://www.python.org/downloads/release/python-396/
2021-07-07 20:24:48 +01:00
Andreas Kling 4ad389d0d6 Ports: Add a missing pipe character to AvailablePorts.md 2021-07-07 21:21:37 +02:00