Commit graph

63305 commits

Author SHA1 Message Date
Timothy Flynn
4833ba06ea UI/Qt: Process drag-and-drop events through the web view
This forwards all drag-and-drop events from the UI to the WebContent
process. If the page accepts the events, the UI does not handle them.
Otherwise, we will open the dropped files as file:// URLs.
2024-08-19 13:29:19 +02:00
Timothy Flynn
ac062d0c97 UI/AppKit: Process drag-and-drop events through the web view
This forwards all drag-and-drop events from the UI to the WebContent
process. If the page accepts the events, the UI does not handle them.
Otherwise, we will open the dropped files as file:// URLs.
2024-08-19 13:29:19 +02:00
Timothy Flynn
948b6de3b1 LibWeb+LibWebView+WebContent: Add IPC to send drag-and-drop events
This adds the IPC and related hooks to allow the UI to send drag-and-
drop events from the UI process to the WebContent process.
2024-08-19 13:29:19 +02:00
Timothy Flynn
4bb9168712 LibWeb: Implement the DataTransfer files attribute 2024-08-19 13:29:19 +02:00
Timothy Flynn
8b4d28b5fd LibWeb: Disallow creating a FileAPI::FileList with a vector of files
This factory forced callers to make a list of GC-allocated FileAPI::File
objects. This isn't safe - this opens a window for these files to be
garbage collected before the FileList object stores / visits the list.

Instead, only allow creating an empty FileList and incrementally adding
files to that list.
2024-08-19 13:29:19 +02:00
Timothy Flynn
a3a69b8ad2 LibWeb: Add a forward declaration of FileAPI::FileList 2024-08-19 13:29:19 +02:00
Timothy Flynn
9f4e3c7e25 LibWeb: Implement the DataTransfer types attribute 2024-08-19 13:29:19 +02:00
Timothy Flynn
e8a1b89447 LibWeb: Begin implementing the drag-and-drop processing model
The drag-and-drop processing model allows for users to drag around
either elements within the DOM or objects completely outside the DOM.
This drag event can either end without action (via cancellation or user
input), or in a drop event, where the dragged object is dropped onto
another element within the DOM.

The processing model is rather large. This implements enough of it to
allow the UI process to specifically handle dragging objects outside of
the DOM onto the DOM. For example, dragging an image from the OS file
manager onto a file-upload input element. This does not implement the
ability to drag DOM elements.
2024-08-19 13:29:19 +02:00
Timothy Flynn
3674e037f3 LibWeb: Implement the DataTransfer effect attributes 2024-08-19 13:29:19 +02:00
Timothy Flynn
9e98e63559 LibWeb: Begin implementing the drag data store 2024-08-19 13:29:19 +02:00
Timothy Flynn
dcb76572e4 LibWeb: Add an empty DataTransferItemList IDL implementation 2024-08-19 13:29:19 +02:00
Timothy Flynn
9e3c6921ab LibWeb: Add an empty DataTransferItem IDL implementation 2024-08-19 13:29:19 +02:00
Timothy Flynn
b6c99c27af LibWeb: Move EditEventHandler's inclusion to EventHandler.cpp
We can get away with using the forward declaration of EditEventHandler
in the header file (and avoid ~1k rebuilt files when EditEventHandler is
modified).

