Commit graph

35087 commits

Author SHA1 Message Date
Tim Ledbetter 107549dc86 LibWeb/WebDriver: Align execute script methods with the specification
This change updates `ExecuteScript::execute_script()` and
`ExecuteScript::execute_script()` to bring their behavior in line with
each other and the current specification text.

Instances of the variable `timeout` have also been renamed to
`timeout_ms`, for clarity.
2024-09-06 09:54:16 +02:00
Sam Atkins a50da405e9 LibWeb/CSS: Implement cascade layers (aka @layer)
This is done quite simply for now, there are certainly optimizations
that can and should be made later.

With this we now pass:
- http://wpt.live/css/css-cascade/layer-basic.html
- http://wpt.live/css/css-cascade/layer-important.html
- http://wpt.live/css/css-cascade/layer-statement-copy-crash.html
- http://wpt.live/css/css-cascade/layer-stylesheet-sharing-important.html
- http://wpt.live/css/css-cascade/layer-stylesheet-sharing.html
- http://wpt.live/css/css-cascade/layer-vs-inline-style.html
2024-09-06 07:49:55 +02:00
Sam Atkins cbb4be3e5e LibWeb/CSS: Replace style-rule iteration methods with a generic one
I didn't want to add another set of boilerplatey tree-walking methods,
so here's a general-purpose one. :^)

`for_each_effective_rule()` walks the tree of effective style rules, and
runs the callback on each one, in either pre- or postorder.  The
previous `for_each_effective_style/keyframes_rule()` methods of
`CSSStyleSheet` are then reimplemented in terms of
`for_each_effective_rule()`, and we can get rid of their equivalents
elsewhere.
2024-09-06 07:49:55 +02:00
Sam Atkins 4c98906e2c LibWeb/CSS: Parse @layer rules
This causes us to pass all of
http://wpt.live/css/css-cascade/parsing/layer.html :^)
2024-09-06 07:49:55 +02:00
Sam Atkins 1c6133aa52 LibWeb/CSS: Add CSSOM types for @layer rules
Depending on usage, `@layer` has two forms, with two different CSSOM
types. One simply lists layer names and the other defines a layer with
its contained rules.
2024-09-06 07:49:55 +02:00
Timothy Flynn bf9d05d97a LibWeb: Re-assign cmd+arrow key events to home/end keys on macOS
In text documents, pressing the left/right arrow keys with the cmd key
pressed should be treated as home/end key presses.
2024-09-06 07:42:59 +02:00
Timothy Flynn a0072f422a LibWeb: Support jumping across word boundaries in text nodes
This also supports holding shift to modify the selection.
2024-09-06 07:42:59 +02:00
Timothy Flynn ecf2cc600b LibWeb: Add Document helpers to move its cursor to word boundaries
This implementation is based on the same feature I added to Serenity's
TextEditor:

https://github.com/SerenityOS/serenity/pull/17477
2024-09-06 07:42:59 +02:00
Timothy Flynn eece7697fd LibWeb: Rename CharacterData's segmenter indicate it is for graphemes
We will be adding a word segmenter as well, so this is to disambiguate
the two.
2024-09-06 07:42:59 +02:00
Timothy Flynn feecf89d65 LibWeb: Define a helper constant for the platform word-jumping key
On Linux/Windows, the ctrl key is used in conjunction with arrow keys to
jump word-by-word in text documents. On macOS, the option key is used
(which is mapped to the alt key code).
2024-09-06 07:42:59 +02:00
Timothy Flynn 3e116769fb LibUnicode: Add code point GC queries for Punctuation and Separator 2024-09-06 07:42:59 +02:00
Timothy Flynn ed3c450359 LibWebView+UI: Move the database and cookie jar to WebView::Application
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
The main motivator here was noticing that --disable-sql-database did not
work with AppKit. Rather than re-implementing this there, move ownership
of these classes to WebView::Application, so that each UI does not need
to individually worry about it.
2024-09-05 19:45:47 -04:00
Timothy Flynn 60f30aad72 LibWeb: Limit the minimum scrollbar size to the overflown box's size
A hard-coded value of 50px is too large for text boxes with a size that
is less than 50px. Reduce this to 24px, and further limit it by the size
of the overflown box.
2024-09-06 01:34:40 +02:00
BenJilks 7e38e12bb0 LibWeb: Use transform-box for resolving percentage transform values
Some checks are pending
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (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-22.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
Factor out computing the transform box rect into its own method. Then
use it when resolving the transformation matrix, to compute percentage
values.
2024-09-05 19:22:26 +02:00
Aliaksandr Kalenik a9d5a99568 LibGfx+LibWeb: Replace remaining OpenType implementation with Skia
This change should move us forward toward emoji support, as we are no
longer limited by our own OpenType implementation, which was failing
to parse the TrueType Collection format used to store emoji fonts
(at least on macOS).
2024-09-05 19:21:52 +02:00
Aliaksandr Kalenik 99f64139d0 LibGfx+WebContent: Load resource://fonts after FontDatabase construction
This is a preparation for upcoming changes where Gfx::Typeface will
depend on `FontDatabase::should_force_fontconfig()`, so we will no
longer be able to construct typefaces from FontDatabase constructor
because of circular dependency.
2024-09-05 19:21:52 +02:00
Aliaksandr Kalenik db74244fb2 LibWeb: Read header to check if a blob without mime type is WOFF/WOFF2
Currently we rely on parser returning an error if encoded data cannot be
parsed into a valid WOFF or WOFF2 font, which is not going to be true
after switching to Skia that sometimes does not fail even if a data does
not represent a valid font.
2024-09-05 19:21:52 +02:00
Aliaksandr Kalenik 8cd6682e6f LibGfx+WebContent: Remove unused Font::variant() and Typeface::variant() 2024-09-05 19:21:52 +02:00
Tim Ledbetter b4652e4895 LibWeb: Account for scroll offset when interacting with media controls
Previously, using the mouse to interact with the media player wouldn't
work as expected if the page had been scrolled vertically or
horizontally.
2024-09-05 18:11:31 +02:00
Jamie Mansfield 936ca720b4 LibWeb: Implement WorkerNavigator.mediaCapabilities 2024-09-05 14:52:26 +01:00
Jamie Mansfield f08946bcd2 LibWeb: Implement Navigator.mediaCapabilities
This is enough to stop Crunchyroll showing an unsupported browser
modal :^)
2024-09-05 14:52:26 +01:00
Jamie Mansfield 4c5a176354 LibWeb: Stub MediaCapabilities IDL interface 2024-09-05 14:52:26 +01:00
Timothy Flynn 1240aaa294 LibWeb: Update editable node selections with arrow/home/end keys
When an editable node is focused and one of the arrow/home/end keys are
pressed while shift is held, we will now create or update the document's
selection. There is a bit of nuance to the behavior here, which matches
how the cursor behaves in other engines.

We will of course want to abstract this in the future to extend any non-
editable node text selections. This also does not implement holding ctrl
to jump by word, rather than grapheme.
2024-09-05 14:37:57 +01:00
Timothy Flynn 7ae7e3eef3 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.
2024-09-05 14:37:57 +01:00
BenJilks 813612096c LibWeb: Test for hits around fragments in InlinePaintable
This allows you to select text at the end of fragments, just like in
non-inline elements.
2024-09-05 14:19:01 +01:00
BenJilks 8c465c95aa LibWeb: Pick the closest hit test result, instead of the first
When performing a hit test of type TextCursor, it would check if the
position is around each fragment and not just inside it. This resulted
in always selecting the first fragment checked.

This commit computes the distance of each hit test result, and picks the
closest one.
2024-09-05 14:19:01 +01:00
BenJilks ef037b4152 LibWeb: Use the correct dimension when computing the max grid size
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
When deciding if the grid containers min size should be limited by a
max size. Check for a max height or width depending on the dimension,
instead of just always checking for a max width.
2024-09-04 22:41:15 +02:00
Tim Ledbetter a56a2faf51 LibWeb: Don't handle media player key events if any modifier is pressed
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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-09-04 09:59:40 -04:00
Tim Ledbetter 63231fd276 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.
2024-09-04 09:59:40 -04:00
Timothy Flynn f1395a2c38 LibWebView: Properly handle new lines inside styled view-source elements
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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
When we want to inject a CSS counter for a line, we need to be sure to
handle if we had previously opened a styled span for the current source
substring. For example, if we see a new line in the middle of a comment,
we will have previously opened the following tag:

    <span class="comment">

