Commit graph

47982 commits

Author SHA1 Message Date
Timothy Flynn
31bdd8a918 headless-browser: Massage URLs a bit before loading
This is to mimic what Ladybird and Browser do before trying to load the
URL.
2023-03-13 12:41:10 +00:00
kleines Filmröllchen
4420e48dc3 LibAudio: Use symbolic constants for MP3 frame and granule size 2023-03-13 13:25:42 +01:00
kleines Filmröllchen
264cc76ab4 LibAudio: Move audio stream buffering into the loader
Before, some loader plugins implemented their own buffering (FLAC&MP3),
some didn't require any (WAV), and some didn't buffer at all (QOA). This
meant that in practice, while you could load arbitrary amounts of
samples from some loader plugins, you couldn't do that with some others.
Also, it was ill-defined how many samples you would actually get back
from a get_more_samples call.

This commit fixes that by introducing a layer of abstraction between the
loader and its plugins (because that's the whole point of having the
extra class!). The plugins now only implement a load_chunks() function,
which is much simpler to implement and allows plugins to play fast and
loose with what they actually return. Basically, they can return many
chunks of samples, where one chunk is simply a convenient block of
samples to load. In fact, some loaders such as FLAC and QOA have
separate internal functions for loading exactly one chunk. The loaders
*should* load as many chunks as necessary for the sample count to be
reached or surpassed (the latter simplifies loading loops in the
implementations, since you don't need to know how large your next chunk
is going to be; a problem for e.g. FLAC). If a plugin has no problems
returning data of arbitrary size (currently WAV), it can return a single
chunk that exactly (or roughly) matches the requested sample count. If a
plugin is at the stream end, it can also return less samples than was
requested! The loader can handle all of these cases and may call into
load_chunk multiple times. If the plugin returns an empty chunk list (or
only empty chunks; again, they can play fast and loose), the loader
takes that as a stream end signal. Otherwise, the loader will always
return exactly as many samples as the user requested. Buffering is
handled by the loader, allowing any underlying plugin to deal with any
weird sample count requirement the user throws at it (looking at you,
SoundPlayer!).

This (not accidentally!) makes QOA work in SoundPlayer.
2023-03-13 13:25:42 +01:00
kleines Filmröllchen
d707c0a2f5 LibGUI: Make thumbnail generation resilient between FileSystemModels
With the new canceled background actions, some thumbnail generation
callbacks are not executed if the user closes the window with a
FileSystemModel quickly enough. Therefore, we remember which thumbnails
we started to generate and consider the associated promises if we're
looking up a thumbnail. Since the thumbnail generation itself continues
running and the cache is application-global, instead of never displaying
thumbnails for images that were "interrupted" generating thumbnails the
first time, we can now fetch their images immediately and reliably.
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
cf1fa419ab LibThreading: Register BackgroundAction with EventLoop
BackgroundActions are now added as a job to the event loop, therefore
they get canceled when the loop exits and their on_complete action never
runs. This fixes all UAF bugs related to BackgroundAction's use of
EventLoops, as seen with e.g. thumbnail generation.
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
8f4d0d3797 LibCore+Userland: Make Promise's on_resolve fallible
This will be primarily necessary for BackgroundAction integration, but
it already allows us to add proper error handling in LibIMAP :^)
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
dc318d3080 LibCore: Add a constructor that sets the parent object 2023-03-13 12:12:17 +00:00
kleines Filmröllchen
30295bd988 LibCore: Allow EventLoop to manage and cancel promises
In this context, the promises are considered "jobs", and such jobs
depend in some way on the event loop. Therefore, they can be added to
the event loop, and the event loop will cancel all of its pending jobs
when it ends.
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
bfd9f681f7 LibCore+Userland: Allow canceling promises
To make EventLoop cancel its managed Promises, we need the ability to
cancel them in the first place.
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
afd0f941b7 LibCore: Add Promise to the forward declare header 2023-03-13 12:12:17 +00:00
Tim Ledbetter
82219d0879 Base: Add missing options to sort man page 2023-03-13 07:53:24 +00:00
Tim Ledbetter
0454d655bb sort: Add an option to sort in reverse order
Lines can now be sorted in reverse order by specifying the `-r` option.
2023-03-13 07:53:24 +00:00
Timothy Flynn
f5f1a5228e LibWeb: Escape HTML text fragments with multi-byte code point awareness
The UTF-8 encoding of U+00A0 (NBSP) is the bytes 0xc2 0xa0. By looping
over the string to escape byte-by-byte, we replace the second byte with
" ", but leave the first byte in the resulting text. This creates
an invalid UTF-8 string, with a lone leading byte.
2023-03-13 07:29:40 +00:00
Andrew Kaster
3219ecbdc0 Ports: Add port of backward-cpp, a pretty backtrace library 2023-03-13 07:23:53 +00:00
Andrew Kaster
e690b35fdc Ports: Install libiberty from binutils port
Normally this is supposed to be installed from gdb or gcc. If a port
wants to link against libbfd though, we need to make sure libiberty is
actually available in the root filesytem without requiring the port to
depend on those larger packages.
2023-03-13 07:23:53 +00:00
Andrew Kaster
6ce7257ad7 Kernel: Don't include Kernel/Arch/RegisterState from userspace
Any userspace cpp file that included <syscall.h> would end up with
a large glob of Kernel headers included, all the way down to
Kernel/Arch/x86_64/CPU.h and friends.

