Commit Graph

103 Commits

Author SHA1 Message Date
circl
0f7623dd83 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.
2024-07-04 14:15:51 +02:00
Andrew Kaster
29b4f21c7b WebContent: Add shutdown_server IPC call to request process exit
This ensures that removing the last view from a WebContentClient will
close its associated process, assuming the WebContent process is not
hung. A more drastic measure will be needed to trigger forcefully
killing the process when it doesn't respond to this request.
2024-07-01 18:10:56 +02:00
Andrew Kaster
4cc3d598f9 LibWebView+LibCore: Manage process lifecycle using a SIGCHLD handler
This large commit also refactors LibWebView's process handling to use
a top-level Application class that uses a new WebView::Process class to
encapsulate the IPC-centric nature of each helper process.
2024-07-01 18:10:56 +02:00
Andrew Kaster
54f66c574c LibWebView: Allow querying and iterating all extant WebContentClients
This is mostly useful when some application-level logic needs to
iterate over all child processes. A more robust Process abstraction
would make this easier.
2024-06-26 16:09:33 -06:00
Aliaksandr Kalenik
c92f8ab1ea Everywhere: Use IOSurface as backing store on macOS
Using mmap-allocated memory for backing stores does not allow us to
benefit from using GPU-accelerated painting, because all the performance
increase we get is mostly negated by reading the GPU-allocated texture
back into RAM, so it can be shared with the browser process.

With IOSurface, we get a framebuffer that is both shareable between
processes and can be used as underlying memory for an OpenGL/Metal
texture.

This change does not yet benefit from using IOSurface and merely wraps
them into Gfx::Bitmap to be used by the CPU painter.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
c46bea479c 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.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
be2c484bb6 LibWebView+WebContent: Move backing store allocation into WebContent
In the upcoming changes, we are going to switch macOS to using an
IOSurface for the backing store. This change will simplify the process
of sharing an IOSurface between processes because we already have the
MachPortServer running in the browser, and WebContent knows how to
locate the corresponding server.
2024-06-24 13:09:08 +02:00
Tim Ledbetter
d33c4c751f LibWeb+WebContent: Provide feedback on find in page requests
This change allows the results of a find in page query to be reported
back to the user interface. Currently, the number of results found and
the current match index are reported.
2024-06-09 21:12:33 -04:00
Aliaksandr Kalenik
94eacf6da7 LibWeb: Remove did_request_scroll_to IPC call
No longer used after moving scrollbar painting into WebContent.
2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
cc3d95a356 LibWeb: Remove did_request_scroll IPC call
No longer used after moving scrollbar painting into WebContent.
2024-06-05 07:03:42 +02:00
Timothy Flynn
2851c05dee LibWebView: Display each tab's title in the Task Manager
This allows us to more easily differentiate between WebContent processes
in the Task Manager at a glance.
2024-04-22 14:46:10 -06:00
Andrew Kaster
5e1d678bae Ladybird+Userland: Remove use of unnecessary fd passing socket concept
Now that LibIPC is using SCM_RIGHTS properly, we can go back to only
having one socket laying around when needing to transfer fds to peers.
2024-04-19 16:38:55 -04:00
Andrew Kaster
6d4ba21832 LibIPC+Userland: Make IPC::File always own its file descriptor
Add factory functions to distinguish between when the owner of the File
wants to transfer ownership to the new IPC object (adopt) or to send a
copy of the same fd to the IPC peer (clone).

This behavior is more intuitive than the previous behavior. Previously,
an IPC::File would default to a shallow clone of the file descriptor,
only *actually* calling dup(2) for the fd when encoding or it into an
IPC MessageBuffer. Now the dup(2) for the fd is explicit in the clone_fd
factory function.
2024-04-19 06:34:07 -04:00
Timothy Flynn
9c608b46fd LibWeb+LibWebView+WebContent: Remove now-unused history change IPC 2024-04-14 18:53:58 -07:00
Timothy Flynn
8e2b1a8a1d LibWebView: Update the stored URL when WebContent's URL changes 2024-04-14 18:53:58 -07:00
Aliaksandr Kalenik
c96fc902ff LibWeb+LibWebView+WebContent: Add did_change_url() IPC call 2024-04-14 02:42:53 -07:00
Aliaksandr Kalenik
a8cf1aca7c LibWeb: Rename did_update_url() to did_history_api_push_or_replace()
The previous name was extremely misleading, because the call is used for
pushing or replacing new session history entry on chrome side instead of
only changing URL.
2024-04-14 02:42:53 -07:00
Aliaksandr Kalenik
461184d964 LibWeb+LibWebView+WebContent: Add did_update_navigation_buttons_state()
It is going to be used to communicate whether it is possible to navigate
back or forward after session history stored on browser side will no
longer be used to driver navigation.
2024-04-14 02:42:53 -07: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
Timothy Flynn
b1a30d8269 LibWebView+WebContent: Remove some SPAM_DEBUG log points
I don't know if anyone ever enables these anymore but I think we're well
past needing to persist logging these particular IPC endpoints.
2024-03-29 22:00:25 +01:00
Timothy Flynn
7a1847e6e3 LibWebView: Reduce IPC boilerplate within the chrome process
Add a small helper function to find the view / log when the view cannot
be found.
2024-03-29 22:00:25 +01:00
Timothy Flynn
8b1ad5c496 LibWeb+LibWebView+WebContent: Add a new IPC for modifying history state
Let's not re-invoke the "page did start loading" IPC when the history
state is pushed/replaced. It's a bit misleading (the change does not
actually load the new URL), but also the chromes may do more work than
we want when we change the URL.

