Commit graph

35197 commits

Author SHA1 Message Date
Aliaksandr Kalenik 866608532a LibWeb: Add parent-child relationship between scroll frames
This allows the calculation of the cumulative scroll offset for a scroll
frame by adding its scroll offset to the parent’s scroll offset, rather
than traversing the containing block chain. While it doesn't greatly
simplify calculations for typical scroll frames, it serves as a
preparation for supporting "position: sticky".
2024-08-30 19:03:06 +02:00
Khaled Lakehal 2565757c7a LibWeb: Set document type to HTML for text and media documents
This update fixes an issue where the document type was incorrectly set
to XML instead of HTML when initializing text and media documents.
2024-08-30 08:28:16 -04:00
Tim Ledbetter a95905f93f LibWeb: Support animations in embedded SVG images 2024-08-30 13:35:07 +02:00
Onorio Catenacci b86f57ebf7 LibWeb: Add minimum thumb size
This change is intended to insure that the thumb control on the dialog
will never be narrower than 50 pixels no matter how long the line it's
displaying.
2024-08-30 13:32:29 +02:00
Timothy Flynn a04327a0c9 LibWebView: Add a command line option to override the User-Agent
This commit just adds a command line option to case-insensitively accept
a User-Agent name to use as the UA override. The UIs will individually
need to make use of this option.
2024-08-29 13:05:47 +01:00
Andreas Kling a6bf253602 LibJS: Use the system native page size as the HeapBlock::block_size
Before this change, we were hard-coding 4 KiB. This meant that systems
with a 16 KiB native page size were wasting 12 KiB per HeapBlock on
nothing, leading to worse locality and more mmap/madvise churn.

We now query the system page size on startup and use that as the
HeapBlock size.

The only downside here is that some of the pointer math for finding the
base of a HeapBlock now has to use a runtime computed value instead of a
compile time constant. But that's a small price to pay for what we get.
2024-08-29 13:56:09 +02:00
Tim Ledbetter df431a0c32 LibWeb: Use the correct base class in for SVGImageElement 2024-08-29 11:46:36 +01:00
Adam Harald Jørgensen 3e92ec80f3 LibWeb: Set correct longhand values when using grid-placement shorthand
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
According to https://www.w3.org/TR/css-grid-2/#placement-shorthands
when setting the 'grid-row' and 'grid-column' shorthand property to a
single <custom-ident> value, both 'grid-row-start'/'grid-column-start'
and 'grid-row-end'/'grid-column-end' should be set to that
<custom_ident>.
2024-08-29 07:00:00 +02:00
Andrew Kaster 77718c0a66 LibWeb: Implement the Data state for the Swift tokenizer
And add tests! This implementation closely follows the current C++
implementation, replacing macros and gotos with a slightly more
complex state machine. It's very possible that an async version that
yields tokens on "emit" would be even simpler, but let's get this
one working first :).
2024-08-29 06:31:25 +02:00
Andrew Kaster a3e6856b56 AK+Swift: Remove Foundation.Data footgun for AK.StringView
Also give the Swift.String init routines an explict label when
constructing from AK String types, as this caused issues in a later
commit to have them both with `_ data`.
2024-08-29 06:31:25 +02:00
Tim Ledbetter 03bbc2b111 LibWeb/SVG: Implement SVGImageElement
This element allows images to be embedded within SVGs.
2024-08-29 06:28:44 +02:00
Tim Ledbetter 267420d5aa LibWeb: Remove ImagePaintable::layout_box()
This was not used.
2024-08-29 06:28:44 +02:00
Andreas Kling b64df59cc6 LibWeb: Fix crash when setting innerHTML inside iframe srcdoc document
In particular, there was an assertion failure due to the temporary
parser document's "about base URL" being empty when trying to "parse a
URL" during parsing.

We fix this by copying the context element's document's about base URL
to the temporary parsing document while parsing a fragment.

This fixes a crash when loading search results on https://amazon.com/
2024-08-29 06:24:18 +02:00
Jamie Mansfield f1098b4226 LibWeb: Implement ServiceWorkerContainer.onmessageerror
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-08-28 18:36:28 +01:00
Jamie Mansfield 4b1273cbde LibWeb: Implement ServiceWorkerContainer.onmessage 2024-08-28 18:36:28 +01:00
simonkrauter 820676857a LibWeb: Use nearest-neighbor scaling for ScalingMode::SmoothPixels
Adjust the translation from Gfx::ScalingMode to Skia SkFilterMode, so
that CSS::ImageRendering::Pixelated will result in
SkFilterMode::kNearest.

Before:
ScalingMode::SmoothPixels -> kLinear

After:
ScalingMode::SmoothPixels -> kNearest

Fixes #1170
2024-08-28 19:30:40 +02:00
sideshowbarker e76e48421f LibWeb: Add “valid floating-point number” for HTMLInputElement.value
This change adds checking for the following spec requirements:

- https://html.spec.whatwg.org/#number-state-(type=number):value-sanitization-algorithm
- https://html.spec.whatwg.org/#range-state-(type=range):value-sanitization-algorithm

That is, it adds checking that HTMLInputElement.value is what the spec
defines as a “valid floating-point number” when the “type” attribute for
the HTMLInputElement is either “number” or “range”.

This change causes Ladybird to pass all the failing tests at
https://wpt.fyi/results/html/semantics/forms/the-input-element/number.html?run_id=5080423051034624
and to match the relevant behavior in Webkit, Blink, and Gecko.