There will be an upcoming DragAndDropEventHandler class, so this patch
just sets things up so that the edit and drag-and-drop event handlers
are stored the same way in EventHandler.
2024-08-19 13:29:19 +02:00
Timothy Flynn
4727ee0139 LibWeb: Remove needless public specifiers from event structs 2024-08-19 13:29:19 +02:00
Andrew Kaster
c367063823 Tests: Add first test for LibWeb Swift bindings
Just to sanity check that we can import the library, and that it at
least interprets the generated enumeration values properly, let's
do some simple testing of the swift integration.
2024-08-19 12:56:55 +02:00
Andrew Kaster
b03b13b720 AK+LibGfx+LibWebView: Add wrapper header around swift/bridging
When using a configuration without a swift compiler, we need to no-op
the swift annotations. Other, cleverer solutions beyond the has include
all fell flat in the face of the clang modules implementation used by
swift to parse-once use-everywhere each module.
2024-08-19 12:56:55 +02:00
Andrew Kaster
d105b1d4f8 LibWeb: Generate a clang module map file, including generated headers 2024-08-19 12:56:55 +02:00
Andrew Kaster
e45b7b0a86 LibWeb: Add missing Page.h include to SVGDecodedImageData
The PageClient for SVGDecodedImageData needs to actually have the
definition of PageClient available in order to inherit from it. This
fixes importing this header from Objective-C or Swift.
2024-08-19 12:56:55 +02:00
Andrew Kaster
35f4b8bb5c LibWeb: Remove circular include NavigatorBeacon.h <-> Navigator.h
NavigatorBeaconMixin doesn't even need to know about Navigator
2024-08-19 12:56:55 +02:00
Andrew Kaster
422f1ed8de LibCore: Don't wrap <mach/mach.h> in extern "C" on Darwin
This causes issues when loading the file into a clang module, such as
when using Core::MachPort from Objective-C or Swift.
2024-08-19 12:56:55 +02:00
Andrew Kaster
804729fe37 Libraries+Ladybird: Rename LibProtocol -> LibRequests
The identifier "Protocol" is claimed by Objective-C and Swift for use
by the language's built-in protocol conformance feature, which is
similar to Rust traits or Java interfaces.

Rename LibProtocol -> LibRequests, and its namespace from Protocol to
Requests to accomodate this.
2024-08-19 12:56:55 +02:00
Jamie Mansfield
bb95a48035 LibWeb/WebGL: Stub missing includes for WebGLRenderingContext 2024-08-19 09:04:50 +02:00
Jamie Mansfield
b0fd4aff1a LibWeb/Canvas: Stub missing includes for CanvasRenderingContext2D 2024-08-19 09:04:50 +02:00
Aliaksandr Kalenik
3edd22143d LibWeb: Remove set_needs_display() from PageClient::ready_to_paint()
There is no need to force repaint when client is ready for the next
frame. We simply need to make sure HTML event loop processing is
scheduled.
2024-08-19 09:03:33 +02:00
Aliaksandr Kalenik
c87214d79c LibWeb: Skip documents of decoded SVGs while processing HTML event loop
None of HTML event loop processing steps are relevant for decoded SVGs,
so we can simply skip them while collecting documents for processing.
2024-08-19 09:03:33 +02:00
Tim Ledbetter
00f03f3e90 LibWeb: Match attribute selectors case insensitively in XML documents
The values of attribute selectors are now compared case insensitively
by default if the attribute's document is not a HTML document, or the
element is not in the HTML namespace.
2024-08-19 09:03:22 +02:00
Tim Ledbetter
c422518792 LibWeb: Add the scope attribute 2024-08-19 09:03:22 +02:00
Tim Ledbetter
353e3e75dc LibWeb: Limit HTMLProgressElement.max to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a
negative value.
2024-08-19 09:02:21 +02:00
Braydn
a94bf9bd09 LibThreading: ThreadPool deadlock test
Enable `LibThreading` tests and add a test to check for deadlocks in
`ThreadPool`s
2024-08-19 03:08:04 +02:00
Braydn
8d336d2a25 LibThreading: Adjust ThreadPoolLooper m_busy_count sections
The `ThreadPoolLooper` should increment `m_busy_count` before attempting
to access the global queue. Otherwise, there exists a possible race
condition where `wait_for_all` checks the exit conditions before the
looper increments `m_busy_count` but after it empties the `ThreadPool`
queue.

Next, incrementing / decrementing `m_busy_count` is moved to be the
responsibility of `ThreadPoolLooper`. Otherwise, it is possible that
decrementing `m_busy_count` in the caller of `Looper::next` causes
`m_busy_count` to underflow if the call to `Looper::next` returns
before incrementing `m_busy_count`.
2024-08-19 03:08:04 +02:00
Braydn
a0fd7cf371 LibThreading: Fix deadlocks in ThreadPool
When adding tests for `ThreadPool` a handful of deadlocks can be
observed when worker threads wait on `m_work_available`.

The first deadlock is in the destruction of `ThreadPool` where it
is possible for a worker thread to be in the process of acquiring
`m_mutex` when the  broadcast to `m_work_available` in the
destructor happens. This causes the destructor to hang on joining the
thread which is now perpetually waiting on `m_work_available`. This is
solved by repeatedly broadcasting on `m_work_available` until the thread
to join exits.

