Commit Graph

2672 Commits

Author SHA1 Message Date
Jamie Mansfield
38dc317291 LibWeb: Implement HTMLTableCellElement.cellIndex
See:
 - http://wpt.live/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
(cherry picked from commit fa5800ebc52a51ad66ddbf5a97ffb9fbb5424b70)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
d81af2f5f5 LibWeb: Set script force async to false when async changes
(cherry picked from commit bedb626c29913f4e355dfd50c29194e15ed71561)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
ceebaac9ef LibWeb: Script force async flag should default to true
See:
 - http://wpt.live/html/semantics/scripting-1/the-script-element/async_001.htm
(cherry picked from commit 77c41a82bec370ae7c8998aa939bd1117a29b31a)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
d1e17efefe LibWeb/HTML: MathML's <ms> is a special tag
This is an omission I noticed while browsing some code :^)

(cherry picked from commit b3fa8f0ce2b8594c7439bf3c9408456d3b9c5dc6)
2024-11-07 23:07:20 -05:00
Shannon Booth
fd427b4efe 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
(cherry picked from commit 07940a89cad5ecfa21c2d1d8e055941bdb097ef9)
2024-11-07 23:07:20 -05:00
Bastiaan van der Plaat
3f1147bb7e LibWeb: Add autocomplete property
(cherry picked from commit 517b1a26905667a1dca5ddb61958e0197f9b158a)
2024-11-07 23:07:20 -05:00
Colin Reeder
145c218c8d LibWeb: Use base URL for link loading
(cherry picked from commit c6975a16806a6e7d203a178bd5821941f8a9e4fa)
2024-11-07 23:07:20 -05:00
Jelle Raaijmakers
154af3da1c LibWeb: Implement HTMLMediaElement.preload attribute
This implements the `preload` reflected attribute. No actual preloading
is going on yet.

(cherry picked from commit fe933b2057eee8eb65d6e43a97b934bbe85d03bb)
2024-11-07 23:07:20 -05:00
bbb651
3e710465ca 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.

(cherry picked from commit e6a668ad913f0755840954c188c255fc5fc66606)
2024-11-07 22:42:20 -05:00
bbb651
bb691c5537 HTML: Update coop-check-access-report to match spec
(cherry picked from commit f82e3345f2244e6150102fd0c99fb49cdf3af224)
2024-11-07 22:42:20 -05:00
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