Otherwise, without this change, Ladybird fails those tests, and the
relevant Ladybird behavior isn’t interoperable with other engines.
2024-08-28 07:49:17 -04:00
Tim Ledbetter b688b5d9d4 LibWeb: Correctly test if WebDriver ExecuteScript timeout is reached
Previously, the conversion assumed that the supplied timeout was in
seconds rather than milliseconds.
2024-08-28 06:57:42 +01:00
Andrew Kaster c5153cb398 Meta+Libraries+AK: Append Cxx to imported library module names in swift
At the same time, simplify CMakeLists magic for libraries that want to
include Swift code in the library. The Lib-less name of the library is
now always the module name for the library with any Swift additions,
extensions, etc. All vfs overlays now live in a common location to make
finding them easier from CMake functions. A new pattern is needed for
the Lib-less modules to re-export their Cxx counterparts.
2024-08-27 17:22:31 -06:00
Andrew Kaster f27d638e0a CMake: Always use a target for linking skia 2024-08-27 17:22:31 -06:00
Timothy Flynn e782947a03 LibJS: Use the IteratorStepValue AO in Iterator prototypes
This is an editorial change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/b4ccc31
2024-08-27 13:00:37 -04:00
Timothy Flynn 48bef246a0 LibJS: Change generator state enum casing in IteratorHelperPrototype
This is an editorial change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/f1427ec
2024-08-27 13:00:37 -04:00
Jelle Raaijmakers dee81f3545 LibWeb: Compare start container to parent in Text.splitText()
Some checks failed
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Validate code with clang plugins / build-and-verify (push) Has been cancelled
Tiny mistake in the implementation of the spec; fixes 16 FAILs in the
WPT `/dom/ranges/Range-mutations-splitText.html` tests.
2024-08-27 07:13:08 -04:00
Jelle Raaijmakers 732e3fa82f LibWeb: Propagate input/textarea selection update to document selection
Calling `.setSelectionRange()` or `.select()` now updates the document
selection as well, visualizing the text selection.
2024-08-27 07:11:50 -04:00
Jelle Raaijmakers badcdcacf5 LibWeb: Update input/textarea selection on document selection change
This causes UI interactions with the document selection to also update
the input and textarea DOM selection state. Note that we switch around
the order of focusing a DOM node and setting the selection, so we allow
the focus event to override whatever selection we came up with.
2024-08-27 07:11:50 -04:00
Jelle Raaijmakers 814ca3267e LibWeb: Implement input/textarea selection APIs
For both types of elements, `.selectionStart`, `.selectionEnd`,
`.selectionDirection`, `.setSelectionRange()`, `.select()` and the
`select` event are now implemented.
2024-08-27 07:11:50 -04:00
Jelle Raaijmakers 69bbeea4ef LibWeb: Remove duplicate code from ViewportPaintable
No functional changes.
2024-08-27 07:11:50 -04:00
Timothy Flynn 660e846e94 Revert "LibWeb: Change where content selection via mouse is allowed"
This reverts commit 6c9adf3dbc.