Only the kernel needs RegisterState, so hide it from userspace.
2023-03-13 07:23:53 +00:00
Timothy Flynn
11fe34ce0f headless-browser: Re-implement headless-browser using an OOPWV
headless-browser currently uses its own PageClient to load web pages
in-process. Due to this, it also needs to set up a whole bunch of other
objects needed to run LibWeb, e.g. image decoders, request servers, etc.

This changes headless-browser to instead implement a WebView to launch
WebContent out-of-process. This implementation is almost entirely empty,
but can be filled in as-needed. For example, we may want to print
JavaScript console messages.
2023-03-13 07:21:00 +00:00
Timothy Flynn
add15a5f04 Ladybird+LibWebView: Move WebContent process launcher to LibWebView
This is to allow headless-browser to reuse this code. We have a similar
helper for launching SQLServer from Ladybird.
2023-03-13 07:21:00 +00:00
Karol Baraniecki
be4da57004 Base: Make keyboard keys in the BrickGame manual and Help page stand out
by making them `monospace` in the Help page, and bold in the manual.
This helps to quickly find out where the keyboard controls are in the
manual when skimming its contents.
2023-03-13 06:43:59 +00:00
Karol Baraniecki
d4d625b58e Base: Document Escape and P pausing/unpausing BrickGame 2023-03-13 06:43:59 +00:00
Karol Baraniecki
ddac8192e3 BrickGame: Add a "Pause" option to the Game menu
This is how the menu looks like after this commit:
┌────┐
│Game│ Help
├────┴─────────────────────────────┐
│   New game                   F2  │
│   Toggle pause                P  │
├──────────────────────────────────┤
│   Quit                   Alt+F4  │
└──────────────────────────────────┘
2023-03-13 06:43:59 +00:00
Karol Baraniecki
a337557658 BrickGame: Show a box with "Paused" in it when the game is paused
Looks a bit like this:

  ┌────────────┐
  │            │
  │   Paused   │
  │            │
  └────────────┘
2023-03-13 06:43:59 +00:00
Karol Baraniecki
1fd61d2af3 BrickGame: Disallow manual piece movement while paused
This make the pause feature feel much better.
2023-03-13 06:43:59 +00:00
Karol Baraniecki
06a9e4280b BrickGame: Stop bricks from falling when paused
Allows for pausing with either the `P` or `Escape` keys. In this commit
you can still rotate pieces when paused - which makes for an interesting
"stop-time" cheat mechanic, but probably isn't yet what we want.
2023-03-13 06:43:59 +00:00
Nico Weber
dfb45705e6 LibCompress: Make DeflateCompressor::write() use loop, not recursion
This is performance-neutral, but Instruments.app had a hard time
visualizing the very deeply nested stack frames here.

