Commit Graph

873 Commits

Author SHA1 Message Date
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
Timothy Flynn
0da5d5a0d0 Ladybird/Qt: Display a tool tip on the tab mute button 2024-03-30 19:28:20 +01:00
Timothy Flynn
45b03bf75d Ladybird/Qt: 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
Timothy Flynn
8ff3cd6d76 Ladybird: Reset the default favicon when starting a new page load
This matches the AppKit chrome. This resets the favicon so that we do
not keep using the previous site's favicon if the new site does not have
one.
2024-03-29 08:52:01 -04:00
Timothy Flynn
45c4e1c446 Ladybird/AppKit: Implement history state change mechanics
We now appropriately update the current history item or create a new
history item in the chrome process.
2024-03-29 08:52:01 -04:00
Timothy Flynn
258b1f30b4 Ladybird/AppKit: Remove an unused property from Tab
This was added for a feature that has since been removed, and is now
unused.
2024-03-29 08:52:01 -04:00
Timothy Flynn
2830bdf04a Ladybird/Qt: Implement history state change mechanics
We now appropriately update the current history item or create a new
history item in the chrome process.
2024-03-29 08:52:01 -04:00
Timothy Flynn
8d765f1084 Ladybird/AppKit: Display an audio button on tabs that are playing audio
When audio begins playing, add a button as an accessory view with a
speaker icon to indicate which tab is playing audio. This button is
currently disabled, but in the future may be used to mute the tab.
2024-03-28 21:08:23 +01:00
Timothy Flynn
18821d3509 Ladybird/Qt: Display an audio button on tabs that are playing audio
When audio begins playing, add a button to the left of the favicon with
a speaker icon to indicate which tab is playing audio. This button is
currently disabled, but in the future may be used to mute the tab.
2024-03-28 21:08:23 +01:00
Timothy Flynn
8503bcb897 Ladybird/Qt: Display a default favicon and title
This ensures we consistently show a favicon and that we update the title
to at least display the page URL when there isn't a <title> tag. We
would otherwise continue displaying the previous page's title.
2024-03-28 21:08:23 +01:00
RGBCube
720feaa658 nix: Clean up files, use good practices 2024-03-25 14:19:34 -06:00
Timothy Flynn
ed24d8f2b5 Ladybird/AppKit: Implement pasting content from the clipboard 2024-03-25 08:14:00 +01:00
Timothy Flynn
8af140fd7b Ladybird: Use Core::Resource to locate the emoji lookup path
The path we were using is no longer correct, and we've been silently
dropping this error. Use Core::Resource instead, which we use for most
other Ladybird resources. This would have made it much more obvious that
emoji were not installed with the application.
2024-03-23 17:26:31 -04:00
Timothy Flynn
7463b31754 Ladybird: Ensure emoji files are installed into the Ladybird bundle
Otherwise, we are unable to render emoji on websites.
2024-03-23 17:26:31 -04:00
Timothy Flynn
2f85620b43 Meta: Ensure we install resource files when those resource files change 2024-03-23 17:26:31 -04:00
Aliaksandr Kalenik
561e011e07 LibWeb+WebContent+Ladybird: Add ability to paste text from clipboard
Text can be pasted by pressing Ctrl/Cmd+V or by using button in the
context menu. For now only the Qt client is supported.
2024-03-22 15:47:33 -04:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Timothy Flynn
a68b134e6d Meta: Do not place headless-browser and WebDriver in libexec
These are standalone applications meant to be run by the user directly,
as opposed to other libexec processes which are programmatically forked
by the browser. To do this, we simply remove these processes from the
`ladybird_helper_processes` list. We must also explicitly list the
dependencies for these processes.
2024-03-16 19:44:40 -04:00
Timothy Flynn
3a8bde9ef2 Ladybird/AppKit: Implement <input type=file> file type filtering 2024-03-16 08:42:33 +01:00
Timothy Flynn
a0e6c7457a Ladybird/Qt: Implement <input type=file> file type filtering 2024-03-16 08:42:33 +01:00
Timothy Flynn
6760d236e4 Ladybird+LibWeb+WebContent: Parse the <input type=file> accept attribute
This parses the accept attribute value for file input types and passes
it along to the browser chromes.
2024-03-16 08:42:33 +01:00
Andrew Kaster
1d70306c41 Meta: Handle output directories for multi-config CMake generators
For Ninja Multi-Config, Xcode and Visual Studio, the way we set up our
output directories would result in exectuables that can't run from the
build directory. Add the same sauce that we added to Jakt to insert
``$<CONFIG>`` where appropriate.
2024-03-14 17:05:05 -06:00
Bastiaan van der Plaat
16fdb005f0 Ladybird/Qt: Allow CR inside of elements title attributes 2024-03-13 07:58:36 -04:00
Timothy Flynn
3e1ffc03c4 Ladybird/Qt: Adjust the Inspector context menu by the device pixel ratio
Otherwise, the context menu is very out of position on devices with a
device pixel ratio other than 1.
2024-03-11 16:49:20 +01:00
Timothy Flynn
b5e8f0ebfe Ladybird/Qt: Move positional device pixel ratio adjustment to a helper
The code to convert a Gfx::IntPoint to a QPoint adjusted for the device
pixel ratio is a bit of a mouthful, and will be needed outside of Tab,
so move it to a helper that can be reused.
2024-03-11 16:49:20 +01:00
Andrew Kaster
096ddb0021 Ladybird: Include Userland/ in for Applications that use LibWeb
After ea682207d0, we need Userland/
included directly in these application executables. This only impacts
the build with Ladybird/CMakeLists.txt as the top level CMakeLists, as
the Lagom/ directory includes Userland/ globally.
2024-03-06 19:50:00 -05:00
Timothy Flynn
8a602876d7 Ladybird/Qt: Explicitly ignore wheel events with the ctrl key pressed
This allows ctrl+wheel events to zoom in and out of the page. This was
ported incorrectly in commit c1476c3405.
2024-03-06 11:20:38 -05:00
Ali Mohammad Pur
6dfb2f9dc8 Everywhere: Merge the WebSocket service into RequestServer
This keeps the APIs separate as they are wildly different, a future
improvement could be to somehow unify the APIs (if possible).

