Commit Graph

2372 Commits

Author SHA1 Message Date
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
56658b5354 LibWeb+WebContent: Remove unused page_did_click_link()
Not used since we migrated to navigables.
2023-12-21 19:25:18 +01:00
Aliaksandr Kalenik
7458c27c4b WebContent: Pre-emptively update viewport offset on request to scroll 2023-12-19 20:59:52 +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
Aliaksandr Kalenik
161082e282 LibAccelGfx+LibWeb: Explicitly pass OpenGL context to Painter
Let's not assume there is one global OpenGL context because it might
change once we will start creating >1 page inside single WebContent
process or contexts for WebGL.
2023-12-16 19:39:36 +01:00
Bastiaan van der Plaat
b73ae80d8b LibWeb: Refactor WebContentServer mouse input message to DevicePixel 2023-12-16 11:08:51 +01:00
Andreas Kling
70193c0009 LibWeb: Let Document have a direct GCPtr to its containing Web::Page
With this change, Document now always has a Web::Page. This means we no
longer rely on the breakable link between Document and BrowsingContext
to find a relevant Web::Page.

Fixes #22290
2023-12-15 22:04:46 +01:00
Bastiaan van der Plaat
c069ab1ca0 LibWeb: Refactor int types in WebContentServer to DevicePixels 2023-12-15 17:01:16 +01:00
Ali Mohammad Pur
89877b3f40 RequestServer: Avoid race condition between cached request end/start
Prior to this commit, it was possible to get a socket stuck in a state
with enqueued entries, waiting for a nonexistent request to finish.
This state could be entered by issuing a request immediately after the
completion of another one, and before deferred_invoke execution in the
event loop.

This commit closes this hole by making sure the socket is never in a
state where it can queue requests without an active job.
2023-12-15 09:00:30 +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
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
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
Shannon Booth
6ce0d588ee Everywhere: Avoid calling from_utf8 on FlyString or String
We already have a String :^)
2023-12-10 09:45:03 +01:00
Timothy Flynn
e0450301ab WebContent: Always return a ShareableBitmap object from screenshot APIs
The empty value we are currently returning hits the `decltype(nullptr)`
constructor of TakeDocumentScreenshotResponse. This is interpreted as an
invalid response by LibIPC. Instead, return a Gfx::ShareableBitmap that
the client-side can handle, and e.g. display an error, rather than the
message just being dropped.
2023-12-10 09:44:34 +01:00
Bastiaan van der Plaat
466153e680 Ladybird+LibWeb: Add basic select element support 2023-12-09 22:06:20 +01:00
Bastiaan van der Plaat
b8219e2cc4 WindowServer: Send menu_item_activated before visibility_did_change 2023-12-09 22:06:20 +01:00
Timothy Flynn
c6a11a77b5 LibWebView+WebContent: Add a WebContent IPC to clone a DOM node 2023-12-07 23:16:34 +01:00
Timothy Flynn
111e53a2f6 LibWebView+WebContent: Add WebContent IPC to create children DOM nodes
This adds IPC to create append a child <div> element or a text node to
a DOM node.
2023-12-07 23:16:34 +01:00
Timothy Flynn
f7de1369d2 LibWebView+WebContent: Add a WebContent IPC to take DOM node screenshots 2023-12-07 10:53:12 +01:00
Timothy Flynn
a7b98a9761 LibWeb+WebContent+WebWorker: Add an option to skip painting the overlay
This will allow the Inspector to take a screenshot of a DOM node without
the overlay which renders the inspected node outline / box data.
2023-12-07 10:53:12 +01:00
Timothy Flynn
bea11f6d99 LibWebView+WebContent: Add a WebContent IPC to get a DOM node's HTML 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
9a5fe740c6 LibWebView: Make a best-effort attempt to not "shift" edited attributes
Currently, when editing a DOM attribute, the replacement method first
removes the attribute, then adds the replacement attributes. This
results in the edited attribute jumping to the end of the attribute
list in the Inspector.

This patch will try to avoid removing the attribute if one of the
replacements has the same name. This will keep the edited attribute in
the same location.
2023-12-06 13:04:50 +01:00
Timothy Flynn
777b4f7921 LibWebView+WebContent: Add a WebContent IPC to remove a DOM node
The FIXME added to ConnectionFromClient::remove_dom_node is copied from
Web::EditEventHandler. The same behavior is observed here, with many
lingering Layout::TextNodes, for example.
2023-12-06 13:04:50 +01:00
Timothy Flynn
86d90f324d LibWebView+WebContent: Add a WebContent IPC to add DOM attributes 2023-12-06 13:04:50 +01:00
Timothy Flynn
2cdad0f068 LibWeb+LibWebView+WebContent: Add an Inspector IPC to add DOM attributes 2023-12-06 13:04:50 +01:00
Timothy Flynn
2633ea8c79 LibWeb+LibWebView+WebContent: Add an Inspector IPC to open context menus
The Inspector will have context menu support to manipulate the DOM, e.g.
adding or removing nodes/attributes. This context menu will require some
detailed knowledge about what element in the Inspector has been clicked.
To support this, we intercept the `contextmenu` event and collect the
required information to be sent to the Inspector client over IPC.
2023-12-06 13:04:50 +01:00
Timothy Flynn
fff65046a3 WebWorker: Do not prefix WebWorker include with "Services/"
We don't do this elsewhere and this breaks the GN build.
2023-12-05 14:20:03 -05:00
Shannon Booth
0ae5c070c7 LibWeb: Make Web::Page GC-allocated
This is a first step towards removing the various Page& and Page*
we have littering the engine with "trust me bro" safety guarantees.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-12-05 09:38:32 +01:00
Shannon Booth
6e6f3a9a8f LibWeb: Make Web::PageClient GC-allocated
This is a first step towards simplifying the ownership model of
Web::Page. Soon Web::Page will store its WebClient as a
NonnullGCPtr to help solve lifetime issues of the client being
destroyed before the page.
2023-12-05 09:38:32 +01:00
Andrew Kaster
9f01e0f826 WebWorker: Log URL and reason for Worker script load failure 2023-12-04 19:59:10 -05:00
Timothy Flynn
1236cbd41a LibWeb+LibWebView+WebContent: Add Inspector IPCs to manipulate DOM nodes
This adds the IDL methods and IPC to forward DOM-editing events from the
Inspector WebView to the Inspector client.
2023-12-04 01:33:57 +01:00
Timothy Flynn
4cfeb41c4b LibWebView+WebContent: Add APIs to manipulate DOM nodes
This adds APIs to allow Ispector clients to:
* Change a DOM text or comment node's text data.
* Add, replace, or remove a DOM element's attribute.
* Change a DOM element's tag.
2023-12-04 01:33:57 +01:00
Shannon Booth
f976ec005c LibWeb: Port DOM::Document from DeprecatedString 2023-12-02 22:54:53 +01:00
Timothy Flynn
9f374a5d2a LibWeb+LibWebView+WebContent: Add an Inspector IPC to execute JavaScript
The Inspector will have an <input> element to execute user-provided JS.
This adds an IDL method and IPC to forward that JS from the Inspector
WebView to the Inspector client.
2023-12-02 10:34:22 +01:00
Timothy Flynn
8fc5c8b7df WebContent: Print a warning if GPU painting is enabled but not supported 2023-12-01 20:07:27 -05:00
Timothy Flynn
ea81470fc0 WebContent: Remove a bunch of unused includes from PageHost
Mostly just to narrow down where HAS_ACCELERATED_GRAPHICS is used, to
make it easier to see where it needs to be defined by the build system.
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
Shannon Booth
1b05598cd3 LibWeb: Port ParsedCookie from DeprecatedString to String 2023-11-28 17:15:27 -05: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
Andrew Kaster
1602663b9e LibWeb+WebWorker: Implement a first cut of post_message for Workers
This implementation completely ignores MessagePorts, and manually plumbs
data through LocalSockets.
2023-11-24 08:41:38 +01:00
Andrew Kaster
05ec93e276 WebWorker: Reuse main thread VM for DedicatedWorker realms
While creating a new VM feels warm and fuzzy from an isolation
perspective, having multiple JS heaps in the same process is a footgun
waiting to happen. Additionally, there are still many places in LibWeb
that reach for the main thread VM to check for the current realm to do
things, such as Web::HTML::incumbent_settings_object().
2023-11-24 08:41:38 +01:00
Andrew Kaster
e30ecacb71 WebWorker: Exit the event loop when the connection from the client dies
This mimics the behavior of other services, and prevents zombie service
processes from sticking around when no longer needed.
2023-11-24 08:41:38 +01:00
Aliaksandr Kalenik
5f7ac559a7 LibAccelGfx+LibWeb: Add support for stacking context opacity
For each stacking context with an opacity less than 1, we create a
separate framebuffer. We then blit the texture attached to this
framebuffer with the specified opacity.