So when injecting a new line and the <span class="line"> element (for
CSS counters), we need to close the previous span and insert a newly
opened tag to continue using the style.
2024-09-04 13:14:38 +02:00
Aliaksandr Kalenik 79b57ef094 LibGfx/Font: Remove unused ScaledFont::glyph_metrics() 2024-09-04 13:14:05 +02:00
Aliaksandr Kalenik f7891c7ec0 LibGfx/Font: Remove unused Typeface::glyph_advance() 2024-09-04 13:14:05 +02:00
Aliaksandr Kalenik ae82bf5f7a LibGfx/Font: Use harfbuzz in ScaledFont::glyph_width() 2024-09-04 13:14:05 +02:00
Aliaksandr Kalenik fb539b2412 LibGfx/Font: Delete unused glyphs_horizontal_kerning() 2024-09-04 13:14:05 +02:00
Aliaksandr Kalenik 4786604f8b LibGfx: Replace ad-hoc text width calculation with harfbuzz
Since harfbuzz is already used to calculate glyph positions, let's
also use it to measure width.
2024-09-04 13:14:05 +02:00
Aliaksandr Kalenik a541a0792c LibWeb: Use harfbuzz for canvas text layout
harfbuzz is already used for regular text layout in LibWeb, so
for consistency let's also switch canvas.
2024-09-04 13:14:05 +02:00
Johan Dahlin 977e77bd4a HTMLImageElement: Improve decoding stub
Add an enum and warn when setting to sync/async.
2024-09-04 09:55:33 +02:00
Timothy Flynn 03f9915054 LibWebView: Use the download directory facility for saving files
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.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-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.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-22.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-09-03 14:13:41 -04:00
Timothy Flynn 8fbb39803e LibWebView: Add facilities to ask the user for a download directory
If the Downloads directory exists, we will use it (note that this will
respect the XDG_DOWNLOAD_DIR environment variable).

Otherwise, we will ask the UI layer to retrieve a download directory
from the user. This directory is not saved, so it will be re-prompted
every time. Once a proper settings UI is complete, we will of course
integrate with that for persistent settings.
2024-09-03 14:13:41 -04:00
Timothy Flynn d392c38a73 LibUnicode: Cache all created icu::TimeZone objects
This cache works exactly the same as the existing icu::Locale cache.
2024-09-03 19:26:04 +02:00
Timothy Flynn 6becd13a83 LibJS: Add a non-BigInt overload of GetNamedTimeZoneOffsetNanoseconds
In some cases, we have a timestamp as a double in milliseconds. We then
would convert it to nanoseconds as a BigInt, just to bring it back to a
double for TZDB lookups. Add an overload to avoid this needless round
trip.
2024-09-03 19:26:04 +02:00
Timothy Flynn 5ee92af1d9 LibJS+WebContent: Cache the resolved system time zone identifier
Even though the underlying time zone is already cached by LibUnicode, JS
performs additional expensive lookups with that time zone. There's no
need to do those lookups again until the system time zone has changed.
2024-09-03 19:26:04 +02:00
Timothy Flynn 7d0e33cb27 LibJS: Implement Uint8Array.prototype.setFromHex 2024-09-03 17:43:03 +02:00
Timothy Flynn c7afd175bc LibJS: Implement Uint8Array.fromHex 2024-09-03 17:43:03 +02:00
Timothy Flynn 440183b669 LibJS: Implement Uint8Array.prototype.setFromBase64 2024-09-03 17:43:03 +02:00
Timothy Flynn e8f27160bf LibJS: Implement Uint8Array.fromBase64
Note that we can currently only use simdutf for Base64 decoding if the
provided stopBeforePartial option is loose, which is the default. There
is an open issue for simdutf to implement strict and stop-before-partial
options. Until then, for those options, we implement a slow decoder that
is written exactly as the spec steps dictate.

See: https://github.com/simdutf/simdutf/issues/440
2024-09-03 17:43:03 +02:00
Timothy Flynn c69d6fab8f LibJS: Implement Uint8Array.prototype.toHex 2024-09-03 17:43:03 +02:00
Timothy Flynn b97f9f2c55 LibJS: Implement Uint8Array.prototype.toBase64 2024-09-03 17:43:03 +02:00
HolonProduction 94230acf28 LibWeb: Update Selection.collapse algorithm 2024-09-03 17:42:13 +02:00
Andreas Kling 8a6c8a1c27 LibWeb: Propagate text-decoration-* properties to anonymous wrappers
Fixes an issue where old prices were not displayed with strike-through
text on the PlayStation store. :^)
2024-09-03 17:41:05 +02:00