Closes #23080.
2024-03-06 10:07:27 +01:00
Andrew Kaster
4dd2ec68fc RequestServer: Transfer ownership of Protocols to all_protocols map
It's no change in application behavior to have these objects owned by
the function-scope static map in Protocol.cpp, while allowing us to
remove some ugly FIXMEs from time immemorial.
2024-03-06 08:15:03 +00:00
Timothy Flynn
2c31ef11bc Ladybird/AppKit: Handle input events through LibWebView
The AppKit chrome currently handles all input events before selectively
forwarding those events to WebContent. This means that WebContent does
not see events like cmd+c.

Here, we make use of LibWebView's input handling and wait for LibWebView
to inform the chrome that it should handle the event itself.
2024-03-06 07:46:18 +01:00
Timothy Flynn
c1476c3405 Ladybird/Qt: Handle input events through LibWebView
The Qt chrome currently handles all input events before selectively
forwarding those events to WebContent. This means that WebContent does
not see events like ctrl+c.

Here, we make use of LibWebView's input handling and wait for LibWebView
to inform the chrome that it should handle the event itself.
2024-03-06 07:46:18 +01:00
Filiph Siitam Sandström
fd694e8672 AK+Lagom: Make it possible to build for iOS
This commit makes it possible to build AK and most of Lagom for iOS,
based on the work for the Ladybird build demoed on discord:
https://discord.com/channels/830522505605283862/830525031720943627/1211987732646068314
2024-03-03 13:13:42 -07:00
Sam Atkins
163a40c539 Ladybird: Use Core::Environment instead of Core::System::*env() 2024-02-27 08:33:48 +00:00
Tim Ledbetter
a968bc6f80 Ladybird/Qt: Use a precise timer for event loop timer events
This improves the accuracy of `setTimeout()`.
2024-02-26 16:12:20 -07:00
Andrew Kaster
ea59bfaae7 Ladybird: Move helper processes to CMAKE_INSTALL_LIBEXECDIR
It aligns better with the Filesystem Heirarchy Standard[1] to put our
program-specific helper programs that are not intended to be executed by
the user of the application in $prefix/libexec or in whatever the
packager sets as the CMake equivalent. Namely, on Debian systems this
should be /usr/lib/Ladybird or similar.

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrlibexec
2024-02-26 13:16:27 -07:00
Andrew Kaster
68402bec12 Ladybird: Remove $SERENITY_SOURCE_DIR from resource root candidates
Now we will only load resources from $build/share/Lagom. On macOS, we
load from the bundle directory Contents/Resources instead. This
simplifies the commands and environment variables needed to execute
Ladybird from the build directory, and makes our install setup less
awkward for distributions and packagers.
2024-02-26 13:16:27 -07:00
Andrew Kaster
0a55749a39 Ladybird+Userland: Use ByteString for candidate server paths
We've adopted a stance that paths should be ByteStrings rather than
UTF-8 strings, so apply that to the Ladybird helpers.
2024-02-26 13:16:27 -07:00
Andrew Kaster
1e0dd9aa8c Ladybird: Copy resources into the build directory
This will let us remove the dependence on SERENITY_SOURCE_DIR
2024-02-26 13:16:27 -07:00
Andrew Kaster
86c1d97e3c Ladybird: Always place helper processes in bundle directory on macOS
Don't put them in bin/ and then copy them to the bundle dir later, as
this means that they only get updated in the bundle directory if the
Ladybird binary itself needs updated. Which is not a fun workflow if you
are working on WPT and want to hack on the WebDriver binary.
2024-02-26 13:16:27 -07:00
Timothy Flynn
a346f14fb4 Ladybird/AppKit: Implement the <input type=file> UI 2024-02-26 14:18:49 +01:00
Timothy Flynn
834f76ef24 Ladybird/Qt: Implement the <input type=file> UI 2024-02-26 14:18:49 +01:00
Dan Klishch
b77996884e LibCore+Ladybird: Don't force timer ids to be integer just to remap them
If we don't force event loop to fit timer id into integer, we can
eliminate awkward IDAllocator inside EventLoopImplementations.
2024-02-25 17:24:36 -07:00
Dan Klishch
bed4af6fef LibCore+Ladybird: Make unregistering timer infallible
Let's force calling code to provide valid timer ids. No code changes are
required since, surprise, nobody used this obscure functionality.
2024-02-25 17:24:36 -07:00
Dan Klishch
21097d1c9e LibCore+Ladybird: Don't store timer_id in Core::TimerEvent 2024-02-25 17:24:36 -07:00
Shannon Booth
9ce8189f21 Everywhere: Use unqualified AK::URL
Now possible in LibWeb now that there is no longer a Web::URL.
2024-02-25 08:54:31 +01:00
Simon Wanner
81d1b129f7 Ladybird/QT: Avoid incorrect round trip via QUrl
QUrl::toString reverses the Unicode->ASCII conversion that already
occurred here. The text of m_location_edit is already in the format we
expect, so let's just convert QString->AK::URL directly, instead of
taking the detour QString->QUrl->AK::URL
2024-02-21 09:25:12 -05:00
Simon Wanner
cac23820c5 Ladybird/QT: Avoid constructing AK String types from char* without size
While QByteArray::data does return a null-terminated char* it's nicer to
avoid strlen() when we already know the size
2024-02-21 09:25:12 -05:00
Bastiaan van der Plaat
656f764b1b Ladybird/AppKit: Convert select dropdown position to correct scale 2024-02-19 13:36:58 -05:00
Andrew Kaster
ff9eb62f3d WebDriver: Add commandline option to pass extra certificates
This is useful for running WPT
2024-02-14 06:55:40 +01:00
Andrew Kaster
bb9da0ed8d Ladybird: Plumb overriding root certificate paths through the chromes 2024-02-08 08:49:32 -07:00
Andrew Kaster
080aa567a5 RequestServer+LibTLS: Allow applications to specify multiple root certs 2024-02-08 08:49:32 -07:00
Andrew Kaster
f739e976a4 Tests: Pass App Bundle path to WebDriver to WPT CTest test on macOS
The WebDriver binary in ${CMAKE_CURRENT_BINARY_DIR}/bin doesn't actually
have access to the Ladybird binary in the default CMake setup.
2024-02-08 15:53:46 +01:00
Dan Klishch
38164411f0 Ladybird/Qt: Properly listen for DPI changes on Wayland
Some Wayland compositors have support of fractional-scale-v1 protocol.
The protocol allows compositor to announce a preferred fractional scale
on a per-wl_surface basis. Qt forwards these Wayland events to an
application using a usual DevicePixelRatioChange event. However, in
contrast to the other platforms, this DevicePixelRatioChange event is
issued directly on widgets and not screens. Additionally, the exact
fractional scale is stored in QWindow object and not the current screen.