No behavior change.
2023-03-13 06:32:56 +00:00
Nico Weber
e26aebca4f SpiceAgent: Remove unused BMPWriter.h include 2023-03-12 22:09:34 +01:00
Xexxa
402ff46b78 Base: Add Batak to font Katica Regular 10
1BC0-1BF3, 1BFC-1BFF https://www.unicode.org/charts/PDF/U1BC0.pdf
2023-03-12 22:09:20 +01:00
Tim Schumacher
515f31339c LibC: Correctly reset the getopt state on optind = 1
The Linux `getopt_long` manpage tells users to reset `optind` to 1 when
scanning the same argument vector or a new argument vector again. This
makes sense, since `optind` denotes the _next_ option to be processed.

The behavior of setting `optind` to 0 doesn't seem to be specified
anywhere, so let's also remove that comment from `unistd.h`.
2023-03-12 22:09:09 +01:00
Lucas CHOLLET
b5594bf9a2 PixelPaint: Display color information on mousemove with the PickerTool
Per-channel values of the pixel color are now displayed in the status
bar when the PickerTool is selected. This information obviously updates
on mousemove.
2023-03-12 22:08:24 +01:00
Nico Weber
c587ada084 LibGfx: Make BMPWriter::dump() return ErrorOr
...and use TRY() consistently in BMPWriter.cpp
2023-03-12 21:07:25 +00:00
Nico Weber
a2ccf38f11 LibGfx: Make BMPWriter::dump() not take a RefPtr 2023-03-12 21:32:21 +01:00
Nico Weber
833d0d95c9 LibGfx: Remove a redundant copy of all data when writing a BMP 2023-03-12 21:32:21 +01:00
Nico Weber
f1a3028ef1 LibGfx: Change BMPWriter API to be consistent with other image writers 2023-03-12 21:32:21 +01:00
Nico Weber
01387eb72b LibGfx: Change second argument of BMPWriter::dump() to Options struct
This makes it more economical to add more options here, and makes it
possible to use similar API surface for the other image writers.

(It looks like nothing currently uses this optional parameter, but
having a way to pass options to image writers seems like something
we generally want.)
2023-03-12 21:32:21 +01:00
Nico Weber
74891ab656 LibGfx: Remove unused BMPWriter::set_compression()
This has always been unused, and after #8440 BMPWriter::dump()
unconditionally writes to m_compression, meaning even if this
method was called, it would have no effect.
2023-03-12 21:32:21 +01:00
Andreas Kling
7bb7d87807 LibWeb: Resolve percentage line-height values before CSS inheritance
Percentage line-height values are relative to 1em (i.e the font-size
of the element). We have to resolve their computed values before
proceeding with inheritance.
2023-03-12 18:10:32 +01:00
Andreas Kling
7b55d79d3a LibWeb: Actually incorporate style from imported style sheets 2023-03-12 18:10:32 +01:00
Andreas Kling
1b262f8c89 Tests/LibWeb: Only care about *.html files in layout test runner 2023-03-12 18:10:32 +01:00
Andreas Kling
92eaad8f2e LibWeb: Consider entire stack of floated boxes when floating new box
If normal flow layout has caused us to progress past the current
innermost float in the block axis, we still need to consider the floats
stacked outside of it.

Fix this by always walking the currently stacked floats from innermost
to outermost when placing new floats.
2023-03-12 18:10:32 +01:00
Andreas Kling
6960a1bb45 LibWeb: Stop polluting layout tree dumps with TextNode memory addresses
I've never actually used this for anything, and it's pretty noisy.
2023-03-12 18:10:32 +01:00
Liav A
633006926f Kernel: Make the Jails' internal design a lot more sane
This is done with 2 major steps:
1. Remove JailManagement singleton and use a structure that resembles
    what we have with the Process object. This is required later for the
    second step in this commit, but on its own, is a major change that
    removes this clunky singleton that had no real usage by itself.
