Commit Graph

365 Commits

Author SHA1 Message Date
Ben Wiederhake
4e101d1fa2 Ladybird: Remove unused IODevice.h include 2023-05-21 07:52:52 +02:00
Timothy Flynn
6970f1b6c1 Browser+Ladybird+LibWebView: Handle trivial content APIs in LibWebView
The goal here is to reduce the amount of WebContent client APIs that are
duplicated across every ViewImplementation. Across our three browsers,
we currently:

    Ladybird - Mix some AK::Function callbacks and Qt signals to notify
    tabs of WebContent events.

    Browser - Use only AK::Function callbacks.

    headless-browser - Drop most events on the floor.

Instead, let's only use AK::Function callbacks across all three browsers
to propagate events to tabs. This allows us to invoke those callbacks
directly from LibWebView instead of all three browsers needing to define
a trivial `if (callback) callback();` override of a LibWebView virtual
function. For headless-browser, we can simply not set these callbacks.

As a first pass, this only converts WebContent events that are trivial
to this approach. That is, events that were simply passed onto the tab
or handled without much fuss.
2023-05-17 19:47:05 +02:00
Timothy Flynn
c113d780c6 Ladybird: Move ownership of the JS console/inspector to the tab object
This is to match Browser, where ownership of all "subwidgets" is placed
on the tab as well. This further lets us align the web view callbacks to
match Browser's OOPWV as well, which will later let us move them into
the base LibWebView class.
2023-05-17 19:47:05 +02:00
Timothy Flynn
2d51b8c286 Browser+Ladybird+LibWebView: Virtualize computing content/widget points
This will allow moving some copy-pasted functionality from web view
implementations to the base LibWebView class.
2023-05-17 19:47:05 +02:00
Timothy Flynn
31d7565cf3 Ladybird: Remove unused JS console methods
Note that the real implementations of these functions are:
    notify_server_did_output_js_console_message
    notify_server_did_get_js_console_messages

Which have the same method bodies as these unused variants.
2023-05-17 19:47:05 +02:00
Timothy Flynn
d8b14da380 Browser+Ladybird+LibWebView: Move some common functions to LibWebView
The implementations of handle_web_content_process_crash and
take_screenshot are exactly the same across Browser and Ladybird. Let's
reduce some code duplication and move them to LibWebView.
2023-05-17 19:47:05 +02:00
MacDue
77008d4bac Ladybird: Fix context menus being in slightly the wrong position
Previously, we were doing mapToGlobal() via the Tab widget, but the
widget position was actually relative to the WebContentView. This
meant context menus appeared slightly vertically offset from where
you clicked.
2023-05-16 13:22:15 -07:00
Timothy Flynn
b0edc7b6e4 Ladybird: Add screenshot actions to the page context menu
Browser on Serenity has these actions already.
2023-05-16 19:47:18 +02:00
Timothy Flynn
e30dcc7391 Ladybird: Add a context menu for image elements 2023-05-16 12:48:39 +02:00
Timothy Flynn
0d1b5e7f7a Ladybird: Add a context menu for link elements 2023-05-16 12:48:39 +02:00
Timothy Flynn
1b2394d92e Ladybird: Add a context menu for video elements 2023-05-16 12:48:39 +02:00
Timothy Flynn
a0e31bf1de Ladybird: Move the page context menu from the BrowserWindow to the Tab
This will allow us to show different context menus depending on what
element is clicked, much like we do for Browser on Serenity.
2023-05-16 12:48:39 +02:00
Timothy Flynn
d8f03dda08 Browser+LibWeb+WebContent: Broadcast video element context menu requests
This just sets up the IPC to notify the browser process of context menu
requests on video elements. The IPC contains a few pieces of information
about the state of the video element.
2023-05-16 12:48:39 +02:00
Andreas Kling
85c542ab00 Ladybird+LibWebView: Move backing store management code to LibWebView
This lets us share this code on all platforms, and makes resizing the
window much faster on SerenityOS as well. :^)
2023-05-15 12:13:34 +02:00
Andreas Kling
ec2600f246 Ladybird: Make resizing the window a lot less laggy
While resizing, we now pad the shared bitmap allocations with 256 pixels
extra in both axes. This avoids churning through huge allocations for
every single resize step.

