Commit graph

53036 commits

Author SHA1 Message Date
Hendiadyoin1 127b966219 AK: Expose Checked::saturating_[add|sub] as static helpers 2023-08-05 20:03:09 +02:00
Hendiadyoin1 af161a8b83 AK+LibWeb: Round to int in clamp_to_int instead of truncating
This caused inaccuracies in float->CssPixel conversions
2023-08-05 20:03:09 +02:00
MacDue 7b7ba38655 Ladybird: Fix scroll step size
The Qt docs are not that clear, but to get the number of steps the
wheel was scrolled you divide by 120 (which when multiplied by
wheelScrollLines() gives the scroll offset).
2023-08-05 19:50:17 +02:00
MacDue 22d06a4ff0 LibWeb: Set scroll step size to a value consistent with Qt/Ladybird
This probably should not be hardcoded, but for now having a consistent
value makes things feel nice.
2023-08-05 19:50:17 +02:00
Liav A 29fb3a1a60 Utilities/ls: Add an option to print raw inode numbers
This is only possible if listing an entire directory, because the LibC
readdir function will return the raw inode number in each struct dirent,
therefore allowing to print it as well.
2023-08-05 18:41:01 +02:00
Liav A 93ef955597 LibCore: Keep the raw inode number value in DirectoryEntry
This will be used later on by other userspace programs that need it.
2023-08-05 18:41:01 +02:00
Liav A 5efb91ec06 Kernel/VFS: Ensure working with mount entry per a custody is safe
Previously we could get a raw pointer to a Mount object which might be
invalid when actually dereferencing it.
To ensure this could not happen, we should just use a callback that will
be used immediately after finding the appropriate Mount entry, while
holding the mount table lock.
2023-08-05 18:41:01 +02:00
Liav A d216f780a4 Kernel/VFS: Remove the find_mount_for_guest method
We don't really need this method anymore, because we could just try to
find the mount entry based on the given mount point host custody.

This also allows us to remove the is_vfs_root and root_inode_id methods
from the VirtualFileSystem class.
2023-08-05 18:41:01 +02:00
Liav A e5c7662638 Kernel/VFS: Check matching absolute path when jump to mount guest inode
We could easily encounter a case where we do the following:

```
mkdir -p /tmp2
mount /dev/hda /tmp2
```

would produce a bug that doing `ls /tmp2/tmp2` will give the contents
on `/dev/hda` ext2 root directory and also on `/tmp2/tmp2/tmp2` and so
on.
To prevent this, we must compare the current custody against each mount
entry's custody to ensure their paths match.
2023-08-05 18:41:01 +02:00
Liav A 80f400a150 Kernel/VFS: Don't resolve root inode mounts when traversing a directory
This is not useful, as we have literally zero knowledge about where this
inode is actually located at with respect to the entire global path tree
so we could easily encounter a case where we do the following:

```
mkdir -p /tmp2
mount /dev/hda /tmp2
```

and when traversing the /tmp2 directory entries, we will see the root
inode of /dev/hda on "/tmp2/tmp2", even if it was not mounted.

Therefore, we should just plainly give the raw directory entries as they
are written "on the disk". Anything else that needs to exactly know if
there's an underlying mounted filesystem, can just use the stat syscall
instead.
2023-08-05 18:41:01 +02:00
Liav A debbfe07fb Kernel/VFS: Ensure Custodies' absolute path don't match before mounting
This ensures that the host mount point custody path is not the same like
the new to-be-mounted custody.

A scenario that could happen before adding this check is:
```
mkdir -p /tmp2
mount /dev/hda /tmp2/
mount /dev/hda /tmp2/
mount /dev/hda /tmp2/ # this will fail here
```

