Commit graph

291 commits

Author SHA1 Message Date
Timothy Flynn ad8183beb4 Meta: Support running ladybird with arguments from serenity.sh
You may now, for example, run:

    ./Meta/serenity.sh run lagom ladybird https://serenityos.org
2023-01-27 08:14:24 -05:00
Sam Atkins a5db4a0551 Ladybird: Replace uses of JsonObject::get_deprecated() 2023-01-27 08:07:24 -05:00
Andreas Kling ddbdeb3ca0 Ladybird: Add --dump-layout-tree mode that dumps layout tree and exits 2023-01-27 10:41:24 +01:00
Andreas Kling 90fee39290 Ladybird: Fire the WebContentView::on_load_finish hook if set 2023-01-27 10:33:18 +01:00
Tim Schumacher 82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Cameron Youell 3bd96f29d2 Ladybird: Add LocationEdit Highlighting 2023-01-22 21:15:22 -07:00
Cameron Youell b97f9f5809 Ladybird: Make LocationEdit its own class
Also make return key behave more like other browsers when editing
2023-01-22 21:15:22 -07:00
Karol Kosek f3c6510b83 Ladybird: Accept file drops 2023-01-19 19:22:03 +00:00
Karol Kosek 731fec525e Ladybird: Add URL and 'open in background' parameters to new_tab()
This will avoid loading starting about:blank page in places when we know
exactly what we want to load.

The opening in background part might be useful for future things like
file drops and right-click open in new tab.
2023-01-19 19:22:03 +00:00
Karol Kosek 194ddca24f Ladybird: Move the initial blank page load to BrowserWindow
Takes care of a FIXME :^)
2023-01-19 19:22:03 +00:00
Karol Kosek 5e89773937 Ladybird: Don't prepend 'about:' urls with an http:// scheme 2023-01-19 19:22:03 +00:00
Karol Kosek 4f36893fda Ladybird: Set initial page when NOT connected to WebDriver
This flips an if check condition, making the JS console work in new tabs
again.
2023-01-19 19:22:03 +00:00
Liav A 649f78d0a4 LibGfx+Ladybird+Userland: Don't sniff for TGA images with only raw bytes
Because TGA images don't have magic bytes as a signature to be detected,
instead assume a sequence of ReadonlyBytes is a possible TGA image only
if we are given a path so we could check the extension of the file and
see if it's a TGA image.

When we know the path of the file being loaded, we will try to first
check its extension, and only if there's no match to a known decoder,
based on simple extension lookup, then we would probe for other formats
as usual with the normal sniffing method.
2023-01-18 21:48:35 +01:00
Sam Atkins 1dd6b7f5b7 AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()
This is a preparatory step to making `get()` return `ErrorOr`.
2023-01-17 19:52:52 -05:00
Linus Groh f183745f4e LibWebView+Ladybird: Move preferred color scheme to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 5bf5697f16 LibWebView+Ladybird: Move text selection to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 8c11a2c253 LibWebView+Ladybird: Move running JavaScript to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 55609f744d LibWebView+Ladybird: Move debug request to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh de1c0c87fe LibWebView+Ladybird: Move page loading to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 2428e3e675 LibWebView+Ladybird: Move DOM inspection helpers to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh f313708237 LibWebView+Ladybird: Move get source request to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 5d9f4b2ffc LibWebView+Ladybird: Move zoom logic to ViewImplementation 2023-01-12 23:39:36 +01:00
Linus Groh 5411adca22 LibWebView+Ladybird: Begin de-duplicate WebView implementations
This starts moving code equally shared between the OOPWV and Ladybird
WebContentView implementations to WebView::ViewImplementation, beginning
with the client state.
2023-01-12 23:39:36 +01:00
Andreas Kling 2eaebdea5b Ladybird: Add Ctrl+= as an alternate "zoom in" shortcut
On many keyboards, Ctrl++ is actually Ctrl+Shift+=, and Ctrl+= makes
more sense as it's symmetric with Ctrl+-.

