Commit Graph

2662 Commits

Author SHA1 Message Date
Jamie Mansfield
334d2e0764 LibWeb/Canvas: Stub missing includes for CanvasRenderingContext2D
(cherry picked from commit b0fd4aff1a9a5d1f02f2a36b63812a63728eceea)
2024-11-07 22:42:20 -05:00
Aliaksandr Kalenik
8e3b7e3680 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.

(cherry picked from commit c87214d79cf834ee9b7b4da65e902e5233c0a5cc)
2024-11-07 22:42:20 -05:00
Tim Ledbetter
1ca34ff710 LibWeb: Add the scope attribute
(cherry picked from commit c4225187927f12d444612a8bc4e5d0f6bd21aa83)
2024-11-07 22:42:20 -05:00
Tim Ledbetter
8537cd76f3 LibWeb: Limit HTMLProgressElement.max to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a
negative value.

(cherry picked from commit 353e3e75dcff05f05a65cfc3c70d1cff8db5d50c)
2024-11-07 22:42:20 -05:00
Jamie Mansfield
01919367d8 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
(cherry picked from commit 17c1e99ce4b3a05d5f71e15513b2f1e4251047e2)
2024-11-07 22:17:03 -05:00
Shannon Booth
51b710bce1 LibWeb: Actually perform "update the href steps"
We completely missed this step, which made setters not actually do
anything!

Fixes 336 test failures on:

https://wpt.live/url/url-setters-a-area.window.html
(cherry picked from commit deff8df2c79af718f08f16bc47f5a22ac6add553)
2024-11-07 21:52:13 -05:00
Aliaksandr Kalenik
db01e39913 LibWeb: Call set_needs_display() if navigable is scrolled or resized
`m_needs_repaint = true` is not enough because it doesn't schedule
repaint of a parent navigable.

Fixes the bug when an iframe is not repainted after scrolling.

(cherry picked from commit 40742d95e66c98857fa43ea1c6632dbe75ecb3b3)
2024-11-07 21:52:13 -05:00
Nico Weber
6f9b4b8129 LibWeb: Implement canvas setLineDash(), getLineDash(), lineDashOffset
Also add coverage for that to canvas-stroke-styles.html.
2024-11-07 19:06:56 -05:00
Jamie Mansfield
a49db64dac LibWeb: Make preferred languages configurable
This also changes fetch to use the preferred languages for the
Accept-Language header.

(cherry picked from commit 2ca8fd1832462c05fdec16a1de73494820597140)
2024-11-05 11:41:15 -05:00
Tim Ledbetter
01324df21e LibWeb: Implement setRangeText for input and textarea elements
This method replaces range of text in its respective element with a new
string

(cherry picked from commit 2f5b0707163db5df5ff2d25dc329e70d8f54a7f1)
2024-11-04 19:28:16 -05:00
Tim Ledbetter
13ea62f247 LibWeb: Subclass FormAssociatedElement text selection methods
These are only relevant to HTMLInputElement and HTMLTextArea elements.

(cherry picked from commit 206262cd55ed9cead004bc074b9d7b813512b895)
2024-11-04 19:28:16 -05:00
Tim Ledbetter
bda31d3fce LibWeb: Don't handle media player key events if any modifier is pressed
(cherry picked from commit a56a2faf51cded86393d93e353369691f0a04ace)
2024-11-04 14:18:06 -05:00
Tim Ledbetter
264f31aaf4 LibWeb: Don't propagate key events that are handled by the media player
If a key is pressed when the media player is in focus, which causes the
media player to perform some action, that key event is no longer
propagated further.

(cherry picked from commit 63231fd2763e3db094be926f599486122265243f)
2024-11-04 14:18:06 -05:00
Jamie Mansfield
56330768ed LibWeb: Support Gecko and WebKit navigator compatibility modes
This will log a debug message when calls are made to the
NavigatorIDMixin that make decisions based on the compatibility mode.

(cherry picked from commit 1128375dff8a2b8183f33e6cee59adf6b2c84210)
2024-11-04 13:54:07 -05:00
Tim Ledbetter
95527fd7aa LibWeb: Implement cloning steps for HTMLTextAreaElement
(cherry picked from commit d3e076f963716222787903a9613e0678d909a7ab)
2024-11-04 13:39:53 -05:00
Tim Ledbetter
3710a5b1fb LibWeb: Implement cloning steps for HTMLInputElement
(cherry picked from commit 71cfa705d1eab052e773e6a695c438bab87ec8b0)
2024-11-04 13:39:53 -05:00
Arhcout
d4249604d7 LibWeb: Readonly input element's arrow buttons don't change the value
(cherry picked from commit c31f9815b46a12c931f7d446f7e4e42c71eacf5d)
2024-11-04 13:38:49 -05:00
Jelle Raaijmakers
33562cc25e LibWeb: Propagate input/textarea selection update to document selection
Calling `.setSelectionRange()` or `.select()` now updates the document
selection as well, visualizing the text selection.

