Commit Graph

2637 Commits

Author SHA1 Message Date
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
Timothy Flynn
7085b7f127 LibWeb: Implement the DataTransfer types attribute
(cherry picked from commit 9f4e3c7e25bbc94a479a2a96cdbe85c47f634627)
2024-11-01 19:58:08 -04:00
Timothy Flynn
87d2766cd7 LibWeb: Implement the DataTransfer effect attributes
(cherry picked from commit 3674e037f38119e7b497b4a5c90707ff94cf44bb)
2024-11-01 19:58:08 -04:00
Timothy Flynn
cfd1c66552 LibWeb: Begin implementing the drag data store
(cherry picked from commit 9e98e63559ebaaf50e7260c62ea750869bb3613d)
2024-11-01 19:58:08 -04:00
Timothy Flynn
80c1ab0de1 LibWeb: Add an empty DataTransferItemList IDL implementation
(cherry picked from commit dcb76572e4d33e8ee91e3cb191dabf5099dd0bdb)
2024-11-01 19:58:08 -04:00
Timothy Flynn
7afdd457af LibWeb: Add an empty DataTransferItem IDL implementation
(cherry picked from commit 9e3c6921ab541cddeda186460ee96dc8e56a7192)
2024-11-01 19:58:08 -04:00
Andrew Kaster
425b1bef72 LibWeb: Visit the DataTransfer member of DragEvent
(cherry picked from commit b73bd76571a5be1d41eb667193cab2972604f58c)
2024-11-01 18:41:49 -04:00
Jamie Mansfield
ce7cbe3baa LibWeb: Implement NavigatorStorage mixin interface
Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
(cherry picked from commit e3b3041a0c87f4cfd6d7941963452c3c9428b487)
2024-11-01 18:23:28 -04:00
Timothy Flynn
3a3d8b15b7 LibWeb: Limit select-all actions to editable nodes when they are focused
If the user presses ctrl+a inside an <input> element, for example, we
now select that element's text only.

(cherry picked from commit 7ae7e3eef3d239d27855af02f455c2f61abfbe4e)
2024-11-01 16:16:08 -04:00
Jamie Mansfield
f3190e5ed6 LibWeb: Implement Navigator.doNotTrack
(cherry picked from commit 61e616c974ef2deb5edd4f85ae0a3b6da215521a)
2024-11-01 12:00:07 -04:00
Tim Ledbetter
ac68be994b LibWeb: Implement a minimal version of Window.find()
This is a non-standard API that other browsers implement, which
highlights matching text in the current window.

This is just a thin wrapper around our find in page functionality, the
main motivation for adding this API is that it allows us to write tests
for our find in page implementation.

(cherry picked from commit c4d5ae28ea40ae0a0c783f34d840fb94662780fb)
2024-11-01 09:38:01 -04:00
Nico Weber
a2763f9bbe LibWeb: Implement canvas lineJoin and miterLimit attributes 2024-10-25 21:30:08 -04:00
Nico Weber
d6e325ef6b LibGfx+Clients: Make Path::stroke_path() take a parameter struct
This makes several calling sites shorter, and makes it easier
to add a miter limit with less plumbing in the future.

This also exposed a bug in AffineDisplayListPlayerCPU.cpp: We weren't
passing path linecap style on. I added a FIXME for that for now.

No intended behavior change.
2024-10-25 20:35:23 -04:00
Sam Atkins
a627165df9 LibWeb/CSS: Make font-stretch a legacy alias for new font-width
CSS Fonts level 4 renames font-stretch to font-width, with font-stretch
being left as a legacy alias. Unfortunately the other specs have not yet
been updated, so both terms are used in different places.

(cherry picked from commit 4a67b28600437901e6d8a366c56a5ddd8665deb1)
2024-10-21 09:36:47 -04:00
Jelle Raaijmakers
004462c6e9 LibWeb: Implement history.scrollRestoration
(cherry picked from commit 2106617f5b97dd2e3c4aea11ef26685f43e75261)
2024-10-20 16:39:16 -04:00
Andreas Kling
1b73445f55 LibWeb: Note what's causing a style invalidation to happen
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.