To avoid the performance overhead of reading pixels from the texture
into Gfx::Bitmap, a new method that allows for direct blitting from
the texture is introduced, named blit_scaled_texture().
2023-11-24 08:39:55 +01:00
Aliaksandr Kalenik
d5630fedf1 LibAccelGfx+WebContent: Introduce Canvas that represents framebuffer 2023-11-24 08:39:55 +01:00
Timothy Flynn
ffdc2d8add LibWeb+LibWebView+WebContent: Add an Inspector IDL object to the Window
This is an internal object that must be explicitly enabled by the chrome
before it is added to the Window. The Inspector object will be used by a
special WebView that will replace all chrome-specific inspector windows.
The IDL defines methods that this WebView will need to inform the chrome
of various events, such as the user clicking a DOM node.
2023-11-24 08:37:19 +01:00
Timothy Flynn
30e96749de LibWebView+WebContent: Remove unused did_get_dom_node_properties IPC
This is never invoked. The functionality it provides is implemented by
the return value of the `inspect_dom_node` IPC.
2023-11-24 08:37:19 +01:00
Shannon Booth
6c42de3e8b LibWeb: Port XMLSerializer from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
e28fb5c64c LibWeb: Port Cookie from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
6aff55d655 LibWeb: Port NavigatorID from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Liav A
b9141d85d8 WindowServer: Introduce the window roll-up feature
The roll-up feature allows the user to set the window content to be
hidden, while retaining the window title bar visibility.
While in roll-up mode, the window height size is not changeable.
However, tiling the window or maximizing (as well as unmaximize) it will
instruct exiting the roll-up mode.
2023-11-17 17:31:51 +00: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
Tim Ledbetter
1793f51bc6 LibDNS: Make DNS packet parsing fallible
Previously, a DNS packet containing an invalid name would be returned
with an empty name. With this change, an error is returned if any error
is encountered during parsing.
2023-11-14 10:12:44 +01:00
Aliaksandr Kalenik
6d1a1daff9 LibAccelGfx+LibWeb: Use framebuffer object instead of EGLs PBuffer
Framebuffer object is allocated using OpenGL's API and is not platform
specific which means it could be used on both macOS and Linux unlike
EGL specific PBuffer.
2023-11-11 22:19:43 +01:00
Timothy Flynn
306850652f LibWebView+WebContent: Add an IPC hook to insert data into the clipboard 2023-11-11 08:54:37 +01:00
david072
7f501d4d8a Taskbar/QuickLaunchWidget: Ensure config backwards compatibility
The QuickLaunchWidget can now also parse the old config format, so that
we stay compatible with the old format. After loading, it deletes the
old config values and saves them in the new format.
2023-11-09 23:35:52 +01:00
david072
620b3bd492 Taskbar/QuickLaunchWidget: Show a tooltip with the entry's name on hover 2023-11-09 23:35:52 +01:00
david072
2d29a96dbe Taskbar/QuickLaunchWidget: Small cleanup 2023-11-09 23:35:52 +01:00
david072
e100c1458a Taskbar/QuickLaunchWidget: Reorder methods to make .cpp and .h match
This makes it a bit easier to find things in my opinion.
2023-11-09 23:35:52 +01:00
david072
13b98d01c0 Taskbar/QuickLaunchWidget: Properly save Quick Launch Entries
The entries in the QuickLaunchWidget are now saved properly. This means
that the format with which they are saved needed to be changed, since we
now also need to store the order of the entries. To do this, the entries
are now saved using the following value format: "<index>:<path>". When
loading, we simply parse this structure out and sort by the index,
before parsing the path into `QuickLaunchEntry`s.
2023-11-09 23:35:52 +01:00
david072
84340c4ca7 Taskbar/QuickLaunchWidget: Allow reordering the entries :^)
You can now drag the entries in the QuickLaunchWidget to reorder them!
2023-11-09 23:35:52 +01:00
david072
63cac2839d Taskbar/QuickLaunchWidget: Do rendering ourselves
The QuickLaunchWidget now renders the buttons on its own, in preparation
for allowing the user to reorder the widget's entries.
2023-11-09 23:35:52 +01:00
david072
70f7c10ab9 Taskbar+WindowServer: Adding to Quick Launch via windows :^)
You can now add applications to Quick Launch via the context
menu option of their windows. Clicking it creates an event with the
stored PID of the process that created the window. The Taskbar receives
the event and tells the QuickLaunchWidget to add the PID, which then
gets the executable using /sys/kernel/processes. It also looks for an
AppFile using the name from the process object and if there is one, it
uses that, since it should contain a better formatted name.
2023-11-09 23:35:52 +01:00
david072
4386182be1 LibGUI+WindowServer: Store the source process' PID in the Window classes
The "Window" classes in LibGUI and WindowServer now store the PID of the
process that created the window. LibGUI's Window obtains the PID in the
constructor via getpid(), and passes it in Window::show() to
WindowServer via the create_window() IPC route. WindowServer then saves
it in its own Window class.
This allows us to find the process that created a window in order to add
process-specific actions to the window.
2023-11-09 23:35:52 +01:00
Tim Schumacher
a2f60911fe AK: Rename GenericTraits to DefaultTraits
This feels like a more fitting name for something that provides the
default values for Traits.
2023-11-09 10:05:51 -05:00
Tim Ledbetter
4e3b59a4bb LibDNS: Prefer spans over raw pointers when parsing DNS packets
This means we don't have to keep track of the pointer and size
separately.
2023-11-08 09:38:36 +01:00
Sergey Bugaev
38a368c8f6 WebContent: Fix checking for accelerated graphics
What matters here is whether or not we can use LibAccelGfx and OpenGL,
not whether the kernel is Linux.
2023-11-08 09:29:59 +01:00
Shannon Booth
ea2b733862 LibWeb: Port custom properties to FlyString 2023-11-07 11:33:41 +01:00
Daniel Bertalan
6f972c190b Everywhere: Work around Clang trunk bug with templated lambda + Variant
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when
evaluating certain `requires` expressions inside templated lambdas.
There isn't an imminent fix on the horizon, so let's work around the
issue by specifying the type of the offending lambda arguments
explicitly.

See https://github.com/llvm/llvm-project/issues/67260
2023-11-05 13:41:13 -07:00
Rummskartoffel
dcbb8cf0ac NotificationServer: Make notifications not overlap when they appear
Before this patch, if two or more notifications were created after one
another, they would overlap. This was caused by the previously lowest
notification's m_original_rect being used to calculate the position for
each new notification instead of the notification's actual rect, which
can be different.
This patch makes notifications use each others' rect() method instead,
which makes them appear in the correct position. With that,
m_original_rect has no use anymore, so this patch removes it.
2023-11-05 09:06:33 +01:00
Rummskartoffel
a281fa3902 NotificationServer: Don't shuffle notifications on first hover
Before this patch, hovering with the mouse over one of at least two
newly created notifications would cause all notifications to be
reordered on the screen, when previously they appeared in order of
creation, growing downwards.
This happened because the position of all notifications is updated when
any of them is hovered, in case the hovered notification was resized.
By using an ordered HashMap instead, creation order is preserved.
2023-11-05 09:06:33 +01:00
Liav A
1b00618fd9 Kernel+Userland: Replace the beep syscall with the new /dev/beep device
There's no need to have separate syscall for this kind of functionality,
as we can just have a device node in /dev, called "beep", that allows
writing tone generation packets to emulate the same behavior.

