Commit graph

63749 commits

Author SHA1 Message Date
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
7b45d6a6ab LibWeb: Allow WebSockets to be established within workers
Previously, we would crash when attempting to establish a web socket
connection from inside a worker, as we were assuming that the ESO's
global object was a `Window`.

(cherry picked from commit 0c0595bb31db827fc14b5d16b8645bc6aa912d60)
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
rmg-x
2d67391151 UI/Qt: Move "Open in New Tab" to the top of the link context menu
(cherry picked from commit 7a2d837c8ab137d8d31b3789dfe7ef377b3b225e)
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
88b2d705e2 LibWeb: Invalidate less style on textContent change and node removal
...unless there are :has() selectors present. Then we have to invalidate
everything for now.

(cherry picked from commit b8ce34068f5bf8ab8cf049d56b864bff52ef3dff)
2024-11-10 10:46:01 -05:00
Andreas Kling
a49ba1914a LibWeb: Distinguish parent/child on style invalidation for DOM insertion
(cherry picked from commit 7d644ecd50c57454dfb73b92e59d7112d54a1b1d)
2024-11-10 10:46:01 -05:00
Andreas Kling
66c8631bf8 LibWeb: Don't try to invalidate style for character data nodes
Character data nodes like text and HTML comments don't have style,
so let's just exit invalidation immediately for those.

(cherry picked from commit f351f75a34619ad969f660312a2e5486f742f685)
2024-11-10 10:46:01 -05:00
Andreas Kling
319dd59fc4 LibWeb: Cache whether there are any :has() selectors present
As useful as they may be to web developers, :has() selectors complicate
the style invalidation process quite a lot.

Let's have StyleComputer keep track of whether they are present at all
in the current set of active style sheets. This will allow us to
implement fast-path optimizations when there are no :has() selectors.

(cherry picked from commit 8beb7c77002a3359ad2fe73969fc6bb2dbc75413)
2024-11-10 10:46:01 -05:00
Andreas Kling
f23323d3d7 LibWeb: Include siblings+descendants when invalidating style
When an element is invalidated, it's possible for any subsequent sibling
or any of their descendants to also need invalidation. (Due to the CSS
sibling combinators, `+` and `~`)

For DOM node insertion/removal, we must also invalidate preceding
siblings, since they could be affected by :first-child, :last-child or
:nth-child() selectors.

This increases the amount of invalidation we do, but it's more correct.

In the future, we will implement optimizations that drastically reduce
the number of elements invalidated.

(cherry picked from commit df048e10f5a84d7fd90b1115c6bb90f45acd75ec)
2024-11-10 10:46:01 -05:00
Andreas Kling
b0b5a056b3 LibWeb: Allow setting shorthand CSS properties via CSSStyleDeclaration
We now expand shorthands into their respective longhand values when
assigning to a shorthand named property on a CSSStyleDeclaration.

We also make sure that shorthands can be round-tripped by correctly
routing named property access through the getPropertyValue() AO,
and expanding it to handle shorthands as well.

A lot of WPT tests for CSS parsing rely on these mechanisms and should
now start working. :^)

Note that multi-level recursive shorthands like `border` don't work
100% correctly yet. We're going to need a bunch more logic to properly
serialize e.g `border-width` or `border` itself.

(cherry picked from commit e40ad73ae79023f64e250f854d0730c21e0f54fc)
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
Tim Ledbetter
5272446a09 LibWeb: Return a WindowProxy from document.defaultView
This aligns our implementation with the most recent specification steps.

(cherry picked from commit 089139f09dbc78455c5c09916cbc97e33f823ca0)
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
Annya
a371e02c5f LibWeb: Implement Range's extension method
This patch implements `Range::getClientRects` and
`Range::getBoundingClientRect`. Since the rects returned by invoking
getClientRects can be accessed without adding them to the Selection,
`ViewportPaintable::recompute_selection_states` has been updated to
accept a Range as a parameter, rather than acquiring it through the
Document's Selection.

With this change, the following tests now pass:

- wpt[css/cssom-view/range-bounding-client-rect-with-nested-text.html]
- wpt[css/cssom-view/DOMRectList.html]

Note: The test
"css/cssom-view/range-bounding-client-rect-with-display-contents.html"
still fails due to an issue with Element::getClientRects, which will
be addressed in a future commit.

(cherry picked from commit 75c7dbc5d2dd045733a4c319aeab6644b5b7b36d)
2024-11-10 10:46:01 -05:00
ronak69
ec2ee2720a LibWebView: Do floating-point-error-free zoom calculation using rounding
The current min/max zoom levels are supposed to be: 30% and 500%.
Before, due to floating point error accumulation in incremental addition
of zoom-step into zoom-level, one extra zoom step would get allowed,
enabling user to zoom 20%-to-510%.