The second deadlock occurs when the final signal to `m_work_done` is
missed by the wait in `wait_for_all`. At this point all workers are in
the hot loop of attempting to get work from the work queue, however
since there is no work remaining all workers end up waiting on
`m_work_available`. At this point the `wait_for_all` call is also
waiting on `m_work_done`, which will never be signalled again as all
workers are waiting on `m_work_available`.

This requires 2 changes to fix, the first is that workers will signal
`m_done_work` before waiting on `m_work_available`. The second change is
to acquire `m_mutex` before checking the wait conditions as done when
using `wait_while`.
2024-08-19 03:08:04 +02:00
Diego Frias
ed153a1720 LibWasm: Grow table type in table.grow 2024-08-18 23:35:02 +02:00
Diego Frias
0aa76b5f67 LibWeb/WebAssembly: Throw when a table type's max > initial 2024-08-18 23:35:02 +02:00
Diego Frias
80434fa516 LibWeb/WebAssembly: Change behavior of explicit undefined in tables 2024-08-18 23:35:02 +02:00
Diego Frias
3be7e88903 LibWeb/WebIDL: Throw correct error when converting integers
When an integer doesn't fit within the range of an integral type
defined by WebIDL, the spec says to throw a `TypeError`, not a
`RangeError`.
2024-08-18 23:35:02 +02:00
Diego Frias
4e7d3026d2 LibWasm+LibWeb: Allow tables to have externrefs in the JS API 2024-08-18 23:35:02 +02:00
Shannon Booth
fc83653f3c LibWeb: Use HeapFunction directly in SessionHistoryTraversalQueue
This allows us to use HeapFunction all of the way down, allowing us
to remove the Handle usage in after_session_callback for
create_new_child_navigable.
2024-08-18 11:15:08 +02:00
Shannon Booth
b6d2ab2332 LibWeb: Port populate_session_history_entry_document to HeapFunction
...For the completion steps. This is quite nice, as we can simply
capture this in the heap function where it is used instead of
needing to establish a new root.

Note that with these changes, to represent 'an empty algorithm', we now
use a null HeapFunction and do not invoke the steps.
2024-08-18 11:15:08 +02:00
Shannon Booth
3a7ccf8c25 LibWeb: Convert create_new_child_navigable to HeapFunction 2024-08-18 11:15:08 +02:00
Shannon Booth
b86ddac11a LibWeb: Port HTMLImageElement BatchingDispatcher to HeapFunction 2024-08-18 11:15:08 +02:00
Shannon Booth
a622abde77 LibWeb: Port ReadLoopReadRequest to JS::HeapFunction 2024-08-18 11:15:08 +02:00
Shannon Booth
87d964b2f5 LibJS: Use HeapFunction for IteratorHelper 2024-08-18 11:15:08 +02:00
Andrew Kaster
315a666e53 Tests: Add test to verify CxxSequence protocol conformance of containers
Building the test in debug mode currently crashes the swift frontend,
so we'll need to build this in release mode until that's fixed.
2024-08-17 17:44:37 -06:00
Andrew Kaster
7f0044a721 CMake: Add helper to swiftify imported properties from dependencies
Works around https://gitlab.kitware.com/cmake/cmake/-/issues/26195
2024-08-17 17:44:37 -06:00
Andrew Kaster
756ef2c722 AK: Conform SimpleIterator to the random access iterator requirements
This requires pulling in some of the STL, but the result is that our
iterator is now STL Approved ™️ and our containers can be
auto-conformed to Swift protocols.
2024-08-17 17:44:37 -06:00
Tim Ledbetter
227ac9973f Documentation: Update wpt.fyi URL in getting started contributing guide 2024-08-18 00:22:21 +01:00
circl
7d4500a109 Documentation: Remove SerenityOS mentions from patterns reference 2024-08-17 11:51:06 -06:00
circl
336bfb9e88 Documentation: Remove extra <hr>s from the smart pointers reference
They are either redundant or duplicated from GitHub's formatting
2024-08-17 11:51:06 -06:00
circl
954b7ffb52 Documentation: Change two titles to not mention SerenityOS 2024-08-17 11:51:06 -06:00
circl
0dfc13f37d Documentation: Add a getting started contributing guide
This document aims to be a beginner-friendly summary of the existing
contribution requirements for Ladybird, intended to be linked to
new-comers.
2024-08-17 11:51:06 -06:00