Commit graph

428 commits

Author SHA1 Message Date
MacDue 47c074ab11 Ladybird: Fix silly tiny back/forward/reload icons in context menu
Rather than set a hacky scale factor on our QIconEngine, just set the
icon size for the toolbar icons. This avoids the icons being
unnecessarily scaled in other places (i.e. the context menu).
2023-07-31 05:19:53 +02:00
Shannon Booth 8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Andreas Kling cc8c4266f5 Ladybird: Use plain QCoreApplication in WebContent process
Now that we no longer use QFont from LibWeb, we can also stop using
QGuiApplication in the WebContent process entirely.

This removes a whole bunch of unnecessary work from the event loop,
and also allows nice things like running headless-browser while
*actually* headless. :^)
2023-07-30 16:04:51 +02:00
MacDue 1837e94ba4 Ladybird: Use custom QIconEngine to render scalable/vector icons
Rather than render the icons to a 16x16 bitmap, keep them as vector
graphics and render them on request. This keeps the icons crisp on high
DPI displays.
2023-07-30 09:31:43 +02:00
Andreas Kling de31a8a425 Ladybird: Ignore Qt preferred fonts and just load from our fallback list
The Qt StyleHint system didn't work on X11 anyway, and we ended up with
the default UI font being used for both `serif` and `sans-serif`.

Instead of asking Qt for something it can't do properly, let's just grab
the first available font from our list of fallbacks. This should give us
better results everywhere.
2023-07-29 19:16:08 +02:00
Andreas Kling c93952f0fb Ladybird: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Andreas Kling 5d6169793a Ladybird+LibWebView: Respawn with same JS interpreter after crash
WebView::ViewImplementation now remembers which JS interpreter it
started with, and uses the same setting if the WebContent process
crashes and we have to spawn a new one.
2023-07-22 08:49:59 -04:00
Sebastian Zaha 919033fffd Ladybird: Prevent QAction leaking
In some places in the code QAction instances are added to a parent
directly on instantiation. In the case they are not, Valgrind
reports them as leaking.
2023-07-19 21:26:43 +01:00
Sebastian Zaha d974142c7e Ladybird: Allow copying text in the js console 2023-07-19 21:26:43 +01:00
Sebastian Zaha 8e8f124ca9 Ladybird: Implement JS console input history
One can now use KeyUp and KeyDown to navigate through the already run
commands in the JS console.
2023-07-19 21:26:43 +01:00
Sebastian Zaha 6f15b92ace Ladybird: Fix typo in variable name 2023-07-19 21:26:43 +01:00
Sebastian Zaha 5d430b276c Ladybird: Scroll the JS console to the bottom on input 2023-07-19 21:26:43 +01:00
Andrew Kaster e02b2a7b9a Ladybird: Make Android build work again, and tidy up files
We don't need the extra gradle files in our sources, the Qt CMake
integration will generate suitable ones for us.

Make sure that assets is always a folder, so that we can get the proper
layout for the ladybird-assets.tar.gz and CMake doesn't create a gzip
file with the name "assets".

Fix up the AndroidPlatform file and make sure it's linked into all the
applications that need it. Also make sure to copy all the application
shared libraries into the ladybird APK so that when we make them into
proper Services, the libs are already there.
2023-07-19 12:25:37 -06:00
Karol Kosek 729aae8437 Ladybird: Allow loading 'data:' URLs from a search bar 2023-07-11 15:30:11 +02:00
Timothy Flynn f319f72d00 Ladybird: Add a few missing Qt-to-Serenity keycode mappings
And add a link to the Qt documentation that maps event keys to their
enumerated names for convenience.
2023-07-09 06:32:20 +02:00
Timothy Flynn ddf4f6f44f Ladybird: Include the keypad modifier in key events sent to WebContent 2023-07-09 06:32:20 +02:00
Timothy Flynn c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Andrew Kaster 2a4f2110b9 Ladybird: Move the AudioThread class into its own file
This implementation detail of audio support in ladybird is a QObject
that needs moc'd by the moc tools. Putting it in its own file follows
the pattern we have for all the other QObjects in Ladybird.
2023-07-07 06:41:51 -04:00
Andrew Kaster ab9ae8ead3 Ladybird: Add missing QUrl include to WebContentView 2023-07-07 06:41:51 -04:00
MacDue dfcd7b3ca5 Ladybird: Replace forward/back/reload SVGs with TVGs
Doing this removes the qt6-svg dependency and allows our rasterizer to
be used for these little icons (and happens to be a fair bit smaller
than the old SVGs).
2023-07-03 23:54:51 +02:00
Timothy Flynn b57199ccb9 Ladybird: Propagate "empty" key events to the WebContent process
We currently drop events which do not have text associated with them.
This prevents e.g. arrow keys from being able to be handled by web
elements. We now match Browser's behavior on Serenity, where these key
events are already propagated.
2023-07-03 19:07:26 +02:00
kleines Filmröllchen b4fbd30b70 AudioServer+Userland: Decouple client sample rates from device rate
This change was a long time in the making ever since we obtained sample
rate awareness in the system. Now, each client has its own sample rate,
accessible via new IPC APIs, and the device sample rate is only
accessible via the management interface. AudioServer takes care of
resampling client streams into the device sample rate. Therefore, the
main improvement introduced with this commit is full responsiveness to
sample rate changes; all open audio programs will continue to play at
correct speed with the audio resampled to the new device rate.

