Commit Graph

2731 Commits

Author SHA1 Message Date
Timothy Flynn
6cef8e5bfd LibWeb: Remove range-count filter from selection change handlers
The implementation of setBaseAndExtent will create a new range.

(cherry picked from commit 96ad310643ff90af557b9ca71db450ebd4d37ba5)
2024-11-12 07:13:58 -05:00
Timothy Flynn
af3222b686 LibWeb: Update the document cursor position when the selection changes
Otherwise, it looks a bit awkward where the cursor position does not
update while the selection is elsewhere.

Note that this requires passing along the raw selection positions from
`set the selection range` to the elements. Otherwise, consider what will
happen if we set the selection start and end to the same value. By going
through the API accessor, we hit the case where the start and end are
the same value, and return the document cursor position. This would mean
the cursor position would not be updated.

The test changes here more closely match what Firefox produces now. It
is not a 100% match; the `select event fired` test case isn't right. The
problem is the event fires for the input element, but we most recently
focused the textarea element. Thus, when we retrieve the selection from
the input element, we return the document's cursor position, which is
actually in the textarea element. The fix will ultimately be to fully
implement the following:

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-cursor

That is, each input / textarea element should separately track its own
text cursor position.

(cherry picked from commit fd289deb44e0fc26f54a133c637c136bf0716cd5)
2024-11-12 07:13:58 -05:00
Shannon Booth
001db03171 LibWeb: Ensure fully active document before appending to an iframe
(cherry picked from commit 15c15116dd3d62c5a9ee17f6c80e1782cd2a1a96)
2024-11-12 04:24:21 -05:00
Piotr
850692f6c1 LibWeb: Set textarea rows and cols default value if 0
The cols and rows attributes are limited to only positive numbers with
fallback. The cols IDL attribute's default value is 20. The rows IDL
attribute's default value is 2.

The default value was returned only for the negative number. I added an
additional check for the case when the attribute is 0 to match the
specification.

(cherry picked from commit 205155a7abb9b9754cd0917901cfc04d86291820)
2024-11-12 04:24:21 -05:00
Totto16
c1b0ac6376 LibWeb: Reject Promise in createImageBitmap for Not Implemented Types
If we don't reject the Promise, it lasts forever,
so rejecting non implemented Promises is essential,
to not timeout in e.g. WPT tests

(cherry picked from commit aab5a9e944f8b1c1a9de321047556bbcaa282a56)
2024-11-11 19:54:09 -05:00
Tim Ledbetter
c8319c9166 LibWeb: Don't print messages from workers to the console twice
Previously, any message logged to the console within a worker with a
log level greater than trace was printed twice.

(cherry picked from commit d0008ae5e0100984f3188c32a67008a03c05bea8)
2024-11-11 19:54:09 -05:00
Timothy Flynn
85c6ca8417 LibWeb: Remove debug spam from Navigator methods
These are logged ~1000 times on fast.com.

(cherry picked from commit 76152845fdb74d4881c6d8e43790146780fbe7b3)
2024-11-11 19:54:09 -05:00
Shannon Booth
191b686699 LibWeb: Throw exception for invalid URL before creating traversable
Which fixes the following WPT test from failing due to issues stemming
from all of the windows which have been opened.

https://wpt.live/url/failure.html

This will give us 1205 new subtests passing in WPT.

(cherry picked from commit f2134dc1e960cb1d0c743b375509fe165885ddbe)
2024-11-11 17:22:42 -05:00
Shannon Booth
9150241db9 LibWeb: Throw a SyntaxError on invalid URL for Location href setter
Aligning with a spec update, fixing 195 tests for:

https://wpt.live/url/failure.html
(cherry picked from commit ea971792b5da5f10cadb4f88f49c9722d88b32f6)
2024-11-11 17:22:42 -05:00
Shannon Booth
e1e4b50a9c LibWeb: Put setting object's promise's in WindowOrWorkerGlobalScope
This aligns with an update to the HTML specification which instead
stores these promises on the global object instead of the settings
object.

It also makes progress towards implementing the ShadowRealm proposal
as these promises are not present in the 'synthetic' realm for that
proposal.