and after adding this check, the following scenario is now this:
```
mkdir -p /tmp2
mount /dev/hda /tmp2/
mount /dev/hda /tmp2/ # this will fail here
mount /dev/hda /tmp2/ # this will fail here too
```
2023-08-05 18:41:01 +02:00
Liav A 8da7d84512 Kernel/VFS: Remove misleading part of debug message when mounting 2023-08-05 18:41:01 +02:00
Bastiaan van der Plaat 220e34b69d LibWeb: Add Canvas Context2D basic text align and text baseline support
Add the CanvasTextDrawingStyles mixin with the textAlign and
textBaseline attributes. Update fill_text in CanvasRenderingContext2D
to move the text rect by the text align and text baseline attributes.
Wrote a simple HTML example to showcase the new features.
2023-08-05 17:17:08 +02:00
Ali Mohammad Pur e689422564 LibRegex: Keep track of instruction positions for backwards tree jumps 2023-08-05 16:40:04 +02:00
Andreas Kling 64c06c345e LibWeb: Parse :host() selector
We were already parsing non-function-syntax :host, so let's also do
the :host(...) variant. Note that we don't have matching for these yet.

This fixes many issues on sites generated by Wix, as they often have
selector lists that include some :host() selector, and we'd reject the
entire rule after failing to parse it.
2023-08-05 13:23:12 +02:00
Aliaksandr Kalenik ac2d9d9273 Ladybird: Do not try to use pixelDelta() to calculate wheel offset
Documentation says that pixelDelta() is not reliable across platforms
so always using angleDelta() should produce more predictable scrolling
behaviour.
2023-08-05 13:22:59 +02:00
Andreas Kling 6f0a93b5df Tests/LibWeb: Rebaseline a block-and-inlines layout test
This test was created before layout test dumps included the paint tree.
2023-08-05 12:09:34 +02:00
Tim Ledbetter eda73af265 Ports/potrace: Add zlib dependency 2023-08-05 12:03:21 +02:00
Zaggy1024 2582b85ab1 LibWeb: Update reactive images according to spec after fetches finish
Reactive images that had an image source selected based on viewport
size would only update when the images were first fetched, meaning the
last valid image source would become stuck in an image element. By
implementing the last step for reacting to environment changes, we can
run the proper updates even when the image does not need to be fetched.
2023-08-05 11:41:41 +02:00
Tim Ledbetter 256084b0b9 top: Disable echo and line buffering on startup
This means we no longer show any characters the user types while top
is running.

Disabling line buffering has the same effect as enabling
non-blocking I/O, but it doesn't crash the terminal when we exit the
program without restoring stdin to its original state. This would
previously happen when a SIGKILL signal was received, for example.
2023-08-05 11:08:16 +02:00
Andreas Kling 41e7c5766e LibWeb: Support more kinds of indefinite widths on flex column items
This stuff is pretty hairy since the specifications don't give any
guidance on which widths to use when calculating the intrinsic height of
flex items in a column layout.

However, our old behavior of "treat anything indefinite as fit-content"
was definitely not good enough, so this patch improves the situation by
considering values like `min-content`, `max-content` and `fit-content`
separately from `auto`, and making the whole flex layout pipeline aware
of them (in the cross axis context).
2023-08-05 10:58:12 +02:00
Daniel Bertalan 17b363b596 Ports/vim: Override uname output to fix compilation on macOS
`vim` does not use a mechanism like `config.sub` for determining the
canonical system name from the `--target` triple passed to `configure`.
Instead, it directly executes the `uname` executable on the host. This
leads to it trying to build macOS-specific files on Mac hosts even if we
are compiling for a different platform. To make cross-compilation
possible, developers added a way to override `uname`'s output with
environment variables. Let's set these.

See vim/vim#9338
Obsoletes #11426

Co-Authored-By: unixinspace <unixinspace@users.noreply.github.com>
2023-08-05 10:57:27 +02:00
Andi Gallo 7b0b501418 LibWeb: Improve adjustment of automatic table width with percentages
Use the max-width of percentage cells instead of min-width as the
reference to be used to compute the total table width. The specification
only suggests that the UA should try to satisfy percentage constraints
and this behavior is more consistent with other browsers.
2023-08-05 10:32:48 +02:00
Aliaksandr Kalenik d32bf4cd41 LibWeb: Set min-width for inline child boxes after inside layout
min-width for boxes with inline children can only be applied after
inside layout is done and width of box content is known.
2023-08-05 09:25:24 +02:00
Hediadyoin1 50bf303edd LibJS: Capture UnrealizedSourceRanges in ExecutionContext, not ASTNodes
This loosens the connection to the AST interpreter and will allow us to
generate SourceRanges for the Bytecode interpreter in the future as well