In addition to that, we remove LibC sysbeep function, as this function
was never being used by any C program nor it was standardized in any
way.
Instead, we move the userspace implementation to LibCore.
2023-11-03 15:19:33 +01:00
Liav A
ac70abcb73 DeviceMapper: Add a mechanism to handle pluggable-once char devices 2023-11-03 15:19:33 +01:00
Andreas Kling
6b580d68a3 LibWeb: Rename DOM::Node::id() to unique_id()
The old name was pretty confusing, since it had nothing to do with the
common "id" content attribute.

This makes way for using id() to return the "id" attribute instead. :^)
2023-11-02 17:09:34 +01:00
Aliaksandr Kalenik
1e85bf221d LibAccelGfx+WebContent: Use the same Painter across page repaints
In the upcoming changes, Painter will be used to store the state of
OpenGL context. For example, if Painter is aware of the shader that
have already been loaded, it will be possible to reuse them across
repaints. Also, it would be possible to manage state of loaded textures
and add/remove them depending on which ones are present in the next
sequence of painting commands.
2023-11-02 07:41:51 +01:00
Andrew Kaster
40363f54d8 WebContent: Use the accelerated_graphics CMake helper
Instead of relying on AK_OS_LINUX, actually use the more accurate
HAS_ACCELERATED_GRAPHICS define to figure out if we should try to use
the generic LibAccelGfx GPU painter.
2023-11-01 14:30:30 -06:00
Aliaksandr Kalenik
b6732b0234 Ladybird+WebContent: Add option to use GPU painter
Adds `--enable-gpu-painting` param to enable painting command executor
that uses LibAccelGfx.
2023-10-29 17:13:23 +01:00
Lucas CHOLLET
fbc25ad302 Lagom: Don't include Serenity's ImageDecoder service
This service assumes paths from the serenity environment, bringing it to
Lagom in its current form is useless.
2023-10-27 07:26:32 +02:00
Andrew Kaster
0f0c9f910a WebDriver: Print out the entire error when failing to start a session 2023-10-27 07:11:35 +02:00
Aliaksandr Kalenik
f915aa70cd LibWeb/Painting: Introduce PaintingCommandExecutor
Decoupling painting command executor from RecordingPainter allows to
introduce painters other than CPU Gfx::Painter :)
2023-10-26 11:02:04 +02:00
Aliaksandr Kalenik
f32764975a LibWeb: Remove ClearRect command in RecordingPainter
There is only one usage of ClearRect command and it could be replaced
with FillRect to make set of commands in RecordingPainter smaller.
2023-10-21 18:50:28 +02:00
Aliaksandr Kalenik
063e66cae9 LibWeb: Introduce RecordingPainter to serialize painting commands
This modification introduces a new layer to the painting process. The
stacking context traversal no longer immediately calls the
Gfx::Painter methods. Instead, it writes serialized painting commands
into newly introduced RecordingPainter. Created list of commands is
executed later to produce resulting bitmap.

Producing painting command list will make it easier to add new
optimizations:
- It's simpler to check if the painting result is not visible in the
  viewport at the command level rather than during stacking context
  traversal.
- Run painting in a separate thread. The painting thread can process
  serialized painting commands, while the main thread can work on the
  next paintable tree and safely invalidate the previous one.
- As we consider GPU-accelerated painting support, it would be easier
  to back each painting command rather than constructing an alternative
  for the entire Gfx::Painter API.
2023-10-18 10:58:42 +02:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Andreas Kling
a396bb0c0b LibGfx: Remove indexed palette formats from Bitmap and Painter
Nobody was actually using these formats anymore, and this simplifies
and shrinks the code. :^)
2023-10-12 07:39:05 +02:00
Shannon Booth
e4f8c59210 LibWeb: Port AttributeNames to FlyString 2023-10-08 08:11:48 -04:00
Karol Kosek
03a54a519a Userland: Port remaining calls to Widget::set_tooltip_deprecated()
Replaces `set_tooltip_deprecated(string);` with
`set_tooltip(MUST(String::from_deprecated_string(string)));`
purely to get rid of the deprecated function in the following commit.
2023-10-06 08:20:11 +02:00
Karol Kosek
ed3e729d4e Userland: Use nondeprecated set_tooltip for static and formatted strings 2023-10-06 08:20:11 +02:00
Junior Rantila
a5b01689f1 LibWeb+LibWebView+WebContent: Add support for meta theme-color 2023-10-03 16:17:43 -06:00
Shannon Booth
ff72436448 LibWeb: Add a FlyString version of Element::tag_name
Renaming the DeprecatedString version of this function to
deprecated_tag_name. A FlyString is used here as we often need to
perform equality checks here, and the HTMLParser already has tag_name as
a FlyString.

Remove a FIXME while we're at it - we were already following the spec
there, and we still are :^)
2023-10-03 14:47:53 +01:00
Shannon Booth
50350fb79c LibWeb: Add a non-DeprecatedString version of Element::get_attribute
Renaming the DeprecatedString version of this function to
Element::get_deprecated_attribute.

While performing this rename, port over functions where it is trivial to
do so to the Optional<String> version of this function.
2023-10-03 09:41:20 +02:00
Tim Ledbetter
eaa6304aab Userland: Return empty if ImageDecoder client receives an invalid frame
This simplifies error checking for all the users of the ImageDecoder
client.
2023-10-03 08:33:53 +02:00
Karol Kosek
9ce2682ce6 Userland: Port lists of mime types to String 2023-09-29 14:40:21 +01:00
Karol Kosek
e75d694974 Userland: Compare event MIME type list with a StringView
The following commit will port MIME types to String. Traits<String>
- used in Vector::contains_slow - can't compare String type with char*,
so we need to use StringView instead.
2023-09-29 14:40:21 +01:00
Karol Kosek
2f35348104 Userland: Store MIME keys as String in Core::MimeData 2023-09-29 14:40:21 +01:00
circl
2995a2e212 LibWeb+LibWebView+WebContent: Add support for <input type="color">
This commit introduces 3 things:
- Support for the color type in HTMLInputElement itself
- A mechanism for handling non event loop blocking dialogs in Page
- The associated plumbing up to ViewImplementation

Frontends may add support for the color picker with the
ViewImplementation.on_request_color_picker function
2023-09-27 12:16:41 +01:00
Shannon Booth
47514e07b4 LibWeb: Make Element attribute getters take a StringView
These functions are deferring to NamedNodeMap::get_attribute which
already takes a StringView. This changes also leads to finding some
places which were passing though a const char* instead of an entry from
Attribute names. Fix that where applicable, and switch to has_attribute
in some of those places instead of deprecated_attribute where
equivalent.