Both Firefox and Chrome already support this alternate shortcut,
so let's be nice and support it in Ladybird as well. :^)
2023-01-12 19:05:07 +00:00
Andreas Kling c8ea23a4fe Ladybird: Use QKeySequence::StandardKey as much as possible
Let Qt pick the most appropriate native shortcut when it knows one.
2023-01-12 19:05:07 +00:00
Andreas Kling 9c7e26b8d4 Ladybird: Add "Copy" and "Select All" actions to the Edit menu 2023-01-12 19:55:10 +01:00
Linus Groh 966d808135 Ladybird: Replace ColorScheme enum with Web::CSS::PreferredColorScheme
This matches OutOfProcessWebView::set_preferred_color_scheme().
2023-01-12 18:27:34 +00:00
Linus Groh 0cc151bc1c Ladybird: Implement zoom :^) 2023-01-12 15:14:09 +00:00
Linus Groh 05ef6c9b64 Ladybird: Set 'device pixels per CSS pixel' to device pixel ratio :^) 2023-01-12 15:14:09 +00:00
Linus Groh f49a65cb28 Ladybird: Use standard font paths in FontPluginQt
This makes vector fonts load on macOS, where /usr/share/fonts doesn't
exist and Ladybird would only load the bitmap fonts from ./res/fonts
in the SerenityOS resource root directory.
Additionally, fonts in {/usr/share/local,~/.local}/fonts are now loaded
on Linux.
2023-01-11 20:54:49 +00:00
Karol Kosek e3d9a3426e Ladybird: Port to Core::Stream::File 2023-01-09 22:50:53 +00:00
Andreas Kling f476b827de Ladybird: Let Qt pick the reload shortcut
This fixes an issue on platforms where Ctrl+R is the preferred native
shortcut, and we were effectively trying to set it twice.
2023-01-09 17:32:00 +01:00
Karol Kosek 01a786310d Ladybird: Add Qt's standard refresh key (F5) to reload shortcuts 2023-01-08 19:38:35 +01:00
Jonah 367b1634fd LibWebView+WebContent: Expose the Accessibility Tree to Other Processes
This patch also stubs out notify_server_did_get_accessiblity_tree in
ladybird since ViewImplementation now has it. However, this feature
is still immature, so just stubbing out in ladybird for now. Once we
have more robust support in Serenity (namely ARIA properties/state
and accessible names and descriptions) we can port this
functionality over.
2023-01-07 10:51:53 +00:00
Davide Cavalca 1fc7740152 Ladybird: Install SQLServer binary
Install the SQLServer binary added in 2cb3ae1 so that it's actually
available on the target system when doing a standalone build of
Ladybird.
2023-01-03 09:32:07 -05:00
networkException 4c7a99fe06 Ladybird: Remove separate LICENSE file
Since ladybird is part of the serenity monorepo now there's no need to
keep a separate LICENSE file around :^)
2023-01-03 12:37:18 +01:00
Luke Wilde b85f4ab66a Ladybird: Tell Qt that we manually handle the Cookie header
In some cases, Qt would silently drop the Cookie header and start
causing Cookie authenticated requests to start failing.
2022-12-30 23:52:09 +01:00
Nico Weber ac039d93f0 Ladybird: Fix typos 2022-12-30 17:21:57 +01:00
MacDue 678dfa8f75 Ladybird: Close inspector and JS console when tab closes
Keeping these around can lead to use-after-frees and crashes.
2022-12-25 15:30:08 -07:00
MacDue 33249c727a Ladybird: Add the node properties tabs to the inspector
This now allows you to view the computed and resolved style values,
along with the CSS variables of a node.
2022-12-25 15:30:08 -07:00
MacDue aa85a88158 Ladybird: Reimplement the DOM inspector :^)
This has been broken since the switch to the multiprocess architecture
(and even before then was very limited).

This restores the previous functionally and also implements the ability
to inspect individual elements (by selecting them in the tree view).
The inspector also now correctly updates when navigating between pages.
2022-12-25 15:30:08 -07:00
MacDue 0313814d3b Ladybird: Allow replacing underlying model of ModelTranslator 2022-12-25 15:30:08 -07:00
Andrew Kaster e79e7dc3b9 Documentation: Move Ladybird BuildInstructions to Documentation
Update Ladybird/README.md at the same time to reflect its new monorepo
status.
2022-12-25 07:58:58 -07:00
Andrew Kaster b4d80f92ec Ladybird: Support building Ladybird as a non-top-level project
The implementation assumes that Lagom is either the top level project,
or included before Ladybird is.
2022-12-25 07:58:58 -07:00
Timothy Flynn 03294b0177 Ladybird/WebDriver: Retrieve process environment in an OS-dependent way 2022-12-25 07:58:58 -07:00
Timothy Flynn e5192073d9 Ladybird/WebDriver: Move to using local socket files for WebDriver IPC
This allows us to use standard Serenity IPC infrastructure rather than
manually creating FD-passing sockets. This also lets us use Serenity's
WebDriver Session class, removing the copy previously used in Ladybird.
This ensures any changes to Session in the future will be picked up by
Ladybird for free.
2022-12-25 07:58:58 -07:00
Andreas Kling ea26e45594 Ladybird: Fix build after Gfx::load_system_theme() return type change 2022-12-25 07:58:58 -07:00
Timothy Flynn 4c1f414713 Ladybird: Migrate SQLServer to be launched as a singleton process
Rather than manually launching the SQLServer process, use SQLClient's
new functionality to launch the server just once for all Ladybird
instances. Quit the SQLServer process when it no longer has any
connected clients.
2022-12-25 07:58:58 -07:00
Timothy Flynn 1dd14e1324 Ladybird: Quit SQLServer when its connected client exits
When Ladybird exits, SQLServer can get stuck spinning at 100% CPU after
the socket connection is closed. This changes the client to quit the
event loop when that disconnect happens to ensure that SQLServer is
properly destroyed.
2022-12-25 07:58:58 -07:00
Andreas Kling e54932ee73 Ladybird: Fix build after ConsoleGlobalEnvironmentExtensions rename 2022-12-25 07:58:58 -07:00
Timothy Flynn 2cb3ae132a Ladybird: Implement SQLServer for Ladybird :^)
This adds a SQLServer binary for Ladybird to make use of Serenity's SQL
implementation. This has to use the same IPC socket handling that was
used to make WebContent and WebDriver work out-of-process.