(cherry picked from commit 732e3fa82f216a6f4114eb0e6bb89e167e95ab42)
2024-11-04 13:17:37 -05:00
Jelle Raaijmakers
cb1edae2ca LibWeb: Implement input/textarea selection APIs
For both types of elements, `.selectionStart`, `.selectionEnd`,
`.selectionDirection`, `.setSelectionRange()`, `.select()` and the
`select` event are now implemented.

(cherry picked from commit 814ca3267ed73d7ad8492ef69ff87f95240cf922)
2024-11-04 13:17:37 -05:00
Timothy Flynn
b106429d4f LibWeb: Append attributes to the correct element
The spec indicates we should append attributes to the top element of the
stack of open elements. We were appending the attribute to the bottom.

(cherry picked from commit 657bbd1542ce8fcd3357e5b4dada895229faf834)
2024-11-04 13:17:19 -05:00
Timothy Flynn
7cb6a40e95 LibWeb: Use an infallible method to add attributes to nodes
In the HTML parser spec, there are 2 instances of the following text:

    add the attribute and its corresponding value to that element

The "add the attribute" text does not have a corresponding spec link to
actually specify what to do. We currently use `set_attribute`, which can
throw an exception if the attribute name contains an invalid character
(such as '<'). Instead, switch to `append_attribute`, which allows such
attribute names. This behavior matches Firefox.

Note we cannot yet make the unclosed-html-element.html test match the
expectations of the unclosed-body-element.html due to another bug that
would prevent checking if the expected element has the right attribute.
That will be fixed in an upcoming commit.

(cherry picked from commit 9fe35ddddf895b0835a347eab7b45b33d1638ce7)
2024-11-04 13:17:19 -05:00
Andreas Kling
5c4c048195 LibWeb: Rename invalidate_layout() => invalidate_layout_tree()
I believe this is slightly less confusing, since what the function does
is trigger a full layout tree *rebuild*, not just a relayout.

(cherry picked from commit aa8f17aea4d1aa1950a66969fc8b5c431fbc1b7c)
2024-11-04 13:17:01 -05:00
Tim Ledbetter
973ed173c5 LibWeb: Implement Navigator.serviceWorker
This currently returns a stubbed `ServiceWorkerContainer` object.

(cherry picked from commit f3405b6eb22eed00b6caa208dc94b43bb6638c52)
2024-11-04 13:16:23 -05:00
Tim Ledbetter
8ef2496882 LibWeb: Stub the ServiceWorkerContainer interface
(cherry picked from commit 53ab6fa403ac774d6edb76c33a9b0f460eea9640)
2024-11-04 13:16:23 -05:00
Tim Ledbetter
c455a7492d LibWeb: Stub the ServiceWorkerRegistration interface
(cherry picked from commit 0c0a4a6042f7d25186c65ca60aa04d066dc51e97)
2024-11-04 13:16:23 -05:00
Bastiaan van der Plaat
ceca910486 LibWeb: Apply input range accent color not when appearance: none;
(cherry picked from commit 9fbf5039a63cbb461470f095bc308caae68db805)
2024-11-04 12:53:24 -05:00
Bastiaan van der Plaat
4b3c5f5ad5 LibWeb: Make input color a rectangle shape like other browser engines
(cherry picked from commit 51f5c4a71848742bed6747bbff1631efcf4be37d)
2024-11-04 12:53:24 -05:00
Tim Ledbetter
3d130ee6ef LibWeb: Don't group radio buttons from different trees together
Previously, we were searching for other radio buttons from the document
root, rather than the element root.

(cherry picked from commit 67981af276cf55d69d51a872ec83e5b59d793b6c)
2024-11-04 12:29:19 -05:00
Timothy Flynn
50378e093f LibWeb: Only set the editable text cursor position if necessary
When the user clicks on a text node, the event handler sets the cursor
position to the location that was clicked. But it would then be set back
to 0 in the DOM node's focus handler. Leave the cursor alone, unless the
the DOM node was never set as the cursor position node (which will occur
when the user clicks on the DOM node, but outside the shadow text node).
In that case, move the cursor to the end of the text node.

The end result here is that the cursor is placed where the user clicked,
or set to the end of node if the user clicked outside of the shadow text
node.

(cherry picked from commit fc37c4ad40beba249a7ea5452f11014d43da68f6)
2024-11-04 12:28:53 -05:00
sideshowbarker
5ab804501d 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.

(cherry picked from commit e76e48421f9ee5e6be12035aee47e91b1656bf0e)
2024-11-04 12:28:33 -05:00
Andreas Kling
b3e8e67ca3 LibWeb: Honor appearance: none when creating input element layout node
Per css-ui-4, setting `appearance: none` is supposed to suppress the
creation of a native-looking widget for stuff like checkboxes, radio
buttons, etc.