Ideally this should be taking a 'FlyString const&', but to continue
porting away from DeprecatedString, just leave a FIXME for now.
2023-09-25 15:39:29 +02:00
Tim Ledbetter
b4e134cb52 Userland: Use non-fallible EventReceiver::add() where possible 2023-09-25 10:58:31 +02:00
Tim Ledbetter
50d0d6e710 WindowServer: Add an IPC call to get the window floating rect 2023-09-24 20:07:54 -06:00
Tim Ledbetter
3aa49f268c Userland: Make Window::set_main_widget() non-fallible 2023-09-21 10:20:23 +02:00
Liav A
c9297126db SystemServer: Use correct unix device numbers for null, full and random
This fixes regression made in 446200d6f3
2023-09-20 13:27:09 -06:00
Andreas Kling
38cb15ff49 LibWeb: Move system visibility state to TraversableNavigable
This no longer belongs in BrowsingContext.
2023-09-20 18:29:17 +02:00
Tim Ledbetter
a6f6a1afd2 Userland: Prefer non-fallible construction for LibGUI objects 2023-09-18 18:00:45 +02:00
Tim Ledbetter
c9e4a82c04 WebServer: Return 403 for a GET request to an inaccessible path
Previously, trying to access a non-readable file would cause a
connection reset in the browser; trying to access a non-executable
directory would show a completely empty directory listing.
2023-09-17 17:10:04 -06:00
Tim Ledbetter
b2f0c50376 WebServer: Don't display file on directory listing if stat call fails
Previously, the program would crash when attempting to display a symlink
which pointed outside of the permitted directory.
2023-09-17 17:10:04 -06:00
Tim Ledbetter
1dd0791c7e WebServer: Use human-readable sizes on directory listing
A size is no longer displayed for directories; previously, a size of
4096 was always shown.
2023-09-17 17:10:04 -06:00
Aliaksandr Kalenik
3c675e3f25 Userland+Ladybird: Always specify url to be about:srcdoc in load_html()
After moving to navigables, we started reusing the code that populates
session history entries with the srcdoc attribute value from iframes
in `Page::load_html()` for loading HTML.

This change addresses a crash in `determine_the_origin` which occurred
because this method expected the URL to be `about:srcdoc` if we also
provided HTML content (previously, it was the URL passed along with the
HTML content into `load_html()`).
2023-09-17 21:08:59 +02:00
Shannon Booth
8ce9e51c97 LibWeb: Port Node interface from DeprecatedString to String
Which is fortunately quite straight forward :^)
2023-09-17 20:29:18 +02:00
Aliaksandr Kalenik
a76ef04ae6 LibWeb+WebContent: Create WebContentConsoleClient for every document
Fixes regression introduced in b4fe118dff

The `WebContentConsoleClient` needs to be created not just once, but
for every new document. Although the JS Console window allows
communication only with the active document associated with the
top-level browsing context, we still need a console client for each
iframe's document to ensure their console logs are printed.

In the future, we might consider adding the ability to switch which
document the JS Console window communicates with.

Fixes https://github.com/SerenityOS/serenity/issues/21117
2023-09-17 19:58:28 +02:00
Aliaksandr Kalenik
d17b1d6b1f LibWeb: Update WebDriverConnection::close_window() to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
df5db1631b LibWeb: Update WebDriverConnection::close_session() to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
d559fb8b7e WebContent: Update wait_for_navigation_to_complete to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
dd7bba66ed LibWeb: Change viewport ownership from BrowsingContext to Navigable 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
aef4b84e22 LibWeb+WebContent: Add option to dump session history of a traversable 2023-09-16 16:53:32 +02:00
Tim Ledbetter
81f5b3e66d FileOperation: Don't preserve ownership when copying files 2023-09-16 11:14:40 +02:00
Tim Ledbetter
f15a896324 FileOperation: Set umask to 0 when creating new files or directories
This ensures that file permissions are correctly preserved.
2023-09-16 11:14:40 +02:00
Bastiaan van der Plaat
836a7b00dd Ladybird+LibWeb: Add MouseEvent screenX and screenY support 2023-09-15 22:12:56 +02:00
Liav A
50429d3b22 LibC+Kernel: Move GPU-related API methods to a LibC header file
The Kernel/API directory in general shouldn't include userspace code,
but structure definitions that both are shared between the Kernel and
userspace.

All users of the ioctl API obviously use LibC so LibC is the most common
and shared library for the affected programs.
2023-09-15 11:05:25 -06:00
Aliaksandr Kalenik
6f8be44c0e LibWeb+WebContent+headless-browser: Support async text tests
Previously, we used `on_load_finish` to determine when the text test
was completed. This method did not allow testing of async functions
because there was no way to indicate that the runner should wait for
the async call to end.

This change introduces a function in the `internals` object that is
intended to be called when the text test execution is completed. The
text test runner will now ignore `on_load_finish` which means a test
will timeout if this new function is never called.

`test(f)` function in `include.js` has been modified to automatically
terminate a test once `load` event is fired on `window`.
new `asyncTest(f)` function has been introduces. `f` receives function
that will terminate a test as a first argument.

Every test is expected to call either `test()` or `asyncTest()` to
complete. If not, it will remain hanging until a timeout occurs.
2023-09-15 08:52:25 +02:00
Tim Ledbetter
c74f7e5f2a Userland: Don't use String::from_utf8() for literal strings 2023-09-15 08:44:52 +02:00
Sam Atkins
f3add3dd72 WebContent: Add "load-reference-page" debug request
This attempts to load the URL of the first `<link rel="match" href=""/>`
it finds. If that tag is missing, we load an error page to make sure
the ref-test fails. (And to provide some feedback if someone looks at
the screenshot somehow.) Wrong URLs will instead end up loading the
default 404 error page.
2023-09-13 08:48:19 +02:00
Sam Atkins
cb8c4cd2e6 WebContent: Return once debug_request is handled
The request can only be one string, so once we've matched it, stop
checking all the other possible values. :^)
2023-09-13 08:48:19 +02:00
Timothy Flynn
573cbb5ca0 LibJS+LibWeb+WebContent: Stop using ThrowableStringBuilder 2023-09-09 13:03:25 -04:00
Liav A
446200d6f3 Kernel+Services: Enable barebones hot-plug handling capabilities
Userspace initially didn't have any sort of mechanism to handle
device hotplug (either removing or inserting a device).
This meant that after a short term of scanning all known devices, by
fetching device events (DeviceEvent packets) from /dev/devctl, we
basically never try to read it again after SystemServer initialization
code.

To accommodate hotplug needs, we change SystemServer by ensuring it will
generate a known set of device nodes at their location during the its
main initialization code. This includes devices like /dev/mem, /dev/zero
and /dev/full, etc.

The actual responsible userspace program to handle hotplug events is a
new userspace program called DeviceMapper, with following key points:
- Its current task is to to constantly read the /dev/devctl device node.
  Because we already created generic devices, we only handle devices
  that are dynamically-generated in nature, like storage devices, audio
  channels, etc.

- Since dynamically-generated device nodes could have an infinite minor
  numbers, but major numbers are decoded to a device type, we create an
  internal registry based on two structures - DeviceNodeFamily, and
  RegisteredDeviceNode. DeviceNodeFamily objects are attached in the
  main logic code, when handling a DeviceEvent device insertion packet.
  A DeviceNodeFamily object has an internal HashTable to hold objects of
  RegisteredDeviceNode class.

- Because some device nodes could still share the same major number (TTY
  and serial TTY devices), we have two modes of allocation - limited
  allocation (so a range is defined for a major number), or infinite
  range. Therefore, two (or more) separate DeviceNodeFamily objects can
  can exist albeit sharing the same major number, but they are required
  to allocate from a different minor numbers' range to ensure there are
  no collisions.

- As for KCOV, we handle this device differently. In case the user
  compiled the kernel with such support - this happens to be a singular
  device node that we usually don't need, so it's dynamically-generated
  too, and because it has only one instance, we don't register it in our
  internal registry to not make it complicated needlessly.

The Kernel code is modified to allow proper blocking in case of no
events in the DeviceControlDevice class, because otherwise we will need
to poll periodically the device to check if a new event is available,
which would waste CPU time for no good reason.
2023-09-07 11:50:50 -06:00
Liav A
9dbd22b555 SystemServer: Make decision on whether to enable a service more readable
This change ensures that code in the Service class doesn't try to check
the g_system_mode variable, but instead is asked on whether it supports
a given system mode string value.

Also, don't assume that we should create sockets for any new Service
instance, but instead do that only if the Service should run in the
current system mode.
2023-09-07 11:50:50 -06:00
Liav A
0c14a2aba7 SystemServer: Organize initialization sequence into logical units
Just a small cleanup to ensure we can get these pieces of code out to
other files and still have the main.cpp file organized.