We also don't reallocate at all when making the window smaller.

3 seconds after the user stops resizing, we resize the backing stores
again so they fit the window perfectly.
2023-05-15 10:04:29 +02:00
Andreas Kling
984630845d Ladybird: Only request repaint for what's in the visible viewport
Before this change, we asked WebContent to fill the whole shared bitmap
with content, even if we couldn't show it all in the viewport.
2023-05-15 10:04:29 +02:00
Andreas Kling
def37e65f3 Ladybird+LibWebView: Remember the size of the last paint
This will allow us to change the size of the backing store bitmap
without conflating the size of the bitmap and the size of the paint.
2023-05-15 10:04:29 +02:00
Andreas Kling
68271c4fce Ladybird: Floor the WebContentView viewport offset at 0, 0
This fixes an unpleasant visual glitch when resizing the window.
When the user makes our QAbstractScrollArea larger, the scroll bars can
end up with negative values, which we were happily forwarding to the
WebContent process and asking it to paint the whole page at an offset.
2023-05-15 10:04:29 +02:00
Luke Wilde
3894a8b995 Ladybird: Send the double click event to WebContent 2023-05-14 13:51:05 +02:00
MacDue
404804db36 Ladybird: Add common handy actions to context menu
This commit adds the common actions you'd expect to the Ladybird context
menu, arranged like so:

	┌──────────────────────────────┐
	│  Go Back           Alt+Left  │
	│  Go Forward        Alt+Right │
	│  Reload            Ctrl+R    │
	│ ──────────────────────────── │
	│  Copy              Ctrl+C    │
	│  Select All        Ctrl+A    │
	│ ──────────────────────────── │
	│  View Source       Ctrl+U    │
	│  Inspect Element             │
	└──────────────────────────────┘
2023-05-13 15:54:34 +02:00
Andreas Kling
0db94daf5e Ladybird: Disable SQL database by default (until we can trust it)
The asynchronous query execution keeps causing bugs with document.cookie
so let's make the SQL database backend default off until we can trust it
to do what we need.
2023-05-13 07:52:22 +02:00
Lucas CHOLLET
8c34959b53 AK: Add the Input word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
2023-05-09 11:18:46 +02:00
MacDue
09773048b6 Ladybird: Allow right clicking and inspecting elements
This adds "Inspect Element" (currently the only entry) to the context
menu for the page, which will do what you expect (most of the time),
and bring up the Inspector with hovered element selected.
2023-05-09 06:16:58 +02:00
martinfalisse
f7c27556fa Documentation: Homogenize Ladybird build instructions
Change the file name so that it is similar to the other build
instructions and may be easier to find :^).
2023-05-08 20:53:25 -06:00
martinfalisse
c719a542c5 LibWeb: Add --layout-test-mode flag to HeadlessBrowser
The `layout-test-mode` flag changes the font to be SerenitySans as this
is the font used for layout tests for cross-platform compatibility of
tests.
2023-05-08 14:47:52 +02:00
martinfalisse
00e446facd Ladybird: Move arguments parsing before FontPluginQt init
In a future commit will pass arguments parsed to the FontPluginQt
constructor.
2023-05-08 14:47:52 +02:00
MacDue
b5e593d0e7 Ladybird: Don't ask Qt to decode any images for us
We should only rely on LibGfx to decode images for us, if LibGfx
can't decode an image that should be motivation to improve LibGfx,
not hidden by Qt picking up the slack :^)
2023-05-07 21:13:02 +02:00
Andreas Kling
af5d892a7e Ladybird: Don't ask Qt to decode SVG images for us
While it's nice to see <img src="foo.svg"> suddenly work in Ladybird
after linking with the Qt SVG module, this is cheating.

