Commit graph

451 commits

Author SHA1 Message Date
Andreas Kling
ec24d7555a LibWeb: Add a simple internals objects only available during testing
This object is available as `window.internals` (or just `internals`) and
is only accessible while running in "test mode".

This first version only has one API: gc(), which triggers a garbage
collection immediately.

In the future, we can add more APIs here to help us test parts of the
engine that are hard or impossible to reach via public web APIs.
2023-08-06 15:26:34 +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
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
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
Bastiaan van der Plaat
059857d26f Ladybird: Add app icon for macOS 2023-08-04 15:36:37 -06:00
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
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
Karol Kosek
49df2e1e3a Ladybird+Browser: Update zoom text on menu after clicking zoom button 2023-08-04 15:16:48 +02:00
MacDue
abd53a8719 Ladybird: Use AK::Url rather than prefix list to check if URL is valid
If a URL is not valid we try navigating to https:// + the url. It's
better to ask AK::Url if it thinks the url is valid than put a big list
of prefixes here, with this obscure protocols like Gemini are now
recognised and with `--enable-lagom-networking` can be viewed in
Ladybird (thanks to #2218).
2023-08-03 15:02:47 +02:00
Andrew Kaster
7d7c419ce6 Ladybird: Add WebSocket server for use by Lagom networking
Hide its use behind the same flag as RequestServer in WebContent.
2023-08-03 09:55:20 +02:00
Andrew Kaster
a1e5a6ac40 Ladybird: Remove Qt dependency from RequestServer
This requires two parts: Core::System::current_executable_path(), and
passing the serenity-resource-root as an argument to the process.
2023-08-03 09:55:20 +02:00
Andrew Kaster
88ccaae11e Ladybird: Rename classes ending with Ladybird
Now that all the classes for Ladybird are in the Ladybird namespace, we
don't need them named as Ladybird::FooBarLadybird. For the Qt-specific
classes, we can tack on a Qt at the end for clarity, but FontPlugin and
ImageCodecPlugin no longer have anything to do with Qt.
2023-08-03 09:55:20 +02:00
Andrew Kaster
506b03740c Ladybird: Move classes and types into the Ladybird namespace
We were super inconsistent about this, with most "new" classes living in
the Ladybird namespace, while "old" ones were in the global namespace,
or even sitting in the Browser namespace.
2023-08-03 09:55:20 +02:00
Timothy Flynn
58e3b8cf58 Ladybird: Ensure RequestServer depends on its generated sources
Ladybird's RequestServer needs to depend on its generated IPC header
files to ensure they are generated before RequestServer is compiled,
which we currently bundle into LibWebView.
2023-08-02 12:35:05 -04:00
Andrew Kaster
b5bfe732d7 Ladybird: Add RequestServer process to optionally replace Qt Networking
LibTLS still can't access many parts of the web, so let's hide this
behind a flag (with all the plumbing that entails).

Hopefully this can encourage folks to improve LibTLS's algorithm support
:^).
2023-08-02 05:44:43 +02:00
Andrew Kaster
5062ba347b Ladybird+LibWebView: Move Lagom code to Ladybird, Qt code to Utilities
Re-organize our helper files here a bit, to make a clearer distinction
between Qt-specific helpers and generic non-serenity helpers.

A future commit will move Lagom specific code from LibSQL to ladybird
as well, so that we can see about future generic apis for spawning
helper procesess.
2023-08-02 05:44:43 +02:00
Andrew Kaster
3be71a81bb Ladybird: Don't link SQLServer against Qt when it doesn't need it 2023-08-02 05:44:43 +02:00
Andrew Kaster
172fba4582 Ladybird: Don't prefix application files with Applications/
This was the only instance of this pattern in all of Ladybird
2023-08-02 05:44:43 +02:00
Sebastian Zaha
fd86509ef8 Ladybird: Remove unused spawn helper
The spawn_helper_process method was introduced together with
get_paths_for_helper_process but was only ever used briefly to spawn
WebContent. Other helper processes (SqlServer, headless_browser etc)
are either execed or spawned with their own helpers & custom arguments.
2023-08-01 07:36:15 +02:00
Sebastian Zaha
05fc63932b Ladybird: Fix JS console crash when history is empty
Do not try to navigate JS console history forward when it is empty. A
crash was occurring because of size_t underflow.
2023-08-01 07:33:36 +02:00
Andrew Kaster
b6d60980bb Ladybird: Rename FontPluginQt -> Ladybird as it is unrelated to Qt now
The Qt relationship was removed in de31a8a4, so let's acknowledge that
and make it clearer to potential non-Qt ports that this file is usable
by them :^).
2023-08-01 05:06:40 +02:00
Timothy Flynn
1d59a62944 Ladybird: Remove macOS workaround for WebContent GUI interaction
This reverts commit 4dcdc3bd25.

Now that WebContent is a QCoreApplication, this workaround is no longer
needed.
2023-07-31 20:00:49 +02:00
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