The populate_devtmpfs_char_devices_based_on_sysfs() method is removed
because we can simply create the /dev/devctl device node without looking
at the SysFS. This assumed-to-exist device node will be used later on in
an event loop to handle hotplug events.
2023-09-07 11:50:50 -06:00
Aliaksandr Kalenik
b4fe118dff LibWeb+WebContent: Set ConsoleClient for nested browsing contexts
Before page_did_create_main_document() only initialized ConsoleClient
for top-level browsing context which means that nested browsing context
could not print into the console.

With this change, ConsoleClient is initialized for documents created
for nested browsing context too. One ConsoleClient is shared between
all browsing contexts within the same page.
2023-09-07 09:06:00 -06:00
Sergey Bugaev
fcced97509 LookupServer: Fix building on GNU Hurd
The Hurd has sin_len, just like the BSDs.

This happened to hit a clang-format bug, and we have been advised
to disable clang-format for this block of code for now.
2023-09-06 11:41:16 -06:00
Andreas Kling
545d8336b8 LibGfx: Convert Font APIs to return String instead of DeprecatedString 2023-09-06 11:29:03 -04:00
kleines Filmröllchen
a7c770268f Userland: Migrate to String in notification system 2023-09-01 12:06:08 +02:00
Zaggy1024
9d65965060 WebContent: Replace the Serenity audio plugin with the agnostic one
The behavior of the Serenity `PlaybackStream` implementation should
match the `AudioCodecPluginSerenity` class removed by this commit. Any
inconsistencies should be fixable without needing feature additions to
the underlying implementation.
2023-08-29 11:31:10 +02:00
Shannon Booth
901220c588 LibWeb: Port Storage interface from DeprecatedString to String
Which ends up bubbling all the way up to the Browser storage model.
2023-08-29 10:05:02 +02:00
Liav A
aee5f4e4b2 Kernel: Remove the /sys/kernel/constants directory
The name for this directory is a bit awkward. Also, the distinction of
constant information is not really valuable as I thought it would be, so
let's bring that information back into the /sys/kernel directory.
2023-08-27 22:50:22 +02:00
Liav A
751aae77bc Kernel: Rename /sys/kernel/variables => /sys/kernel/conf
The name "variables" is a bit awkward and what the directory entries are
really about is kernel configuration so let's make it clear with the new
name.
2023-08-27 22:50:22 +02:00
Sam Atkins
84a5c67d6b LibWeb: Use system colors in more places 2023-08-25 20:30:20 +01:00
Sam Atkins
ec340f03a5 WebContent+LibWebView: Add support for user style sheets 2023-08-23 05:32:10 +02:00
Sam Atkins
7fe97ee6c5 LibWeb: Make StyleValue::to_string() infallible 2023-08-22 17:51:48 +01:00
stelar7
23b378822b LibWeb: Stub out Release Actions
This allows WPT to open the browser, and it no longer instantly crashes
2023-08-21 13:22:04 -06:00
Andreas Kling
25375bf1d5 LibWeb: Make Document::paintable() return a ViewportPaintable 2023-08-20 05:02:59 +02:00
Andreas Kling
8bb275f2ea LibWeb: Move painting logic from Layout::Viewport to ViewportPaintable 2023-08-20 05:02:59 +02:00
Timothy Flynn
6d331389ad WebDriver: Coerce window handles to strings when activating a tab
This allows the session to reject the request with "no such window",
instead of crashing by assuming the JSON value was already a string.
2023-08-19 05:15:51 +02:00
camc
d978dd4af8 LibGUI: Add deprecated suffix to {set_,}tooltip in Widget 2023-08-18 10:43:37 +01:00
Timothy Flynn
c0758882c5 WebContent: Convert image/media context menu positions to device pixels
On Serenity and on my Linux machine, we have a 1:1 CSS-to-device pixel
ratio. On macOS, we have a 2:1 ratio. This did not affect the Qt chrome,
because we are ignoring this position and placing the context menu at
the globally-accessible mouse position. The AppKit chrome will be using
this position, though.

This might be what caused the issue worked around by commit 8177ecb.
2023-08-18 05:24:59 +02:00
Timothy Flynn
5287c9aff4 WebContent: Group context menu request definitions together
Having all 4 of these methods together makes it more immediately obvious
that the 2 moved here are not correct (we are not converting the CSS
pixel point to a device pixel point).
2023-08-18 05:24:59 +02:00
Aliaksandr Kalenik
24edb7c97f Ladybird, WebContent: Add option in debug menu to output GC graph dump 2023-08-17 18:27:02 +02:00
Andreas Kling
eec328e2ab LibGUI: Remove Menu::try_add_submenu()
And fall back to the infallible add_submenu().
2023-08-14 14:57:54 +02:00
Andreas Kling
58e482a06d LibGUI: Remove Layout::try_add_spacer()
And fall back to the infallible add_spacer().

Work towards #20557.
2023-08-14 14:57:54 +02:00
Andreas Kling
8322b31b97 LibGUI: Remove Widget::try_set_layout<T>()
And fall back to the infallible set_layout<T>().

Work towards #20557.
2023-08-14 14:57:54 +02:00
Shannon Booth
9d60f23abc AK: Port URL::m_fragment from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Shannon Booth
c25485700a AK: Port URL scheme from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Shannon Booth
21fe86d235 AK: Port URL::m_query from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Andreas Kling
72c9f56c66 LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
2023-08-13 15:38:42 +02:00
kleines Filmröllchen
d905498fb6 AudioServer: Clean up ClientAudioStream APIs
- Use Optional references instead of pointers
- Clean up some const and nullability weirdness
- Use proper error return value for get_next_sample
2023-08-12 12:22:16 -06:00
kleines Filmröllchen
aacb4fc590 AudioServer: Move ClientAudioStream to own files
This class will only grow, and it should really have its own files.
2023-08-12 12:22:16 -06:00
kleines Filmröllchen
1e67435ff5 Meta: Rename compile_gml to stringify_gml
This is what this function really does, it doesn't compile anything.
2023-08-11 21:33:48 +02:00
Timothy Flynn
3e2449d1fe Browser+WebDriver: Set the initial URL to about:blank from WebDriver
We already do this for headless-browser. There's no need to open any URL
other than about:blank when starting a WebDriver session. We should also
do this from WebDriver code, rather than in special logic in Browser's
main.cpp.
2023-08-09 05:33:24 +02:00
Andreas Kling
2eaa528a0e LibJS: Rip out the AST interpreter :^)
This has been superseded by the bytecode VM, which is both faster
and more capable.
2023-08-08 13:07:13 +02:00
Andreas Kling
99ac34eeae Ladybird+LibWebView+Browser: Remove ability to run with AST interpreter 2023-08-08 13:07:13 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Timothy Flynn
db3e1b128c SQLServer: Remove Core::EventReceiver parent from DatabaseConnection
This relationship was entirely unused.
2023-08-07 14:38:38 -04:00
Timothy Flynn
08d77ca6b1 SQLServer: Remove Core::EventReceiver parent from SQLStatement
This relationship was only used to provide factory methods and a parent-
child relationship between SQLStatement and DatabaseConnection.
2023-08-07 14:38:38 -04:00
Timothy Flynn
1151ba333a LibSQL+SQLServer: Remove Core::EventReceiver parent from SQL::Database
This relationship was only used to provide factory methods for the
database.
2023-08-07 14:38:38 -04:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Andreas Kling
26647f2b10 LibCore: Remove the Core::Objects::all_objects() list
Nobody actually used the list of all Core::Objects anyway.
2023-08-06 18:09:25 +02:00
Aliaksandr Kalenik
b549f2d1d9 WebContent: Coalesce multiple sequential MouseWheel events
Same as a58d84407f but for MouseWheel :)
2023-08-05 04:47:46 +02:00
Torstennator
d8320d0a14 WindowServer: Fix menu height when invisible items are involved
This patch checks for visible items to determine the menu height. Now
the last visible item is used to determine the height of the menu.
Before this patch that menu height could be wrong e.g. if the last item
was not visible.
2023-08-04 12:11:13 +02:00
Andreas Kling
09eed8eea2 LibWeb+headless-browser: Include paint tree in layout test output
This will give us a more comprehensive look at what actually gets
rendered in the end, and also allows us to catch more behavior changes.
2023-08-03 13:21:26 +02:00
Andrew Kaster
7d7c419ce6 Ladybird: Add WebSocket server for use by Lagom networking
Hide its use behind the same flag as RequestServer in WebContent.
2023-08-03 09:55:20 +02:00
Andrew Kaster
b5bfe732d7 Ladybird: Add RequestServer process to optionally replace Qt Networking
LibTLS still can't access many parts of the web, so let's hide this
behind a flag (with all the plumbing that entails).

