Commit graph

939 commits

Author SHA1 Message Date
Sidicer
4a36ae5a70 UI/Qt: Fix hover_label hiding URLs
m_hover_label did not have checks if the mouse is in the same location.
This caused clickable URLs to be hidden.
Also shortened the label text to not be longer than half of the window.

(cherry picked from commit edf29857f8f8b669c45d673b088d9c0236659d73)
2024-12-21 14:58:20 -05:00
Timothy Flynn
dda405e652 UI/Qt: Execute dialogs opened from the page asynchronously
Invoking exec() entirely blocks the UI application's main thread. Qt
explicitly recommends against this. In practice, it seems prevents some
IPC messages from being handled by the UI until the dialog is closed by
the user.

Instead, use open() (which is non-blocking) and set up a signal handler
to deal with the result.

(cherry picked from commit ea9abe26e1c40c0d2e96007bf7d69afb49a7052a)
2024-11-28 18:58:55 -05:00
Timothy Flynn
965e1baa8c LibWeb+UI: Detect and handle left vs. right modifier keys
Our handling of left vs. right modifiers keys (shift, ctrl, etc.) was
largely not to spec. This patch adds explicit UIEvents::KeyCode values
for these keys, and updates the UI to match native key events to these
keys (as best as we are able).

(cherry picked from commit 4fcaeabe1a6acd9f4d5fd811a36f2e86748b2a72;
amended to make the rest of the system build and to keep `Mod_AltGr`
around in addition to adding it as a key)

Co-authored-by: Nico Weber <thakis@chromium.org>
2024-11-28 15:15:36 -05:00
Timothy Flynn
50fd33a531 UI/AppKit: Send keyboard events for modifier-only key presses/releases
If the user only presses the shift key, for example, we are required to
still send that event to WebContent and generate the corresponding JS
events. Unfortunately, NSApp does not inform us of these events via the
keyDown/keyUp methods. We have to implement the flagsChanged interface,
and track for ourselves what modifier keys were pressed or released.

(cherry picked from commit eabd5b0f2271e7a89727daf80dd28623711f3416)
2024-11-28 15:15:36 -05:00
Andrew Kaster
84231892c8 Ladybird+LibIPC: Move clearing FD_CLOEXEC helper logic to IPC::File
(cherry picked from commit 343a3a0d7e05a2abba96a91630ebac0547cde1a6)
2024-11-24 20:50:01 -05:00
Aliaksandr Kalenik
360fa4a0bf Everywhere: Hand pid of new process to client in launch_server_process()
Allows WebContentClient to get pid of WebContent process right after
creation, so there is no window between forking and
notify_process_information() IPC response, when client doesn't know the
pid.

(cherry picked from commit c46bea479c1cbf9bb9a30cbecaaa10c85a4ba321)
2024-11-24 20:50:01 -05:00
Timothy Flynn
52099ff54d LibWebView: Generate hyperlinks for attributes that represent links
On the view-source page, generate anchor tags for any 'href' or 'src'
attribute value we come across. This handles both when the attribute
contains an absolute URL and a URL relative to the page.

This requires sending the document's base URL over IPC to resolve
relative URLs.

(cherry picked from commit 1aab7b51ea9c27a6ffff8df0c8bcbec87680865c;
amended to update `on_received_source` signature in Browser too)
2024-11-17 11:03:57 -05:00
Sam Atkins
c7613b186b LibWebView+UI: Highlight CSS in the style sheet inspector
(cherry picked from commit f0dd0c51073823ad2e30041896030a2831419786)
2024-11-16 14:05:12 -05:00
Sam Atkins
d094c2984b Inspector: Add a basic style sheet inspector
Choosing options from the `<select>` will load and display that style
sheet's source text, with some checks to make sure that the text that
just loaded is the one we currently want.

The UI is a little goofy when scrolling, as it uses `position: sticky`
which we don't implement yet. But that's just more motivation to
implement it! :^)

(cherry picked from commit da171c3230caaee53213d0dd04007c9b4343e3e2)
2024-11-15 23:10:03 -05:00
Sam Atkins
549f5fe374 UI/Qt: Assign dropdown handler for select in WebContentView, not Tab
This makes `<select>` elements also work outside of Tab content, for
example in the Inspector.

Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
(cherry picked from commit 421fb6309f6d5ea13676c5788a3d8294631a403b;
amended to resolve conflict due to us not yet having
LadybirdBrowser/ladybird#910, so this will cause extra conflicts
when finally cherry-picking that. But that PR will need lots of
conflict resolving anyways.)
2024-11-15 23:10:03 -05:00
Jamie Mansfield
70d69c194f Ladybird/Qt: Rename convert functions to reflect their new types
This is a follow up to GH-1111 to reflect the new signatures that these
functions have.

