Commit Graph

806 Commits

Author SHA1 Message Date
Timothy Flynn
8588008d42 Ladybird: Use RequestServer for networking by default
This really only affects headless-browser when it is linked with Qt. In
that case, it currently uses Qt networking by default and does not have
a flag to use RequestServer instead. Change the default to use RS so it
can undergo sanitized testing in CI.
2024-04-26 09:48:20 +02:00
Andrew Kaster
ce9eed918f ImageDecoder: Schedule decode jobs on the LibThreading background thread
This allows the ImageDecoder service to handle new IPC requests while
decoding in parallel.
2024-04-26 09:41:24 +02:00
Timothy Flynn
c11019ebc1 Ladybird: Use Core::Process facilities to spawn singleton processes 2024-04-24 15:51:58 -06:00
Timothy Flynn
9fb84e4693 Ladybird: Use Core::Process facilities to spawn helper processes
Note that WebContent now also uses launch_generic_server_process()
instead of its own implementation.
2024-04-24 15:51:58 -06:00
Timothy Flynn
ec492a1a08 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There are a couple of weird cases where clang-format now thinks that a
pointer access in an initializer list, e.g. `m_member(ptr->foo)`, is a
lambda return statement, and it puts spaces around the `->`.
2024-04-24 16:50:01 -04:00
Andrew Kaster
39dfb659cf LibWeb+WebContent: Convert ImageCodecPlugin to use the promise-based API 2024-04-23 12:32:04 -06:00
Andrew Kaster
28fcf64835 Documentation: Update Ladybird README with more descriptive information 2024-04-23 11:24:14 -06:00
Jamie Mansfield
b7bd3fd920 Ladybird: Calculate the 'physical pixels' for screens
Previously the 'device independent pixels' (which consider scaling)
were used, and then scaling would be applied again when calculating the
screen width for CSS.
2024-04-23 16:25:20 +02:00
Timothy Flynn
771054bff7 Ladybird: Slightly increase the size of the Task Manager window
This adds a bit more room to see most titles on one line.
2024-04-22 14:46:10 -06:00
Timothy Flynn
d2bd692bbe Ladybird: Register RequestServer with the chrome's mach server on macOS
This ensures we register RequestServer with the appropriate mach server
name.
2024-04-22 14:46:10 -06:00
Timothy Flynn
b83babdf8b Ladybird: Register SQLServer with the task manager 2024-04-22 14:46:10 -06:00
Timothy Flynn
278fc8e57f Ladybird: Return a reference to the mach server name
Rather than a copy, return a reference so that it's a bit safer to use
the result as a StringView within the calling scope.
2024-04-22 14:46:10 -06:00
Timothy Flynn
f16f89eb32 Ladybird+LibWebView: Move SQLServer launcher to Ladybird
It previously resided in LibWebView to hide the details of launching a
singleton process. That functionality now lives in LibCore. By moving
this to Ladybird, we will be able to register the process with the task
manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn
5dd3b91f0e LibCore+LibWebView: Move process statistics to LibCore
This will be needed to collect statistics from processes that do not
have anything to do with LibWebView. The ProcessInfo structure must be
virtual to allow callers to add application-specific information.
2024-04-22 14:46:10 -06:00
Shannon Booth
5bf34ecc32 Ladybird: Add an option to enable internals object outside of test mode
Sometimes I like to play around with running Ladybird tests using full
blown Ladybird instead of just headless browser to interactively mess
around with the test page. One problem with this is that the internals
object is not exposed in this mode.

This commit supports this usecase by adding an option to specifically
expose the internals object without needing to run headless-browser
in test mode.
2024-04-22 08:10:08 +02:00
Shannon Booth
1ec6399c00 Everywhere: Remove uneeded short option argument where possible 2024-04-22 08:10:08 +02:00
Andrew Kaster
5e1d678bae Ladybird+Userland: Remove use of unnecessary fd passing socket concept
Now that LibIPC is using SCM_RIGHTS properly, we can go back to only
having one socket laying around when needing to transfer fds to peers.
2024-04-19 16:38:55 -04:00
Andrew Kaster
c87e32154a Ladybird+headless-browser: Make RequestServer single instance on Lagom
Co-Authored-By: Timothy Flynn <trflynn89@pm.me>
2024-04-17 10:09:49 -04:00
Andrew Kaster
336b661835 Ladybird: Move QApplication class to its own file
We'll attach some global data to it in an upcoming commit, so it needs
to be accessible outside of main.cpp.
2024-04-17 10:09:49 -04:00
Andreas Kling
1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Andreas Kling
f4f4f7781d Ladybird+LibWeb: Add optional IDL call tracing
When launched with the new --enable-idl-tracing option, we now log
every call to web platform APIs declared via IDL, along with the
arguments passed.