The immediate benefits are manifold:
- Gets rid of the legacy hardware sample rate IPC message in the
  non-managing client
- Removes duplicate resampling and sample index rescaling code
  everywhere
- Avoids potential sample index scaling bugs in SoundPlayer (which have
  happened many times before) and fixes a sample index scaling bug in
  aplay
- Removes several FIXMEs
- Reduces amount of sample copying in all applications (especially
  Piano, where this is critical), improving performance
- Reduces number of resampling users, making future API changes (which
  will need to happen for correct resampling to be implemented) easier

I also threw in a simple race condition fix for Piano's audio player
loop.
2023-07-01 23:27:24 +01:00
Andreas Kling c0a5787395 Ladybird: Don't scroll web view if wheel event is a Ctrl+Wheel zoom 2023-07-01 08:12:42 +02:00
Zack Penn 5775993a2a Ladybird: Add initial support for Ctrl+Scroll to zoom in/out
This commit adds basic functionality to zoom in/out using the
Ctrl+Scroll shortcut.
2023-07-01 08:07:33 +02:00
networkException 5bc2c333bd Ladybird: Add qt6.qtmultimedia to dependencies in nix-shell script
See a34e369252
2023-06-29 21:20:37 +01:00
Xexxa 84e7dd60ea Ladybird: Add missing shortcuts
Add the missing shortcuts from Ladybird SerenityOS to Ladybird QT
2023-06-24 06:19:39 +02:00
Timothy Flynn f6e10ecbfd Ladybird: Set the sample rate on the audio device's audio format
For example, on https://xboygeniusx.bandcamp.com/album/the-record, a
song with a duration of 03:52 would actually complete in 03:33 on my
machine. This issue only affects Ladybird on Lagom; on Serenity, we
already take the entire 03:52 to play the song.
2023-06-22 18:19:21 +02:00
Timothy Flynn bcd222cfae Ladybird+LibWeb+WebContent: Prevent out-of-bounds seeking audio elements
It's currently possible to seek to the total sample count of an audio
loader. We must limit seeking to one less than that count.

This mistake was duplicated in both AudioCodecPluginSerenity/Ladybird,
so the computation was moved to a helper in the base AudioCodecPlugin.
2023-06-22 06:58:07 +02:00
Timothy Flynn 33dbfa3281 Ladybird: Detect changes to the default audio device
When the default audio device changes on the host, it's convenient to
automatically switch to that device rather than needing to reload the
page to update.
2023-06-21 19:02:57 +02:00
Timothy Flynn afe53a4856 Ladybird: Respect the audio channel configuration and buffer size
We are currently forcing audio to play with a sample size of 16 bits. We
are also feeding the output audio device a hard-set amount of samples
without considering the actual size of its sample buffer. This would
cause a wide array of issues when playing audio elements. On my Linux
machine, we would hear some cracking; on my macOS machine, audio was
quite garbled.

We now write samples of the size requested by the output audio device.
We also limit the samples we provide to the audio device to however many
bytes are available in its buffer.
2023-06-21 06:14:15 +02:00
Timothy Flynn 1c4dd0caad Ladybird+LibWeb+WebConent: Drive audio in Ladybird off the main thread
The main thread in the WebContent process is often busy with layout and
running JavaScript. This can cause audio to sound jittery and crack. To
avoid this behavior, we now drive audio on a secondary thread.

Note: Browser on Serenity uses AudioServer, the connection for which is
already handled on a secondary thread within LibAudio. So this only
applies to Lagom.