Note that in theory it is possible to obtain per-screen fractional
scaling on Wayland by interpolating data provided by wl_output and
xdg_output events but qtwayland does not do that.

If fractional-scale-v1 is not available, qtwayland will still fire
per-Widget DevicePixelRatioChange events, but, obviously, with the
per-screen possibly larger ceiled scaling.

This whole thing makes handling DPI changes on Wayland really simple.
All we need to do is to intercept DevicePixelRatioChange events firing
on QWindow objects and call the old device_pixel_ratio_changed handler
with the window's devicePixelRatio(). The only caveat here is not forget
to always set QWidget's parent before calling devicePixelRatio() on it.
2024-02-06 09:59:17 -07:00
Tim Ledbetter
8320faf052 Ladybird/Qt: Map Enter keypresses to the code point '\n'
Previously, on systems where pressing Enter would generate "\r\n", only
the '\r' character was being sent to the event handler. This change
ensures consistent behavior across platforms regardless of their native
line ending characters.
2024-02-05 16:52:03 -05:00
Andrew Kaster
36cd2fb7c5 Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.

This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
2024-02-03 20:51:37 -05:00
Andrew Kaster
677bdc2a4f Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new
tab or new window. Such as calls to window.open(), or specific WebDriver
calls.
2024-02-03 20:51:37 -05:00
Andrew Kaster
7245f6f11c Ladybird: Open files from the open files dialog as a QURL
This prevents us from needing to properly prepend file:// to the
returned filename.
2024-02-03 20:51:37 -05:00
Andrew Kaster
c75bd4ed15 Ladybird/Qt: Rename new_tab to new_tab_from_url and make it take AK::URL
Instead of having QString be the API for these load() calls, just pipe
AK::URL throughout the UI.
2024-02-03 20:51:37 -05:00
Andrew Kaster
a91680dd55 Ladybird/Qt: Rename new_tab(StringView) to new_tab_from_content
Having an overload of new_tab with StringView and QString that each do
very different things is uncomfortable, to say the least.
2024-02-03 20:51:37 -05:00
Andrew Kaster
48ce8fb4e9 Ladybird: Add ability to create a tab without creating a new WebContent 2024-02-03 20:51:37 -05:00
Dan Klishch
77e4f0d7d8 LibCore: Allow listening for multiple conditions using a single Notifier
While on it, implement currently unused Notifier::set_type correctly
(but not efficiently) by re-registering Notifier in the EventLoop.
2024-02-03 16:43:13 -07:00
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
5945cdc054 Ladybird+Meta: Extract AK into its own library on Lagom
We currently bundle AK with LibCore on Lagom. This means that to use AK,
all libraries must also depend on LibCore. This will create circular
dependencies when we create LibURL, as LibURL will depend on LibUnicode,
which will depend on LibCore, which will depend on LibURL.
2024-01-22 08:48:34 -05:00
Bastiaan van der Plaat
dc2233ef7a Ladybird+WebContent: Add chrome command line and exe path passing 2024-01-17 17:32:05 +01:00
Nico Weber
398f34bb81 Ladybird/AppKit/CMake: Use a more civilized way of finding Cocoa
Finding Cocoa.framework is the linker's job, not CMake's.