Hopefully this can encourage folks to improve LibTLS's algorithm support
:^).
2023-08-02 05:44:43 +02:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Tim Ledbetter
b284e525f3 FileOperation: Replace LibC rename() call with LibCore equivalent 2023-07-26 08:44:49 +02:00
Tim Ledbetter
21fdefd297 FileOperation: Preserve mode bits and owner when copying files
Previously, all files and folders copied with FileManager would be
created with the default mode bits set and would have the same uid
and gid as the currently logged in user.
2023-07-26 08:44:49 +02:00
Andreas Kling
a3e97ea153 Browser+LibWebView: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Shannon Booth
2b46e6f664 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2023-07-15 16:21:29 +02:00
Andreas Kling
bf25568703 LibWeb: Bring measuring of scrollable overflow closer to spec
Importantly, we now only consider overflow from descendants with
explicltly visible overflow, and only from descendants that have the
measured box as their containing block.

Also, we now measure scrollable overflow for all boxes, not just scroll
containers. This will allow us to fix a long-standing paint problem in
the next commit.
2023-07-13 05:09:08 +02:00
implicitfield
e504b63406 LibGUI: Make the calendar widget scrollable 2023-07-13 04:31:40 +03:30
implicitfield
28b5438395 ClockWidget: Deduplicate logic for updating calendar buttons 2023-07-13 04:31:40 +03:30
implicitfield
9a1018389c LibGUI+Calendar: Move date control logic to the calendar widget 2023-07-13 04:31:40 +03:30
Sebastian Zaha
88872ca42d LibIPC: Do not leak the Core::File fd by default
This prevents fd leaks when the user of the API forgets to pass
CloseAfterSending to IPC::File. Since we are calling leak_fd in the
constructor, we want it to also take care of closing.
2023-07-12 18:22:18 -04:00
Ali Mohammad Pur
0c5c75e8a4 LibCore: Slightly rework the Core::Promise API
The previous iteration of this API was somewhat odd and rough in random
places, which degraded usability and made less than perfect sense.
This commit reworks the API to be a little closer to more
conventional promise APIs (a la javascript promises).

Also adds a test to ensure the class even works.
2023-07-08 23:13:00 +01:00
MacDue
91e1a77854 SpiceAgent: Pledge cpath
Without this the spice agent can't create files on drag/drop.
2023-07-08 22:55:06 +01:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Jonah
afb07281ad Browser+LibWebView: Load and Display ARIA Properites and State
The inspector widget now has a new ARIA tab which displays an
individual element's ARIA properties and state. The view itself
is pretty basic for now, just being a table- there is definitely room
for some better UX here but it's enough for a first cut.
2023-07-06 11:21:36 +01:00
Jelle Raaijmakers
5c64686666 Kernel+AudioServer: Use interrupts for Intel HDA audio buffer completion
We used to not care about stopping an audio output stream for Intel HDA
since AudioServer would continuously send new buffers to play. Since
707f5ac150ef858760eb9faa52b9ba80c50c4262 however, that has changed.

Intel HDA now uses interrupts to detect when each buffer was completed
by the device, and uses a simple heuristic to detect whether a buffer
underrun has occurred so it can stop the output stream.

This was tested on Qemu's Intel HDA (Linux x86_64) and a bare metal MSI
Starship/Matisse HD Audio Controller.
2023-07-04 00:05:34 +02:00
Lucas CHOLLET
ff47223301 LibCore: Make NetworkJob::start() take a Stream::BufferedSocketBase&
It used to take a plain `Socket` and cast it to a `BufferedSocketBase`,
which can lead to unpleasant result when used with a non-buffered
`Socket`.
2023-07-03 23:29:28 +02:00
Timothy Flynn
27ca90646d WebContent: Clear Serenity's audio buffers when seeking
Without this, the already-buffered audio may continue playing after a
seek. The SoundPlayer application does the same operation here.
2023-07-03 19:07:26 +02:00
kleines Filmröllchen
b4fbd30b70 AudioServer+Userland: Decouple client sample rates from device rate
This change was a long time in the making ever since we obtained sample
rate awareness in the system. Now, each client has its own sample rate,
accessible via new IPC APIs, and the device sample rate is only
accessible via the management interface. AudioServer takes care of
resampling client streams into the device sample rate. Therefore, the
main improvement introduced with this commit is full responsiveness to
sample rate changes; all open audio programs will continue to play at
correct speed with the audio resampled to the new device rate.

The immediate benefits are manifold:
- Gets rid of the legacy hardware sample rate IPC message in the
  non-managing client
- Removes duplicate resampling and sample index rescaling code
  everywhere
- Avoids potential sample index scaling bugs in SoundPlayer (which have
  happened many times before) and fixes a sample index scaling bug in
  aplay
- Removes several FIXMEs
- Reduces amount of sample copying in all applications (especially
  Piano, where this is critical), improving performance
- Reduces number of resampling users, making future API changes (which
  will need to happen for correct resampling to be implemented) easier

I also threw in a simple race condition fix for Piano's audio player
loop.
2023-07-01 23:27:24 +01:00
kleines Filmröllchen
33829f05fe Userland: Convert config listener callbacks to use StringView
The immutability of the string is not relevant here, since the string
we're given was allocated in the IPC serialization layer and will be
destroyed shortly afterwards. Additionally, noone relies on
DeprecatedString-specific functionality. This will make it easier to
convert the IPC layer itself to String later on.
2023-06-27 15:37:00 +01:00
kleines Filmröllchen
e0dce41ddf AudioServer: Add a hack to make audio "just work" on HDA for now
This should be fixed properly, but we have decided that a quick hack is
fine so that audio "just works" for most people.
2023-06-25 00:16:44 +02:00
kleines Filmröllchen
03fac609ee AudioServer+Userland: Separate audio IPC into normal client and manager
This is a sensible separation of concerns that mirrors the WindowServer
IPC split. On the one hand, there is the "normal" audio interface, used
for clients that play audio, which is the primary service of
AudioServer. On the other hand, there is the management interface,
which, like the WindowManager endpoint, provides higher-level control
over clients and the server itself.

The reasoning for this split are manifold, as mentioned we are mirroring
the WindowServer split. Another indication to the sensibility of the
split is that no single audio client used the APIs of both interfaces.
Also, useless audio queues are no longer created for managing clients
(since those don't even exist, just like there's no window backing
bitmap for window managing clients), eliminating any bugs that may occur
there as they have in the past.

Implementation-wise, we just move all the APIs and implementations from
the old AudioServer into the AudioManagerServer (and respective clients,
of course). There is one point of duplication, namely the hardware
sample rate. This will be fixed in combination with per-client sample
rate, eliminating client-side resampling and the related update bugs.
For now, we keep one legacy API to simplify the transition.