2. Use IntrusiveLists to keep references to Process objects in the same
    Jail so it will be much more straightforward to iterate on this kind
    of objects when needed. Previously we locked the entire Process list
    and we did a simple pointer comparison to check if the checked
    Process we iterate on is in the same Jail or not, which required
    taking multiple Spinlocks in a very clumsy and heavyweight way.
2023-03-12 10:21:59 -06:00
Nico Weber
9b297c634f LibGfx: Make QOIWriter use ErrorOr
In addition to it now handling allocation failures, the encode() API is
now consistent with PNGWriter.
2023-03-12 13:23:34 +00:00
MacDue
b698d64ee9 LibGfx: Use StringView literals for CSS color list
And also remove the null terminating entry in favour of for-each loop.
2023-03-12 12:46:24 +00:00
Nico Weber
b10ec6743f Userland: Add an image utility
At the moment, all it can do is read all image formats that LibGfx can
read and save to any image format that LibGfx can write (currently bmp,
png, qoi).

Currently, it drops all image metadata (including color profiles).

Over time, this could learn tricks like keeping color profiles,
converting an image to a different color profile, cropping out a part of
an image, and so on.
2023-03-12 12:17:26 +00:00
Nico Weber
3cff36b7ab Meta+CMake: Remove "image" ninja target in favor of "qemu-image"
"image" was an alias for "qemu-image".

I want to add an `image` userland utility, which clashes with that
shortname.

So remove the existing "image" target. It was just an alias for
"qemu-image".

If you use serenity.sh to build, nothing changes. This only affects you
if you run ninja manually -- you now have to say `ninja qemu-image` to
build the disk image.
2023-03-12 01:48:56 +00:00
MacDue
952222ec4d LibGfx: Fix segfault and painting off-by-one in fill_path()
Previously, this would paint scanlines one pixel too long and segfault
when painting AA scanlines that were <= 1px long.
2023-03-11 23:51:20 +01:00
MacDue
a425b6f772 LibGfx: Make all fill_path() code member functions and move into .cpp
This makes all the code for fill_path() member functions of the painter,
and moves them into a new FillPathImplementation.cpp. This allows us
to avoid polluting Painter.h with implementation details, and makes
the edit, compile, retry loop much shorter.
2023-03-11 18:34:26 +00:00
MacDue
b1a72d66f6 LibGfx: Speed up fill_path() with per scanline clipping & fast fills
This improves fill_path() performance by adding an API to the painter
that allows painting an entire scanline rather than just a pixel.
With this paths can be clipped a scanline at a time rather than each
pixel, removing a fair amount of checks.

Along with optimized clipping, this can now use a fast_u32_fill() to
paint all but the subpixels of a scanline if a solid color with no
alpha channel is used (which is quite common in SVGs).

This reduces scrolling around on svg.html from 21% in set_pixel() and
19% in fill_path() to just 7.8% in fill_path (with set_pixel()
eliminated). Now fill_path() is far from the slowest code when
scrolling the page.
2023-03-11 18:34:26 +00:00
Kenneth Myhra
be958a14cf LibWeb: Use from_deprecated_fly_string() instead of from_utf8()
Use FlyString::from_deprecated_fly_string() in these instances instead
of FlyString::from_utf8(). As we convert to new FlyString/String we want
to be aware of these potential unnecessary allocations.
2023-03-11 18:32:33 +00:00
Kenneth Myhra
e28a6d5da4 AK: Add FlyString::from_deprecated_fly_string()
Let's add FlyString::from_deprecated_fly_string() so we can use it
instead of FlyString::from_utf8(). This will make it easier to detect
potential unncessary allocations as we transfer to FlyString.
2023-03-11 18:32:33 +00:00