Commit graph

63399 commits

Author SHA1 Message Date
Jamie Mansfield aac342bf74 LibWeb/HTML: Update "can have its URL rewritten" for spec changes
This updates the spec comments and removes a FIXME. Functionally,
this doesn't change anything as a fix was already in place.

See:
 - https://github.com/whatwg/html/commit/89a387c
 - https://github.com/whatwg/html/issues/10551
2024-08-20 20:31:39 +02:00
Andreas Kling 7cf7a4d7aa Ladybird/AppKit: Use sRGB color space when blitting web content
Before this change, we were passing CGColorSpaceCreateDeviceRGB() to
CGImageCreate(), causing the system to assume that the image data is
in a device-specific RGB space without any color profile adjustments.

If your monitor is more vibrant than the assumed profile (for example,
a wide-gamut display), colors may appear over-saturated as there's no
correction applied for how the display actually renders those colors.

We now pass CGColorSpaceCreateWithName(kCGColorSpaceSRGB) instead,
which makes colors look the same in Ladybird as in other browsers. :^)
2024-08-20 20:31:10 +02:00
Aliaksandr Kalenik bc20e3ac6c LibWeb: Do not allocate mask bitmap for CSS "clip-path" property
Instead, it could be applied directly as a clip path in Skia painter.

As a side bonus, we get rid of some DeprecatedPath and
AntiAliasingPainter usage.
2024-08-20 20:00:56 +02:00
Timothy Flynn 2dbf846ff8 LibWebView: Include the document doctype in the exported Inspector HTML 2024-08-20 12:24:56 -04:00
Timothy Flynn 9f1517492c LibJS: Update spec link to the hashbang comment syntax
The proposal reached stage 4 and was merged into the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/2006dea
2024-08-20 12:24:49 -04:00
Timothy Flynn caf1606c9f LibJS: Mark a call to DetachArrayBuffer as infallible
Noticed while looking at the merged ArrayBuffer transfer proposal.
2024-08-20 12:24:49 -04:00
Timothy Flynn bf3e7d3ac4 LibJS: Update spec steps/links for the ArrayBuffer transfer proposal
The proposal reached stage 4 and was merged into the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/44bb0e0
2024-08-20 12:24:49 -04:00
Andreas Kling 4bc3055c0f LibWeb: Only invalidate shadow root when style sheet inside changes
We don't have to invalidate style for the entire document when a style
sheet changes inside of a shadow root.

To make this possible, StyleSheetList now keeps track of which
Document-or-ShadowRoot it corresponds to, instead of just tracking the
containing Document.

This avoids a lot of style recomputation on pages with lots of shadow
DOM content (like GitHub).
2024-08-20 16:10:33 +02:00
Andreas Kling e71ed67069 LibWeb: Show in dumps when elements represent a pseudo element
You can now tell in DOM dumps that an element represents e.g a text
input ::placeholder pseudo element.
2024-08-20 16:10:33 +02:00
Andreas Kling 62083bf586 LibWeb: Only recompute before and after pseudo element styles
Before this change, we would go through every known pseudo element and
compute style for it whenever recomputing the style of an element.

This led to disastrous performance on pages with selectors like
`::selection` or `::placeholder`, as they'd effectively match every
single element and thus we'd compute multiple additional styles for
every element in the DOM.

The fix is simple: only recompute `before` and `after` pseudo element
styles, since those are the only two pseudo elements that generate
*new* nodes -- other pseudo elements refer to (possibly) existing
nodes or concepts within the DOM (or internal shadow DOM).

This makes style updates take ~40ms on our GitHub repo instead of
~220ms. It's still slower than it should be, but a huge improvement.
2024-08-20 16:10:33 +02:00
Tim Ledbetter 681c0b5d1b CI: Update MacOS runner XCode version 2024-08-20 15:07:02 +01:00
Andreas Kling 2f3128333d LibWasm: Make BytecodeInterpreter overrides final
This gives us free devirtualization of some hot calls inside the
bytecode interpreter. Most notably the did_trap() checks.

Modest performance improvement on the https://figma.com/ landing page.
2024-08-20 12:01:43 +02:00
bbb651 e6a668ad91 HTML: BrowsingContext: Remove m_parent and fix is_ancestor_of
`BrowsingContext::m_parent` has been removed from the spec,
and previously `m_parent` was always null.

`BrowsingContext::is_top_level` was already always returning
true before because of that, and the updated spec algorithm
causes assertions to fail.

This fixes the following example:
```html
<a href="about:blank" target="test">a
<iframe name="test">
```
clicking the link twice no longer causes it to open in a new tab.
2024-08-20 09:36:11 +02:00
bbb651 f82e3345f2 HTML: Update coop-check-access-report to match spec 2024-08-20 09:36:11 +02:00
Andreas Kling dd1b8de671 Ladybird+LibWeb+LibGfx: Add option to force use of fontconfig
This allows us to get identical metrics on macOS and Linux. Without
this, Skia will use CoreText on macOS and give us slightly different
text metrics. That causes layout tests to be slightly different on
different platforms, which is a huge headache. So let's not do that.

You can now launch Ladybird and headless-browser with --force-fontconfig
to load fonts through fontconfig. Tests run in this mode by default.
2024-08-20 09:30:05 +02:00
Andreas Kling 3ed0381a2a LibGfx: Remove unused font code dealing with left-side bearing 2024-08-20 09:30:05 +02:00
Andreas Kling d4d7feffca LibWeb: Compensate for CRC2D transform in internal stored path
The CRC2D path should be unaffected by the CRC2D transform changing.
To achieve this, we transform the path to compensate whenever the
CRC2D transform is changed.
2024-08-20 09:30:05 +02:00
Andreas Kling 0d57de4236 LibWeb: Make 2D canvas save/restore perform save/restore on painter
This ensures that any internal state maintained by the painter gets
synchronized appropriately.
2024-08-20 09:30:05 +02:00
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