The new AudioManagerServer also gains a hardware sample rate change
callback to have exact symmetry on the main server parameters (getter,
setter, and callback).
2023-06-25 00:16:44 +02:00
Valtteri Koskivuori
c3f5b514c8 WindowServer: Yank out window frame opacity
This facility was added in 15a1d9a, but isn't being used for anything.
It wasn't even hooked up to LibGUI for applications to use.
Relevant use-cases, such as the most prominent one in `AnalogClock`, use
`GUI::Window::set_frameless()` instead.
2023-06-24 23:45:27 +02:00
Valtteri Koskivuori
6931a5a0a8 WindowServer+LibGUI: Yank out window-global opacity
From what I can tell, this facility was added to WSWindow/GWindow in
2019 in 9b71307. I only found a single place in the codebase still using
this facility: `WindowServer::Menu::start_activation_animation()`. A
subtle fade-out animation that happens when a menu item is selected, and
the menu disappears.
I think our compositing facilities have improved enough to make this
facility redundant. The remaining use mentioned above was ported to just
directly blit the fade-out animation instead of requesting it from
WindowServer.
2023-06-24 23:45:27 +02:00
Timothy Flynn
bcd222cfae Ladybird+LibWeb+WebContent: Prevent out-of-bounds seeking audio elements
It's currently possible to seek to the total sample count of an audio
loader. We must limit seeking to one less than that count.

This mistake was duplicated in both AudioCodecPluginSerenity/Ladybird,
so the computation was moved to a helper in the base AudioCodecPlugin.
2023-06-22 06:58:07 +02:00
Tim Ledbetter
f02ccffaa8 WebServer: Show the correct port when using port 0
Specifying port 0 on the command line causes WebServer to select a
random available port. We now show the port WebServer is actually
using rather than assuming it is the same as the command line argument.
2023-06-21 08:35:44 +02:00
Timothy Flynn
1c4dd0caad Ladybird+LibWeb+WebConent: Drive audio in Ladybird off the main thread
The main thread in the WebContent process is often busy with layout and
running JavaScript. This can cause audio to sound jittery and crack. To
avoid this behavior, we now drive audio on a secondary thread.

Note: Browser on Serenity uses AudioServer, the connection for which is
already handled on a secondary thread within LibAudio. So this only
applies to Lagom.

Rather than using LibThreading, our hands are tied to QThread for now.
Internally, the Qt media objects use a QTimer, which is forbidden from
running on a thread that is not a QThread (the debug console is spammed
with messages pointing this out). Ideally, in the future AudioServer
will be able to run for non-Serenity platforms, and most of this can be
aligned with the Serenity implementation.
2023-06-21 06:14:15 +02:00
Tim Ledbetter
1a17e08f87 Everywhere: Correctly report progress of downloads larger than 4GiB
This commit changes the variables used to represent the size and
progress of downloads from u32 to u64. This allows `pro` and
`Browser` to report the total size and progress of a download
correctly for downloads larger than 4GiB.
2023-06-19 06:13:19 +02:00
Timothy Flynn
9e95c9892c Ladybird+LibWeb+WebContent: Add context menu controls for muting audio 2023-06-16 19:34:42 +02:00
Timothy Flynn
14ca04de25 Ladybird+LibWeb+WebContent: Generalize video context menus for all media
The data we want to send out of the WebContent process is identical for
audio and video elements. Rather than just duplicating all of this for
audio, generalize the names used for this IPC for all media elements.

This also encapsulates that data into a struct. This makes adding new
fields to be sent much easier (such as an upcoming field for muting the
element).
2023-06-16 19:34:42 +02:00
Timothy Flynn
d3b8d88598 LibWeb: Expose volume controls through the platform audio plugin 2023-06-16 13:50:15 +02:00
Ben Wiederhake
d3a6512643 WindowServer: Properly handle OOM on drag-and-drop metadata copy 2023-06-15 08:07:17 +02:00
Valtteri Koskivuori
e56098f734 LibCore+Userland: Remove uses of DeprecatedString in file utility
Mainly replacing DeprecatedString with StringView, since the actual mime
type and description texts are just static strings anyway.
2023-06-14 11:18:22 -04:00
Jelle Raaijmakers
70ca295404 LibSQL+SQLServer: Do not re-open databases
Both `Database` and `Heap` were allowed to be opened twice. Prevent
this, and change SQLServer to only open databases that are not already
opened.

This fixes a Ladybird crash where opening the application twice would
erroneously duplicate free heap block indices.
2023-06-13 16:33:42 -04:00
Lucas CHOLLET
521ad55a61 SystemServer: Handle waitpid's status correctly
We used to call `did_exit()` directly with the status returned from
`waitpid` but the function expected an exit code. We now use several
of `wait`-related macros to deduce the correct information.
2023-06-13 06:15:10 +02:00
Timothy Flynn
a34e369252 Ladybird+LibWeb+WebContent: Create a platform plugin for playing audio
This creates (and installs upon WebContent startup) a platform plugin to
play audio data.

On Serenity, we use AudioServer to play audio over IPC. Unfortunately,
AudioServer is currently coupled with Serenity's audio devices, and thus
cannot be used in Ladybird on Lagom. Instead, we use a Qt audio device
to play the audio, which requires the Qt multimedia package.

While we use Qt to play the audio, note that we can still use LibAudio
to decode the audio data and retrieve samples - we simply send Qt the
raw PCM signals.
2023-06-13 06:14:01 +02:00
Timothy Flynn
936ec94f81 AK+LibAudio+AudioServer: Silence very noisy debug statements by default
These are spammed quite heavily on the debug console, especially at the
end of audio playback.
2023-06-13 06:14:01 +02:00
Aliaksandr Kalenik
147c3b3d97 LibWeb+WebContent: Forbid access to underlying type of CSSPixels
Although DistinctNumeric, which is supposed to abstract the underlying
type, was used to represent CSSPixels, we have a whole bunch of places
in the layout code that assume CSSPixels::value() returns a
floating-point type. This assumption makes it difficult to replace the
underlying type in CSSPixels with a non-floating type.

To make it easier to transition CSSPixels to fixed-point math, one step
we can take is to prevent access to the underlying type using value()
and instead use explicit conversions with the to_float(), to_double(),
and to_int() methods.
2023-06-13 06:08:27 +02:00
Liav A
43903aa960 SystemServer: Ensure service drop privileges could fail only when root
If we try to launch a lazily-spawned service and the SystemServer as a
(running --user) session leader is running with root permissions, then
if it is instructed to drop the root permissions for a the new service
then it will make sense to abort the entire spawn procedure if dropping
of privileges failed.

For other users, trying to change UID/GID to something else doesn't make
sense (and will always actually fail) as we are already running in non
root permissions, hence we don't attempt to do this anymore.
It should be noted that if an explicit User configuration was actually
specified for a Service to be used with, we would still try to login
with the requested User option value, which would fail when running as
non-root user.

This is useful for example when trying to run the pro utility with pls
to elevate to root permissions, but the session leader is still the same
so trying to "drop" privileges to UID 0 doesn't make sense.
2023-06-03 14:42:22 +02:00
Simon Wanner
ee7282cbe4 LibWeb: Make pseudo-elements inspectable
This makes it possible to set a pseudo-element as the inspected node
using Document::set_inspected_node(), Document then provides
inspected_layout_node() for the painting related functions.
2023-06-03 05:54:49 +02:00
Caoimhe
4be5000c22 SpiceAgent: Exit early if SPICE_DEVICE doesn't exist 2023-06-03 05:52:16 +02:00
Caoimhe
13506a612e SpiceAgent: Don't pledge cpath or open SPICE_DEVICE as rwc
Core::File's new `DontCreate` open mode removes the need for these
capabilities on SpiceAgent. We shouldn't have to create this file,
as if it doesn't exist, QEMU never initiated a spice connection!
2023-06-03 05:52:16 +02:00
Nico Weber
c9b8af70bf WebContent: Prevent renderer crash on partially invalid image
If an image had a valid header and valid metadata, but decoding the
image frame data failed, the renderer used to crash.

The crash only happened in SerenityOS, because there
ImageCodecPluginSerenity returned nullptr bitmaps.  Instead, return
{} like ImageCodecPluginLadybird already does if there's a nullptr
frame.

Fixes #19141.