We should implement SVG-as-image ourselves instead of relying on 3rd
party code to do it. :^)
2023-05-07 09:06:48 +02:00
Andreas Kling
0eb7c24e7d Ladybird: Stop telling Qt to use HTTP pipelining
For some reason, this was causing incomplete HTTP loads in some cases.
As an example, we would only load half of the "Ahem" CSS font from the
wpt.live server when running Acid3.

I only enabled pipelining in the first place because I assumed it would
be a performance boost, but it appears to do more than that.

I suppose there's a reason it's off by default (and most Qt API users
don't bother enabling it.)
2023-05-06 12:49:12 +02:00
Andreas Kling
4b5cbe7931 Ladybird: Use vector icons in the browser toolbar
We now load SVG icons (via the Qt resource system) and render them into
a QIcon (with normal and disabled variants) using system colors.
We also re-render them if the system color theme changes.

This instantly makes Ladybird look less foreign on my Linux box.

I drew the icons myself, and they could definitely be more optimized,
but this was my first time using Inkscape. :^)
2023-05-05 16:58:08 +02:00
Andreas Kling
60312f2c83 Ladybird: Remove the "home" icon from the toolbar (and the concept)
This feature isn't really that useful in practice, so let's remove it.
(Other browsers haven't had this action for years either.)
2023-05-05 16:58:08 +02:00
Andreas Kling
72195ade9d Ladybird: Let WebContent know if the current system theme is dark
This means we now actually respect @media (prefers-color-scheme: dark)
by default when in dark mode. :^)
2023-04-30 00:27:28 +02:00
Timothy Flynn
4dcdc3bd25 Ladybird: Prohibit GUI interaction of the WebContent process on macOS
The WebContent process behaves a bit awkwardly on macOS. When we launch
the process, we have to create a QGuiApplication to access system fonts.
But on macOS, doing so creates an entry in the Dock, and also causes the
WebContent to be focused. So if you enter cmd+Q without first focusing
the Ladybird GUI, WebContent is closed, while the Ladybird process keeps
running.
2023-04-27 07:26:05 +02:00
Andreas Kling
f61947fa9e LibCore: Remove unused EventLoopManager::wake()
Only EventLoopImplementation needs to know how to wake up.
2023-04-26 19:17:04 +01:00
Andreas Kling
b61a87c03c LibCore: Move post_event() back to EventLoopImplementation
This shouldn't have been moved to EventLoopManager, as the manager is
global and one-per-process, and the implementation is one-per-loop.

This makes cross-thread event posting work again, and unbreaks
SoundPlayer (and probably other things as well.)
2023-04-26 19:17:04 +01:00
Timothy Flynn
61c0174fec Browser+Ladybird: Render text in the JS console with a monospace font 2023-04-26 15:43:57 +02:00
Timothy Flynn
d44df16704 Ladybird: Explicitly set the font family for CSS generic fonts
We currently query Qt for system fonts using QFont::setStyleHint(). The
docs from Qt have the following note regarding this API on X11:

    Qt does not support style hints on X11 since this information is not
    provided by the window system.

This prevents any monospace font from working on X11 systems. For now,
work around this by specifying the font-family for fonts which Qt has
listed as mapping to a CSS generic font-family.
2023-04-26 15:43:57 +02:00
Andreas Kling
7b963e1e98 LibCore+Ladybird: Add EventLoopManager interface for persistent state
Things such as timers and notifiers aren't specific to one instance of
Core::EventLoop, so let's not tie them down to EventLoopImplementation.

Instead, move those APIs + signals & a few other things to a new
EventLoopManager interface. EventLoopManager also knows how to create a
new EventLoopImplementation object.
2023-04-25 18:01:35 +02:00
Andreas Kling
c21eb30a2b Ladybird+LibCore: Use QCoreApplication to drive the main Qt event loop
Using QEventLoop works for everything but it breaks *one* little feature
that we care about: automatically quitting the app when all windows have
been closed.

