Commit graph

64571 commits

Author SHA1 Message Date
Jelle Raaijmakers
185335ac63 LibWeb: Remove superfluous VERIFY from StackingContext
We just checked if it's an SVG box, let's not do it again.
2024-10-31 00:59:32 +01:00
Sam Atkins
760943d584 LibWeb/CSS: Correct matching of calc() against <number-percentage>
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This seems to have vanished from the spec, but in any case, we still
need it. Without this change we erroneously thought that calculations
that match <percentage> did not match <number-percentage>.
2024-10-30 20:58:16 +01:00
Shannon Booth
797b0d0f43 LibJS+LibWeb: Remove remaining use and reference to SafeFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
716e86f042 LibJS: Use HeapFunction for async body closure in Array.fromAsync 2024-10-30 20:55:45 +01:00
Shannon Booth
e6d1123ce8 LibWeb: Make ResourceLoader callbacks HeapFunctions 2024-10-30 20:55:45 +01:00
Shannon Booth
1c18b900e2 LibWeb: Port EventLoop::spin_XXX to HeapFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
29cea5bd24 LibWeb: Make EventLoopPlugin::deferred_invoke take a HeapFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
7487a782db LibWeb: Use HeapFunction for EventLoopPlugin::spin_until 2024-10-30 20:55:45 +01:00
Shannon Booth
de1a805898 LibWeb: Use HeapFunction for Platform::Timer 2024-10-30 20:55:45 +01:00
Shannon Booth
ede3c91688 LibWeb: Make Platform::Timer GC-allocated
This will allow us to remove the use of SafeFunction in it's
implementation. This requires a fair amount of plumbing to wire up the
GC heap to the appropriate places in order to create the timers.
2024-10-30 20:55:45 +01:00
Shannon Booth
e44702f090 LibWeb: Construct ResourceLoader with a GC Heap
This will allow us to easily make use of HeapFunctions instead of
SafeFunction for all of the callbacks in ResourceLoader.
2024-10-30 20:55:45 +01:00
Aliaksandr Kalenik
a8077f79cc LibWeb: Separate text control input events handling from contenteditable
This input event handling change is intended to address the following
design issues:
- Having `DOM::Position` is unnecessary complexity when `Selection`
  exists because caret position could be described by the selection
  object with a collapsed state. Before this change, we had to
  synchronize those whenever one of them was modified, and there were
  already bugs caused by that, i.e., caret position was not changed when
  selection offset was modified from the JS side.
- Selection API exposes selection offset within `<textarea>` and
  `<input>`, which is not supposed to happen. These objects should
  manage their selection state by themselves and have selection offset
  even when they are not displayed.
- `EventHandler` looks only at `DOM::Text` owned by `DOM::Position`
  while doing text manipulations. It works fine for `<input>` and
  `<textarea>`, but `contenteditable` needs to consider all text
  descendant text nodes; i.e., if the cursor is moved outside of
  `DOM::Text`, we need to look for an adjacent text node to move the
  cursor there.