Loading #19141 in the browser satisfyingly also serves as a manual
test for the bug.  (No automated test since we don't run layout
tests within SerenityOS on the bots.)
2023-06-02 09:57:20 +01:00
Ben Wiederhake
522809032a WindowServer: Don't crash when trying to set invalid effects 2023-06-01 21:17:29 +02:00
Rummskartoffel
47d1b45583 NotificationServer: Stop notifications showing in the top left at first
Before this commit, notifications would appear in the top left of the
screen when created, then move to the top right once hovered by the
mouse. This happened because the first notification would use its own
default-constructed position of 0,0 as a point of reference.
2023-05-31 14:45:54 +02:00
Aliaksandr Kalenik
393068afba WebContent: Wait for Resource to load in wait_for_navigation_to_complete
Fixes wait_for_navigation_to_complete() so it actually waits for
ongoing page loading request in FrameLoader to complete.
2023-05-30 20:40:23 +02:00
Ben Wiederhake
8df7b42078 FileSystemAccessServer: Don't transmit unused data
The server cannot use these values anywhere, because this method always
sets 'prompt = ShouldPrompt::No'. This saves a bunch of roundtrips for
all clients that use FSAS to read abritrary files.
2023-05-29 13:17:22 +02:00
Ali Mohammad Pur
e47f81d954 Ladybird+Browser: Add a 'Dump All Resolved Styles' debug option
This option dumps all styles for all elements in the document; very
helpful for finding properties that have changed unintentionally :^)
2023-05-29 05:35:41 +02:00
Andreas Kling
097b5e4803 WebContent+headless-browser: Use document.body.innerText for text tests
This should be less fickle than the "select all & copy selected text"
trick we were doing earlier.
2023-05-28 22:03:57 +02:00
Ben Wiederhake
bdeccf8844 Chess+ChessEngine: Fix stockfish by setting correct blocking flag
Stockfish apparently cannot handle non-blocking I/O, and it does not
make sense to assume that all chess engines can do so.

Fixes #18946.
2023-05-27 18:44:21 +02:00
Sam Atkins
465ecf37c2 LibWeb: Make property_id_from_string() return Optional 2023-05-25 06:36:10 +02:00
kleines Filmröllchen
fc5cab5c21 Everywhere: Use MonotonicTime instead of Duration
This is easily identifiable by anyone who uses Duration::now_monotonic,
and any downstream users of that data.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
effcd080ca Userland: Remove remaining users of Duration::now_realtime()
This is a clear sign that they want to use a UnixDateTime instead.

This also adds support for placing durations and date times into SQL
databases via their millisecond offset to UTC.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
213025f210 AK: Rename Time to Duration
That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
2023-05-24 23:18:07 +02:00
Andreas Kling
655d9d1462 LibWeb: Make CSSPixels and Length use 64-bit (double) floating point
This fixes a plethora of rounding problems on many websites.
In the future, we may want to replace this with fixed-point arithmetic
(bug #18566) for performance (and consistency with other engines),
but in the meantime this makes the web look a bit better. :^)

There's a lot more things that could be converted to doubles, which
would reduce the amount of casting necessary in this patch.
We can do that incrementally, however.
2023-05-24 14:40:35 +02:00
Caoimhe
bafc1193ee SpiceAgent: Don't send ClipboardGrab if the shared clipboard is disabled
The spice server will ignore any clipboard-related messages if we don't
have the appropriate capabilities, but I think it's better for us to
do less CPU churning whenever the user copies something to their
clipboard.

It also stops the spice server from warning in the console
about a clipboard grab message being recieved when the capability was
never announced.
2023-05-23 22:56:36 +02:00
Jelle Raaijmakers
f391ccfe53 LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last
column's coordinate still inside the rectangle, or `left + width - 1`.
This is called 'endpoint inclusive' and does not make a lot of sense for
`Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would
return 4 as its right side. This same problem exists for `.bottom()`.

This changes `Gfx::Rect` to be endpoint exclusive, which gives us the
nice property that `width = right - left` and `height = bottom - top`.
It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly
the same.

All users of `Gfx::Rect` have been updated accordingly.
2023-05-23 12:35:42 +02:00
Timothy Flynn
35fdc7f8c8 SpiceAgent: Gracefully exit when the Spice server disconnects 2023-05-22 15:11:33 +02:00
Timothy Flynn
36d61c01bc SpiceAgent: Reduce copying of potentially large byte buffers
This moves buffers around instead of implicitly copying them, and marks
the message types that hold these buffers as move-only.
2023-05-22 15:11:33 +02:00
Caoimhe
0f3f190a5a SpiceAgent: Handle file transfer requests properly :^)
Now, we write the data recieved to a file when the user drags a file
onto the Spice Viewer window. Once complete, the FileExplorer will open
with the copied file highlighted.
2023-05-21 18:45:53 +02:00
Caoimhe
d87f823a68 SpiceAgent: Implement FileTransferData messages 2023-05-21 18:45:53 +02:00
Caoimhe
af91c75080 SpiceAgent: Implement FileTransferStatus messages 2023-05-21 18:45:53 +02:00
Caoimhe
476774d681 SpiceAgent: Implement FileTransferStart messages 2023-05-21 18:45:53 +02:00
Caoimhe
0d98920930 SpiceAgent: Implement sending clipboard data to the spice server 2023-05-21 18:45:53 +02:00
Caoimhe
9f92e52464 SpiceAgent: Add support for copying images to the clipboard 2023-05-21 18:45:53 +02:00
Caoimhe
50a8db3922 SpiceAgent: Add support for reading chunks larger than 2048 bytes 2023-05-21 18:45:53 +02:00
Caoimhe
3b6d63f723 SpiceAgent: Implement setting the user's clipboard contents for text
We also now use GUI::Clipboard for setting the clipboard contents,
instead of using a custom connection to the Clipboard server.
2023-05-21 18:45:53 +02:00
Caoimhe
9c4538a9a8 SpiceAgent: Implement ClipboardRequest messages 2023-05-21 18:45:53 +02:00
Caoimhe
8202f13169 SpiceAgent: Implement ClipboardGrab messages 2023-05-21 18:45:53 +02:00
Caoimhe
79c73dd260 SpiceAgent: Let's start rewriting the messaging system :^)
The old message system was very dependent on syscalls, and the overall
structure made it hard to implement new features.

The new message system is pretty expandible, where each message has its
own dedicated class. As well as this, we now use Core::File and
AK::Stream for reading and writing messages.

Using AK::Stream also allows us to change the actual data source
(in this case, Core::File) without having to update a whole lot of code
in the future.
2023-05-21 18:45:53 +02:00
Caoimhe
3c0b6919f7 SpiceAgent: Minor formatting changes 2023-05-21 18:45:53 +02:00
Caoimhe
7e3fd73410 SpiceAgent: Use ErrorOr<T> for on_message_received 2023-05-21 18:45:53 +02:00
Ben Wiederhake
d030f0fe9b WebSocket: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
9b9a38ec81 RequestServer: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
0ee5a4e308 Clipboard: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
f0586d74d7 WebServer: Convert document_root_path from DeprecatedString to String 2023-05-21 07:52:41 +02:00
Ben Wiederhake
e795641d99 WebServer: Prefer LibFileSystem over DeprecatedFile 2023-05-21 07:52:41 +02:00
Ben Wiederhake
fecaf27b3a FileSystemAccessServer: Prefer LibFileSystem over DeprecatedFile 2023-05-21 07:52:41 +02:00
Liav A
f7185dfa91 SystemServer: Print useful information when failing to drop privileges
It occurred to me that when trying to running "pls pro SOME_URL" with a
subsequent failure (which will be fixed in a future patch), that a small
error message was printed to the debug log about "Failed to drop
privileges (GID=0, UID=0)".

To actually understand where it failed, I added the actual errno to
printed message which helped me with further debugging, but this could
easily help others in similar scenarios so let's print the actual error.
2023-05-20 21:44:03 +02:00
Ben Wiederhake
b4ad3f1b37 LookupServer: Prefer File::read_until_eof over DeprecatedFile 2023-05-19 23:31:20 +02:00