(cherry picked from commit b0fc8b67d64089587552effbe3b994cdb5967ce5)
2024-11-15 23:10:03 -05:00
Timothy Flynn
4a6e669343 UI/Qt: Process drag-and-drop events through the web view
This forwards all drag-and-drop events from the UI to the WebContent
process. If the page accepts the events, the UI does not handle them.
Otherwise, we will open the dropped files as file:// URLs.

(cherry picked from commit 4833ba06eaef20053f85343a13c0307394d67ded)
2024-11-15 19:27:44 -05:00
Tim Ledbetter
27f724b435 WebWorker: Allow the WebWorker process to optionally use Qt networking
This change adds a `--use-lagom-networking` flag to the WebWorker
process. Qt networking is used if this flag isn't passed. The flag is
passed the UI launches the WebWorker process unless the Qt chrome is
being run with the `--enable-qt-networking` flag.

(cherry picked from commit 886714632759c1e2feeb636388975f0e3b515839;
amended Qt/main.cpp to resolve minor conflict due to serenity not having
LadybirdBrowser/ladybird#284 LadybirdBrowser/ladybird#45, and
WebWorker/CMakeLists.txt due to serenity still having
`SERENITY_SOURCE_DIR` instead of `LADYBIRD_SOURCE_DIR` --
LadybirdBrowser/ladybird#17)
2024-11-15 19:07:17 -05:00
Tim Ledbetter
42712fd165 WebDriver: Add option to use Qt networking
Using Qt networking when running web platform tests improves
performance significantly. The time to run the subset of tests we run
on CI drops from 21.9 seconds to 8.2 seconds on my machine.

(cherry picked from commit ff2123a949446b834e6c3b0be7ca4c994d71f3e1)
2024-11-15 19:07:17 -05:00
Asutosh Variar
50cc1b5d63 Everywhere: Convert from_string_view -> from_string_literal where static
(cherry picked from commit 229b64a4b723a391c21f247d72d78cd575ace6ff;
minorly amended to fix conflict in image.cpp due to serenity in the
meantime adding webp writing support, and due to changes in Android and
Vulkan-related files that serenity doesn't have)
2024-11-15 08:56:39 -05:00
Galvin
4ed48dfb9e UI/AppKit: Fix tab title icon and text layout
Make the tab title icon and text vertical center

(cherry picked from commit e8ff9b6eb4c77d8606e492e8f0608190d40b7649)
2024-11-13 10:17:34 -05:00
Timothy Flynn
69953cb70e UI/Qt: Remove unused WebContentView::dump_layout_tree
(cherry picked from commit b688bbf26c6efb84fec19ec900cd3f1a4cf04a1b)
2024-11-12 10:45:53 -05:00
Kostya Farber
cec134792e Qt: Add box icon to line box debug menu action
(cherry picked from commit 3e7faae6472d9696637d58f30994199a28dddc01)
2024-11-12 07:14:25 -05:00
rmg-x
7f96fb2c1f UI/Qt: Simplify link context menu and update keyboard shortcuts
Removes the unnecessary separator, redundant open action, and changes
shortcuts to match other browsers.

(cherry picked from commit 1f365ba44a2f95006121f689429e2f58db30bc5b)
2024-11-11 19:54:09 -05:00
Andreas Kling
ad4abc1818 UI/AppKit: Make "Dump GC Graph" menu action actually work again
This was originally implemented as a debug request, but later changed.
The Qt UI already did the right thing, so just copy the logic over.

(cherry picked from commit 08ae305dc5a621233b2d329581969899efbb1195)
2024-11-10 19:39:05 -05:00
Jelle Raaijmakers
b471972353 UI/Qt: Enable basic IME keyboard input for WebContentView
This makes dead keys work (e.g. typing ' and e results in é).

(cherry picked from commit 7e57cc7b090455e93261c847064f12a61d686ff3)
2024-11-10 18:24:10 -05:00
Jamie Mansfield
603f66017a Ladybird/Qt: Don't change to new tab with 'Open in New Tab'
It now just opens a new tab, without changing the current tab.

(cherry picked from commit df34ee058b1285d31386ee973f056d56f13d7bf6)
2024-11-10 18:24:10 -05:00
Jamie Mansfield
088c42ab6e Ladybird/Qt: Display ampersands in tab titles
Qt reads ampersands as shortcut keys, so this escapes them (with &&) so
they display correctly :^)

(cherry picked from commit 6133707df88d0b6e2e9eb62797658c1a88380a07)
2024-11-10 18:24:10 -05:00
Timothy Flynn
bedf88c8eb UI/Qt: Do not create signal notifiers until after an event loop exists
We are currently creating a signal socket and socket notifier before the
Qt event loop itself has been created. Thus, when we receive a signal,
we are not actually notified when we write that signal number to the
signal socket.

This was also the source of the following error message being displayed
on every launch of the browser:

    QSocketNotifier: Can only be used with threads started with QThread

(cherry picked from commit 3393a7477103cb2dc2fe970e3559abb34b3a0ce8)
2024-11-10 10:46:01 -05:00
rmg-x
2d67391151 UI/Qt: Move "Open in New Tab" to the top of the link context menu
(cherry picked from commit 7a2d837c8ab137d8d31b3789dfe7ef377b3b225e)
2024-11-10 10:46:01 -05:00
ronak69
c74a70ea1d UI/Qt: Do not perform search if query text is empty
(cherry picked from commit 276ad23b7090a3edc778a6d48e8ff2ff450f2896)
2024-11-09 16:08:01 -05:00
PiyushXCoder
2b84c92566 UI/Qt: Don't allow tabs to be dragged past the new tab button
Before this change, if would a tab it will pass the add new tab button
(+ button).

closes #1124

(cherry picked from commit 9b79081a0601ef6649592acc1025b12c52e63d5c)
2024-11-09 16:08:01 -05:00
Tim Ledbetter
d460654347 UI/Qt: Don't change LocationEdit cursor position on right click
Previously, right clicking highlighted text in the location bar would
cause the current selection to be lost.

(cherry picked from commit 6c608bac659b7e39be52ffecd68ecd46172665bc)
2024-11-09 16:08:01 -05:00
sideshowbarker
2949d90c82 Ladybird: Remove unnecessary copy of decoded images
This also eliminates the clang-tidy warning “Std::move of the const
expression has no effect”.

(cherry picked from commit ff170de49dfae56d123fb5e8bb61825e7cd16f5c)
2024-11-09 07:29:52 -05:00
Timothy Flynn
3e78150670 UI/AppKit: Add a debug menu item to dump RequestServer connection info
(cherry picked from commit b1433a8097a01798344e158f24ee4798028ecac9)
2024-11-08 21:51:25 -05:00
Timothy Flynn
4881c7ac47 UI/Qt: Unregister WebContentView instances just once
We already unregister the view in the ViewImplementation destructor. We
do not need to do so again in the WebContentView destructor.

(cherry picked from commit 62fa84865d64b6ac7bcb1f8f285b556e56481cb6)
2024-11-08 21:51:25 -05:00
Tim Ledbetter
79e67484fb UI/Qt: Don't crash when launching Inspector with Qt networking enabled
(cherry picked from commit a4b289ebac837c4cfeced9b9145aa5e15cb3281e)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
218f3aa536 Ladybird/Qt: Add missing filters for TVG icons
Ladybird now uses the correct theme colours when hovering over icons.

(cherry picked from commit 01ff3d428684c1f638cfd47fb451179e66a78dd5)
2024-11-08 21:51:25 -05:00
Sam Atkins
7d81892991 UI/Qt: Manually paint the tab-bar background where the "add" button was
The TabBar itself does not stretch the entire width of the TabWidget,
because it leaves space for the width of the new-tab button. So, we
manually tell Qt to paint the TabBar's background into the gap.

Fixes #768.

(cherry picked from commit 06484d0663c120198323547e6515404ba0a594ee)
2024-11-08 21:51:25 -05:00
Sam Atkins
42fda81bd0 UI/Qt: Make TabWidget responsible for new-tab button positioning
Makes use of the fact that QTabWidget automatically reserves space
for "corner widgets", and gives us the ability to override their
location with a custom style.

Also, determine the height of the new-tab button using the height of the
tab bar, instead of a hard-coded 32px which was too tall on MacOS.

(cherry picked from commit e17362ab79d8442af70c146d351e29168bb8a5b7)
2024-11-08 21:51:25 -05:00
lmutter
f5b850cbd6 UI/Qt: Move New Tab button in tab bar
(cherry picked from commit abddd0ac1b73407737981e283450a82cad79e877)
2024-11-08 21:51:25 -05:00
Sidicer
6dec4de06d UI/Qt: Move cursor to the front
Fix long URLs showing the end instead of domain

(cherry picked from commit c380dcf15e689b58737a8bb7411bdafbd85dbbe4)
2024-11-08 07:44:45 -05:00
Timothy Flynn
335b527f19 LibWeb+LibWebView: Add a button to the Inspector to export its contents
When working on the Inspector's HTML, it's often kind of tricky to debug
when an element is styled / positioned incorrectly. We don't have a way
to inspect the Inspector itself.

This adds a button to the Inspector to export its HTML/CSS/JS contents
to the downloads directory. This allows for more easily testing changes,
especially by opening the exported HTML in another browser's dev tools.

We will ultimately likely remove this button (or make it hidden) by the
time we are production-ready. But it's quite useful for now.

(cherry picked from commit 3ec5c1941f25041c6bf073f2940f6035e084a4e2)
2024-11-08 07:44:45 -05:00
circl
e744abc3ce LibWeb+UI: Add tooltip overriding and use it for <video> tags
This call is used to inform the chrome that it should display a tooltip
now and avoid any hovering timers. This is used by <video> tags to
display the volume percentage when it is changed.

(cherry picked from commit ceb9c3b79746e5499dce781e1fc81a9107c86f84;
amended to add a FIXME: to OutOfProcessWebView for these new hooks)
2024-11-07 20:52:11 -05:00
circl
206642afb1 LibWeb+UI/Qt: Display 'title' tooltips only when the mouse stops moving
Now instead of sending the position in which the user entered the
tooltip area, send just the text, and let the chrome figure out how to
display it.

In the case of Qt, wait for 600 milliseconds of no mouse movement, then
display it under the mouse cursor.

(cherry picked from commit 0f7623dd8322f0fd5ef6ee0e27e1295e11f276e6;
amended to update OutOfProcessWebView.cpp for on_enter_tooltip_area
API change)
2024-11-07 20:52:11 -05:00
Jamie Mansfield
a225b9ca51 Ladybird/Qt: Add setting for preferred languages
(cherry picked from commit 132ab775d8bf712c2f461e40e4e20c431fcadc90)
2024-11-05 11:41:15 -05:00
Andreas Kling
09a3dcb9c9 LibWeb: Implement very basic in-memory HTTP caching
This patch adds a simple in-memory HTTP cache to each WebContent
process.

It's currently off by default (turn it on with --enable-http-cache)
since the validation logic is lacking and incomplete.

(cherry picked from commit a3c8e60710451c1325f6718b253e8d1ee2029a30)
2024-11-05 11:22:07 -05:00
Tim Ledbetter
fb2a030762 UI/Qt: Don't hide the location bar URL when creating a tab from a URL
The location bar URL is no longer hidden when creating a new tab or
opening a new window that has an associated URL. Conversely, the
location bar is now always focused and the URL hidden when creating a
window or tab without an associated URL.

The location bar is focused when:
* Opening the browser from the command line with no URL arguments
* Opening a new tab (Ctrl+T)
* Opening a new window (Ctrl+N)

The location bar is not focused when:
* Opening the browser from the command line with one or more URLs
* Opening hyperlinks in a new tab
* Clicking a hyperlink with `target="_blank"`

This matches the behavior of other major browsers.

(cherry picked from commit efce3d967183f7071d47f27ce93310662217ef5e)
2024-11-05 10:47:18 -05:00
Tim Ledbetter
370ab9dc16 UI/Qt: Set a minimum size policy for the navigation control toolbar
This prevents the user being able to shrink the window to the point
that the location bar and other controls are no longer visible.

(cherry picked from commit 4ed46adeeec4860b55d455da49aa93aff26bf1a3)
2024-11-05 06:03:32 -05:00
Jamie Mansfield
196a70b3bc Ladybird/Qt: Only update navigation buttons for current tab
This resolves a bug where if you opened a link in a new tab and quickly
went back to the original, the navigation buttons would update for the
new page shortly after.

(cherry picked from commit 7abf47f4bf5039869a8f38c12f1be62bba97e463)
2024-11-05 06:02:54 -05:00
simonkrauter
0ab04f92a3 Ladybird/Qt: Apply selected color scheme for new tabs
Previously, new tabs always had the `auto` color scheme, regardless of
what the user has selected before.
Replace the 3 individual slots with a `set_preferred_color_scheme`
method.

(cherry picked from commit 82915e1914bd9a8d4a6dcbec53982b3ba2caa68d)
2024-11-04 20:56:17 -05:00
Jamie Mansfield
3ba99107c2 Ladybird/Qt: Add actions to set navigator compatibility mode
(cherry picked from commit 197f57f5d2641755698125c54db36776d72148b1)
2024-11-04 13:54:07 -05:00
Bastiaan van der Plaat
ddd4f6b232 Ladybird/AppKit: Use system accent color in palette
(cherry picked from commit 86e372b7dd8a0567bc256fa4a90c0757f40fa2d0)
2024-11-04 12:53:24 -05:00
Timothy Flynn
4a7e1737af UI/AppKit: Process drag-and-drop events through the web view
This forwards all drag-and-drop events from the UI to the WebContent
process. If the page accepts the events, the UI does not handle them.
Otherwise, we will open the dropped files as file:// URLs.

(cherry picked from commit ac062d0c977de7ca648504ef6238a8a016076aa6)
2024-11-01 19:58:08 -04:00
Tim Ledbetter
0d8dd2e699 WebDriver: Launch Ladybird with --force-new-process
This allows multiple WPT tests to be run in parallel with using the
`--processes` option.

(cherry picked from commit c14dc77349eca6f9cddd7fbb1d8e216cc9fa6cf8)
2024-11-01 16:16:23 -04:00