Commit graph

35075 commits

Author SHA1 Message Date
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
Aliaksandr Kalenik 415ea4ec0c LibWeb: Resolve "position: sticky" insets relative to scrollport
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, 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
Reading of https://drafts.csswg.org/css-position revealed I was wrong
assuming sticky insets need to be resolved relative to containing block.
2024-09-03 11:34:31 +02:00
Tim Ledbetter dcbb073b3e LibWeb: Relayout document when SVG image is successfully loaded 2024-09-03 10:30:22 +01:00
Colin Reeder 45e4ab69d6 LibWeb: Add background color to input fields 2024-09-03 10:16:13 +01:00
Sam Atkins da171c3230 Inspector: Add a basic style sheet inspector
Choosing options from the `<select>` will load and display that style
sheet's source text, with some checks to make sure that the text that
just loaded is the one we currently want.

The UI is a little goofy when scrolling, as it uses `position: sticky`
which we don't implement yet. But that's just more motivation to
implement it! :^)
2024-09-03 10:12:07 +01:00
Sam Atkins 49b2eb5f51 LibWeb: Add Document::get_style_sheet_source()
This returns the source text of the specified style sheet. StyleComputer
now exposes user agent style sheets so that these can also be requested.
2024-09-03 10:12:07 +01:00
Sam Atkins 51a426cc05 LibWeb: Add method for listing all style sheets on a page
This will be used by the inspector, for showing style sheet contents.

Identifying a specific style sheet is a bit tricky. Depending on where
it came from, a style sheet may have a URL, it might be associated with
a DOM element, both, or neither. This varied information is wrapped in
a new StyleSheetIdentifier struct.
2024-09-03 10:12:07 +01:00
Sam Atkins dd3b011f15 LibWeb: Keep track of each CSSStyleSheet's CSSImportRules
This will be used to gather up a list of all loaded style sheets for the
inspector.
2024-09-03 10:12:07 +01:00
Sam Atkins b00137df38 LibWeb/CSS: Store the style sheet's source text on the CSSStyleSheet
This is to enable the inspector to show this source.

There's a fairly hefty FIXME here because duplicating the source text is
a significant waste of memory. But I don't want to get too sidetracked.
2024-09-03 10:12:07 +01:00
Sam Atkins 8cbc211616 Meta: Make embed_as_string_view.py produce Strings instead
This is only used for CSS style sheets. One case wants it as a String,
and the others don't care, but will in future also want to have the
source as a String.
2024-09-03 10:12:07 +01:00
Sam Atkins fd49562f50 LibWeb: Add helper for accessing Inspector's PageClient
This is a bit easier to understand.
2024-09-03 10:12:07 +01:00
Sam Atkins 240b58e90f LibWeb/CSS: Set @import as the owner rule of their loaded style sheet 2024-09-03 10:12:07 +01:00
Sam Atkins 4e18fce3a5 LibWeb: Set the location URL for @import-ed/<link>-ed style sheets
The spec text had changed for the value of `<link>`'s location, so I've
updated that.
2024-09-03 10:12:07 +01:00