Moves UnrealizedSourceRanges from TracebackFrame to the JS namespace for
this
2023-08-05 06:39:06 +02:00
Lucas CHOLLET cd9bb985d4 LibGfx/JPEGXL: Add support for the self-correcting predictor
This predictor is much more complicated than the others. Indeed, to be
computed, it needs its own value but for other pixels. As you can guess,
implementing it involved the introduction of a structure to hold that
data.

Fundamentally, this predictor uses the value of the error between the
predicted value and the true value (aka decoded value) of pixels around.
One of this computed error (namely max_error) is used as a property, so
this patch also solves a FIXME in `get_properties`.

To ease the access to value that are close in the channel and moving
their values around, this patch adds a `Neighborhood` struct which holds
this data. It has been used in `prediction()` and it allowed to simplify
the signature and to remove the explicit retrieval of the underlying
data.

All this work allows us to decode the default image that appears when
loading `https://jxl-art.surma.technology`. However, we still render it
incorrectly due to the lack of support for orientation values different
from 1.
2023-08-05 06:30:59 +02:00
MacDue a01a2f712e LibWeb: Fix calculating the corner radius values for SVG <rect>
Previously, this would treat having both rx and ry set as if just rx
was set. The checks are now updated to match the spec comments above
them :).
2023-08-05 04:50:33 +02:00
Tim Schumacher d95f1deade Meta: Add myself to CODEOWNERS 2023-08-05 04:50:00 +02:00
Aliaksandr Kalenik b549f2d1d9 WebContent: Coalesce multiple sequential MouseWheel events
Same as a58d84407f but for MouseWheel :)
2023-08-05 04:47:46 +02:00
Aliaksandr Kalenik 6631314874 Ladybird: Send mouse wheel events to WebContent process
Rather than directing mouse wheel events to the QAbstractScrollArea,
send them to the WebContent process, allowing it to determine if they
should be consumed by the element or used for page scrolling.
2023-08-05 04:47:46 +02:00
Andrew Kaster 3a82f2d7ec Meta: Port 059857d26f to gn build 2023-08-04 20:02:28 -06:00
Daniel Bertalan a2daed5817 Ports/gettext: Replace manually linking libintl with a libtool patch
The `gettext` port comprises of multiple libraries, however `libintl.so`
is the one most commonly used in external executables/libraries, so
porting the patches to this one is enough.
2023-08-05 01:05:06 +02:00
Daniel Bertalan e9ce317483 Ports: Replace manually linking freetype with a libtool patch 2023-08-05 01:05:06 +02:00
Daniel Bertalan a050d91073 Ports/zlib: Do not manually link zlib into a shared library
Instead, pass our system name to its (non-autotools) configure script.
Tell it to include a SONAME to avoid breaking dependent ports when
updating zlib.
2023-08-05 01:05:06 +02:00
Sebastian Zaha 100714b8ac Meta: Pretty-print strings in gdb as a single object, not by character
This changes the string pretty-printer to show strings as
"full" as opposed to {"f", "u", "l", "l", "\0"}.
2023-08-05 02:16:55 +03:30
Sebastian Zaha e13b89dd20 Meta: Implement support for the new String in the gdb formatter
The pretty-print gdb helpers were not updated since the
DeprecatedString change. This commit introduces a new printer for String
and renames the old one to DeprecatedString.
2023-08-05 02:16:55 +03:30
0GreenClover0 259228d8d2 Spreadsheet: Set Help window mode to Modeless in the constructor
And don't try to do it every time the Help button is clicked.
This fixes a crash when clicking the Help button twice (setting window
mode on an already visible window is not supported).