No behavior change.
2024-01-15 11:18:55 -07:00
Nico Weber
d324517ed7 Ladybird/AppKit: The "Window" menu should be called "Window"
...not "Windows".
2024-01-15 12:15:16 -05:00
Bastiaan van der Plaat
cde14901bc Ladybird+LibWeb: Add initial about:version internal page 2024-01-13 13:41:09 -05:00
Andrew Kaster
02edd240ae LibWeb+WebContent: Spawn Worker processes from the chrome
Instead of spawning these processes from the WebContent process, we now
create them in the Browser chrome.

Part 1/N of "all processes are owned by the chrome".
2024-01-12 15:53:11 -07:00
Timothy Flynn
7db8b206a8 Ladybird/AppKit: Show an informational dialog after taking a screenshot
The dialog displays where the screenshot is saved and presents an option
to open its containing folder.
2024-01-06 20:11:12 +00:00
Timothy Flynn
8801fed54e Ladybird/Qt: Show an informational dialog after taking a screenshot
The dialog displays where the screenshot is saved and presents an option
to open its containing folder.
2024-01-06 20:11:12 +00:00
Bastiaan van der Plaat
0dd5aa40a8 LibWeb: Allow input color to give continuous updates 2024-01-06 10:02:15 -07:00
Timothy Flynn
d8fa226a8f Ladybird+LibWebView+WebContent: Make the screenshot IPCs async
These IPCs are different than other IPCs in that we can't just set up a
callback function to be invoked when WebContent sends us the screenshot
data. There are multiple places that would set that callback, and they
would step on each other's toes.