This change breaks e.g. typing into the search box on google.com and
comment boxes on github.com.
2024-08-26 14:08:59 -04:00
Timothy Flynn fa4b324a12 LibUnicode: Remove unused time zone cache option
Some checks are pending
CI / Lagom (FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Added this during development while testing some callers, but forgot to
remove it before opening a PR.
2024-08-26 11:37:02 -04:00
Bram Otte 003fc4f8ee LibWeb: Handle multiple result values for WebAssembly functions 2024-08-26 16:50:05 +02:00
Andreas Kling c22acc2551 LibWeb: Implement vertical-align: middle correctly for atomic inlines
This makes inline icons pop into the right place on https://ahrefs.com/
2024-08-26 15:49:07 +02:00
Samuel Fry c42679597a LibWeb: Support parsing columns 2024-08-26 08:26:22 +01:00
Samuel Fry 23b4367c9c LibWeb: Support parsing column-span 2024-08-26 08:26:22 +01:00
Samuel Fry c113d3fae9 LibWeb: Support parsing column-width 2024-08-26 08:26:22 +01:00
Andreas Kling 84ab8bf797 LibWeb: Make CSS :hover selector match shadow-inclusive ancestors
Before this change, :hover wouldn't match anything outside the shadow
boundary when hovering elements inside a shadow tree. This was most
noticeable when hovering the text inside an input element and hover
styles disappearing from the hosting input element itself.
2024-08-25 12:53:08 +02:00
Tim Ledbetter f3405b6eb2 LibWeb: Implement Navigator.serviceWorker
This currently returns a stubbed `ServiceWorkerContainer` object.
2024-08-25 09:48:30 +02:00
Tim Ledbetter 53ab6fa403 LibWeb: Stub the ServiceWorkerContainer interface 2024-08-25 09:48:30 +02:00
Tim Ledbetter 0c0a4a6042 LibWeb: Stub the ServiceWorkerRegistration interface 2024-08-25 09:48:30 +02:00
Tim Ledbetter d3e076f963 LibWeb: Implement cloning steps for HTMLTextAreaElement 2024-08-25 09:48:19 +02:00
Tim Ledbetter 71cfa705d1 LibWeb: Implement cloning steps for HTMLInputElement 2024-08-25 09:48:19 +02:00
Timothy Flynn d8c69a0e9e LibWebView+WebContent: Monitor for system time zone changes
This creates a TimeZoneWatcher in the UI process to inform all open
WebContent processes when the time zone changes. The WebContent process
will clear its time zone cache to retrieve a fresh zone the next time
it is asked for one.
2024-08-25 09:47:42 +02:00
Timothy Flynn 577efcdc32 LibCore: Create a system time zone watcher
This creates platform-dependent monitors to detect when the system time
zone changes. On Linux, we use a file watcher to monitor files such as
/etc/localtime for changes. On macOS, this uses CFNotificationCenter to
be notified by the OS when the time zone changes.

Note: the macOS implementation requires running in a process which is
running the CoreFoundation event loop. Both the AppKit and Qt chromes
are doing so in the UI process, but this means we cannot run this
monitor in the WebContent process.
2024-08-25 09:47:42 +02:00
Timothy Flynn b31c11bca5 LibUnicode: Cache the system time zone
It's expensive to determine the system time zone from disk each time it
is requested. This makes LibUnicode cache the result, and provides an
API to clear that cache. This will let us set up a monitor to watch for
system time zone changes in platform-dependent ways.
2024-08-25 09:47:42 +02:00
Timothy Flynn e25681203e LibCore: Add support for monitoring symbolic links
Symbolic links are currently always followed to their target. This lets
us monitor the link file itself.
2024-08-25 09:47:42 +02:00
Timothy Flynn 9f496a9c65 LibCore: Improve support for the macOS file watcher with actual files
When asked to monitor a file (not a directory), we often need to instead
monitor the parent directory to receive FS events. For example, when a
symbolic link is deleted/created, we don't receive any events unless we
are watching the parent.
2024-08-25 09:47:42 +02:00
Timothy Flynn 574b4be433 LibCore: Remove deleted monitored files before invoking change callbacks
The caller may want to re-add the monitored file. It won't be able to do
so if we internally believe the file is still being monitored.
2024-08-25 09:47:42 +02:00
Timothy Flynn abc462999e LibCore: Remove monitored file data before invoking system calls
The monitored files can be internally removed by inotify. If we then try
to explicitly remove them, the inotify_rm_watch call will fail. We do
this when the file is deleted and we receive an IN_DELETE event. This
ensures we clean up the monitored files.
2024-08-25 09:47:42 +02:00
Timothy Flynn 61419cf717 LibCore: Silently ignore IN_IGNORED events
According to the inotify man page, this event is always generated after
a IN_DELETE, which we separately handle. Just ignore IN_IGNORED events
to avoid spamming stderr.
2024-08-25 09:47:42 +02:00
Andrew Kaster 49733ed09b LibWeb: Add an HTML tokenizer re-implementation in swift
It doesn't do much yet, the fun part was the scaffolding
2024-08-24 19:14:09 -06:00
Andrew Kaster e15dd3c22a LibGfx: Use new AK+Swift extensions to simplify parseHexString 2024-08-24 19:14:09 -06:00
Andreas Kling 349b17cc7a LibWeb: Don't paint text fragments with CSS visibility:hidden
We *could* even skip creating a paintable for hidden nodes, but that
means that dynamic updates to the CSS visibility property would require
mutating the paint tree, so let's keep it simple for now.
2024-08-24 14:53:26 +02:00
Jamie Mansfield 2e9aec984c LibWeb/HTML: Implement DataTransferItem.webkitGetAsEntry() 2024-08-24 14:53:11 +02:00
Jamie Mansfield 169163b002 LibWeb/EntriesAPI: Implement FileSystemEntry 2024-08-24 14:53:11 +02:00
Jamie Mansfield b583aec3ac LibWeb: Add [Clamp] extended attribute to WebSocket.close 2024-08-24 14:52:27 +02:00
Jamie Mansfield f02ca0c431 LibWeb: Expose TextMetrics to Worker 2024-08-24 11:25:19 +01:00
Jamie Mansfield 4133177895 LibWeb: Expose Worker to DedicatedWorker and SharedWorker 2024-08-24 11:25:19 +01:00
mrdcbrush b757ee0bc8 LibWebView: Add Kagi search engine to menu
LibWebView: Add Kagi search engine to selection menu
2024-08-24 11:21:25 +01:00
Andrew Kaster 33e50889f2 LibWeb: Add CustomStringConvertible extension for HTMLToken types 2024-08-23 19:17:20 -06:00
Andrew Kaster fb074f9d0c LibWeb: Add start of HTML Tokenizer in Swift
Currently it's just a Token class.
2024-08-23 19:17:20 -06:00
Jamie Mansfield 67976d041b LibWeb/FileAPI: Add [Clamp] extended attribute to Blob.slice
See:
 - http://wpt.live/FileAPI/blob/Blob-slice-overflow.any.html
2024-08-23 12:08:11 +01:00
Jamie Mansfield 9650a5ff33 LibWeb/FileAPI: Update Blob.slice for spec changes 2024-08-23 12:08:11 +01:00
Timothy Flynn 181ece4d9c LibWeb: Implement DataTransferItem.prototype.getAsString() 2024-08-23 10:10:34 +01:00
Timothy Flynn b978dba8bd LibWeb: Implement DataTransferItem.prototype.getAsFile()
This is used on imgur after drag-and-dropping an image onto its page.
2024-08-23 10:10:34 +01:00
simonkrauter 6c9adf3dbc LibWeb: Change where content selection via mouse is allowed
Previously, only DOM nodes with `is_editable()` allowed selection via
the mouse. This had the unwanted consequence, that read-only
input/textarea elements did not allow selection.

Now, `EventHandler::handle_mousedown()` asks the node's non-shadow
parent element over the new virtual method `is_child_node_selectable()`,
if selection of the node is allowed.
This method is overridden for `HTMLButtonElement` and
`HTMLInputElement`, to disallow selection of buttons and placeholders.

Fixes #579
2024-08-23 09:31:05 +01:00
simonkrauter a2e4259099 LibWeb: Introduce variable dom_node in EventHandler::handle_mousedown
to make the code more readable
2024-08-23 09:31:05 +01:00
Jamie Mansfield dda7325358 LibWeb/XHR: Expose FormData to Worker
See:
 - http://wpt.live/fetch/api/response/response-init-contenttype.any.worker.html
2024-08-22 19:52:06 -06:00
Andreas Kling 8eacfc8f10 LibWeb: Derive SVG root's natural size from width/height attributes
We were incorrectly looking at the CSS computed values for width and
height to determine the natural size of <svg> root elements.
This meant that elements where the attribute and computed value were
different values would end up with incorrect natural size.
2024-08-22 15:29:29 +02:00
Timothy Flynn b16b9709b9 LibWeb: Include the Content-Type boundary directive in form submissions
The spec requires that "multipart/form-data" Content-Type headers also
include a boundary directive. This allows the content server to validate
the submitted form data.

Google Lens, for example, rejects forms missing this directive.
2024-08-22 14:21:13 +02:00
Timothy Flynn 1cdccf901b LibWeb: Transform errant return to a break in form submission
There are more steps to be run after extracting the form body and type.
2024-08-22 14:21:13 +02:00
Timothy Flynn 001d8384e5 LibWeb: Implement the DataTransferItem kind and type attributes 2024-08-22 14:21:13 +02:00
Timothy Flynn ceb9e30d42 LibWeb: Implement the DataTransferItemList indexed getter 2024-08-22 14:21:13 +02:00
Timothy Flynn 843f8f04a5 LibWeb: Implement the DataTransferItemList length attribute 2024-08-22 14:21:13 +02:00
Timothy Flynn 74d9cfbf2a LibWeb: Implement DataTransferItemList.prototype.add() 2024-08-22 14:21:13 +02:00
Timothy Flynn b3bfd02e64 LibWeb: Store a list of DataTransferItem on the DataTransfer object
When scripts receive a DataTransferItem from any IDL method, the spec
requires we return the same DataTransferItem for a particular item in
the drag data store. Meaning, we cannot just create these on the fly as
needed.

To do this, we store a list of DataTransferItem on the DataTransfer
object. We will return one of these objects any time one is requested by
a script.

It feels a bit weird to have the DataTransfer object store: the drag
data store, a DataTransferItemList, and a list of DataTransferItem. But
this is how other engines implement this as well. It basically has to be
this way as DataTransferItemList is just a proxy to the DataTransfer -
meaning, DataTransfer is the source of truth for all IDL access.
2024-08-22 14:21:13 +02:00
Timothy Flynn c82fec0a8c LibWeb: Add a factory method to create a DataTransferItem
A DataTransferItem is associated with a DataTransfer, and points to an
item in the drag data store. We don't yet support removing items from
the store, but when we do, we will clear the index stored here to set
the DataTransferItem's mode to "disabled".
2024-08-22 14:21:13 +02:00
Timothy Flynn 5c9287aa99 LibWeb: Implement separate DataTransfer factories for IDL / internal use
The IDL constructor has to take separate steps than a DataTransfer that
is internally constructed. Notably, an IDL-created object has its own
drag data store, and that store is placed in a read-write mode.
2024-08-22 14:21:13 +02:00
Timothy Flynn f7c4165dde LibWeb: Make the drag data store reference counted
Ownership of the drag data store is a bit weird. In a normal drag-and-
drop operation, the DragAndDropEventHandler owns the store. When events
are fired for the operation, the DataTransfer object assigned to those
events are "associated" with the store. We currently represent that with
an Optional<DragDataStore&>.

However, it's also possible to create DataTransfer objects from scripts.
Those objects create their own drag data store. This puts DataTransfer
in a weird situation where it may own a store or just reference one.

Rather than coming up with something like Variant<DDS, DDS&> or using
MaybeOwned<DDS> here, we can get by with just making the store reference
counted.
2024-08-22 14:21:13 +02:00
Timothy Flynn 1b70362954 LibWeb: Implement the DataTransfer items attribute 2024-08-22 14:21:13 +02:00
Timothy Flynn 34ad67e056 LibWeb: Remove unused DataTransfer-related IDL factories
The IDL for DataTransferItem and DataTransferItemList do not have
constructors.
2024-08-22 14:21:13 +02:00
Timothy Flynn 535f03b6cf LibWeb: Implement DataTransfer.prototype.getData()
This is used by Google Lens. It will always return the empty string when
dragging an image onto the Google Lens search field.
2024-08-22 14:21:13 +02:00
Timothy Flynn 0b0d44da27 LibWeb: Implement the ClipboardEvent IDL interface
We don't actually generate any such events ourselves. But Google Lens
will create one with the DataTransfer attribute set to that of any drop
event we send it.
2024-08-22 14:21:13 +02:00
Tim Ledbetter 2c5d626b21 LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction
Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.
2024-08-22 13:49:41 +02:00
Gasim Gasimzada 785180dd45 LibJS+WebContent: Implement console.table
- Expose table from console object
- Add new Table log level
- Create a JS object that represents table rows and columns
- Print table as HTML using WebContentConsoleClient
2024-08-22 09:08:50 +01:00
Andreas Kling a2a9a11466 LibWebView: Update User-Agent spoofing strings with new versions
Also use an OrderedHashMap so they show up in the same order in UI.
2024-08-22 09:39:20 +02:00
Ali Mohammad Pur a60ecea16a LibWasm+LibWeb+test-wasm: Refcount Wasm::Module for function references
Prior to funcref, a partial chunk of an invalid module was never needed,
but funcref allows a partially instantiated module to modify imported
tables with references to its own functions, which means we need to keep
the second module alive while that function reference is present within
the imported table.
This was tested by the spectests, but very rarely caught as our GC does
not behave particularly predictably, making it so the offending module
remains in memory just long enough to let the tests pass.

This commit makes it so all function references keep their respective
modules alive.
2024-08-22 09:36:40 +02:00
Andreas Kling 5606ce412e LibWeb: Handle document/navigable disconnection during favicon decode
If the document is disconnected from the navigable by the time a favicon
decode completes successfully, we don't want to show the favicon for
whatever document is now loaded in the navigable.

Fix this by deferring getting the navigable until after the decode has
completed.
2024-08-22 09:34:54 +02:00
Andreas Kling bde2d3dc7b LibWeb: Adjust flex item intrinsic contributions through aspect ratio
When determining the intrinsic cross size contribution of a flex item
with a preferred aspect ratio, we have to account for any min/max
constraints in the main axis.
2024-08-21 13:38:39 +02:00
Francesco Gazzetta 81fbb5ebc2 LibGfx: Fix build with system skia
Compare with Userland/Libraries/LibWeb/CMakeLists.txt:780
2024-08-21 06:28:10 -04:00
Kenneth Myhra 26fe7a628c LibWeb: Capture incoming reason argument
Capture the incoming reason argument to
transform_stream_default_source_cancel_algorithm() on the
on_fulfilled_callback() of WebIDL::react_to_promise() on step 7.
2024-08-21 11:21:54 +01:00
Khaled Lakehal 514a2a1757 LibWeb: Add setter implementation for location.search
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.
2024-08-21 10:52:19 +01:00
Sam Atkins 5bd585d446 LibWeb/CSS: Add dump method to CalculatedStyleValue
The individual nodes all have dump methods, but there was no way of
calling them from the outside. So now there is.
2024-08-21 10:51:48 +01:00
Sam Atkins 3af6a69f1e LibWeb: Introduce color-function-specific style values
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class
with subclasses for each different color function, to match the Typed-OM
spec. This means moving the color calculations from the parsing code to
the `to_color()` method on the style value.

This lets us have calc() inside a color function, instead of having to
fully resolve the color at parse time. The canvas fillStyle tests have
been updated to reflect this.

The other test change is Screenshot/css-color-functions.html: previously
we produced slightly different colors for an alpha of 0.5 and one of
50%, and this incorrect behavior was baked into the test. So now it's
more correct. :^)
2024-08-21 10:51:48 +01:00
Sam Atkins 27be8678c9 LibWeb/CSS: Introduce helper methods for parsing numeric values
"Parse a style value for <foo>", where we don't care if it's a literal
<foo> or a calculated one, is a really common thing that we previously
didn't have methods for.