That only works if you drive the outermost main event loop with a
QCoreApplication instead of a QEventLoop. This is unfortunate, as it
complicates our API a little bit, but I'm sure we can think of a way to
make this nicer someday.

In order for QCoreApplication::exec() to process our own
ThreadEventQueue, we now have a zero-timer that we kick whenever new
events are posted to the thread queue.
2023-04-25 18:01:35 +02:00
Andreas Kling
1c6c3685c4 Ladybird: Remove Web::Platform plugins for Qt in favor of LibCore
Now that the Core::EventLoop is driven by a QEventLoop in Ladybird,
we don't need to patch LibWeb with Web::Platform plugins.

This patch removes EventLoopPluginQt and TimerQt.

Note that we can't just replace the Web::Platform abstractions with
LibCore stuff immediately, since the Web::Platform APIs use
JS::SafeFunction for callbacks.
2023-04-25 14:48:40 +02:00
Andreas Kling
3494c2382d Ladybird: Run the Core::EventLoop with a Qt backend
This patch adds EventLoopImplementationQt which is a full replacement
for the Core::EventLoopImplementationUnix that uses Qt's event loop
as a backend instead.

This means that Core::Timer, Core::Notifier, and Core::Event delivery
are all driven by Qt primitives in the Ladybird UI and WC processes.
2023-04-25 14:48:40 +02:00
Andreas Kling
411d36719e LibCore: Simplify Core::Notifier by only allowing one event type
Not a single client of this API actually used the event mask feature to
listen for readability AND writability.

Let's simplify the API and have only one hook: on_activation.
2023-04-25 14:48:40 +02:00
Timothy Flynn
8fe846eb7f Ladybird: Define AK_DONT_REPLACE_STD via CMake rather than in every file 2023-04-24 14:49:04 +02:00
Timothy Flynn
4aca24481e Ladybird: Implement the JavaScript console using a WebContentView
This aligns the Ladybird console implementation with the Browser console
a bit more, which uses OutOfProcessWebView for rendering console output.
This allows us to style the console output to try and match the system
theme.

Using a WebContentView is simpler than trying to style the old QTextEdit
widget, as the console output is HTML with built-in "-libweb-palette-*"
colors. These will override any color we set on the QTextEdit widget.
2023-04-23 14:30:23 +02:00
Timothy Flynn
5089766af6 Browser+Ladybird+LibWeb: Port content filters to String 2023-04-22 12:32:40 +02:00
Timothy Flynn
76ae60da15 Browser+Ladybird+LibWeb: Prevent infinite growth of content filters
We never clear content filters on either end of the Browser-WebContent
IPC connection. So when the filters change, we re-append all filters to
the Vector holding them. This incidentally makes it impossible to remove
a filter.

Change both sides to clear their filter lists when receiving a new set
of filters.
2023-04-22 12:32:40 +02:00
Sam Atkins
6d93e03211 LibWeb+Browser+Ladybird: Use JS::SafeFunction for EventLoop callbacks
This automatically protects captured objects from being GC'd before the
callback runs.
2023-04-21 20:44:47 +01:00
Timothy Flynn
3d0ac399c4 Ladybird: Add a command line flag to disable launching SQLServer 2023-04-21 07:56:14 +02:00
Timothy Flynn
1ffd533ea2 Ladybird: Propagate autoplay settings to the WebContent process 2023-04-18 16:30:02 +02:00
MacDue
0329ddf46a Ladybird+LibWebView: Add -P/--enable-callgrind-profiling option
This adds a -P option to run Ladybird under callgrind. It starts with
instrumentation disabled. To start capturing a profile (once Ladybird
has launched) run `callgrind_control -i on` and to stop it again run
`callgrind_control -i off`.

P.s. This is pretty much stolen from Andreas (and is based on the patch
everyone [that wants a profile] have been manually applying).
2023-04-15 06:37:51 +02:00