(cherry picked from commit 1096b6493668724ff9776929339e40b33213f410)
2024-11-11 09:14:29 -05:00
samu698
a37e4092bc LibWeb/HTML: Implement inner text set according to spec
Replaced the ad-hoc implementation with a spec compliant one.
This change fixes 36 WPT tests.

(cherry picked from commit 50f642613de54c73473c216fdc4d7e607e712679)
2024-11-10 21:48:40 -05:00
rmg-x
f30aed2e08 LibWeb/HTML: Check if evaluationStatus has a value before dereferencing
Previously, we would crash if scripting was disabled and a javascript
URL was evaluated.

(cherry picked from commit 57f82c029c1f66c516650d96c176ba0f47da0f78)
2024-11-10 21:48:40 -05:00
sideshowbarker
8c9acd4a76 LibWeb: Normalize all WebIDL definition lines to four leading spaces
This change takes all existing WebIDL files in the repo that had
definition lines without four leading spaces, and fixes them so they
have four leading spaces.

(cherry picked from commit 51528ec6779202747cc3b99d3b77772a124a0b47)
2024-11-10 21:19:33 -05:00
Andreas Kling
0897967771 LibWeb: Recompute targetStep during "apply the history step"
This is an ad-hoc change to account for the fact that we may run
arbitrary code while waiting for the tasks in this function to complete.

I don't have a way to reproduce it, but I've seen trouble caused by
navigables disappearing, which causes the history step numbers to be
disturbed.

(cherry picked from commit ac48222ed7b497b13343ec79a234ba432ffd29e2)
2024-11-10 20:06:23 -05:00
Tim Ledbetter
736255ae87 LibWeb: Avoid division by zero in SourceSet width descriptor calculation
(cherry picked from commit 087d4004721193c290b18515e90b047192880a70)
2024-11-10 18:24:10 -05:00
Andrew Kaster
1b36465eea LibWeb: Deduplicate attributes when emitting start and end tags
The HTML tokenizer specification says that we're supposed to do this
when leaving the Attribute name or when emitting the token, as
appropriate.

Hopefully 'as appropriate' can mean only when emitting the token, as
that's the easiest place to insert this logic without complicating the
tokenizer any more.

(cherry picked from commit 7aa0165fe75bb94b79bc847484c7913d249ce263)
2024-11-10 10:46:01 -05:00
Sam Atkins
efb32e1bcc LibWeb/HTML: Re-order promise resolution to match spec
Applies changes in https://github.com/whatwg/html/pull/10658 and also
whichever previous change split the step for firing the navigateerror
into two parts.

(cherry picked from commit ec15f8fa626e5b0faf5b3e420080e944ab31ff11)
2024-11-10 10:46:01 -05:00
Aliaksandr Kalenik
2a9b255b41 LibWeb: Forbid reentrancy of style-layout-repaint in EventLoop::process
Fixes crashing on https://playbiolab.com/ in
VERIFY(page.client().is_ready_to_paint()) caused by attempting to start
the next repaint before the ongoing repaint is done.

(cherry picked from commit f341af1d7265eee880355f10ef5d479c9ebceaf2)
2024-11-10 10:46:01 -05:00
Tim Ledbetter
fa08ac3631 LibWeb: Fire error event when script has an execution error
We now use the "report an exception" AO when a script has an execution
error. This has mostly replaced the older "report the exception" AO in
various specifications. Using this newer AO ensures that
`window.onerror` is invoked when a script has an execution error.