Instead, the screenshot APIs on ViewImplementation now return a Promise
which callers can interact with to receive the screenshot (or an error).
2024-01-01 10:11:45 +01:00
Timothy Flynn
c4e2c725ec Ladybird/Qt: Ensure the Inspector widget is deleted before the WebView
According to Qt documentation, destruction of a QObject's children may
happen in any order. In our case, the Tab's WebContentView is deleted
before its InspectorWidget. The InspectorWidget performs cleanup on that
WebContentView in its destructor; this causes use-after-free since it
has already been destroyed.

From reading Qt threads, if a particular destruction order is required,
it is okay to enforce that order with manual `delete`s. This patch does
so with the InspectorWidget to ensure it is deleted before the
WebContentView. Qt's object ownership is okay with this - it will remove
the InspectorWidget from the Tab's children, preventing any double
deletion.
2023-12-29 15:48:06 +01:00
Bastiaan van der Plaat
009729d5e3 LibWeb: Use resources to find internal HTML template paths 2023-12-27 10:54:07 -05:00
Bastiaan van der Plaat
b39d99cf2f LibWeb: Use resource scheme for icons in internal pages 2023-12-27 10:54:07 -05:00
Timothy Flynn
bacf3cede4 Ladybird+BrowserSettings: Load the NTP/home resource files with LibWeb 2023-12-24 14:09:23 +01:00
Bastiaan van der Plaat
29ee576345 LibWeb: Fix select dropdown position when scrolled on a page 2023-12-23 10:12:36 +01:00
Aliaksandr Kalenik
02936f6944 LibWebView+WebContent: Drive repainting from WebContent process
With this change, chrome no longer has to ask the WebContent process
to paint the next frame into a specified bitmap. Instead, it allocates
bitmaps and sends them to WebContent, which then lets chrome know when
the painting is done.

This work is a preparation to move the execution of painting commands
into a separate thread. Now, it is much easier to start working on the
next frame while the current one is still rendering. This is because
WebContent does not have to inform chrome that the current frame is
ready before it can request the next frame.