Unlike Serenity, Ladybird creates a new SQLServer instance for each
Ladybird instance. In the future, we should try to make sure there is
only one SQLServer instance at a time, and allow multiple Ladybird
instances to communicate with it.
2022-12-25 07:58:58 -07:00
Timothy Flynn a0cd260410 Ladybird: Do not domain match on cookie updates
This matches a corresponding change to Serenity's Browser.
2022-12-25 07:58:58 -07:00
Thitat Auareesuksakul 5b8d1a6f61 Ladybird/Documentation: Add cmake to macOS dependencies 2022-12-25 07:58:58 -07:00
MacDue d768abffa0 Ladybird: Pass Gfx::IntPoint by value 2022-12-25 07:58:58 -07:00
MacDue 4709f5961b Ladybird: Pass Gfx::IntSize by value 2022-12-25 07:58:58 -07:00
Aliaksandr Kalenik 88667ce9f0 Ladybird: Fix build with JS::MarkupGenerator's new string type usage
Fix to build after JS::MarkupGenerator got converted to use
new string type:
112b3f7342
2022-12-25 07:58:58 -07:00
Linus Groh 5a5c4f079b Ladybird: Update for AK::{String => DeprecatedString} rename 2022-12-25 07:58:58 -07:00
Baitinq 97dd5a085f Ladybird: Replace history entry if loading URL because of a redirect
We now replace the current history entry if the page-load has been
caused because of a redirect. This makes it able to traverse the
history if one of the entries redirects you, which previously
caused an infinite history traversion loop.