(cherry picked from commit 579a289d3db849657987c3310e7b1d71d290b566)
2024-11-10 10:46:01 -05:00
Jamie Mansfield
7003437a43 LibWeb/HTML: Implement TextTrackCueList idl interface
(cherry picked from commit cfec88feb312f3fbffe2270009a9ba07e2fd9b3f)
2024-11-10 10:46:01 -05:00
Jamie Mansfield
24f5f7289f LibWeb/HTML: Implement TextTrackCue idl interface
(cherry picked from commit 0b2449d8d264f58b39ed2a4a69b0afb8eb762011)
2024-11-10 10:46:01 -05:00
Daniel La Rocque
051f218007 LibWeb: Fix "attempt to update a history entry's document"
This updates our implementation of
[attempt-to-populate-the-history-entry's-document](https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document)
after fixes were made to the logic inside the queued task in
cdd014ae84 (diff-41cf6794ba4200b839c53531555f0f3998df4cbb01a4d5cb0b94e3ca5e23947dL99534).

(cherry picked from commit ed04124cbffbfe8b850e8e3a1bc0788513ce6a4d)
2024-11-10 10:46:01 -05:00
Timothy Flynn
dc60651607 LibWeb: Clean up HTMLInputElement-related includes
This mainly uses forward declarations as appropriate for input element
related files. This reduces the number of targets being built when we
change HTMLInputElement.h from 430 to 44.

(cherry picked from commit 57e4fb0caebb0074a23bef70d7558ce5e8a5f357)
2024-11-10 10:46:01 -05:00
Tim Ledbetter
76e28b6a2a LibWeb: Update close_top_level_traversable() to match the spec
(cherry picked from commit 583eef265fe9ba4f91a08e5ef1b7c7339f2371d7)
2024-11-10 10:46:01 -05:00
Andreas Kling
4172811f75 LibWeb: Abort ongoing fetch before starting a new link element fetch
If we decide to fetch another linked resource, we don't care about the
earlier fetch and can safely abort it.

This fixes an issue on GitHub where we'd load the same style sheet
multiple times and invalidate style for the entire document every time
it finished fetching.

By aborting the ongoing fetch, no excess invalidation happens.

(cherry picked from commit 57e26ed6b9b2c0cf1e4f5ac3e85ca0c7f3647caa)
2024-11-10 10:46:01 -05:00
Andreas Kling
adad01a830 LibWeb: Always flush character insertions before exiting HTML parser
This fixes an issue where document.write() with only text input would
leave all the character data as unflushed text in the parser.

This fixes many of the WPT tests for document.write().

(cherry picked from commit a0ed12e839f14b3ac80caca0e18a09ca256fd99d)
2024-11-10 10:46:01 -05:00
Andreas Kling
cfa323ed6e LibWeb: Let style elements remember which StyleSheetList they live in
Instead of trying to locate the relevant StyleSheetList on style element
removal from the DOM, we now simply keep a pointer to the list instead.

This fixes an issue where using attachShadow() on an element that had
a declarative shadow DOM would cause any style elements present to use
the wrong StyleSheetList when removing themselves from the tree.

(cherry picked from commit 8543b8ad6a4d96bd0c247052572b8c2abf3929a7)
2024-11-10 10:46:01 -05:00
Andreas Kling
38ed84421b LibWeb: Add StyleElementUtils::visit_edges()
Let's do this instead of making embedders visit every field of this
helper class.

(cherry picked from commit 2064be708f7318f72553fb210f918fe167e08257)
2024-11-10 10:46:01 -05:00
Tim Ledbetter
8bf45930df LibWeb: Expose crypto object to workers
This change moves the `crypto()` getter from `Window` to
`WorkerOrWindowGlobalScope`. This aligns our implementation with the
WebCrypto specification.

(cherry picked from commit 89b6cd3fb1b9a3058dbada9e12606950b466936a)
2024-11-09 16:08:01 -05:00
Simon Wanner
c7debcd4fd LibWeb: Handle http-equiv pragmas without insertion requirements
These pragmas are either ignored or handled elsewhere

(cherry picked from commit 77610db58cd7297ab30d4fe58f5c604ce1c291cb)
2024-11-09 16:08:01 -05:00
Simon Wanner
52ac4ad816 LibWeb: Use correct http-equiv keywords for comparisons
Previously `#keyword` was used in the macro, meaning all keywords
gained `""` around them

(cherry picked from commit d828d80b756468eb343aec074e7c9944d129437f)
2024-11-09 16:08:01 -05:00
Jamie Mansfield
25d3e1fe74 LibWeb: Implement AbstractWorker
This effectively implements Worker.onerror, and in future
SharedWorker.onerror.

(cherry picked from commit 3440d2b843331fca7392d29ea1b776935d1310de)
2024-11-09 16:08:01 -05:00
Jamie Mansfield
ee8de58b98 LibWeb/HTML: Implement DataTransferItem.webkitGetAsEntry()
(cherry picked from commit 2e9aec984cc3c75f10ea3e6f50ea2ed34f4bd2b6)
2024-11-09 16:08:01 -05:00
Khaled Lakehal
71a01c8122 LibWeb: Add setter implementation for location.search
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.

(cherry picked from commit 514a2a1757b10b9b4ff020237c84f70ba5a79c4b)
2024-11-09 16:08:01 -05:00
Jamie Mansfield
b20a9496f5 LibWeb: Implement ServiceWorkerContainer.onmessageerror
(cherry picked from commit f1098b4226bde9e574995a63eb3580be537d563d)
2024-11-09 12:29:58 -05:00
Jamie Mansfield
02d9f6186a LibWeb: Implement ServiceWorkerContainer.onmessage
(cherry picked from commit 4b1273cbde387b8f10d488ad90512ecb76b567cc)
2024-11-09 12:29:58 -05:00
Shannon Booth
125dfd9849 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.

(cherry picked from commit fc83653f3c7a650229d2be3eef0f1738a9395db9)
2024-11-09 07:30:40 -05:00
Shannon Booth
41e497d8f7 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.

(cherry picked from commit b6d2ab23322ebc6d667276257220c401fe025617)
2024-11-09 07:30:40 -05:00
Shannon Booth
74e0101cb1 LibWeb: Convert create_new_child_navigable to HeapFunction
(cherry picked from commit 3a7ccf8c25e56be550b66dda1d9d154e720c72e1)
2024-11-09 07:30:40 -05:00
Shannon Booth
72738891cb LibWeb: Port HTMLImageElement BatchingDispatcher to HeapFunction
(cherry picked from commit b86ddac11a747f45902aa575cde155818ffcfafb)
2024-11-09 07:30:40 -05:00
Colin Reeder
3b03c98e03 LibWeb: Fix handling of SSEs split across chunks
(cherry picked from commit 347928b9508df8f8effe92c372bd72873c4ba2aa)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
943f47fa97 LibWeb: Implement the setter for location.protocol
(cherry picked from commit 1365289d984c32ca7bc076b7892dd56041ab26e2)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
892c6c0439 LibWeb: Return empty string if object element data URL is invalid
(cherry picked from commit c61262684b51864618de99f8b302567c932455be)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
760fea7ffa LibWeb: Return empty string if image element currentSrc URL is invalid
(cherry picked from commit 4f7a4d9c578429b156f4dab78f4f8b0601be9f39)
2024-11-09 07:30:40 -05:00
Jelle Raaijmakers
fe5fa25f47 LibWeb: Implement the "fire a focus event" spec
We weren't setting the focus event's composed flag and view field
correctly.

(cherry picked from commit 124779a376a6951029f81bda980452440a6c6edf)
2024-11-09 07:30:40 -05:00
Shannon Booth
1afda6b82a 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

(cherry picked from commit ff71d8f2c97441bff5975c117a7e7c8820e33e44)
2024-11-09 07:30:40 -05:00
Colin Reeder
b2e5dd2458 LibWeb: Update stylesheet media value when changing link media attribute
(cherry picked from commit 00f75648e56f1077f5e18d8fca04da57afa93195)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
51854c4ffd LibWeb: Resolve HTMLFormElement.action relative to document base URL
Rather than returning a relative URL, an absolutized URL is now
returned relative to the document base URL

(cherry picked from commit 48e5d28ec985aeaee565d06a625a0d664b6975d3)
2024-11-09 07:29:52 -05:00
Tim Ledbetter
ec91831999 LibWeb: Implement HTMLInputElement.formAction
(cherry picked from commit 33c62be7f96eec887d8f65552bbd61439b09a346)
2024-11-09 07:29:52 -05:00
Tim Ledbetter
42d17fb875 LibWeb: Return document URL if formAction attribute is missing or empty
This change also ensures that relative URLs are resolved relative to
the document's base URL.

(cherry picked from commit c25dda767eb43d1620602ccc2c955bc56ef1745b)
2024-11-09 07:29:52 -05:00