Now, using rounding, the intermediate zoom-level values should be as
close to the theoretical value as FP32 can represent. E.g. zoom-level of
70% (theoretical multiplier 0.7) is 0.69... .

(cherry picked from commit 96335f31d5a8c6180a4cc0254585bc01ba6742fa)
2024-11-10 10:46:01 -05:00
Andreas Kling
4779c6ac60 LibWeb: Keep custom properties from all cascade layers
Before this change, we were cascading custom properties for each layer,
and then replacing any previously cascaded properties for the element
with only the set from this latest layer.

The patch fixes the issue by making each pass of the custom property
cascade add to the same set, and then finally assigning that set of
properties to the element.

(cherry picked from commit 95bd0602ba079e0bd7608e39bcbc3b0403ed89d1)
2024-11-10 10:46:01 -05:00
Ninad Sachania
37c789475e Screenshot: Add mutually exclusive output options 2024-11-10 08:47:12 -05:00
Nico Weber
9f53517674 Meta: Add {Entries,MediaCapabilities}API, AbstractWorker to GN 2024-11-09 16:08:01 -05:00
ronak69
c74a70ea1d UI/Qt: Do not perform search if query text is empty
(cherry picked from commit 276ad23b7090a3edc778a6d48e8ff2ff450f2896)
2024-11-09 16:08:01 -05:00
PiyushXCoder
2b84c92566 UI/Qt: Don't allow tabs to be dragged past the new tab button
Before this change, if would a tab it will pass the add new tab button
(+ button).

closes #1124

(cherry picked from commit 9b79081a0601ef6649592acc1025b12c52e63d5c)
2024-11-09 16:08:01 -05:00
Aliaksandr Kalenik
8d56f0ed15 LibWeb: Print FIXME instead of crashing in abspos SVG element layout
Currently we are crashing in `verify_cast<BlockContainer>(box)` on
attempt to create BFC for SVG box.

(cherry picked from commit fa907029ee6f202095011b84b109bc4a2b56c58b)
2024-11-09 16:08: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
Aliaksandr Kalenik
df69fd9a66 LibWeb: Resolve floating box's paddings before width calculation
...because calculate_inner_width() assumes layout state has resolved
paddings that could be used to account for "box-sizing: border-box".

Fixes regression introduced in 5f74da6ae8ad470ad0ce325f570faa97292384ba

(cherry picked from commit d6a31d80c05db05c34cd56ca865658a5b82dbb69)
2024-11-09 16:08:01 -05:00
Tim Ledbetter
127e01cf47 LibWeb/WebDriver: Use correct dimensions for WPT reftest screenshots
Reftest screenshots are now captured using the dimensions specified in
the draw a bounding box from the framebuffer AO defined in the
WebDriver specification.

(cherry picked from commit b4aff45854bd0d9aaaf76cdbb4f07411bd240755)
2024-11-09 16:08:01 -05:00
Andreas Kling
81f60e2077 LibWeb: Use LayoutState::UsedValues::containing_block_used_values() more
Use this cached pointer to the containing block's used values when
obviously possible. This avoids a hash lookup each time, and these
hash lookups do show up in profiles.

(cherry picked from commit bdb67d2bcb4ab6fa49292c3365facdeab1fd0e20)
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
Tim Ledbetter
961272cf60 LibWeb: Don't crash when determining slot element auto directionality
(cherry picked from commit 0de314507153b6ae17d15f3b03df10a7844ed224)
2024-11-09 16:08:01 -05:00
Tim Ledbetter
d460654347 UI/Qt: Don't change LocationEdit cursor position on right click
Previously, right clicking highlighted text in the location bar would
cause the current selection to be lost.

(cherry picked from commit 6c608bac659b7e39be52ffecd68ecd46172665bc)
2024-11-09 16:08:01 -05:00
sideshowbarker
f60110e5d2 LibWeb: Add CEReactions to all IDL for all ARIA attributes
This change adds the [CEReactions] attributes to all ARIA attributes in
the ARIAMixin WebIDL — as required by the WebIDL in the current spec at
https://w3c.github.io/aria/#ARIAMixin, and by the WPT test case at
http://wpt.live/custom-elements/reactions/AriaMixin-string-attributes.html,
and as implemented in other existing engines.

Otherwise, without this change, Ladybird doesn’t conform to the current
spec, fails all those tests, and isn’t interoperable with other engines.