Rather than using LibThreading, our hands are tied to QThread for now.
Internally, the Qt media objects use a QTimer, which is forbidden from
running on a thread that is not a QThread (the debug console is spammed
with messages pointing this out). Ideally, in the future AudioServer
will be able to run for non-Serenity platforms, and most of this can be
aligned with the Serenity implementation.
2023-06-21 06:14:15 +02:00
Timothy Flynn 2e5fbe8052 Ladybird: Add context menu items to directly open audio files
After commit 7ec7015, we can open audio documents directly. This adds
content menu items to do so, similar to images and videos.
2023-06-19 17:42:55 +02:00
Andreas Kling 9c568282dc Ladybird+LibJS: Add CLI option to run browser with LibJS bytecode VM
This required quite a bit of plumbing, but now you can run

    ladybird --use-bytecode
2023-06-17 14:16:45 +02:00
Timothy Flynn 9e95c9892c Ladybird+LibWeb+WebContent: Add context menu controls for muting audio 2023-06-16 19:34:42 +02:00
Timothy Flynn b3bbdb1e2c Ladybird: Add a context menu for audio elements 2023-06-16 19:34:42 +02:00
Timothy Flynn 14ca04de25 Ladybird+LibWeb+WebContent: Generalize video context menus for all media
The data we want to send out of the WebContent process is identical for
audio and video elements. Rather than just duplicating all of this for
audio, generalize the names used for this IPC for all media elements.

This also encapsulates that data into a struct. This makes adding new
fields to be sent much easier (such as an upcoming field for muting the
element).
2023-06-16 19:34:42 +02:00
Timothy Flynn d3b8d88598 LibWeb: Expose volume controls through the platform audio plugin 2023-06-16 13:50:15 +02:00
kamp aa97c4675f Ladybird: Update screen rects on client creation
This makes pages that use CSS rules like '@media (max-device-width:
600px)' render more correctly.
Without this change device-width and height queries would return 0.
2023-06-13 16:11:33 +02:00
Timothy Flynn a34e369252 Ladybird+LibWeb+WebContent: Create a platform plugin for playing audio
This creates (and installs upon WebContent startup) a platform plugin to
play audio data.

On Serenity, we use AudioServer to play audio over IPC. Unfortunately,
AudioServer is currently coupled with Serenity's audio devices, and thus
cannot be used in Ladybird on Lagom. Instead, we use a Qt audio device
to play the audio, which requires the Qt multimedia package.

While we use Qt to play the audio, note that we can still use LibAudio
to decode the audio data and retrieve samples - we simply send Qt the
raw PCM signals.
2023-06-13 06:14:01 +02:00
Tim Schumacher 85d14bdc5e Ladybird: Add Userland to the list of include directories
This now matches the Lagom-based Ladybird build and the SerenityOS
build.
2023-06-10 07:06:31 +02:00
Xexxa 5f39a3f911 Ladybird: Add "Open File..." to menu 2023-06-09 23:48:57 +02:00
Xexxa e8af912e30 Ladybird: Add two separators to menus 2023-06-09 23:48:57 +02:00
implicitfield 71b184accf Meta+Lagom: Enable CMAKE_BUILD_WITH_INSTALL_RPATH
On macOS, CMake incorrectly tries to add and/or remove rpaths from files
that it has already processed when it performs installation. Setting the
rpaths during the build process ensures that they are only set once, and
as a bonus, makes installation slightly more performant.

Fixes #10055.
2023-06-08 17:59:53 +02:00
Timothy Flynn 529546e14f Ladybird: Use the same default new tab page URL as Browser 2023-06-08 07:22:00 +02:00
Timothy Flynn 5a3825b561 Browser+Ladybird+LibWebView: Consolidate title handling in LibWebView
Namely, let's have empty titles behave the same in both Browser and
Ladybird (display the URL).
2023-06-08 07:21:08 +02:00
networkException 0e5ec8c0ab Toolchain+Ladybird: Declare dependencies in correct nix file
The dependencies added in b5e9b9a939
are a better fit for Ladybird/ladybird.nix
2023-06-04 10:01:34 +02:00
networkException cfd3f749b0 Ladybird: Sort packages in nativeBuildsInputs nix list 2023-06-04 10:01:34 +02:00
Shannon Booth 484635651c Ladybird: Assume file:// URL when URL starts with '/'
Allowing for easily pasting into ladybird the path to some HTML
file (as an example).

This behavior matches chrome and firefox handling.
2023-06-03 11:43:35 +01:00
Nico Weber f3a58f3a5a Ladybird: Simplify ImageCodecPluginLadybird a bit
No behavior change.
2023-06-02 09:57:20 +01:00
Sigmund Lahn 3bc0e7a7ca Ladybird: Look for helper processes at {app_dir}/{helper}/{helper}
Currently, we only look at the relative path `./{helper}/{helper}`,
which fails if the working directory is not the same as the directory
where the ladybird binary lives.
2023-05-31 13:24:49 +02:00