I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.

(cherry picked from commit ddbfac38b0074819470766846fca08fd78630eb0;
minorly amended for conflicts in AK/Debug.h.in and
Meta/CMake/all_the_debug_macros.cmake due to us having more debug
macros. Also, downstream got alphabetical order for
STYLE_INVALIDATION_DEBUG wrong.)
2024-10-20 01:32:53 -04:00
Shannon Booth
3b2bf6534d 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.

(cherry picked from commit df4739d7ced4159deb2b3e40ba6a1a08b7e7dd5b)
2024-10-19 15:26:29 -04:00
Bastiaan van der Plaat
f19a183fe0 LibWeb: Add URL reflection to obsolete HTMLImageElement lowsrc property
(cherry picked from commit f2034270f14a72ebf0ac09493837c21bae0b4adf)
2024-10-19 15:26:29 -04:00
Colin Reeder
cd78e84e68 LibWeb: Also invalidate placeholder style on focus change
(cherry picked from commit cca03e484be96a3d833beff5834416c3c07dfbb2)
2024-10-19 15:26:14 -04:00
Timothy Flynn
c62dd41874 LibWeb: Move the navigable's cursor position to be owned by the document
Navigables are re-used for navigations within the same tab. Its current
ownership of the cursor position is a bit ad-hoc, so nothing in the spec
indicates when to reset the cursor, nor do we manually do so. So when a
cursor update happens on one page, that cursor is retained on the next
page.

Instead, let's have the document own the cursor. Each navigation results
in a new document, thus we don't need to worry about resetting cursors.

This also makes many of the callsites feel nicer. We were previously
often going from the node, to the document, to the navigable, to the
cursor. This patch removes the navigable hop.

(cherry picked from commit faebbbc281d1267062770b02fc6d962d92a3bd62)
2024-10-18 21:58:17 -04:00
Shannon Booth
b37d0b4bbb HTML: Partially implement HTMLInputElement's selection{Start,End}
Now that the implementation is in FormAssociatedElement, the
implementation in HTMLInputElement is effectively just a passthrough,
with some minor differences to handle small behavioural quirks between
the two (such as the difference in nullability of types).

(cherry picked from commit 9f24176cac862c42c9cf4d3ac0e757397a5f6ae1)
2024-10-18 21:58:17 -04:00
Shannon Booth
744b0e2d02 HTML: Put HTMLTextAreaElement selection helpers in FormAssociatedElement
This will allow us to more closely follow the spec and share these
functions with HTMLInputElement.

(cherry picked from commit 62bf428a7f57b585e6d0b8c01af2c0aca336fe2c)
2024-10-18 21:58:17 -04:00
Shannon Booth
8a469cf7e4 HTML: Add const qualified form_associated_element_to_html_element
Put the const cast in a common location to make the helper more
convenient to use.

(cherry picked from commit 28ed8e5d0f79fc9d961f746367127e137faaf46b)
2024-10-18 21:58:17 -04:00
Timothy Flynn
cb17194de8 LibWeb: Avoid allocating UTF-16 strings only the UTF-16 length is needed
(cherry picked from commit 4a166a45ec9db910542893133f08cc7de4ec974f,
minorly amended to resolve #include conflict due to our LibLocale
and LibUnicode being separate -- we don't want
https://github.com/LadybirdBrowser/ladybird/pull/257)
2024-10-18 18:21:18 -04:00
Tim Ledbetter
df8eec7786 LibWeb: Change attribute type to USVString where applicable
Also mark USVString attributes as containing a URL, where applicable.

(cherry picked from commit 1369fc5069598644842defabbfbf3d30d2f3e647)
2024-10-17 21:31:52 -04:00
Shannon Booth
db4bab8041 LibURL: Make percent_encode return a String
This simplifies a bunch of places which were needing to error check and
convert from a ByteString to String.

(cherry picked from commit 84a7fead0eefd967d4319f4d71c0a0ca3095d2d1)
2024-10-16 23:56:40 -04:00