Commit graph

63281 commits

Author SHA1 Message Date
Andreas Kling
8540954bf8 LibWeb: Reject non-finite values in 2D canvas transforms 2024-08-20 09:30:05 +02:00
Andreas Kling
7032cb0235 LibWeb: Stop projecting everything through the current 2D canvas matrix
Now that the underlying Gfx::Painter is being transformed as we go,
we don't need to pre-emptively transform geometry before painting it.
2024-08-20 09:30:05 +02:00
Andreas Kling
feae36f218 LibWeb: Flush 2D canvas transformation matrix after making changes to it 2024-08-20 09:30:05 +02:00
Andreas Kling
5aeb8ebebc LibWeb: Clip underlying Painter in CRC2D::clip() 2024-08-20 09:30:05 +02:00
Andreas Kling
57128f489a LibGfx: Remove most of AntiAliasingPainter 2024-08-20 09:30:05 +02:00
Andreas Kling
91737395f3 LibGfx: Remove unused PathClipper 2024-08-20 09:30:05 +02:00
Andreas Kling
aabad3b94e LibGfx: Remove a bunch of no-longer-used OpenType font code
We're not quite ready to remove the old OpenType implementation yet,
but let's carve off some unused stuff.
2024-08-20 09:30:05 +02:00
Andreas Kling
ca2cd86999 Tests/LibWeb: Update screenshot test reference images for Skia changes 2024-08-20 09:30:05 +02:00
Andreas Kling
137038b185 LibWeb: Port painting to use the new Skia-backed Gfx::Path
SVG and and CSS border rendering now sits on top of SkPath instead of
the old Gfx::DeprecatedPath.

Due to an imperceptible (255, 255, 255) vs (255, 254, 255) color diff
in one ref test, I changed that test to not depend on border rendering
for a positive result, since that was incidental.
2024-08-20 09:30:05 +02:00
Andreas Kling
a3cc03f180 LibGfx+LibWeb: Add new Path class with Skia backend, use for 2D canvas
This thing is essentially a wrapper around an SkPath, although we do
some indirection via a PathImpl class to keep the door open for
alternative rasterizer/path backends in the future.

We also update the 2D canvas code, since that was the only code that
used Painter+DeprecatedPath, and this allows us to just drop that
code instead of temporarily supporting it until the next commit.
2024-08-20 09:30:05 +02:00
Andreas Kling
c8f09312f7 LibGfx: Rename Path => DeprecatedPath 2024-08-20 09:30:05 +02:00
Andreas Kling
de50d27870 LibGfx: Introduce a new Gfx::Painter with a Skia backend
This new painter is written with a virtual interface from the start,
and we begin with a Skia backend.

This patch adds enough to support our basic 2D HTML canvas usecase.
2024-08-20 09:30:05 +02:00
Andreas Kling
0c7670b226 LibGfx: Rename Painter => DeprecatedPainter 2024-08-20 09:30:05 +02:00
Timothy Flynn
099956a7cd LibWeb: Do not unconditionally prevent escape keys from being propagated
We should only block the escape key from being sent to the web page if
the CloseWatcherManager actually closed something.

We use the escape key in the Inspector to cancel editing a DOM field.
This unconditional early return broke this feature.
2024-08-20 09:29:48 +02:00
Timothy Flynn
53f775afb9 LibWeb: Add a testing helper to send a single named key to an element
Unlike internals.sendText(), this allows sending keys like the escape
key.
2024-08-20 09:29:48 +02:00
Timothy Flynn
f14e7c7261 LibWeb: Add a helper to lookup a key code from its string name 2024-08-20 09:29:48 +02:00
Timothy Flynn
a46edc2f8b UI/AppKit: Remove workaround for Protocol naming conflict
The AppKit Application class is responsible for launching all helper
processes. This had to be moved to a .cpp file because we were unable to
include headers with the Protocol namespace in .mm files, as they would
conflict with the Protocol interface defined by Apple.

Now that this namespace has been renamed to Requests, we can remove this
workaround.
2024-08-20 09:29:12 +02:00
Timothy Flynn
3ec5c1941f LibWeb+LibWebView: Add a button to the Inspector to export its contents
When working on the Inspector's HTML, it's often kind of tricky to debug
when an element is styled / positioned incorrectly. We don't have a way
to inspect the Inspector itself.

This adds a button to the Inspector to export its HTML/CSS/JS contents
to the downloads directory. This allows for more easily testing changes,
especially by opening the exported HTML in another browser's dev tools.

We will ultimately likely remove this button (or make it hidden) by the
time we are production-ready. But it's quite useful for now.
2024-08-20 09:28:25 +02:00
Timothy Flynn
cde7c91c54 LibWebView: De-duplicate some Inspector CSS rule blocks
After the refactor to use CSS variables for dark-mode colors in commit
ae25146b89, we had duplicated blocks for
some CSS rules. This patch just unites them into one block.
2024-08-20 09:28:25 +02:00
Khaled Lakehal
2d6069650a LibGfx: Enhance APNG format support
Improve handling of APNG chunks by avoiding premature termination when
encountering non-fcTL chunks. With this patch, the browser now passes
additional APNG-related tests in the "png/" Web Platform Tests (WPT)
suite.
2024-08-19 20:04:31 +02:00
Aliaksandr Kalenik
18fc23b3d6 LibWeb: Reuse display list across repaints
...if only the scroll offset is updated.

Currently, on any document with a large amount of content, the process
of building a display list is often more expensive than its
rasterization. This is because the amount of work required to build a
display list is proportional to the size of the paintable tree, whereas
rasterization only occurs for the portion visible in the viewport.

This change is the first step toward improving this process by caching
the display list across repaints when neither style nor layout requires
invalidation. This means that repainting while scrolling becomes
significantly less expensive, as we only need to reapply the scroll
offsets to the existing display list.

The performance improvement is especially visible on pages like
https://ziglang.org/documentation/master/ or
https://www.w3.org/TR/css-grid-2/
2024-08-19 18:57:20 +02:00
Aliaksandr Kalenik
69c6e07139 LibWeb: Move m_needs_repaint and record_display_list() in Document
Let's make document responsible for display list invalidation,
considering it already takes care of style and layout.
2024-08-19 18:57:20 +02:00
Aliaksandr Kalenik
ab76b99f1e LibWeb: Update scroll thumb position by mutating display list
A new display list item type named PaintScrollBar is introduced. Having
a dedicated type for scroll bars allows the thumb position to be updated
without rebuilding a display list. This was not possible with
FillRectWithRoundedCorners that does not allow to tell whether it
belongs to scroll thumb.
2024-08-19 18:57:20 +02:00
Aliaksandr Kalenik
e2ad568095 LibWeb: Do not mutate display list while scroll offset application
Copy a display list item and apply scroll offset instead of mutating
display list directly.

It's a preparation for upcoming changes where a display list will be
cached across repaints and used multiple times with different scroll
offsets.
2024-08-19 18:57:20 +02:00
Aliaksandr Kalenik
7ddb94c4d6 LibWeb: Rename offset to cumulative_offset in ScrollFrame
New name reflects that offset is not just a frame's own offset but a sum
of offsets from containing block chain.
2024-08-19 18:57:20 +02:00
Aliaksandr Kalenik
a59a839df8 LibWeb: Assign "own scroll frame" to a viewport 2024-08-19 18:57:20 +02:00
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