Additionally, as a side bonus, we can now eliminate the
did_invalidate_content_rect and did_change_selection IPC calls. These
were used solely for the purpose of informing chrome that it needed to
request a repaint.
2023-12-22 17:47:34 +01:00
Andrew Kaster
e89163911c Ladybird/AppKit: Use correct flag name for WebContent debugging
This fixes a CoPilot SNAFU from 1e68e484cc
where I tested the changes on Linux and assumed CI would catch any macOS
problems.
2023-12-21 22:56:47 -05:00
Aliaksandr Kalenik
d87f3a4101 LibWebView+Ladybird: Remove unused on_scroll_into_view callback
Leftover from 9624eca116
2023-12-21 19:25:18 +01:00
Andrew Kaster
1e68e484cc Ladybird: Add command line flag to wait for debugger in WebContent 2023-12-21 19:03:40 +01:00
Andrew Kaster
08108ac579 Meta: Disable -fsanitize=function on macOS with clang 17 or higher
This seems to trip on calling file static functions through a function
pointer directly. Still need to reduce and report upstream.
2023-12-20 12:25:40 -07:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Timothy Flynn
8255a1a5ee Ladybird/Qt: Enable SQLServer for cookie storage by default
It was disabled by default for issues that have since been fixed.
Primarily: 14091f32c6
2023-12-16 13:32:04 +01:00
Timothy Flynn
acf7044544 Ladybird/Qt: Use RequestServer as the networking backend by default
This will let us find and fix any RequestServer issues more easily. Qt
networking is still available via command line.
2023-12-16 13:32:04 +01:00
Aliaksandr Kalenik
4534a43aae Ladybird/Qt: Apply to_content_position after scaling event coordinates
Fixes regression introduced in b73ae80d8b
2023-12-16 12:55:29 +01:00
Bastiaan van der Plaat
b73ae80d8b LibWeb: Refactor WebContentServer mouse input message to DevicePixel 2023-12-16 11:08:51 +01:00
Bastiaan van der Plaat
c069ab1ca0 LibWeb: Refactor int types in WebContentServer to DevicePixels 2023-12-15 17:01:16 +01:00
Bastiaan van der Plaat
04b591b2e0 Ladybird/Qt: Listen to DPI changes and update WebContentView accordingly 2023-12-13 22:25:27 +01:00
Bastiaan van der Plaat
cbb660c756 LibWeb: Make request_select_dropdown more similar to context menu api 2023-12-13 10:30:13 +01:00
Bastiaan van der Plaat
aee8b39c65 Ladybird/Qt: Open context menus at requested position 2023-12-13 10:30:13 +01:00
Bastiaan van der Plaat
8b0abb8ded Ladybird/Qt: Don't use devicePixelRatio() directly 2023-12-13 10:30:13 +01:00
Andrew Kaster
57a04c536c Ladybird: Enable rich debug messages on all processes
Android is excluded from this patch because the Android dbgln routes
messages to the NDK logger, which already includes process and time
information.
2023-12-12 10:11:24 -07:00
Aliaksandr Kalenik
57e5abae92 LibJS+LibWebView+WebContent+Ladybird: Output GC-graph into a file
Instead of displaying a massive JSON in stdout, it's more practical
to save the GC-graph to a file.
2023-12-12 15:35:35 +01:00
Timothy Flynn
451df70275 Ladybird+LibWebView: Ensure existing Inspector widgets inspect the page
If the Inspector widget already exists, be sure to inspect the page when
it is re-opened. However, this should be a no-op if the page was already
inspected (as any existing Inspector will be reset if a new page load
began).

Note this is not an issue in the AppKit chrome.
2023-12-10 16:45:08 +01:00
Bastiaan van der Plaat
466153e680 Ladybird+LibWeb: Add basic select element support 2023-12-09 22:06:20 +01:00
Andrew Kaster
187056ca5e Ladybird: Install required html and inspector files in the CMake build
Companion to 05c8d5ba57 which moved the
files to Base/res/ladybird, and d81c531322
which installed them in the GN build on macOS.
2023-12-08 19:50:02 -05:00
Timothy Flynn
7e974f530d Ladybird+LibWebView: Add an Inspector action to clone a DOM node 2023-12-07 23:16:34 +01:00
Timothy Flynn
d5d6ff8bf1 Ladybird+LibWebView: Add an Inspector action to insert a child DOM node 2023-12-07 23:16:34 +01:00
Dan Klishch
d317309d89 Everywhere: Unport Core::System::current_executable_path from new string
Storing paths in AK::String is never correct.
2023-12-07 10:13:21 -07:00
Timothy Flynn
71fdf0860e Ladybird+LibWebView: Add an Inspector action to screenshot a DOM node 2023-12-07 10:53:12 +01:00
Timothy Flynn
e3df035c5d Ladybird+LibWebView: Add an Inspector action to copy a node's HTML/text 2023-12-07 10:53:12 +01:00
Timothy Flynn
51a0673b5c Ladybird+LibWebView: Add an Inspector action to copy an attribute value 2023-12-07 10:53:12 +01:00
Timothy Flynn
8162dc5ee6 LibWeb+LibWebView+WebContent: Separate tag/attribute in Inspector menu
It was a bit short-sighted to combine the tag and attribute names into
one string when the Inspector requests a context menu. We will want both
values for some context menu actions. Send both names, as well as the
attribute value, when requesting the context menu.
2023-12-07 10:53:12 +01:00
Timothy Flynn
154d201d41 Ladybird/AppKit: Add an Inspector context menu to edit the DOM 2023-12-06 13:04:50 +01:00
Timothy Flynn
be53596fe6 Ladybird/Qt: Add an Inspector context menu to edit the DOM 2023-12-06 13:04:50 +01:00
Timothy Flynn
7970f45953 Ladybird/AppKit: Implement "Copy Email/Phone" menu item for links 2023-12-05 14:20:03 -05:00
Sam Atkins
715d0bacdb Ladybird/Qt: Implement "Copy Email/Phone" menu item for links 2023-12-05 11:36:22 -05:00
Timothy Flynn
05c8d5ba57 Base+Ladybird: Move Ladybird-related HTML files to their own folder
Pages like the new tab page, error page, etc. all belong solely to
Ladybird, but are scattered across a couple of subfolders in Base. This
moves them all to Base/res/ladybird.
2023-12-04 19:46:35 -05:00
Bastiaan van der Plaat
980e32b4fe Ladybird/AppKit: Remove theme color changing background color 2023-12-04 14:56:03 -05:00
Timothy Flynn
c55d8a9971 Ladybird/Qt: Make the Inspector widget owned by its parent tab
This ensures the Inspector is closed when the BrowserWindow which owns
the tab is closed.
2023-12-04 12:03:48 -07:00
Timothy Flynn
4653733a0d Ladybird/Qt: Do not "share" ownership of Qt objects
When a QObject subclass (widgets, etc.) are provided a parent, then
ownership of that object is passed to the parent. Similarly, objects
added to a QLayout are owned by the layout.