Depends on https://github.com/SerenityOS/serenity/pull/16004
2022-12-25 07:58:58 -07:00
Sam Atkins ec55b13e96 Ladybird: Add stub for notify_server_did_finish_handling_input_event
This doesn't need to do anything yet, but will do once we start passing
events to web content *before* they're passed to our GUI.
2022-12-25 07:58:58 -07:00
Timothy Flynn a1e380cc38 Ladybird/WebDriver: Support running headless WebDriver sessions
This adds a dependency from WebDriver to Lagom's headless-browser to be
used if the client's required capabilities indicate to do so.
2022-12-25 07:58:58 -07:00
Timothy Flynn 69cd0d6599 Ladybird: Update stored URL when a page starts/finishes loading
Similar to https://github.com/SerenityOS/serenity/commit/9782660. Unlike
Serenity's browser, this doesn't affect reloading the page, as Ladybird
refers to the History object for reloading (which is updated already on
page load). However, this URL is used for e.g. crash reporting, so let's
update it here as well.
2022-12-25 07:58:58 -07:00
Timothy Flynn 9a5f9c101c Ladybird: Implement updated alert/confirm/prompt IPC methods
WebContent now needs to interact with these dialogs asynchronously. This
updates WebContentView to hold a pointer to whatever dialog is open, and
implements the methods to interact with that dialog.
2022-12-25 07:58:58 -07:00
Idan Horowitz fad3fbfe26 Ladybird: Add block pop-ups checkbox to debug menu 2022-12-25 07:58:58 -07:00
Timothy Flynn 948c4ba102 Ladybird/WebDriver: Implement the cookie endpoints for Ladybird 2022-12-25 07:58:58 -07:00
Timothy Flynn 9e0db602ca Ladybird: Implement WebDriver for Ladybird :^)
This adds a WebDriver binary for Ladybird to make use of Serenity's
WebDriver implementation. This has to use the same IPC socket handling
that was used to make WebContent work out-of-process. Besides that, we
are able to reuse almost everything from Serenity.
2022-12-25 07:58:58 -07:00
Timothy Flynn 54321f49ad Ladybird: Implement WebDriver's navigation and window control endpoints 2022-12-25 07:58:58 -07:00
Timothy Flynn 4031630b49 Ladybird: Construct a WebDriverConnection when instructed to do so
The WebDriver will pass the --webdriver-fd-passing-socket command line
option when it launches Ladybird. Forward this flag onto the WebContent
process, where it will create the WebDriverConnection for IPC.
2022-12-25 07:58:58 -07:00
Timothy Flynn 7021d30288 Ladybird: Foward the WebContent passing socket FD by command line
Rather than needing to set another environment variable for WebDriver's
passing socket, let's forward these FDs by command line. This also moves
the creation of the WebContent connection to a helper function so that
the WebDriver connection can re-use it.
2022-12-25 07:58:58 -07:00
Timothy Flynn 39954f9e7f Ladybird: Give the WebContent socket a descriptive name
WebContent's main() will soon take over multiple sockets. Give the
existing WebContent socket a descriptive name to avoid confusion.
2022-12-25 07:58:58 -07:00
Baitinq e74dff7697 Ladybird/Misc: Add ladybird.nix for nix-shell support 2022-12-25 07:58:58 -07:00
Marco Cutecchia 5a9b891268 Ladybird: Stub out notify_server_did_request_fullscreen_window 2022-12-25 07:58:58 -07:00
Timothy Flynn e592c7691e Ladybird: Stub out history navigation WebView::ViewImplementation APIs
These were added for WebDriver, which doesn't have a Ladybird
implementation yet.
2022-12-25 07:58:58 -07:00
Timothy Flynn fcc0530e26 Ladybird: Stub out new cookie WebView::ViewImplementation APIs
These were added for WebDriver, which doesn't have a Ladybird
implementation yet.
2022-12-25 07:58:58 -07:00
Baitinq e80147afba Ladybird: Fix reloading functionality
Previously, reloading went back to the first page loaded by
WebView::load() or WebView::load_html(), as they are the only methods
that modify m_url, which is what the reload loaded. Now we handle
reloads in Tab.cpp by simply loading the last entry in the m_history.
2022-12-25 07:58:58 -07:00
Timothy Flynn 0b15fd4a12 Ladybird: Stub out new WebView::ViewImplementation APIs
These were added for WebDriver, which doesn't have a Ladybird
implementation yet.
2022-12-25 07:58:58 -07:00
Baitinq 15e4d151c3 Ladybird: Don't add initial about:blank load to history
The hackish initial loading of about:blank was previously added to the
history, so you could go back to it (which wasn't very ergonomic). Now
we set the m_is_history_navigation flag before loading it so it doesn't
get added to the history.
2022-12-25 07:58:58 -07:00
Timothy Flynn 5d0ab45ff4 Ladybird: Add new WebContent source file for WebDriver endpoints 2022-12-25 07:58:58 -07:00
Andreas Kling 385c12c8b6 Ladybird: Add subclass of WebSocket::WebSocketImpl using Qt networking 2022-12-25 07:58:58 -07:00
Gunnar Beutner acd70f44c2 Ladybird: Don't change window icons when background tabs change icons 2022-12-25 07:58:58 -07:00
Gunnar Beutner 5f3b82dcba Ladybird: Don't update window titles when background tabs change titles
Steps to reproduce:
1. Open the Cookie Clicker game in a tab.
2. Open another website in another tab and make that the current tab.
3. Observe how the window's title mentions Cookie Clicker.
2022-12-25 07:58:58 -07:00
Baitinq eaff4a1d65 Ladybird: Don't push to history when loading through history navigation
Previously we were always pushing to history on the on_load_start
callback. Now we only do that if we are NOT navigating through the
history navigation (loading pages by going back/forward). This is what
the SerenityOS browser does:^)
2022-12-25 07:58:58 -07:00
Baitinq 982174706b Ladybird: Handle forward and backward mouse buttons
We now emit a new signal for backward mouse button's mouseup and forward
mouse button's mouseup which is handled by going back and forward in the
history respectively:))
2022-12-25 07:58:58 -07:00
Andreas Kling ef553a4b76 Ladybird: Don't burn 100% CPU in EventLoopPluginQt::spin_until()
There's no point in busy-waiting for the condition to come true.
By passing the `WaitForMoreEvents` flag to `processEvents()`, we allow
Qt to block until it has something for us to react to.