A couple of methods we had have been extended to parse calc(), and the
others have been filled in.

The method for parsing the `flex` property's value is renamed
`parse_flex_shorthand_value()` as it conflicted.
2024-08-21 10:51:48 +01:00
Sam Atkins 79bd942dd1 LibWeb/CSS: Inline number/integer parsing
For simplicity in user code, the `parse_foo_value()` methods should
parse anything that is a `<foo>`. In these cases, that means a
number/integer or calculation that resolves to them.

These uses in parse_css_value_for_properties() specifically only want a
literal IntegerStyleValue/NumberStyleValue, as calc-parsing is done
elsewhere. So, do the parsing for them locally.
2024-08-21 10:51:48 +01:00
Sam Atkins 9bc71ab1fe LibWeb/CSS: Stop using parse_color()
Parsing a `Gfx::Color` no longer makes sense, as CSS has many ways of
defining a color, often in a dynamic way where the color value isn't
known until later. This is a small preparatory change before a much
larger color rewrite.
2024-08-21 10:51:48 +01:00
Sam Atkins 37ea4e3b5f LibWeb: Rename CSSColorValue::create() to create_from_color()
Soon, CSSColorValue will be an abstract class, and we'll instead create
a CSSRGB, CSSHSL, or other specific color type from the Typed-OM spec.
However, it's still useful to have an easy "just give me a style value
for this color" method. So change the name to distinguish this from the
usual StyleValue::create() methods.
2024-08-21 10:51:48 +01:00
Sam Atkins 4e48afd9a7 LibWeb: Store ShadowStyleValue's color as a StyleValue
Colors can be specified in a way that `Gfx::Color` can't represent, such
as named system colors, `currentColor`, or functions involving `calc()`.
2024-08-21 10:51:48 +01:00
Sam Atkins 581d00293c LibWeb: Rename ColorStyleValue -> CSSColorValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue

This is not (yet) the same as the CSSColorValue, but one step at a time.
2024-08-21 10:51:48 +01:00
Sam Atkins 8952764267 LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs
CSS-Typed-OM has the following hierarchy:

CSSStyleValue
- CSSNumericValue
  - CSSUnitValue
  - CSSMathValue
    - ...various math functions...

Somewhat unintuitively, numbers are also stored using CSSUnitValue with
`unit = "number"`.

There are no distinct classes for LengthStyleValue, etc in the spec, but
they're convenient for us, so they are implemented as subclasses of
CSSUnitValue, at least for now.
2024-08-21 10:51:48 +01:00
Tim Ledbetter fe42e2719f LibWeb: Don't crash when parsing HTMLInputElement invalid time values 2024-08-20 23:30:35 +01:00
Jelle Raaijmakers e926b4cbfb LibWeb: Make new ImageData() use unpremultiplied color data
This was already the case for `context.createImageData()`, but I forgot
to do the same for `new ImageData()`. Add a regression test for both
cases.
2024-08-20 20:39:09 +02:00
Jelle Raaijmakers bd55e85027 LibGfx: Implement Gfx::AlphaType for SkiaPainter
Always assuming unpremultiplied color data only worked for PNGs (which
are specced as unpremultiplied) and bitmaps with alpha set to 100%.
Properly propagate the Gfx::AlphaType of a bitmap to Skia.

The reference tests were updated to reflect this change, but visually
it's practically impossible to see the difference. A new test was added
to clearly expose this issue.

Fixes #1104
2024-08-20 20:39:09 +02:00
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
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 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
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 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 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
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 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 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 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
Colin Reeder 347928b950 LibWeb: Fix handling of SSEs split across chunks 2024-08-17 12:54:28 -04:00
Bastiaan van der Plaat f2034270f1 LibWeb: Add URL reflection to obsolete HTMLImageElement lowsrc property 2024-08-17 17:31:14 +01:00
Tim Ledbetter 1369fc5069 LibWeb: Change attribute type to USVString where applicable
Also mark USVString attributes as containing a URL, where applicable.
2024-08-17 07:45:00 +02:00
Shannon Booth d56da8cf9a LibWeb: Sort URLSearchParams using UTF-16 code units
We were previously sorting using code points which could give the wrong
result for certain inputs.

Fixes the last two failing tests on:

https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-17 07:44:13 +02:00
Shannon Booth cff3e78a14 LibWeb: Strip trailing spaces from opaque URL path on query change
This was added in https://github.com/whatwg/url/commit/fdaa0e5a
to fix a case where roundtrips could fail. We had already partially
implemented these steps - but it seems this was missed in the update of
URLSearchParams.