Thus, do not store these objects in an OwnPtr.
2023-12-04 12:03:48 -07:00
Timothy Flynn
a21998003c Ladybird/Qt: Make String allocation infallible 2023-12-04 12:03:48 -07:00
Timothy Flynn
82c827fc56 Ladybird/Qt: Support non-ASCII when converting a QString to a String
QString is UTF-16, thus QString::size returns the number of UTF-16 code
units. Thus, we would fail to perform, for example:

    ak_string_from_qstring(QString("😀"));

Which is 2 UTF-16 code units, but 4 UTF-8 code units.
2023-12-04 12:03:48 -07:00
Timothy Flynn
1aedb0ae5a Ladybird/Qt: Replace the QString-from-AK helpers with a single method
There's no need for 2 overloads for String and DeprecatedString, we can
just use a StringView. This also avoids some cases of needlessly
allocating a DeprecatedString from a StringView when calling this
method.
2023-12-04 12:03:48 -07:00
Timothy Flynn
b10934af27 Ladybird/AppKit: Implement cursor images for row-resize and col-resize 2023-12-02 22:54:06 +01:00
Timothy Flynn
582f19ba24 Ladybird: Allow opening the Inspector with both ctrl+shift+I and F12
Ladybird on Serenity currently only uses F12, and on other platforms
only uses ctrl+shift+I. Most browsers support both hotkeys, so let's do
the same for consistency.

Note that the AppKit chrome cannot support both shortcuts. macOS does
not allow setting multiple "key equivalent" strings on an action. There
are some questionable hacks we could do to support this eventually, but
for now, just ctrl+shift+I is supported on macOS.
2023-12-02 22:54:06 +01:00
Timothy Flynn
dc04385465 Ladybird/AppKit: Remove the standalone JavaScript console 2023-12-02 10:34:22 +01:00
Timothy Flynn
c4daaa9902 Ladybird/Qt: Remove the standalone JavaScript console 2023-12-02 10:34:22 +01:00
Timothy Flynn
4c145fdb12 Ladybird/AppKit: Support enabling the GPU painter 2023-12-01 20:07:27 -05:00
Timothy Flynn
07e9a8f79b Ladybird+LibWebView: Move options used to launch WebContent to a struct
It is currently a bit messy to pass these options along from main() to
where WebContent is actually launched. If a new flag were to be added,
there are a couple dozen files that need to be updated to pass that flag
along. With this change, the flag can just be added to the struct, set
in main(), and handled in launch_web_content_process().
2023-12-01 20:07:27 -05:00
Andrew Kaster
fbfb70f81a LibWeb+WebContent: Plumb ability for WebContent process to hold N pages
In order for same-origin NavigableContainers (iframe, frame, embed, ...)
and window.open() WindowProxies to have the proper JS access to their
embedder/opener, we need to host multiple top level traversables in the
same WebContent process. As a first step, make WebContent::PageHost hold
a HashMap of PageClient objects, each holding their own Web::Page that
represents a TraversableNavigable's API surface with the UI process.
2023-12-01 20:47:44 +01:00
Bastiaan van der Plaat
b21ec0afac Ladybird/AppKit: Select all text of location search field on focus 2023-12-01 09:26:37 -05:00
Timothy Flynn
cd0f5087a7 Ladybird/AppKit: Port the Inspector to the WebView property tables 2023-11-29 13:56:35 +01:00
Timothy Flynn
b5d5e48ffc Ladybird/Qt: Port the Inspector to the WebView property tables 2023-11-29 13:56:35 +01:00
Timothy Flynn
aa4dcda5dc LibWeb+LibWebView+Ladybird: Scale scroll-to CSS positions in PageHost
The `page_did_request_scroll_to` API takes a CSS position, and thus
callers should not scale to device pixels before invoking it. Instead,
align this API with (most) other PageHost APIs which scale to device
pixels before sending the corresponding IPC message.