This was extremely noticeable when waiting for large resources to
finish loading.
2022-12-25 07:58:58 -07:00
Andreas Kling bc6a6190d8 Ladybird: Disable HTTP2 as it's significantly slower
The slowdown is sometimes 5x, possibly more.

This is trivially confirmed by adding a large JS file to a page and
comparing the load time with a simple wget.
2022-12-25 07:58:58 -07:00
Linus Groh 216192143e Ladybird: Clean up linked libraries
- Add Qt::Core, Qt::Gui, LibGfx, LibIPC, and LibJS to the ladybird
  target, remove LibGL, LibSoftGPU, and LibWebSocket
- Add LibJS to the WebContent target, remove LibWebView
- Order them properly :^)

Regressed in https://github.com/SerenityOS/serenity/pull/15746.
Fixes #108.
2022-12-25 07:58:58 -07:00
Linus Groh 66c69654a6 Ladybird/Documentation: Bump GCC requirement to >= 12
See https://github.com/SerenityOS/serenity/pull/15797
2022-12-25 07:58:58 -07:00
Gunnar Beutner dd20b34acb Ladybird: Ignore SIGINT when we're being debugged
Let's ignore SIGINT if we're being debugged because GDB incorrectly
forwards the signal to us even when it's set to "nopass". See
https://sourceware.org/bugzilla/show_bug.cgi?id=9425 for details.
2022-12-25 07:58:58 -07:00
Linus Groh 11b730fccb Ladybird: Use Browser's History.{cpp,h}
There are no custom changes for Ladybird in the current copies of those
files, so we just need to ensure to keep Ladybird up to date for any
changes made upstream.
2022-12-25 07:58:58 -07:00
Linus Groh c91978baa6 Ladybird: Use Browser's CookieJar.{cpp,h}
There are no custom changes for Ladybird in the current copies of those
files, so we just need to ensure to keep Ladybird up to date for any
changes made upstream.

This fixes a build issue introduced by https://github.com/SerenityOS/serenity/pull/15736.
2022-12-25 07:58:58 -07:00
networkException fb71dc5141 Ladybird/CMake: Launch gdb with follow fork mode to debug WebContent 2022-12-25 07:58:58 -07:00
networkException d1b2c2977e Ladybird/CMake: Add options for enabling {A,M,UB}SAN
This patch adds convenient flags for enabling ASAN, MSAN and UBSAN.
2022-12-25 07:58:58 -07:00
Andreas Kling 8b593c9884 Ladybird: Add Ctrl+Shift+G shortcut to force a garbage collection 2022-12-25 07:58:58 -07:00
Andrew Kaster ccf95631ba Ladybird: Add Userland/ subdirs of Lagom binary dir to include path
Recent Serenity changes put generated files for libraries in
_deps/lagom-build/Userland/Libraries rather than lagom-build/Libraries.
2022-12-25 07:58:58 -07:00
Andreas Kling 6d1db6801c Ladybird/RequestManagerQt: Unwrap multiple cookies masquerading as one
Qt can wrap any number of cookies into a single Set-Cookie header in the
network responses it gives us. We now use the QNetworkReply::header()
API to get a "cooked" list of the cookies, and then rewrap them in a
format suitable for LibWeb.

Sites that send multiple Set-Cookie headers in one response now work
a lot better. :^)
2022-12-25 07:58:58 -07:00
Andreas Kling 195cdb33de Ladybird/WebContentView: Make Tab and Shift+Tab work
These didn't work, for two reasons:

1. Qt swallows all Tab key presses by default. We have to override
   the event() function in order to receive them.

2. Qt transforms Shift+Tab into a fake "Backtab" key. We have to
   undo this transformation and send Shift+Tab to WebContent.
2022-12-25 07:58:58 -07:00
Andreas Kling c154d94964 Ladybird/WebContentView: Accept focus and notify WebContent on change 2022-12-25 07:58:58 -07:00
Andreas Kling 71dadabfaa Ladybird: Hook up the CookieJar again after WebContent introduction 2022-12-25 07:58:58 -07:00
Idan Horowitz 775332e179 Ladybird: Accept file paths, domains, and URLs as an argument
This makes opening test files much more ergonomic :^)
2022-12-25 07:58:58 -07:00
Andreas Kling 52a7282c64 Ladybird: Close the other side's file descriptors after forking
When spawning a WebContent process, we have to close the file
descriptors belonging to the "other side" in both processes, or they
will not get naturally "cleaned up" when one of the processes exits.

Fixes #93
2022-12-25 07:58:58 -07:00
Andreas Kling 7362755f30 Ladybird: Implement EventLoopPluginQt::quit()
This breaks out of the main Qt event loop.
2022-12-25 07:58:58 -07:00