With this change, `EventHandler` no longer does direct manipulations on
caret position or text content, but instead delegates them to the active
`InputEventsTarget`, which could be either
`FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or
`EditingHostManager` (for `contenteditable`). The `Selection` object is
used to manage both selection and caret position for `contenteditable`,
and text control elements manage their own selection state that is not
exposed by Selection API.

This change improves text editing on Discord, as now we don't have to
refocus the `contenteditable` element after character input. The problem
was that selection manipulations from the JS side were not propagated
to `DOM::Position`.

I expect this change to make future correctness improvements for
`contenteditable` (and `designMode`) easier, as now it's decoupled from
`<input>` and `<textarea>` and separated from `EventHandler`, which is
quite a busy file.
2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
380907cd48 LibWeb: Allow TextCursor hit-testing mode select empty contenteditable 2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
20852443d3 LibWeb: Clamp end offset in CharacterData::replace_data()
Makes this method to not fail if updating of start offset (which happens
before update of the end offset) already moved end offset to the end of
string on the following step:

> 1. If range’s root is not equal to node’s root, or if bp is after the
     range’s end, set range’s end to bp.
2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
da26941b50 LibWeb: Use cached word segmenter for word selection in EventHandler 2024-10-30 19:29:56 +01:00
Andreas Kling
33507578e0 Tests: Skip css/css-flexbox/abspos/position-absolute-001.html for now
This test is too slow for our GCC CI :^(
2024-10-30 18:45:14 +01:00
Sam Atkins
51fc87bc1b LibWeb/CSS: Return 0 from CSSRule.type for non-spec types
We use the CSSRule::Type enum for identifying the type of a CSSRule, but
the spec requires that only some of these types are exposed via the
`type` attribute. For the rest, we're required to return 0, so let's do
so. :^)
2024-10-30 17:30:58 +01:00
Pavel Shliak
4998385c7a LibAudio: Initialize GainNode properly
That helps to pass WPT tests
under /webaudio/the-audio-api/the-gainnode-interface/ctor-gain.html
2024-10-30 17:30:51 +01:00
stelar7
5630a0d6b4 Meta: Add a script to import WPT tests 2024-10-30 17:29:03 +01:00
Aliaksandr Kalenik
04289fe24e LibWeb: Remove usage of math functions from std namespace
Fixes compilation error with clang from Homebrew introduced in
https://github.com/LadybirdBrowser/ladybird/pull/1962
2024-10-30 17:10:31 +01:00
Florian Cramer
df7cac539e LibXML: Set the doctype when parsing via Parser::parse_with_listener
This fixes at least one WPT test under /domparsing
2024-10-30 14:53:36 +01:00
Gingeh
bd25d0b1b4 LibWeb: Parse drop-shadow filter with missing or starting color
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-10-30 12:41:02 +01:00
Pavel Shliak
0e9c865805 LibWeb: Remove variable self-assignment 2024-10-30 07:40:24 -04:00
Andreas Kling
3180df3337 LibJS: Parse dates like "Tuesday, October 29, 2024, 18:00 UTC"
This format is used on https://jetbrains.com/
2024-10-30 10:47:48 +01:00
Khaled Lakehal
14e1e55319 LibWeb: Implement HTML spec-compliant rules for floating-point parsing
Attempt to implement HTML specs for parsing floating-point number
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
2024-10-30 10:47:41 +01:00
Pavel Shliak
ba71cb1ca4 LibJS: Add calendar id getter to ZonedDateTimePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
2ad48b64ca LibJS: Add calendar id getter to PlainMonthDayPrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
0e1e8c908e LibJS: Add calendar id getter to PlainYearMonthPrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
44fa8410c0 LibJS: Add calendar id getter to PlainDateTimePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
f7cf7382c9 LibJS: Add calendar id getter to PlainDatePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
e60c1ddd4d LibJS: Adds calendar_id identifier 2024-10-30 10:29:48 +01:00
Jonne Ransijn
04920d06f0 AK: Use simdutf when appending UTF-16 to StringBuilder
Adds a fast path for valid UTF-16 using `simdutf`, and fall back to
the slow path for unmatched surrogates.
2024-10-30 10:28:24 +01:00
Jonne Ransijn
ff6020c207 LibJS: Optimize IsStringWellFormedUnicode using simdutf
`simdutf` has a function for this that is much faster.
2024-10-30 10:28:24 +01:00
Alan Kemp
d2fbbabd89 LibWeb: Pageshow event dispatched by the user agent should be trusted
The spec says that "isTrusted is a convenience that indicates whether
an event is dispatched by the user agent (as opposed to using
dispatchEvent())"

But when dispatching a pageshow event the flag was incorrectly set
to false.

This fixes https://wpt.fyi/results/html/syntax/parsing/the-end.html
2024-10-30 10:27:20 +01:00
Andreas Kling
64f18a93c2 LibWeb: Make align-content on flex container behave more correctly
In particular, this property now interacts correctly when the flex
container has flex-wrap: wrap-reverse.

This caused some "regressions" in WPT tests for negative overflow in
flex containers, but the previous behavior wasn't correct either,
it just happened to give false positives on tests.
2024-10-30 10:17:21 +01:00
Andreas Kling
abd24d001d Tests: Import a bunch of WPT tests from /css/css-flexbox 2024-10-30 10:17:21 +01:00
Andreas Kling
0ebdac0b35 Tests: Don't print full error messages in imported WPT tests
...when running in test mode. This cuts down on the time it takes to run
the imported WPT tests, and you can still get the full error by opening
tests in the browser.
2024-10-30 10:17:21 +01:00
Timothy Flynn
53d5c7084e UI/AppKit: Extract bare minimum WebView functionality into its own class
When a window containing a WebView becomes visibile, we have to inform
WebContent. This was only implemented for the Tab class (not Inspector
or Task Manaager).

This patch adds LadybirdWebViewWindow to contain the bare minimum needed
to render a LadybirdWebView. All windows containing a WebView inherit
from this class, to ensure their WebContent processes know they became
visible.
2024-10-30 08:51:14 +01:00
Timothy Flynn
7b3a3c2066 LibJS+LibWeb: Remove now-unused lexical environment override
In our current bytecode interpreter, this override cannot work anyways.
2024-10-30 08:50:31 +01:00
Timothy Flynn
2e71e300ee WebContent: Restore ability to use Inspector accessors like "$0"
We implement these built-in accessors via a lexical environment override
on the inspected document's global scope. However, ClassicScript will
parse the script we provide as a JS program, in which any evaluated
bindings will be interpreted as global bindings. Our global binding
lookup in the bytecode interpreter does not search the lexical env for
the binding, thus scripts like "$0" fail to evaluate.

Instead, we can create an ECMAScriptFunctionObject to evaluate scripts
entered into the Inspector. These are not evaluated as JS programs, and
thus any evaluated bindings are interpreted as non-global bindings. The
lexical environment override we set will then be considered.
2024-10-30 08:50:31 +01:00
Timothy Flynn
99d4c2de29 LibWeb: Make WebDriver's script executor public and a bit more general
The steps to execute a function body in WebDriver is exactly the
behavior we want with the Inspector.
2024-10-30 08:50:31 +01:00
Tim Ledbetter
464a875416 LibWebSocket: Don't send closing frame if connection is already closed 2024-10-30 08:48:17 +01:00
Aliaksandr Kalenik
e95226839e LibWeb: Fix infinite recursion when max-width is min/max-content in GFC
Treat max-width as auto when it's specified to min/max-content and
available size is intrinsic constraint.

Fixes stack overflow on https://claude.ai/
2024-10-30 08:47:52 +01:00
sideshowbarker
58b07bc531 Tests: Import WPT html/dom/aria-attribute-reflection.html test
This change imports the WPT html/dom/aria-attribute-reflection.html test
into being an in-tree test — and deletes the related existing test
from https://github.com/LadybirdBrowser/ladybird/commit/a924e8747a4
previously “ported” from the WPT with changes to run under our (non-WPT)
in-tree test harness.
2024-10-30 08:47:23 +01:00
Andreas Kling
d78c81a9fd Tests: Import LICENSE.md from WPT 2024-10-30 08:28:51 +01:00
Nico Weber
421cf8d9bf LibWeb: Parse stroke-{linejoin,miterlimit} attributes
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Similar to LadybirdBrowser/ladybird#1714.

We don't implement the linejoin values `miter-clip` and `arcs`, because
according to the SVG 2 spec:

> The values miter-clip and arcs of the stroke-linejoin property are at
> risk. There are no known browser implementations. See issue Github
> issue w3c/svgwg#592.

Nothing uses this yet. The next step is to change
SVGPathPaintable::paint() to read `graphics_element.stroke_linejoin()`
and `graphics_element.stroke_miterlimit()` when painting.
2024-10-29 22:37:00 +00:00
Nico Weber
eafcd82e82 LibWeb: Support stroke-linecap as attribute as well
This should have been part of #1714.

(stroke-linecap still isn't implemented, but once it is, it will
now work in attribute form as well.)
2024-10-29 22:37:00 +00:00
Piotr
205155a7ab LibWeb: Set textarea rows and cols default value if 0
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
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.
2024-10-29 16:05:32 +01:00
Sam Atkins
5723ed3443 Tests: Add clip-path to calc() coverage test 2024-10-29 16:05:16 +01:00
Sam Atkins
ec9d67ae17 Tests: Add filter and backdrop-filter to calc() coverage test
Neither of these currently work correctly. This is just so we keep track
of them.
2024-10-29 16:05:16 +01:00