Fixes the last failing WPT test for:

https://wpt.live/url/urlsearchparams-delete.any.html
2024-08-17 07:44:13 +02:00
Jamie Mansfield ea61e189eb LibWeb/SVG: Add missing SVGGElement IDL file 2024-08-17 07:41:04 +02:00
Jamie Mansfield e2f599ebee LibWeb/SVG: Implement <metadata> element 2024-08-17 07:40:45 +02:00
Jamie Mansfield b3fa8f0ce2 LibWeb/HTML: MathML's <ms> is a special tag
This is an omission I noticed while browsing some code :^)
2024-08-17 07:40:10 +02:00
Tim Ledbetter 1365289d98 LibWeb: Implement the setter for location.protocol 2024-08-17 07:39:58 +02:00
Shannon Booth 07940a89ca LibWeb: Handle cases with <template> on the HTML parsing stack
This appears to have been a bug in the spec which was later corrected -
so to fix the crash we can simply remove this assertion.

Fixes: #868
2024-08-16 22:38:18 +01:00
BenJilks 0d63269cb7 LibGfx+LibWeb: Use harfbuzz for text shaping
This replaces glyph positioning system with harfbuzz's shaping
algorithm. Adding support for bidirectional encoded text.
2024-08-16 22:28:34 +02:00
Ali Mohammad Pur 0d05ab2ad0 LibWasm: Allow all Value::to<Integral>() calls
This brings back the old behaviour of Value::to<short>() (and other
similar calls), which WASI depends on.
To make sure all similar issues are caught in the future, this commit
also introduces an static assertion in Value::to().
2024-08-16 21:03:10 +02:00
Jamie Mansfield e3b3041a0c LibWeb: Implement NavigatorStorage mixin interface
Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
2024-08-16 11:22:09 -04:00
Jamie Mansfield 1b84062c74 LibWeb: Stub StorageManager idl interface 2024-08-16 11:22:09 -04:00
Colin Reeder 97d5cf4eef LibWeb: Add support for SVG display attribute 2024-08-16 12:12:09 +02:00
Timothy Flynn 73ca9516a9 LibJS: Remove the InitializeNumberFormat AO
The Initialize* AOs for Intl formatters were removed some time ago, and
the formatter construction steps are now inlined in the constructors
themselves. InitializeNumberFormat was the one remaining initializer we
still had laying around.
2024-08-15 17:21:00 -04:00
Timothy Flynn a1a368bb61 LibJS: Fix editorial rebasing errors in the ECMA-402 spec
This is the remainder of the editorial rebasing errors that were fixed
in:
https://github.com/tc39/ecma402/commit/3f029b0
2024-08-15 17:21:00 -04:00
Timothy Flynn c7dd4afd9c LibJS+LibUnicode: Update the Intl.DateTimeFormat constructor spec steps
This constructor has undergone a handful of editorial changes that we
fell behind on. But we weren't able to take the updates until now due to
a spec bug in those updates. See:
https://github.com/tc39/ecma402/commit/3f029b0

The result is that we can remove the inheritance of Intl::DateTimeFormat
from Unicode::DateTimeFormat; the former now contains the latter as an
internal slot.
2024-08-15 17:21:00 -04:00
Sam Atkins f518811f73 LibWeb: Use CSSKeywordValue for CSS-wide keywords
We previously had 4 single-instance StyleValues for these keywords.
CSS-Typed-OM expects them keywords to be exposed as CSSKeywordValue, so
it's simpler to treat them the same. The single-instance behaviour is
kept by having StyleValue::create() use a cached instance for each of
these.
2024-08-15 13:58:38 +01:00
Sam Atkins 6a74b01644 LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
2024-08-15 13:58:38 +01:00
Sam Atkins 9559f0f123 LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
2024-08-15 13:58:38 +01:00
Sam Atkins 0e3487b9ab LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue

No behaviour changes.
2024-08-15 13:58:38 +01:00
Sam Atkins 2e1f62681c LibWeb/CSS: Flatten ENUMERATE_STYLE_VALUE_TYPES macros
Being constrained by this macro is going to make it more difficult to
refactor our StyleValue types to match the Typed-OM spec, so let's
reintroduce the boilerplate for now.