This can be very helpful when trying to figure out what a site is
doing, especially if it's not doing what you'd expect.
2024-04-16 16:57:06 +02:00
Andreas Kling
5f9a905793 Ladybird+LibJS: Add optional logging of *all* JS exceptions
When running with --log-all-js-exceptions, we will print the message
and backtrace for every single JS exception that is thrown, not just
the ones nobody caught.

This can sometimes be very helpful in debugging sites that swallow
important exceptions.
2024-04-16 16:57:06 +02:00
Timothy Flynn
e5c5dcca6a Ladybird/AppKit: Use LibWeb's history state for history navigation 2024-04-14 18:53:58 -07:00
Timothy Flynn
7c54b15d6d Ladybird/Qt: Remove unused history-related includes 2024-04-14 18:53:58 -07:00
Aliaksandr Kalenik
78af6ca971 Ladybird/Qt: Add icon for "Dump Session History Tree" action 2024-04-14 02:42:53 -07:00
Aliaksandr Kalenik
882904b4bf Ladybird/Qt: Stop using history to drive navigation
Before this change we had to keep session history on browser side to
calculate a url for back/forward/reload action.
Now, with a mature enough implementation of navigation algorithms from
the specification, there is no need to use
history on the browser side to calculate navigation URLs because:
- Traversable navigable owns session history that is aware of all
  navigations, including those initiated by History API and Navigation
  API
- TraversableNavigable::traverse_the_history_by_delta() uses
  traversable's history to calculate the next URL based on delta, so
  there is no need for UI to keep sesion history.

In the future, we will likely want to add a way to pull session history
from WebContent to make it browsable from the UI.
2024-04-14 02:42:53 -07:00
Aliaksandr Kalenik
a8cf1aca7c LibWeb: Rename did_update_url() to did_history_api_push_or_replace()
The previous name was extremely misleading, because the call is used for
pushing or replacing new session history entry on chrome side instead of
only changing URL.
2024-04-14 02:42:53 -07:00
Aliaksandr Kalenik
a71b2e5fd9 Ladybird/Qt: Use reload() IPC call for reload button
Instead of treating reloading as a regular navigation by using
load_url(), now we invoke a navigable reloading algorithm implemented
from the spec.

Now both reloading triggered from UI and location.reload() will use the
same code path.
2024-04-14 02:42:53 -07:00
Timothy Flynn
3ab5ecb671 Ladybird/AppKit: Implement a simple TaskManager window
Unlike the Inspector window, this is owned by the ApplicationDelegate as
there should be only a single task manager for the entire application.
2024-04-12 09:08:16 +02:00
Andrew Kaster
3b5ac433ef Ladybird: Use MachPortServer to get WebContent Mach ports on macOS 2024-04-09 16:43:27 -06:00
Andrew Kaster
8c5e64e686 Ladybird+LibWebView: Add mechanism to get Mach task port for helpers
On macOS, it's not trivial to get a Mach task port for your children.
This implementation registers the chrome process as a well-known
service with launchd based on its pid, and lets each child process
send over a reference to its mach_task_self() back to the chrome.

We'll need this Mach task port right to get process statistics.
2024-04-09 16:43:27 -06:00
Bastiaan van der Plaat
820f966b33 Ladybird: Add indentation to options in optgroup in select dropdown 2024-04-08 17:24:48 -04:00
Bastiaan van der Plaat
1475c1810f LibWeb: Add support for select options disabled state 2024-04-08 17:24:48 -04:00
Bastiaan van der Plaat
4408581ee0 LibWeb: Refactor SelectItem to allow selecting options without value
Currently the `<select>` dropdown IPC uses the option value attr to
find which option is selected. This won't work when options don't
have values or when multiple options have the same value. Also the
`SelectItem` contained so weird recursive structures that are
impossible to create with HTML. So I refactored `SelectItem` as a
variant, and gave the options a unique id. The id is send back to
`HTMLSelectElement` so it can find out exactly which option element
is selected.
2024-04-08 17:24:48 -04:00
Timothy Flynn
f3053f1d01 Ladybird/Qt: Add a "new tab" button to the Qt chrome
This adds a button on the right side of the location bar to create a new
tab.

Ideally, we would actually use QTabWidget::setCornerWidget to put this
button in the tab bar. But it is surprisingly difficult to make that
look nice on all platforms. Even if we ignore macOS, the CSS to make the
button look right on KDE Plasma may not work well on Gnome. So for now,
this location next to the location bar is horizontally the same that it
would be in the tab bar at least.
2024-04-05 15:27:29 +02:00
Timothy Flynn
795efea64f Ladybird/Qt: Close the browser when the last tab's close button is used
We currently do this already when the last tab is closed via the ctrl-W
shortcut. Move the logic for this to BrowserWindow::close_tab so that we
also close the window when the tab is closed via its close button.
2024-04-05 15:27:29 +02:00
Timothy Flynn
d6c8218089 Ladybird/Qt: Show the tab bar by default
We currently only show the tab bar when we have more than one tab open.
This has caused confusion in the past, as it's a bit less obvious that
the browser supports tabs. For example:

https://hackaday.com/2023/10/10/jennys-daily-drivers-serenityos-and-in-particular-ladybird/
"it’s a single window with no tabs"
2024-04-03 20:56:04 +02:00
Timothy Flynn
ecce4ad426 Ladybird/Qt: Set the tab tooltip to its full title
If a tab's title is cut off due to its size, setting a tool tip will
allow for viewing the full title.
2024-04-03 20:56:04 +02:00
Timothy Flynn
2713d4651d Ladybird/Qt: Specify a minimum and maxium tab width
By default, Qt will grow the width of a tab button to fit the title text
of the tab. For long titles or file:// URLs, this looks rather bad. This
sets a min/max tab width to prevent such infinite growth.

To do this, we have to subclass both QTabWidget and QTabBar, because the
functions to be called/overridden are protected.
2024-04-03 20:56:04 +02:00
Timothy Flynn
0234add5fa Ladybird/Qt: Replace the default tab close icon with a vector icon
The default icon used by Qt is a bit jarring. Replace it with an icon
that resembles our other homemade icons.
2024-04-03 20:56:04 +02:00
Timothy Flynn
b577782247 Ladybird/Qt: Move the TVG icon loader to a utility file
It will be needed outside of Tab.
2024-04-03 20:56:04 +02:00
Timothy Flynn
1fc995d4aa Ladybird/Qt: Add a hover effect to the audio play state button
By default, a flat QPushButton does not have a hover effect. Add a small
subclass to provide such an effect to make it clearer it is a button.
2024-04-03 20:56:04 +02:00
Timothy Flynn
c1c1ad8678 Ladybird/Qt: Prevent adding multiple audio state buttons
If the left-hand side of the tab is already occupied with an audio state
button, we would add a second button to the right-hand side. Prevent
that by checking if the occupant is our audio state button.
2024-04-02 15:00:15 -04:00
Andrew Kaster
fa8b64d59a LibWebView+WebContent: Notify UI process about WebContent PID explicitly
On Serenity, it's not trivial to extract the peer pid from a socket that
is created by SystemServer and then passed to a forked service process.
This patch adds an API to let the WebContent process notify the UI
directly, which makes the WebContent process show up in the Serenity
port's TaskManagerWidget. It seems that we will need to do something of
this sort in order to properly gather metrics on macOS as well, due to
the way that self mach ports work.
2024-04-02 09:52:34 -06:00
Andrew Kaster
31c0d00ab1 Ladybird: Add a simple TaskManager window for tracking child processes
This implementation uses a really basic WebView to update stats once
a second. In the future it might make more sense to both move the
details into LibWebView, and to create a native widget for each platform
to remove the overhead of having an extra WebView.
2024-04-02 09:52:34 -06:00
Andrew Kaster
096feaaeb8 Ladybird+LibWebView: Add ProcessManager to track live processes
This model will be used to add a Processes tab to the inspector.
2024-04-02 09:52:34 -06:00
Timothy Flynn
dd54780d5e Ladybird/Qt: Place the tab audio state button on the right on macOS
On macOS, the "close tab" button is on the left, so we should place the
audio state button on the right to avoid conflict. Rather than an OS
ifdef, we do this by detecting if the left side is occupied.
2024-03-31 14:29:17 +02:00
Timothy Flynn
3e659b10f0 Ladybird/Qt: Reference the correct tab when handling the audio icon
We were errantly always referring to the active tab when the audio play
state changed, and when clicking a tab's audio state button, by way of
BrowserWindow::view().

It turns out we also can't copy / rely on the tab index provided to the
signal in any asynchronous context. If the tabs are rearranged, so are
their indices. Instead, capture a pointer to the tab of interest - this
should be safe as we wouldn't be able to click a tab's audio button if
that tab no longer exists.

With this change, we can click the audio button from any tab in the Qt
chrome, and re-arrange tabs at will. The AppKit and Serenity chromes do
not have this issue.
2024-03-31 14:29:17 +02:00
Timothy Flynn
f374e64dfc Ladybird/AppKit: Display a tool tip on the tab mute button 2024-03-30 19:28:20 +01:00
Timothy Flynn
9e4ffbcf70 Ladybird/AppKit: Support muting an entire page
We already display a speaker icon on tabs which are playing audio. This
allows the user to click that icon to mute the tab, at which point the
icon is replaced with a muted speaker icon.

We would previously hide the icon when audio stopped playing. We now do
this only if the tab isn't muted. If it is muted, the muted speaker icon
remains on the tab so that the page isn't stuck in a muted state.
2024-03-30 19:28:20 +01:00