In the AppKit chrome, convert the provided device pixel position to a
widget position.
2023-11-24 17:19:08 -05:00
Timothy Flynn
fb1845f294 Ladybird/AppKit: Invert the horizontal delta scroll value
This matches the negation of the vertical scroll delta value. This makes
the scroll events behave as follows on macOS:

Natural scrolling enabled:
* Scrolling up on the trackpad scrolls down on the page.
* Scrolling right on the trackpad scrolls left on the page.

Natural scrolling disabled:
* Scrolling up on the trackpad scrolls up on the page.
* Scrolling right on the trackpad scrolls right on the page.
2023-11-24 11:22:17 -05:00
Timothy Flynn
c03b69e664 LibWebView+Ladybird: Remove now-unused WebView TreeModel
This was used to provided base functionality for model-based chromes for
viewing the DOM and accessibility trees. All chromes now use the WebView
inspector model for those trees, thus this class is unused.
2023-11-24 08:37:19 +01:00
Timothy Flynn
84c4eef565 Ladybird/AppKit: Port the Inspector to the WebView InspectorClient 2023-11-24 08:37:19 +01:00
Timothy Flynn
52b5bcdb6d Ladybird/Qt: Port the Inspector to the WebView InspectorClient 2023-11-24 08:37:19 +01:00
Sam Atkins
edaa5061c4 headless-browser: Add flag to dump screenshots of failing ref-tests
When the `--dump-failed-ref-tests` flag is provided, screenshots of the
actual and reference pages will be placed in
`Build/lagom/ladbybird/test-dumps`. This makes it a lot easier to spot
what's wrong with a failing test. :^)
2023-11-18 07:49:59 -05:00
Timothy Flynn
72e5b10b30 Ladybird/AppKit: Remove explicit application activation
We call [NSApp activateIgnoringOtherApps:YES] to ensure the application
is brought into view and focused when launched from a terminal. But in
a macOS environment, we're better off using the `open` command to launch
the application (in which case, it does take foreground focus).
2023-11-17 19:14:53 +01:00
Andrew Kaster
124c378472 LibWeb+WebWorker: Move worker execution into a new WebWorker process
We now create a WorkerAgent for the parent context, which is currently
only a Window. Note that Workers can have Workers per the spec.

The WorkerAgent spawns a WebWorker process to hold the actual
script execution of the Worker. This is modeled with the
DedicatedWorkerHost object in the WebWorker process.
A start_dedicated_worker IPC method in the WebWorker IPC creates the
WorkerHost object. Future different worker types may use different IPC
messages to create their WorkerHost instance.

This implementation cannot yet postMessage between the parent and the
child processes.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-11-15 12:56:33 +01:00
Timothy Flynn
0415d03b4f Ladybird: Register Ladybird as a browser-type application on macOS
This allows Ladybird to be the default browser on macOS, and allows for
opening some file types (.html, .svg, .md, etc.) with Ladybird.

Note this currently only works in the GN build (and thus the Qt chrome).
The CMake build does not set up the Resources directory properly for
macOS to run the Ladybird app without $SERENITY_SOURCE_DIR set.
2023-11-14 09:36:36 -05:00