This patch implements this behavior by simply falling back to creating
a layout node based on the CSS `display` property in such cases.

This fixes an issue on the hey.com imbox page where we were rendering
checkboxes on top of sender profile photos.

(cherry picked from commit 58c523ae46af90ab17d6b98966d97fa776ae2bf4)
2024-11-04 10:34:34 -05:00
Jamie Mansfield
c45292e1aa LibWeb: Don't crash with invalid import maps
See:
 - http://wpt.live/import-maps/multiple-import-maps/with-errors.html
(cherry picked from commit c891b83fc079ee0c34ea9ccc71cfed67e3b14cd2)
2024-11-02 06:45:48 -04:00
Andreas Kling
00e187e0a9 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/

(cherry picked from commit b64df59cc61f31b8a0aab91abb4630b3ecb1dcee)
2024-11-02 06:45:38 -04:00
Timothy Flynn
db5b3e5b70 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.

(cherry picked from commit b16b9709b99c51d288d1e514c3c0012c79ea16d2)
2024-11-01 22:04:14 -04:00
Timothy Flynn
229a974c93 LibWeb: Transform errant return to a break in form submission
There are more steps to be run after extracting the form body and type.

(cherry picked from commit 1cdccf901bd6449be51896e64f73acf6375d9f90)
2024-11-01 22:04:14 -04:00
Timothy Flynn
cd69ebdecd LibWeb: Implement the DataTransferItem kind and type attributes
(cherry picked from commit 001d8384e5ea51e2a435517814d299174d65d786)
2024-11-01 22:04:14 -04:00
Timothy Flynn
a6d010c247 LibWeb: Implement the DataTransferItemList indexed getter
(cherry picked from commit ceb9e30d422425582ac1db857ff4c786fb7e212c)
2024-11-01 22:04:14 -04:00
Timothy Flynn
695771695d LibWeb: Implement the DataTransferItemList length attribute
(cherry picked from commit 843f8f04a518ec0968e4f39ce27264efe0546fa9)
2024-11-01 22:04:14 -04:00
Timothy Flynn
cf1bdd72ac LibWeb: Implement DataTransferItemList.prototype.add()
(cherry picked from commit 74d9cfbf2a2ef84e8634dafc78fc56e6cb153b6b)
2024-11-01 22:04:14 -04:00
Timothy Flynn
7553681a6c 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.

(cherry picked from commit b3bfd02e64b4e5a0754c157b18dd42427c931923)
2024-11-01 22:04:14 -04:00
Timothy Flynn
2dac492cde 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".

(cherry picked from commit c82fec0a8cc871aa331de5a557db1adddca7711c)
2024-11-01 22:04:14 -04:00
Timothy Flynn
77a96886e2 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.

(cherry picked from commit 5c9287aa99e52886a3d144c26de6a54980a53db6)
2024-11-01 22:04:14 -04:00
Timothy Flynn
d14a26b9e7 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.

(cherry picked from commit f7c4165dde9cc1f3c84fbc49c8496dea3a898491)
2024-11-01 22:04:14 -04:00
Timothy Flynn
39f991bb68 LibWeb: Implement the DataTransfer items attribute
(cherry picked from commit 1b703629548950882063495679b9307519271b92)
2024-11-01 22:04:14 -04:00
Timothy Flynn
be9e3f6671 LibWeb: Remove unused DataTransfer-related IDL factories
The IDL for DataTransferItem and DataTransferItemList do not have
constructors.

(cherry picked from commit 34ad67e056dd9c290109ab00ee6e6a1c1d82560a)
2024-11-01 22:04:14 -04:00
Timothy Flynn
4e820d36e2 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.

(cherry picked from commit 535f03b6cf664071e03b7f3c95116fa89c33122b)
2024-11-01 22:04:14 -04:00
Jamie Mansfield
abe4acab3a LibWeb: Implement HTMLTrackElement.readyState
(cherry picked from commit 1d12cb69d46a46442de2baa2a316d5b004821352)
2024-11-01 21:11:17 -04:00
Luke Warlow
47c1b65012 LibWeb: Implement popover property and attribute
The popover property now reflects the attribute.

It cannot currently use the Reflect IDL concept because the empty string
value is special cased.

(cherry picked from commit a9669639cee27e81640fe7a37d9d1f319db6b666;
amended to undo unintentional -- and conflicting -- change to
Tests/LibWeb/rebaseline-libweb-test)
2024-11-01 20:16:58 -04:00
Timothy Flynn
a3050819d2 LibWeb: Implement the DataTransfer files attribute
(cherry picked from commit 4bb9168712d6e706465ded9e1b6764a039651ea0)
2024-11-01 19:58:08 -04:00
Timothy Flynn
1848d1c6d9 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.

(cherry picked from commit 8b4d28b5fd7857e3ee47a8d50aa9c01920dcfb4b)
2024-11-01 19:58:08 -04:00