(cherry picked from commit 6bf3d34a6709b5067be0b705ce5a8ed8d4cbfa00)
2024-11-09 16:08:01 -05:00
Noah Bright
80864a9b55 WebDriver: Add boilerplate for endpoint 15.7 Perform Actions
Following the structure of the ReleaseActions endpoints, define
analogous classes and methods for PerformActions

(cherry picked from commit ee352e59dbd4d2b8fbfbec396cb5232a13291274)
2024-11-09 16:08:01 -05:00
Tim Ledbetter
5d9aac0330 LibWeb: Abort dependent signals before firing abort event
Previously, there was a bug in the specification that would cause an
assertion failure, due to the abort event being fired before all
dependent signals were aborted.

(cherry picked from commit 3ae4ea7b10e5022079d0b203844fc93899c08a09)
2024-11-09 16:08:01 -05:00
Aliaksandr Kalenik
5d6ddc5a16 LibWeb: Remove unnecessary copying of UsedValues in BFC
(cherry picked from commit 4ba38c55d6b0f2ad49dd1c84e566412cb9ccc9ed)
2024-11-09 16:08:01 -05:00
Aliaksandr Kalenik
6f7297446a LibJS: Reset in_formal_parameter_context after entering a new function
Fixes a bug when "'Await' expression is not allowed in formal parameters
of an async function" is thrown for "await" encountered in a function
definition assigned to a default function parameter.

Fixes loading of https://excalidraw.com/

(cherry picked from commit 10064d0e1a89a4f48dc1e896de35a65f2ab946f4)
2024-11-09 16:08:01 -05:00
Timothy Flynn
41241828d8 WebContent+WebDriver: Properly define and invoke stubbed methods
(cherry picked from commit 0a482e1a53c7c5fef311abda955557d872402ae0)
2024-11-09 16:08:01 -05:00
Han
423e37b974 WebDriver: Add Routes, IPC definitions, and boilerplates
Added the following Routes, IPC definitions, and boilerplates for the
missing endpoints:

- Switch To Frame
- Switch To Parent Frame
- Element Clear
- Element Send Keys

(cherry picked from commit d1ba317e22d41fd948fd477d44735918a972c158)
2024-11-09 16:08:01 -05:00
Andreas Kling
33bfcc467b LibJS: Don't copy current program counter into new execution contexts
This didn't make any sense, and was already handled by pushing a new
execution context anyway.

By simply removing these bogus lines of code, we fix a bug where
throwing inside a function whose bytecode was shorter than the calling
function would crash trying to generate an Error stack trace (because
the bytecode offset we were trying to symbolicate was actually from
the longer caller function, and not valid in the callee function.)

This makes --log-all-js-exceptions less crash prone and more helpful.

(cherry picked from commit b3f77e47690cfd07058d824ea6f0b652489778bf)
2024-11-09 16:08:01 -05:00
sideshowbarker
8ce5f6257b Tests: Add some colorful pass/fail emoji to a test case
This change adds green and red pass/fail emoji indicators to an in-tree
test — to make it easier to manually scan through the test results and
quickly see which cases are passing, and which are failing.

(cherry picked from commit 6f5d0de5e780f10c63d168bb1d29c69a963376ac)
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
Timothy Flynn
4afa0a1973 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

(cherry picked from commit e782947a03d00f08fcfb16d4164c9edcd9155caf)
2024-11-09 16:08:01 -05:00
Timothy Flynn
464a0b9756 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

(cherry picked from commit 48bef246a0720ae4610b6f9c5dcd42eb8c5b448d)
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
Jamie Mansfield
722e144eba LibWeb/EntriesAPI: Implement FileSystemEntry
(cherry picked from commit 169163b0023302ae3a0762d875e7b7840cfcb687)
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
Thomas Klausner
e81705c9a5 LibGfx: Fix build on NetBSD
NetBSD provides its own popcount() function.

(cherry picked from commit c99674c6ac362508838efbc0ef58a9dfe8779890)
2024-11-09 16:08:01 -05:00
Ninad Sachania
272bc8a803 Utilities/fortune: Fix typo 2024-11-09 12:30:43 -05:00
Ninad Sachania
837012d650 Utilities/json: Add option to control colorized output 2024-11-09 12:30:12 -05:00
Jamie Mansfield
b20a9496f5 LibWeb: Implement ServiceWorkerContainer.onmessageerror
(cherry picked from commit f1098b4226bde9e574995a63eb3580be537d563d)
2024-11-09 12:29:58 -05:00