No functional changes.
2024-08-15 13:58:38 +01:00
Timothy Flynn ca1257c6f9 LibJS+LibUnicode: Make the collation sensitivity default locale-aware
Note this happens to be 'variant' for every locale currently.
2024-08-15 13:44:32 +02:00
Timothy Flynn 78625c746d LibJS+LibUnicode: Make the collation punctation default locale-aware 2024-08-15 13:44:32 +02:00
Timothy Flynn eb8e516ed3 LibJS: Update Intl.Collator spec steps to the latest
The steps have been updated to indicate a few options that should be
defaulted based on locale preferences. Those steps have not yet been
implemented in this patch.
2024-08-15 13:44:32 +02:00
Timothy Flynn eb7e3583c9 LibJS+LibUnicode: Fully implement Intl.Collator with ICU
We were never able to implement anything other than a basic, locale-
unaware collator with the JSON export of the CLDR as it did not have
collation data. We can now use ICU to implement collation.
2024-08-15 13:44:32 +02:00
Aliaksandr Kalenik dc0d5da086 LibWeb: Remove ViewportPaintable::refresh_clip_frames()
After d0da377767 clip frame state is no
longer depends on scroll state, so it could be calculated only once for
each layout invalidation.
2024-08-15 09:45:07 +02:00
Aliaksandr Kalenik c4ce797366 LibWeb: Use scroll frame id in SVGSVGPaintable::before_children_paint()
A display list should not contain coordinates shifted by scroll offset.
Instead, "scroll frame id" needs to be used. In the future it's going to
allow us reuse a display list in cases when only scroll offsets need to
be updated.
2024-08-15 09:45:07 +02:00
Aliaksandr Kalenik 5b23190174 LibWeb: Remove scroll_offset() usage in PaintableWithLines
A display list should not contain coordinates shifted by scroll offset.
Instead, "scroll frame id" needs to be used. In the future it's going to
allow us reuse a display list in cases when only scroll offsets need to
be updated.
2024-08-15 09:45:07 +02:00
Tim Ledbetter c61262684b LibWeb: Return empty string if object element data URL is invalid 2024-08-15 09:44:35 +02:00
Tim Ledbetter 4f7a4d9c57 LibWeb: Return empty string if image element currentSrc URL is invalid 2024-08-15 09:44:35 +02:00
Jamie Mansfield bab086694a LibWeb: Support SRI for import maps
See:
- https://github.com/whatwg/html/commit/b2fdca1
2024-08-14 21:06:25 +01:00
Jelle Raaijmakers 124779a376 LibWeb: Implement the "fire a focus event" spec
We weren't setting the focus event's composed flag and view field
correctly.
2024-08-14 20:53:33 +01:00
Jamie Mansfield 9c4e80a3ec LibWeb/SVG: Implement default_tab_index_value for a element
Another FIXME bites the dust :^)
2024-08-14 20:39:35 +01:00
Aliaksandr Kalenik 9c13644cde LibWeb: Simplify ViewportPaintable::refresh_clip_state()
Removes code that accounts for clip frame's own overflow clip, because
it happens anyway on a first iteration of a loop through containing
blocks chain.
2024-08-14 21:04:46 +02:00
Aliaksandr Kalenik f9f39477a4 LibWeb: Fix clip for boxes nested into a stacking context with transform
Modifies a loop that collects clip rectangles to stop once a box with a
CSS transform is encountered, as its clip still needs to be considered.
2024-08-14 21:04:46 +02:00
sideshowbarker 23da1752b5 LibWeb/Fetch: Set HTTP status code on cached responses
This change causes HTTP status codes to be set on cached HTTP responses.

Otherwise, without this change, no status codes at all are set on cached
HTTP responses — which causes all cached responses to default to being
loaded/served with a 200 status code. And as a result of that, if the
cached response is from a 30x redirect, then without this change, when
that cached 30x response is loaded, we don’t follow the redirect —
because we see a 200 status, rather than the expected/original 30x.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/863