This also fixes a situation where when opening the Help window with an
action, we didn't set its mode to "Modeless".
2023-08-05 02:14:51 +03:30
Bastiaan van der Plaat 059857d26f Ladybird: Add app icon for macOS 2023-08-04 15:36:37 -06:00
Andrew Kaster ef03e73844 Meta: Port ad440f9e9a to gn build 2023-08-04 14:20:00 -06:00
Andrew Kaster 616e61ee23 Meta: Port bc4d4f0f95 to gn build 2023-08-04 14:20:00 -06:00
Andrew Kaster 777fb44bb0 Meta: Port 78e1defbfe to gn build 2023-08-04 14:20:00 -06:00
ronak69 1453028975 Shell: Color bareword yellow if it's a prefix of at least one command
Before, if a bareword wasn't a runnable program's filename it got
colored red and white otherwise. Now, additionally it will be checked if
it is a "prefix" of a possible command and colored yellow if it is and
red if not.

Coloring this way provides another "feedback" to the user: If while
typing out a command name the color changes from yellow to red then a
typo occurred :^)

To check if a bareword is a prefix the `Shell::complete_program_name()`
function is utilized (if pressing tab gives you some suggestions then it
is a prefix).
2023-08-04 23:27:59 +03:30
Zaggy1024 ad440f9e9a LibWeb/Ladybird: Use the abstract audio output in a new audio plugin
The implementation of this plugin is meant to eventually replace all
current audio plugins in Ladybird. The benefits over the current Qt-
based audio playback plugin in Ladybird are:

- Low latency: With direct access to PulseAudio, we can ask for a
specific latency to output to allow minimal delay when pausing or
seeking a stream.
- Accurate timestamps: The Qt audio playback API does not expose audio
time properly. When we have access directly to PulseAudio APIs, we can
enable their timing interpolation to get an accurate monotonically-
increasing timestamp of the playing audio.
- Resiliency: With more control over how the underlying audio API is
called, we have the power to fix most bugs we might encounter. The
PulseAudio wrappers already avoid some bugs that occur with QAudioSink
when running through WSLg.
2023-08-04 13:49:36 -06:00
Zaggy1024 bc4d4f0f95 LibAudio: Create a playback class with a PulseAudio implementation
This adds an abstract `Audio::PlaybackStream` class to allow cross-
platform audio playback to be done in an opaque manner by applications
in both Serenity and Lagom.

Currently, the only supported audio API is PulseAudio, but a Serenity
implementation should be added shortly as well.
2023-08-04 13:49:36 -06:00
Zaggy1024 fe672989a9 LibCore: Add a class for thread-safe promises
Since the existing Promise class is designed with deferred tasks on the
main thread only, we need a new class that will ensure we can handle
promises that are resolved/rejected off the main thread.

This new class ensures that the callbacks are only called on the same
thread that the promise is fulfilled from. If the callbacks are not set
before the thread tries to fulfill the promise, it will spin until they
are so that they will run on that thread.
2023-08-04 13:49:36 -06:00
Zaggy1024 8626404ddb LibCore: Store the event loop stack as a function-scope thread_local
By allocating the event loop stack onto the heap, we were leaking it
when exiting. This way, we should avoid ASAN being unhappy with us.
2023-08-04 13:49:36 -06:00
Zaggy1024 78e1defbfe Ladybird: Allow posting events to the Qt event loop from other threads
Previously, a QTimer was used to start processing of our event queue in
the main Qt event loop. Unfortunately, QTimers are not thread-safe, and
disallow starting of a timer from a different thread than it was
created in.

Instead, use a dummy QObject to post a custom QEvent to the main loop
from whatever thread we like, and process our event queue when it is
received by our dummy object.
2023-08-04 13:49:36 -06:00
Zaggy1024 6131d879f7 Ladybird: Process Qt event queue when polling the event loop
The logic for `EventLoopImplementationQt::pump()` caused calls to
`EventLoop::pump(PumpMode::DontWaitForEvents)` to not consume events
posted to the Qt event queue. This caused the window to be unresponsive
even when polling the event loop, if waiting was not desired.
2023-08-04 13:49:36 -06:00
Tim Schumacher a8f5cf9da7 Ports/sqlite: Replace the stub libtool patch with the full version 2023-08-04 20:51:19 +02:00
Andrew Kaster a0869159cd Meta: Add Alexander Kalenik to the contributors list :^)
With a moderate historical delay, in what seems to be the correct order
2023-08-04 12:04:01 -06:00