Instead, add a new IPC for the history object to invoke.
2024-03-29 08:52:01 -04:00
Timothy Flynn
40c0dd81d2 LibWeb+LibWebView+WebContent: Inform chromes when audio is played/paused
Most browsers have some indicator when audio is playing in a tab, which
makes it easier to find that tab and mute unwanted audio. This adds an
IPC to allow the Ladybird chromes to do something similar.
2024-03-28 21:08:23 +01: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
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
Timothy Flynn
ea682207d0 LibWeb+LibWebView: Migrate Browser's input event handling to LibWebView
The Serenity chrome is the only chrome thus far that sends all input key
and mouse events to WebContent, including shortcut activations. This is
necessary for all chromes - we must give web pages a chance to intercept
input events before handling them ourselves.

To make this easier for other chromes, this patch moves Serenity's input
event handling to LibWebView. To do so, we add the Web::InputEvent type,
which models the event data we need within LibWeb. Chromes will then be
responsible for converting between this type and their native events.

This class lives in LibWeb (rather than LibWebView) because the plan is
to use it wholesale throughout the Page's event handler and across IPC.
Right now, we still send the individual fields of the event over IPC,
but it will be an easy refactor to send the event itself. We just can't
do this until all chromes have been ported to this event queueing.

Also note that we now only handle key input events back in the chrome.
WebContent handles all mouse events that it possibly can. If it was not
able to handle a mouse event, there's nothing for the chrome to do (i.e.
there is no clicking, scrolling, etc. the chrome is able to do if the
WebContent couldn't).
2024-03-06 07:46:18 +01:00
Timothy Flynn
108521a566 LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e.

This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
2024-02-26 14:18:49 +01: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
Timothy Flynn
f07f5a2622 LibWeb+WebContent: Do not embed attributes as data in the Inspector HTML
Attribute values may contain HTML, and may contain invalid HTML at that.
If the latter occurs, let's not generate invalid Inspector HTML when we
embed the attribute values as data attributes. Instead, cache the values
in the InspectorClient, and embed just a lookup index into the HTML.

This also nicely reduces the size of the generated HTML. The Inspector
on https://github.com/SerenityOS/serenity reduces from 2.3MB to 1.9MB
(about 318KB, or 13.8%).
2024-02-20 17:04:36 +01: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
Timothy Flynn
c4820838bf LibWeb+WebContent: Port the did_request_named_cookie IPC to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
9b957ead13 LibWebView+WebContent: Do not manually serialize cookie sources over IPC
LibIPC can serialize enumeration automatically (this was not the case
when these IPCs were added).
2024-01-26 20:22:39 +01:00
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01: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
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
93db790974 LibWebView+WebContent: Make the DOM node HTML retrieval IPC async 2024-01-01 10:11:45 +01:00
Timothy Flynn
3572a047d1 LibWebView+WebContent: Make the DOM node editing IPCs async
All DOM node mutation IPCs now invoke an async completion IPC after the
DOM is mutated. This allows consolidating where the Inspector updates
its view and the selected DOM node.

This also allows improving the response to removing a DOM node. We would
previously just select the <body> tag after removing a DOM node because
the Inspector client had no idea what node preceded the removed node.
Now the WebContent process can just indicate what that node is. So now
after removing a DOM node, we inspect either its previous sibling (if it
had one) or its parent.
2023-12-30 17:30:55 +01:00
Timothy Flynn
1eba170d03 LibWebView+WebContent: Make the hovered node retrieval IPC async 2023-12-30 17:30:55 +01:00
Timothy Flynn
760ba5932b LibWebView+WebContent: Make the DOM node inspection IPC async 2023-12-30 17:30:55 +01:00
Timothy Flynn
4c3bff264e LibWebView+WebContent: Rename DOM/a11y tree IPC response methods
Rename them from "did_get_*" to "did_inspect_*", to correspond to the
request methods "inspect_dom_tree" and "inspect_accessibility_tree". No
functional change, but this makes it a bit easier to stare at IPC files
side-by-side and know which response method corresponds to a request
method at a quick glance.
2023-12-30 17:30:55 +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
Aliaksandr Kalenik
9624eca116 LibWeb+LibWebView+WebContent: Remove unused request_scroll_into_view
`Element::scroll_into_view()` is supposed to be used instead.
2023-12-19 10:45:07 +01: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
Bastiaan van der Plaat
cbb660c756 LibWeb: Make request_select_dropdown more similar to context menu api 2023-12-13 10:30:13 +01:00
Shannon Booth
83758d4cdd LibWeb: Wrap PseudoElements stored in SimpleSelector in a class
No functional impact intended. This is just a more complicated way of
writing what we have now.

The goal of this commit is so that we are able to store the 'name' of a
pseudo element for use in serializing 'unknown -webkit-
pseudo-elements', see:

https://www.w3.org/TR/selectors-4/#compat

This is quite awkward, as in pretty much all cases just the selector
type enum is enough, but we will need to cache the name for serializing
these unknown selectors. I can't figure out any reason why we would need
this name anywhere else in the engine, so pretty much everywhere is
still just passing around this raw enum. But this change will allow us
to easily store the name inside of this new struct for when it is needed
for serialization, once those webkit unknown elements are supported by
our engine.
2023-12-11 16:54:59 +01:00
Bastiaan van der Plaat
466153e680 Ladybird+LibWeb: Add basic select element support 2023-12-09 22:06:20 +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
2cdad0f068 LibWeb+LibWebView+WebContent: Add an Inspector IPC to add DOM attributes 2023-12-06 13:04:50 +01:00