Note that this change also reverts the temporary workaround added in
https://github.com/LadybirdBrowser/ladybird/commit/f735c464d3f
(https://github.com/LadybirdBrowser/ladybird/pull/899).
2024-08-14 14:49:04 +02:00
Timothy Flynn 50dfaf8581 LibJS: Disallow grouping separators in formatted duration fields
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/68b00f3
2024-08-14 11:48:08 +02:00
Timothy Flynn 72f61396cd LibJS: Correctly display a negative sign on negative durations
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/adfc4a1
2024-08-14 11:48:08 +02:00
Timothy Flynn 300f8d3dbb LibJS: Impose limits on a valid duration
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1104cad
https://github.com/tc39/proposal-temporal/commit/45462c4

Although our Temporal implementation is wildly out of date, this AO and
the changes to it are relied on in Intl.DurationFormat.
2024-08-14 11:48:08 +02:00
Timothy Flynn 78328ab83c LibJS: Disallow U+2212 MINUS SIGN in time zone offset strings
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/e7f1e5d
2024-08-14 11:48:08 +02:00
Bastiaan van der Plaat 517b1a2690 LibWeb: Add autocomplete property 2024-08-13 22:53:55 +01:00
Jelle Raaijmakers e7984a7711 LibWeb: Check presence of WWW-Authenticate header in fetch response
If a HTTP 401 response we get does not contain a `WWW-Authenticate`
header, we should not trigger the logic to ask the user for credentials
and retry the request.

This part is hinted at in a TODO / 'Needs testing' remark in the spec
but needs to be fleshed out. Raised an upstream issue to do so:

  https://github.com/whatwg/fetch/issues/1766

This fixes login forms triggering an infinite fetch loop when providing
incorrect credentials.

Co-Authored-By: Victor Tran <vicr12345@gmail.com>
2024-08-13 16:01:48 +01:00
BenJilks 1537d589ca LibWeb: Add start and end values to text-align
The `start` and `end` value set the text alignment based on the computed
value of `direction`. The default value of `text-align` is now `start`
instead of `left`.
2024-08-13 15:19:51 +01:00
BenJilks 82989554ab LibWeb: Use reverse direction on flex containers with rtl direction
If a flex container has `direction: rtl` set, reverse the row direction.
2024-08-13 15:19:51 +01:00
Colin Reeder c6975a1680 LibWeb: Use base URL for link loading 2024-08-13 14:34:15 +01:00
Shannon Booth ff71d8f2c9 LibURL+LibWeb: Pass a mutable reference URL to URL parser
If given, the spec expects the input URL to be manipulated on the fly
as it is being parsed, and may ignore any errors thrown by the URL
parser.

Previously, we were not exactly following the specs assumption here
which resulted in us needed to make awkward copies of the URL in these
situations.

For most cases this is not an issue. But it does cause problems for
situations where URL parsing would result in a failure (which is
ignored by the caller), and the URL is _partially_ updated
while parsing.

Such a situation can occur when setting the host of an href alongside a
port number which is not valid. It is expected that this situation will
result in the host being updates - but not the port number.

Adjust the URL parser API so that it mutates the URL given (if any), and
adjust the callers accordingly.

Fixes two tests on https://wpt.live/url/url-setters-a-area.window.html
2024-08-13 14:14:34 +02:00
Colin Reeder 00f75648e5 LibWeb: Update stylesheet media value when changing link media attribute 2024-08-13 14:12:55 +02:00
Colin Reeder b92abe5c26 LibWeb: Avoid calling matches before evaluate 2024-08-13 14:12:55 +02:00
Timothy Flynn f7fcde7f60 LibTest: Define test expectation macros without copying the input values
Currently, the following test case will actually copy both `a` and `b`
when the test macro is expanded:

    ByteBuffer a = { some large buffer };
    ByteBuffer b = { some other buffer };
    EXPECT_EQ(a, b);

This patch redefines the expectation macros to avoid copying.
2024-08-13 14:11:05 +02:00
Bastiaan van der Plaat e0c8a14fab LibWeb: Fix HTMLFrameElement noresize obsolete property typo 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat 4712f53dd7 LibWeb: Add HTMLImageElement lowsrc obsolete property 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat d1fad9869b LibWeb: Add HTMLObjectElement codebase obsolete property 2024-08-13 14:08:34 +02:00
Jelle Raaijmakers fe933b2057 LibWeb: Implement HTMLMediaElement.preload attribute
This implements the `preload` reflected attribute. No actual preloading
is going on yet.
2024-08-13 14:08:03 +02:00
Jamie Mansfield 77a30bad9f LibWeb/HTML: Implement HTMLImageElement.longDesc 2024-08-13 11:49:19 +01:00
Jamie Mansfield 45c2b1f62c LibWeb/HTML: Implement HTMLIFrameElement.longDesc 2024-08-13 11:49:19 +01:00
Shannon Booth d755a83c09 LibWeb: Actually set empty serialized query to OptionalNone
Because the type returned by to_string is a String, _not_ an
Optional<String>, the following code:

if (serialized_query.is_empty())
    serialized_query = {};

Was achieving nothing at all! Make sure that the type is an
Optional<String> so that we're not just setting an empty string to an
empty string.
2024-08-12 23:01:29 +01:00
Shannon Booth 1ba6dbd86c LibWeb: Use a stable sort for searching URLSearchParams
Quick sort is not a stable sort. This meant we had a subtle issue
implementing this portion of the spec comment:

 > The relative order between name-value pairs with equal names must
 > be preserved.

Switch to insertion sort which is a stable sort, and properly handles
keys which are the same.

Fixes 8 tests on  https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-12 23:01:29 +01:00
Shannon Booth df4739d7ce LibWeb: Don't propogate small OOMs from URLSearchParams
Made easier now that URL percent encode after encoding is also not
throwing any errors. This simplfies a bunch of error handling.
2024-08-12 23:01:29 +01:00
Shannon Booth 4bb211ba88 LibURL: Make percent_encode_after_encoding infallible 2024-08-12 23:01:29 +01:00
Shannon Booth 264b5160c2 LibWeb: Implement value argument of URLSearchParams.has 2024-08-12 23:01:29 +01:00
Shannon Booth 5637dc43b2 LibWeb: Implement value argument of URLSearchParams.delete 2024-08-12 23:01:29 +01:00
Gasim Gasimzada 4a42c97f4d LibJS: Set empty prototype for console object 2024-08-12 17:21:01 +01:00
Aliaksandr Kalenik d0da377767 LibWeb: Make AddClipRect display list item account for scroll offset
Before this change AddClipRect was a "special" because it didn't respect
scroll frame offset and was meant to be recorded using viewport-relative
coordinates. The motivation behind this was to record a "final" clip
rectangle computed by intersecting all clip rectangles used by a clip
frame. The disadvantage of this approach is that it blocks us from
implementing an optimisation to reuse display list if the only change is
in the scroll offset, because any scroll offset change leads to
invalidating all AddClipRect items within a list.

This change aligns AddClipRect with the rest of display list items by
making it account for scroll frame offset. It required discontinuing
the recording of the intersection of all clip rectangles within a clip
frame and instead producing an AddClipRect for each of them.

A nice side effect is the removal of code that shifts clip rectangle by
`enclosing_scroll_offset()` in a bunch of places, because now it happens
automatically in `DisplayList::apply_scroll_offsets()`.
2024-08-12 18:20:13 +02:00
Shannon Booth 0b864bef60 LibTextCodec: Implement UTF8Decoder::to_utf8 using AK::String
String::from_utf8_with_replacement_character is equivalent to
https://encoding.spec.whatwg.org/#utf-8-decode from the encoding spec,
so we can simply call through to it.
2024-08-12 06:38:58 -04:00
Shannon Booth b3bf5c4ea8 AK: Add BOM handling to String::from_utf8_with_replacement_character 2024-08-12 06:38:58 -04:00
Maks Verver c68b8b5bda RequestServer: Fix compiling with -DREQUESTSERVER_DEBUG=ON 2024-08-12 02:27:48 +02:00
Jamie Mansfield 17c1e99ce4 LibWeb: Use keepalive maximum size in NavigatorBeacon
This is defined as 64 KiB in the fetch spec.

See:
 - https://wpt.live/beacon/beacon-basic.https.window.html
2024-08-11 20:07:10 +01:00
Jamie Mansfield 35047de1d8 LibWeb/Fetch: Add a constant for the keepalive maximum size 2024-08-11 20:07:10 +01:00
Gasim Gasimzada c5b8e75204 LibJS: Set configurable toStringTag property for console 2024-08-11 20:06:27 +01:00
Aliaksandr Kalenik dd8c693725 LibWeb: Unify scroll handling between viewport and scrollable boxes
This change causes the viewport to be treated as a "scroll frame,"
similar to how it already works for boxes with "overflow: scroll."
This means that, instead of encoding the viewport translation into a
display list, the items will be assigned the scroll frame id of the
viewport and then shifted by the scroll offset before execution. In the
future it will allow us to reuse a display list for repainting if only
scroll offset has changed.

As a side effect, it also removes the need for special handling of
"position: fixed" because compensating for the viewport offset while
painting or hit-testing is no longer necessary. Instead, anything
contained within a "position: fixed" element is simply not assigned
a scroll frame id, which means it is not shifted by the scroll offset.
2024-08-11 07:53:21 +02:00