Commit graph

35924 commits

Author SHA1 Message Date
Kostya Farber
2534e7aeff LibWeb: Strip tabs before text shaping
Handling tabs during text shaping caused issues because we tried to
index 'input_glyph_info' whilst iterating until 'glyph_count' and these
can be different sizes.

The difference is due to when one or more characters get
merged into the same glyph when calling 'input_glyph_info' (see
https://lazka.github.io/pgi-docs/HarfBuzz-0.0/classes/glyph_info_t.html).

We don't want to render tabs as they come up as tofu characters so
instead let's strip them out of the text chunk before starting text
shaping.
2024-10-22 21:42:54 +02:00
Jelle Raaijmakers
77850b3540 LibWeb/EventHandler: Ignore repeated keyup events
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
Platforms such as X11 will typically send repeated keyRelease/keyup
events as a result of auto-repeating:

  * KeyPress (initial)
  * KeyRelease (repeat)
  * KeyPress (repeat)
  * KeyRelease (repeat)
  * ad infinitum

Make our EventHandler more spec-compliant by ignoring all repeated keyup
events. This fixes long-pressing the arrow keys on
https://playbiolab.com/.
2024-10-22 11:20:35 -04:00
Jelle Raaijmakers
9309cc9df3 UI+LibWeb+WebContent: Implement KeyEvent repeat property
When a platform key press or release event is repeated, we now pass
along a `repeat` flag to indicate that auto-repeating is happening. This
flag eventually ends up in `KeyboardEvent.repeat`.
2024-10-22 11:20:35 -04:00
Jelle Raaijmakers
cf315d54ec UI+LibWeb: Remove unused includes 2024-10-22 11:20:35 -04:00
Kostya Farber
537cbf55c3 LibWeb: Add letter-spacing css property to Node 2024-10-22 15:32:34 +01:00
ronak69
6c3ecf6a34 LibWeb/CSS: Tweak in CSSRGB::to_color() to avoid floating point errors
Example of the difference:

    50 * 2.55      --> 127.4999 --> round towards +∞ --> 127
    50 * 255 / 100 --> 127.5000 --> round towards +∞ --> 128

Now, 9 failing WPT tests in /css/css-color/ pass.
2024-10-22 14:18:17 +01:00
Aliaksandr Kalenik
3e8b2454fb LibWeb: Stub InputEvent.getTargetRanges()
We need this, because https://www.slatejs.org/ that is used by Discord
checks this function to decide whether a browser has "beforeinput" event
support.
2024-10-22 08:44:51 -04:00
Aliaksandr Kalenik
63f502ab0a LibWeb: Implement dispatching of "beforeinput" event 2024-10-22 08:44:51 -04:00
Aliaksandr Kalenik
0de61b0f65 LibWeb: Implement dispatching of "input" event 2024-10-22 08:44:51 -04:00
Aliaksandr Kalenik
d88e6bee5d LibWeb: Put cursor in last text node when contenteditable is focused
With this change we match behavior of other engines a bit more closer.
2024-10-22 08:44:51 -04:00
Kostya Farber
da42c19cb6 LibWeb: Apply the word-spacing css property to Node
This will let us start to begin applying this during
text shaping.
2024-10-22 13:36:26 +01:00
Jelle Raaijmakers
e4533e5595 LibWeb: Do not floor SVG offset in SVGPathPaintable
Resolves a FIXME and improves the visuals of https://tweakers.net :^)
2024-10-22 07:37:59 -04:00
Timothy Flynn
c96c5e45ff LibWeb: Implement KeyboardEvent.charCode according to spec
It should be 0 for keydown/keyup events.
2024-10-22 12:48:58 +02:00
Timothy Flynn
1bbe8309d4 LibUnicode: Add a helper to determine if a code point is printable 2024-10-22 12:48:58 +02:00
Timothy Flynn
b24a7079f1 LibWeb+WebDriver: Add a flag to default WebDriver to headless mode
We previously only supported enabling headless mode on a per-session
basis via the capabilities record. We don't have the ability to mutate
this record from WPT, so this adds a flag to set the default mode.
2024-10-22 04:24:31 +01:00
samu698
d08d305399 LibWeb: Fixed IDL for HTMLInputElement
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
Use Enumerated for the form{Enctype, Method} attributes
2024-10-21 15:41:00 -06:00
samu698
ab04f6d422 LibWeb: Fixed IDL for HTMLButtonElement
Use Enumerated for the form{Enctype, Method} attributes
2024-10-21 15:41:00 -06:00
samu698
6892482755 LibWeb: Use correct IDL for HTTPFormElement's method attribute
Removed the custom getter and updated the idl so that the attribute
is Reflected and Enumerated.
2024-10-21 15:41:00 -06:00
Timothy Flynn
ebe89a3207 WebContent: Parse the type hint in WebDriver's New Window endpoint
Although we aren't using this hint (we always create tabs), we do need
to validate the payload.
2024-10-21 13:15:11 -04:00
Tim Ledbetter
74983e6966 WebDriver: Don't return from new_window() until WebDriver is connected
Previously, tests would intermittently fail because the current session
wasn't yet aware of a newly created window handle.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-10-21 18:02:21 +01:00
Andreas Kling
72f4253911 LibWeb: Scale up "inspected node" hint text to match screen DPI
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 fixes an issue where the text would look very small on macOS.
2024-10-21 15:57:28 +02:00
Aliaksandr Kalenik
629a3ac61e LibWeb: Add missing check if scrollable overflow defined for paintable
With 6a549f6270 we need to check if
optional scrollable overflow exists for paintable box, because it's not
computed for inline nodes.

Fixes crashing after navigating into direct messages screen on Discord.
2024-10-21 15:57:19 +02:00
Jelle Raaijmakers
27928cd28c LibWeb: Add PointerEvent.getCoalescedEvents() and .getPredictedEvents()
Fixes at least 4 WPT subtests in /pointerevents.
2024-10-21 07:37:59 -04:00
Jelle Raaijmakers
effa21a69f LibWeb: Add PointerEvent.persistentDeviceId
Fixes at least 2 WPT subtests in /pointerevents.
2024-10-21 07:37:59 -04:00
Andreas Kling
325ff4ac27 Revert "LibGfx: Use actual vector size as indicated by HarfBuzz"
This reverts commit 14f5f51147.
2024-10-21 12:09:11 +02:00
Andreas Kling
fdfbfcab37 Revert "LibWeb: Unbreak harfbuzz text layout"
This reverts commit a8d0712c28.
2024-10-21 12:09:02 +02:00
Vincent Sgherzi
9ce139a3f0 LibWeb: Fix boolean logic mistake in XMLSerializer for empty public ID
Fixes 5 subtests on http://wpt.live/domparsing/xml-serialization.xhtml
2024-10-21 10:53:02 +02:00
Andreas Kling
a8d0712c28 LibWeb: Unbreak harfbuzz text layout
The reason we were keeping track of the pre-shaping buffer was to know
where we had tab characters in the input. This is a very strange way of
doing that, but since it broke the web, let's patch it up quickly.

Follow-up to #1870 which broke text layout on many web pages.
2024-10-21 10:30:12 +02:00
Ben Wiederhake
14f5f51147 LibGfx: Use actual vector size as indicated by HarfBuzz
This fixes a browser crash as experienced on Wikipedia when encountering
the &ne; entity. As a side-effect, this also affects some tab-align and
-wrap tests.
2024-10-21 10:15:39 +02:00
Jim Broadbent
97ca6036fa LibWeb/XHR: Progess event handle empty length
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-20 22:22:59 +02:00
samu698
50f642613d LibWeb/HTML: Implement inner text set according to spec
Replaced the ad-hoc implementation with a spec compliant one.
This change fixes 36 WPT tests.
2024-10-20 22:15:04 +02:00
Andreas Kling
58c523ae46 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.
2024-10-20 21:58:58 +02:00
stasoid
6b73a2d8a4 LibCore: Port File to Windows
Co-authored-by: Cameron Youell <cameronyouell@gmail.com>
2024-10-20 10:18:03 -06:00
stasoid
f6430035e7 LibCore/System: Add initial Windows support
Co-authored-by: Cameron Youell <cameronyouell@gmail.com>
2024-10-20 10:18:03 -06:00
Timothy Flynn
6cba55893e WebContent: Return the handle of the newly opened window from New Window
We were returning the handle of the already opened window, rather than
the handle of the window we just opened.
2024-10-20 16:41:11 +01:00
Timothy Flynn
981aaba96c LibWeb: Break the Window open steps into two methods for internal use
Some callers (namely WebDriver) will need access to the navigable opened
by these steps. But if the noopener parameter is set, the returned proxy
will always be null.

This splits some of the Window open steps into an internal method that
returns the chosen navigable.
2024-10-20 16:41:11 +01:00
Bastian Müller
748e3c2e6c LibWeb/XHR: Pass API URL character encoding
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-20 07:58:22 -04:00
Bastian Müller
3be93ac49f LibWeb/XHR: Parse URL to resolve blob 2024-10-20 07:58:22 -04:00
Andreas Kling
4fdb266077 LibWeb: Make DOM Node unique IDs strongly typed (and 64 bit)
This is strictly nicer than passing them around as i32 everywhere,
and by switching to i64 as the underlying type, ID allocation becomes as
simple as incrementing an integer.
2024-10-20 13:42:33 +02:00
Tim Ledbetter
eca2318390 WebContent: Use window open steps to create a new window with WebDriver
This matches the specification steps and fixes a WPT regression caused
by us not loading `about:blank` when opening a new window.
2024-10-20 11:42:19 +01:00
Tim Ledbetter
f3c6326f27 LibWeb: Rename Window::open_impl() to Window::window_open_steps()
This is the same name used in the specification.
2024-10-20 11:42:19 +01:00
Shannon Booth
b999f925dc LibWeb: Allow splitting surrogate pairs in CharacterData.substringData() 2024-10-20 11:18:57 +01:00
thislooksfun
0b775da7c7 LibWeb/CSS: Evaluate media queries in shadow roots
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 fixes a rendering issue on https://prodengi.kz/ that someone on
Discord reported. :^)
2024-10-20 07:57:09 +01:00
Timothy Flynn
1aab7b51ea LibWebView: Generate hyperlinks for attributes that represent links
On the view-source page, generate anchor tags for any 'href' or 'src'
attribute value we come across. This handles both when the attribute
contains an absolute URL and a URL relative to the page.

This requires sending the document's base URL over IPC to resolve
relative URLs.
2024-10-20 08:50:01 +02:00
Cameron Youell
94601e1ffd LibCore: Add Windows version of DirIterator
Co-authored-by: stasoid <stasoid@yahoo.com>
2024-10-19 18:14:48 -06:00
rmg-x
57f82c029c LibWeb/HTML: Check if evaluationStatus has a value before dereferencing
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
Previously, we would crash if scripting was disabled and a javascript
URL was evaluated.
2024-10-19 18:28:12 -04:00
Andreas Kling
f106aa9e8a LibWeb: Stop traversal early when marking nodes for child style update
These flags always propagate to the root, so once we encounter an
ancestor with the flag set, we can stop traversal since everything above
it will already be set as well.
2024-10-19 21:13:54 +02:00
Andreas Kling
d21c5631aa LibWeb: Avoid a weird reparse of style attributes for pseudo elements
For pseudo elements that represent a browser-generated shadow tree
element, such as ::placeholder, we were reparsing their style attribute
in StyleComputer for some reason.

Instead of doing this, just access the already-parsed version via
Element::inline_style().
2024-10-19 21:13:54 +02:00
Kemal Zebari
04d16a1ee3 LibWeb/HTML: Add missing HTMLElement IDL autocorrect as a stub
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 adds an IDL stub for the autocorrect HTMLElement attribute.
2024-10-19 07:34:15 +01:00
Jelle Raaijmakers
4c189166f4 LibWeb: Implement indexed property support for HTML::Storage
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
We only supported named properties on Storage, and as a result
`localStorage[0]` would be disconnected from the Storage's backing map.

Fixes at least 20 subtests in WPT in /webstorage.
2024-10-18 23:10:22 +02:00
Timothy Flynn
999c591e83 LibCore: Remove unused Core::System wrappers
As efforts to begin porting to Windows is underway, doing so should be a
bit less daunting if we clean up syscall wrappers that aren't used.

Note: While this removes Serenity-only wrappers, it leaves the Serenity
implementations of used wrappers in place for now, to not needlessly
complicate merging between the two orgs.
2024-10-18 18:16:18 +02:00
Timothy Flynn
1ce10d6b39 Utilities: Remove no-op calls to unveil and pledge 2024-10-18 18:16:18 +02:00
Jelle Raaijmakers
8419a5f60f LibGfx: Remove unused, deprecated code 2024-10-18 18:12:45 +02:00
Aliaksandr Kalenik
11e10d0532 LibWeb: Add missing flex-start and flex-end in to_alignment [GFC]
Fixes crashing on https://tweakers.net/
2024-10-18 18:11:46 +02:00
Edward Banner
912511a152 LibWeb: Use containing block to compute scrollable overflow
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
Instead of using child boxes to compute scrollable overflow for the box,
we use descendants which have the box as their containing block.
2024-10-18 15:26:42 +02:00
Aliaksandr Kalenik
de238328eb LibWeb: Accept paintable instead of layout node in resolve_background() 2024-10-18 14:59:41 +02:00
Aliaksandr Kalenik
78d8989ea4 LibWeb: Accept paintable instead of layout node in paint_background()
After InlinePaintable is gone it's possible to make this function accept
a PaintableBox instead of more broad
Layout::NodeWithStyleAndBoxModelMetrics type.
2024-10-18 14:59:41 +02:00
Timothy Flynn
048b51eb54 WebContent: Add a JS visitor to WebDriver's IPC connection
We've added a few JS::Handle members to this class over time. Let's
avoid creating a new GC root for each of these, and explicitly add a
visitation method.
2024-10-18 09:45:04 +02:00
Timothy Flynn
022e2b8a94 LibWeb+WebContent: Rename the WebDriver get-known-element AO
The underlying concept is the same, but this method was renamed in the
spec to drop the word "connected".
2024-10-18 09:45:04 +02:00
Timothy Flynn
a96a762305 LibWeb+WebContent: Use NNGCPtr in WebDriver code where appropriate
Some of this code is older than widespread use of GCPtr. These functions
returning raw pointers has been a point of confusion at times, so lets
just indicate that they are non-null.
2024-10-18 09:45:04 +02:00
Jelle Raaijmakers
2a98f2a12d LibWeb: Implement AudioListener
This exposes BaseAudioContext.listener, which is a container for
parameters related to the configuration of an actual "listener" in 3D
space.
2024-10-18 09:39:04 +02:00
Timothy Flynn
eeee6ba3f5 LibWeb: Visit the MessagePort's associated Worker target
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
Without this, a worker can be GC'd in a very simple script such as:

    const worker = new Worker("script.js");
    worker.onmessage = () => {};

Where script.js attempts to post a message back to the parent window.

When the Worker is GC'd, the IPC connection from the WebContent process
to the WebWorker process is closed. When this occurs, the WebWorker will
exit() from LibIPC, and any message from the worker to its parent does
not have a chance to run.
2024-10-17 16:34:32 -04:00
Timothy Flynn
ba1b26cdc2 LibWeb: Disentangle associated MessagePorts when a document is destroyed 2024-10-17 16:34:32 -04:00
Timothy Flynn
d44dd756b3 LibWeb: Reset MessagePort's worker event target when it is disentangled 2024-10-17 16:34:32 -04:00
Timothy Flynn
83be2606db LibWeb: Update spec steps for destroying a DOM document
This just updates our copied spec steps - new steps are not implemented
here. This is mostly just to highlight new steps we are missing around
MessagePorts.

No behavior change, but this does resolve an outstanding FIXME around
spec step ordering.
2024-10-17 16:34:32 -04:00
Timothy Flynn
32a22c49e3 LibWeb: Move StructuredSerializeOptions to its own header
This largely reduces the number of files needed to be compiled when we
change the MessagePort header.
2024-10-17 16:34:32 -04:00
Timothy Flynn
5ed702e211 LibWeb: Sort the forwarding header 2024-10-17 16:34:32 -04:00
Andreas Kling
3c5819a6d2 LibJS: Allow GetById to cache getters
1.25x speed-up on this microbenchmark:

    let o = { get x() { return 1; } };
    for (let i = 0; i < 10_000_000; ++i)
        o.x;

I looked into this because I noticed getter invocation when profiling
long-running WPT tests. We already had the mechanism for non-getter
properties, and the change to support getters turned out to be trivial.
2024-10-17 22:06:16 +02:00
Sam Atkins
e4245dc39e LibWeb/CSS: Process style properties from CSSNestedDeclarations rules
These are created when a style rule has properties listed after another
rule. For example:

```css

.test {
  --a: 1;
  --b: 1;
  --c: 1;

  .thing {
    /* ... */
  }

  /* These are after a rule (.thing) so they're wrapped in a
     CSSNestedDeclarations: */
  --d: 1;
  --e: 1;
  --f: 1;
}
```

They're treated like a nested style rule with the exact same selectors
as their containing style rule.
2024-10-17 20:55:55 +02:00
Sam Atkins
53f99e51f8 LibWeb/CSS: Parse and use nested style rules
For example, this:

```css
.foo {
  color: red;
  &:hover {
    color: green;
  }
}
```

now has the same effect as this:

```css
.foo {
  color: red;
}
.foo:hover {
  color: green;
}
```

CSSStyleRule now has "absolutized selectors", which are its selectors
with any `&`s resolved. We use these instead of the "real" selectors
when matching them, meaning the style computer doesn't have to know or
care about where the selector appears in the CSS document.
2024-10-17 20:55:55 +02:00
Sam Atkins
74c448d744 LibWeb/CSS: Use SelectorList type instead of Vector<NNRP<Selector>> 2024-10-17 20:55:55 +02:00
Sam Atkins
d935a00413 LibWeb/CSS: Clear CSSRule's cached layer name when it is moved
Through the CSSOM, rules can be moved around, and so anything cached
(for now just the qualified layer name) needs to be recalculated when
that happens. This method is virtual so that other rules will be able
to clear their cached data too.
2024-10-17 20:55:55 +02:00
Sam Atkins
36afff97d1 LibWeb/CSS: Parse nested rules in style blocks
Nested lists of declarations become CSSNestedDeclarations; at-rules are
allowed as long as they are CSSGroupingRules.
2024-10-17 20:55:55 +02:00
Sam Atkins
9c66ab356a LibWeb: Implement CSSNestedDeclarations type
This is basically a list of properties, without a block around it. It'll
be part of CSSStyleRules' contents.
2024-10-17 20:55:55 +02:00
Sam Atkins
5b4d1b5b05 LibWeb/CSS: Parse the & nesting selector 2024-10-17 20:55:55 +02:00
Andreas Kling
55f58eea99 LibWeb: Use the correct document URL in DOMParser.parseFromString()
We were hard-coding "about:blank" as the document URL for parsed HTML
documents, which was definitely not correct.

This fixes a bunch of WPT tests under /domparsing/ :^)
2024-10-17 19:16:08 +02:00
Kostya Farber
323370dfa3 LibWeb: Start implementation of rendering tabs according to tab-size
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-17 15:00:57 +02:00
Jelle Raaijmakers
2df3488840 LibWeb: Implement pending promises in BaseAudioContext
Move the pending promises list from AudioContext to BaseAudioContext and
deal with all remaining FIXMEs.
2024-10-17 08:48:14 -04:00
Simon König
15d2857a01 LibWeb: Don't crash on encountering display: list-item on pseudo element
On any `display: list-item` Node a CSS pseudo element (`::marker`) needs
to be created. This commit allows the ::maker pseudo element to be
nested within other pseudo elements (e. g. ::before or ::after).

This fixes this WPT test:
http://wpt.live/css/CSS2/generated-content/after-content-display-003.xht
2024-10-17 07:42:59 +01:00
Benjamin Bjerken
0c04bd6676 LibWeb: Add SVGImageElement load and error events
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 resolves all WPT timeouts in html/canvas/element/manual/imagebitmap
We can now run an additional 6 tests and 126 subtests :)

This also adds regression tests for this behavior.
2024-10-16 22:59:28 +01:00
Aliaksandr Kalenik
c097f53875 LibWeb: Remove InlinePaintable
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
It was replaced with PaintableWithLines.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
6a549f6270 LibWeb: Replace InlinePaintable with PaintableWithLines created per line
InlinePaintable was an ad-hoc paintable type required to support the
fragmentation of inline nodes across multiple lines. It existed because
there was no way to associate multiple paintables with a single layout
node. This resulted in a lot of duplicated code between PaintableBox and
InlinePaintable. For example, most of the CSS properties like
background, border, shadows, etc. and hit-testing are almost identical
for both of them. However, the code had to be duplicated to account for
the fact that InlinePaintable creates a box for each line. And we had
quite many places that operate on paintables with a code like:
```
if (box.is_paintable_box()) {
  // do something
} else (box.is_inline_paintable()) {
  // do exactly the same as for paintable box but using InlinePaintable
}
```

This change replaces the usage of `InlinePaintable` with
`PaintableWithLines` created for each line, which is now possible
because we support having multiple paintables per layout node. By doing
that, we remove lots of duplicated code and bring our implementation
closer to the spec.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
c690fb9df3 LibWeb: Rename Layout::Node::paintable() to first_paintable()
Layout node is allowed to have multiple corresponding paintables, so
first_paintable() is more explicit name for getter that returns first
paintable.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
7d22b1c5c8 LibWeb: Allow layout nodes to have multiple paintables
CSS fragmentation implies 1:N relationship between layout nodes and
paintables. This change is a preparation for implementation of inline
fragmentation where InlinePaintable will be replaced with
PaintableWithLines corresponding to each line.
2024-10-16 20:25:42 +02:00
Aliaksandr Kalenik
a6718e5f3b LibWeb: Resolve vertical borders for inline nodes
Preparation for upcoming change where InlinePaintable will no longer be
responsible for doing that.
2024-10-16 20:25:42 +02:00
David Smith
e7c209820d LibWeb: Layout all math elements using InternalDummy context
Always create a new formatting context for <math> elements. Previously
that didn't happen if they only had inline children, e.g. mtable.

This fixes a crash in the WPT MathML test
mathml/crashtests/children-with-negative-block-sizes.html
2024-10-16 19:51:36 +02:00
stelar7
4408ea7c9b LibWeb: Handle calculations without a context better 2024-10-16 16:39:47 +02:00
Tim Ledbetter
c0beacbb76 LibWebSocket: Remove some accidentally included debug logic
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-16 13:22:30 +01:00
Sam Atkins
6e68e8f3c9 LibWeb/CSS: Insert whitespace between tokens in serialized UnresolvedSV
Otherwise, `margin: var(--foo) var(--bar)` would be wrongly serialized
as `margin: var(--foo)var(--bar)`
2024-10-16 08:34:31 +02:00
Sam Atkins
bf3e6daedb LibWeb/CSS: Preserve whitespace and comments in custom properties
A couple of parts of this:
- Store the source text for Declarations of custom properties.
- Then save that in the UnresolvedStyleValue.
- Serialize UnresolvedStyleValue using the saved source when available -
  that is, for custom properties but not for regular properties that
  include var() or attr().
2024-10-16 08:34:31 +02:00
Sam Atkins
f8995d37a2 LibWeb/CSS: Tokenize comments as whitespace tokens
This is in a weird position where the spec tells us to discard the
comments, but then we have to preserve the original source text which
may include comments. As a compromise, I'm treating each comment as a
whitespace token - comments are functionally equivalent to whitespace
so this should not have any behaviour changes beyond preserving the
original text.
2024-10-16 08:34:31 +02:00
Sam Atkins
ea164124de LibWeb/CSS: Preserve original source text for ComponentValues
This requires a little bit of ad-hoc tracking of start/end Tokens for
Function and SimpleBlock.
2024-10-16 08:34:31 +02:00
Sam Atkins
04939d68f0 LibWeb/CSS: Rename Token::representation() to original_source_text()
This is the term used in the Syntax-3 spec as of right now.
2024-10-16 08:34:31 +02:00
Sam Atkins
7c2680b7ef LibWeb/CSS: Serialize empty grid-template-* values correctly
Previously we would serialize these as the empty string. eg, this:

```
<div style="grid-auto-columns: auto"></div>
```

would have a computed `grid-auto-columns` value of ``.
2024-10-16 08:34:02 +02:00
Sam Atkins
69d064697a LibWeb/CSS: Handle calculated integers when expanding unresolved values
In order to know whether `calc(2.5)` is a number or an integer, we have
to see what the property will accept. So, add that knowledge to
`Parser::expand_unresolved_values()`.

This makes `counter-increment: foo calc(2 * var(--n));` work correctly,
in a test I'm working on.
2024-10-16 08:34:02 +02:00
Sam Atkins
aeed4921c4 LibWeb: Indent the CSS dumps correctly
Selectors and at-rules both made assumptions about their indentation
level, which made it difficult to read the dump output. It'll become
even worse once rules can be further nested within each other, so let's
fix it now. :^)
2024-10-16 08:32:29 +02:00
Sam Atkins
5cc75d4de4 LibWeb: Remove tiny-OOM handling from dump code 2024-10-16 08:32:29 +02:00
Tim Ledbetter
ebe1dc6dcd LibWebSocket: Send closing frame when server begins a closing handshake 2024-10-16 08:31:49 +02:00
Tim Ledbetter
0b365061d1 LibWebSocket: Ensure connection is failed on invalid opening handshake 2024-10-16 08:31:49 +02:00
Andrew Kaster
9d0ce4df0f LibWeb: Add support for parsing comments in the Swift HTML tokenizer 2024-10-16 08:31:42 +02:00
Andrew Kaster
36a8ad9157 LibGfx: Move FontDatabase internals to SystemFontProvider interface
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 will be the first step is making better use of system libraries
like fontconfig and CoreText to load system fonts for use by the UI
process and the CSS style computer.
2024-10-15 15:09:16 -06:00
Sam Atkins
81596b4145 LibWeb/CSS: Stop invalidating style when setting an animation's effect
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 reverts 6d25bf3aac

Invalidating the style here means that transitions can cause an element
to leave style computation with its "needs style update" flag set to
true. This then causes a VERIFY to fail in the TreeBuilder.

This invalidation does not otherwise seem to have any effect. The
original commit suggests this was to fix a bug, but it's not clear what
bug that was. If it reappears, we can try to solve the issue in a
different way.
2024-10-15 08:43:26 -04:00
Benjamin Bjerken
63d9ed9d8c LibWeb: Fix CloseWatcher constructor for detached iframes
This fixes the last subtest in /close-watcher/frame-removal.html :)
2024-10-15 08:41:54 -04:00
Jelle Raaijmakers
14b2e5849d LibWeb: Add barebones BaseAudioContext.decodeAudioData()
Implement just enough steps to get https://zty.pe/ working! :^)
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
7b76438d57 LibWeb: Accept JS::HeapFunction when queuing a media element task
This opens up the possibility of easier memory management in future
changes.
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
177e5210e0 LibWeb: Move 'queue a media element task' to BaseAudioContext
We need these steps to be available for the yet to be implemented
`BaseAudioContext.decodeAudioData()`.
2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
273a46cc76 LibWeb: Remove unused include from AudioBuffer 2024-10-15 10:02:15 +02:00
Jelle Raaijmakers
3df3977ca5 LibWeb: Correct AudioBuffer spec link 2024-10-15 10:02:15 +02:00
justus2510
7a92b47a35 LibWeb: Make FileReader fire progress event
Fixes wpt/FileAPI/reading-data-section/filereader_events.any.html :)
2024-10-15 08:42:37 +02:00
Timothy Flynn
c0102aa818 LibJS: Support date strings of the form "Wed Apr 17 2019 23:08:53""
Seen on https://www.skaping.com/valloire/galibier.
2024-10-15 08:25:32 +02:00
Andrew Kaster
a3157c8c69 LibWasm: Reject indirect calls to external function references
Some checks failed
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
Build Dev Container Image / build (push) Has been cancelled
This fixes a test in the WebAssembly spec test suite that was
added in 924c1f816d
2024-10-14 18:14:18 -06:00
Shannon Booth
329e9ed820 LibWeb: Fix spec typo in inner_navigate_event_firing_algorithm
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-14 20:49:03 +02:00
Shannon Booth
dc9861174b LibWeb: Fire traversable event during "apply the history step"
These steps were recently clarified by Andrew in:

https://github.com/whatwg/html/commit/12b0d582
2024-10-14 20:49:03 +02:00
Shannon Booth
bd3ffcdabb LibWeb: Simplify populate_session_history_entry_document conditional 2024-10-14 20:49:03 +02:00
Shannon Booth
41f574155d LibWeb: Factor out AO for 'try to scroll to the fragment'
I had made a stab at implementing this to determine whether it could
assist in fixing an issue where scroll_to_the_fragment was not getting
called at the appropriate time. It did not fix that issue, and actually
ended up breaking one of our in tree tests. In the meantime, factor out
this method into a standalone function.
2024-10-14 20:49:03 +02:00
Andreas Kling
279d229f71 LibWeb: Remove unnecessary use of TRY_OR_THROW_OOM in XMLHttpRequest 2024-10-14 20:47:35 +02:00
Andreas Kling
fa1c5a3e85 LibWeb: Make XMLHttpRequests functions related to MimeType infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
600cb5ccba LibWeb: Make MimeSniff::Resource::sniff() infallible
Everyone was already using this API as if it were infallible anyway.
2024-10-14 20:47:35 +02:00
Andreas Kling
5c20bc2afc LibWeb: Make MimeSniff::MimeType::parse() infallible
It already returns an empty Optional for failures, so there's no need to
wrap it in an ErrorOr as well.
2024-10-14 20:47:35 +02:00
Andreas Kling
88e7688940 LibWeb: Make more MimeSniff::MimeType APIs infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
9a8db40a23 LibWeb: Make MimeSniff::MimeType::create() infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
073bcfd386 AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
2024-10-14 20:47:35 +02:00
Andreas Kling
dd419b5a8d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.
2024-10-14 20:47:35 +02:00
Edward Banner
03569fc509 LibWeb: Fix table overflow issues
- Include vertical border spacing in row group offset calculation so
  that they are axis-aligned with child row/cell elements. This makes it
  so there isn't horizontal and vertical overflow caused by child
  row/cell elements.
- Include horizontal border spacing in tr width calculations. This makes
  it so tr elements don't have overflow anymore when there are multiple
  columns.
- Apply vertical caption offset to row group top offset.
- Don't double-count top padding when calculating vertical offset for
  tr and row groups.
2024-10-14 17:30:17 +01:00
Jelle Raaijmakers
70b3936188 LibMedia: Handle EOF as end of stream in FFmpegLoader
We were dealing with EOF by returning a generic I/O error, but
Audio::Loader requires us to return empty chunks at the end of stream.
2024-10-14 11:59:23 -04:00
Jelle Raaijmakers
c6d0075796 LibWeb: Report audio decoding errors to debug console 2024-10-14 11:59:23 -04:00
ronak69
917a2a3c86 LibWeb: Only return HTML elements from getElementsByName()
Fixes two WPT tests:
document.getElementsByName-namespace-xhtml.xhtml and
document.getElementsByName-namespace.html
2024-10-14 17:59:00 +02:00
Jelle Raaijmakers
d5fd29adb7 LibWeb: Update DOM IDL specs
I noticed some of these were running behind the upstream spec.
2024-10-14 11:57:58 -04:00
Sam Atkins
c79f261bec LibWeb/CSS: Mark grid-[gap, column-gap, row-gap] properties as aliases
These are legacy name aliases for the properties without the 'grid-'
prefix. See https://drafts.csswg.org/css-align-3/#gap-legacy
2024-10-14 17:57:34 +02:00
Bastian Neumann
b3fdeef5d7 LibWeb: Do not accept malformed xml namespace
This runs wpt domparsing/DOMParser-parseFromString-xml-parsererror.html
that previously crashed because of a malformed XML namespace in the
test.
2024-10-14 16:20:57 +01:00
Shannon Booth
cde3545a51 LibWeb: Correct some faulty logic in 'apply the history step'
We were checking if the parent was _not_ null, and not checking for an
auxiliary browsing context at all.
2024-10-14 13:45:34 +01:00
ronak69
592cf556a1 LibWeb/CSS: Don't serialize empty rules in CSSStyleRule
This is a recent spec change:
https://github.com/w3c/csswg-drafts/pull/10974
2024-10-14 13:43:16 +01:00
ronak69
8003d63ff9 LibWeb/CSS: Don't serialize empty rules in CSSMediaRule
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 is a recent spec change:
https://github.com/w3c/csswg-drafts/pull/10981
2024-10-14 09:50:41 +01:00
Taylor Mapes
0522e514a9 LibWeb: Implement CanvasRenderingContext2D.createImageData(ImageData)
Fixes at least one WPT test.
https://wpt.live/html/canvas/element/pixel-manipulation/2d.imageData.create1.basic.html
2024-10-14 09:33:49 +01:00
Taylor Mapes
6ffe83c9da LibWeb: Correct spec link for CanvasImageData 2024-10-14 09:33:49 +01:00
Andreas Kling
5b060da4f4 LibJS: Cache symbolicated stack frames on ExecutionContext
Instead of re-symbolicating entire stacks from scratch every time
we want a JS VM backtrace, we now use the ExecutionContext object as
cache storage via a new CachedSourceRange object.

This means that once a stack frame has been symbolicated, we don't
have to resymbolicate it again (unless the program counter moves
within that stack frame).

This drastically reduces time spent in symbolication in some WPT tests.
2024-10-14 09:51:13 +02:00
Timothy Flynn
e070ed5658 LibWeb+LibWebView: Add an internal API to expire cookies with an offset
Cookies have a minimum expiry resolution of 1 second. So to test cookie
expiration, the test had to idle for at least a second, which is quite a
noticeable delay now that LibWeb tests are parallelized.

Instead, we can add an internal API to expire cookies with a time offset
to avoid this idle delay.
2024-10-14 08:25:41 +02:00
Cory Virok
560c3824b9 LibWeb: Implemented the CanvasRenderingContext2D::createImageData() spec
The only real change here is to use the absolute magnitude of the
width/height when creating the ImageData.

This fixes the crash on this WPT test:
https://wpt.fyi/results/html/canvas/element/pixel-manipulation/2d.imageData.create2.double.html?label=master&product=ladybird
2024-10-14 08:25:19 +02:00
Cory Virok
01301c374b LibWeb: Wrap negative dims for getImageData()
Given negative width or height values for CanvasRenderingContext2D
getImageData(), translate the source rect.

I wasn't able to find this in the spec, but WPT tests for it and MDN
defines this behavior.

Fixes this WPT test:
https://wpt.live/html/canvas/element/pixel-manipulation/2d.imageData.get.source.negative.html

Described in MDN here:
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData#sw

getImageData() spec:
https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata
2024-10-14 08:24:36 +02:00
Cory Virok
d71887e48c LibWeb: Use abs() dimensions for canvas getImageData()
Similar to https://github.com/LadybirdBrowser/ladybird/pull/1774

Fixes the crash in the WPT test:
https://wpt.fyi/results/html/canvas/element/pixel-manipulation/2d.imageData.get.double.html?label=master&product=ladybird
2024-10-14 08:24:36 +02:00
Sam Atkins
e0be17e4fb LibWeb/CSS: Rewrite CSS Parser core methods according to new spec
CSS Syntax 3 (https://drafts.csswg.org/css-syntax) has changed
significantly since we implemented it a couple of years ago. Just about
every parsing algorithm has been rewritten in terms of the new token
stream concept, and to support nested styles. As all of those
algorithms call into each other, this is an unfortunately chonky diff.

As part of this, the transitory types (Declaration, Function, AtRule...)
have been rewritten. That's both because we have new requirements of
what they should be and contain, and also because the spec asks us to
create and then gradually modify them in place, which is easier if they
are plain structs.
2024-10-14 08:08:37 +02:00
Sam Atkins
f11c0e6cc0 LibWeb/CSS: Implement "is a custom property name string" to spec
This will be needed in the Parser soon, so for lack of a better place,
it's going in a separate header.
2024-10-14 08:08:37 +02:00
Sam Atkins
7723873016 LibWeb/CSS: Make CSSStyleRule be a CSSGroupingRule
As part of this, we can now fill in the missing serialization steps.

The parsing is a stub for now, and will be filled out in a subsequent
commit.
2024-10-14 08:08:37 +02:00
Andreas Kling
ac48222ed7 LibWeb: Recompute targetStep during "apply the history step"
This is an ad-hoc change to account for the fact that we may run
arbitrary code while waiting for the tasks in this function to complete.

I don't have a way to reproduce it, but I've seen trouble caused by
navigables disappearing, which causes the history step numbers to be
disturbed.
2024-10-14 07:45:19 +02:00
ronak69
3ff6137121 LibWeb: Insert title as first child on setting title of svg document
Before, the new title element got appended instead of prepended, as
nullptr was passed as the "child" argument to the insert_before()
function.

This change makes two WPT tests pass in:
http://wpt.live/html/dom/documents/dom-tree-accessors/document.title-09.html
2024-10-14 07:13:58 +02:00
Aliaksandr Kalenik
910f9c2c09 LibWeb: Remove BrowsingContext pointer from Layout::Node
It's no longer needed.
2024-10-14 07:12:36 +02:00
Aliaksandr Kalenik
5559a3dc6e LibWeb: Remove BrowsingContext pointer from Paintable
It's no longer needed.
2024-10-13 22:11:04 +01:00
John Diamond
18ade57ae9 LibWeb: Use correct boundary point comparison in Selection.extend
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
Previously Selection.extend() used only the relative node order to decide which
direction to extend the selection. This leads to incorrect behaviour if
both the existing and new boundary points are within the same DOM node
and the selection direction is reversed.

This change fixes all the failing subtests in the WPT extend-* test
suites.
2024-10-13 15:11:49 +02:00
Shannon Booth
ee35e93eb2 LibJS: Early return from Date string parsing on empty string
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
Loading Ladybird on Github results in 37 debug logs about being unable
to parse an empty Date string. This log is intended to catch Date
formats we do not support to detect web compatability problems, which
makes this case not particuarly useful to log.

Instead of trying to parse all of the different date formats and
logging that the string is not valid, let's just return NAN immediately.
2024-10-13 10:12:56 +02:00
Gingeh
f41cbfa2a9 LibWeb: Set both start and end in Selection::extend 2024-10-13 09:47:07 +02:00
Gingeh
93927d8243 LibWeb: Set direction to forwards in addRange 2024-10-13 09:47:07 +02:00
Gingeh
a7953f5e09 LibWeb: Implement Selection::direction 2024-10-13 09:47:07 +02:00
Sebastian-Webster
eec2602424 LibWebView: Add Startpage search engine 2024-10-13 08:36:49 +01:00
sin-ack
f1cab5de7a LibWeb: Compare navigable active_url with fragments included
This was previously negated due to a misread of
https://url.spec.whatwg.org/#concept-url-equals. This change fixes a
bunch of WPT crashes such as
"/html/browsers/history/the-history-interface/001".
2024-10-13 06:47:43 +02:00
Glenn Skrzypczak
3804c4dea1 LibWeb: Don't crash when encountering a resolution in a calculation
calc() seems to support resolutions by now.

The change allows us to pass this WPT test:
http://wpt.live/css/css-values/round-mod-rem-invalid.html
2024-10-12 22:23:03 -06:00
Glenn Skrzypczak
7ed08a401f LibWeb: Support the 'x' resolution unit identifier
The 'x' unit is the same as 'dppx', but was previously not considered
when parsing resolutions.
2024-10-12 22:23:03 -06:00
Ali Mohammad Pur
24c2ad059b LibWeb+LibXML: Cache the result of parsing the XHTML DTD and reuse it
There's no reason to parse this again and again every time we parse an
XHTML document.
2024-10-13 00:24:44 +02:00
Ali Mohammad Pur
fd5ee06bbf LibXML: Avoid allocating ByteStrings for AcceptedRule
These come from string literals and compiletime-known values, no need to
allocate a ByteString.
2024-10-12 23:00:09 +02:00
Ali Mohammad Pur
4d3f764d95 LibXML: Resolve the entity reference definition in DTDs
Fixes the rendering of `&lt;` in XHTML docs.
2024-10-12 23:00:09 +02:00
Ali Mohammad Pur
5c23ef1596 LibWeb: Assume XHTML <html> elements are in the HTML namespace
...unless specified otherwise explicitly.
This is dervied from an interpretation of a note in the html5 spec at
https://html.spec.whatwg.org/#xml
2024-10-12 23:00:09 +02:00
Andreas Kling
175f3febb8 LibWeb: Make DOMException take error message as a String
There was no need to use FlyString for error messages, and it just
caused a bunch of churn since these strings typically only existed
during the lifetime of the error.
2024-10-12 21:14:18 +02:00
ronak69
5f9a36feac LibWeb: Frameset should be the body element if it comes before body
Fixes one WPT test: "Frameset followed by body inside the html element"
http://wpt.live/html/dom/documents/dom-tree-accessors/Document.body.html
2024-10-12 11:52:53 -06:00
sin-ack
711faa8280 LibWeb: Remove redundant DedicatedWorkerGlobalScope prototype setting
Now that the global object correctly sets the property, we don't need
to do it here.
2024-10-12 19:21:59 +02:00
0x4261756D
6923008a55 JPEGLoader: Fix infinite loop on incomplete data
If the image data to decode is incomplete, e.g. a corrupt image missing
its last scanlines the decoder would previously keep looping for ever.
By breaking out of the loop if no more scanlines were produced we can at
least display the partial image up to that point.
2024-10-12 19:21:03 +02:00
Andreas Kling
02da288413 LibWeb: Allow CSS @import rule to import non-UTF-8 style sheets
This fixes a number of WPT crashes in the /css/CSS2/syntax directory.
2024-10-12 19:20:22 +02:00
0x4261756D
c1a14f66ad HTMLEncodingDetection: Use mime type in encoding sniffing
Also added proper spec comments.
Fixes at least one WPT test that was failing previously:
https://wpt.live/encoding/single-byte-decoder.window.html?document
2024-10-12 16:14:38 +02:00
Timothy Flynn
dae6200c1d LibWeb: Update (not replace) timeout values in WebDriver's Set Timeouts
Contradictory to the spec, the Set Timeouts endpoint should update the
existing timeouts configuration in-place, rather than replacing it. WPT
expects this, and other browsers already implement this endpoint this
way.
2024-10-12 15:02:41 +02:00
Timothy Flynn
8396afeb76 LibWeb: Update WebDriver timeout parsing/serializing to the latest spec
Namely, all fields in the timeouts object may now be null. There are a
few calling AOs that we will want to bring up to date as well.
2024-10-12 15:02:41 +02:00
Timothy Flynn
8598ed86fe LibWeb+WebContent: Implement the Element Clear endpoint 2024-10-12 15:01:35 +02:00
Timothy Flynn
516f5f7008 LibWeb: Implement the form associated element clear algorithm
This is a method defined in the WebDriver spec, but requires access to a
bunch of private fields in these classes, so this is implemented in the
same manner as the reset algorithm.
2024-10-12 15:01:35 +02:00
John Diamond
fadb14d31d LibWeb: Compare anchor/focus offsets in selection.isCollapsed
The "isCollapsed" attribute on a selection must "return true if and only
if the anchor and focus are the same".

In addition to checking that the anchor and focus belonged to the same
DOM node, we now also check that they refer to the same position within
the node.

With this change Ladybird passes all the subtests in the "isCollapsed"
WPT suite.

https://wpt.live/selection/isCollapsed.html
2024-10-12 15:00:35 +02:00
sin-ack
27b1d94e04 LibWeb: Obtain basename before passing base_url to ClassicScript::create
This would previously crash because it depended on a specific order for
evaluating function arguments, which is undefined.
2024-10-12 15:00:09 +02:00
Aliaksandr Kalenik
6452bfb612 LibWeb: Store scroll and sticky frames state in single vector
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 way we don't have to allocate separate vector with both scroll and
sticky frame that is used for display list player (scroll and sticky
frames share id pool), so player could access offset by frame id.

No behavior change.
2024-10-12 13:13:14 +02:00
Aliaksandr Kalenik
d07643b122 LibWeb: Introduce a new class responsible for scroll state
It's good to have a wrapper for scroll and sticky state instead of
directly mutating vectors with frames.

No behavior change.
2024-10-12 13:13:14 +02:00
Aliaksandr Kalenik
34261e5490 LibWeb: Don't produce save & restore commands for scroll frame id change
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 allows to substantially decrease display list length and
save/restore churn during painting.

Display list size comparison:

|               | Before | After  |
| ------------- | ------ | ------ |
| basecamp.com  | 19066  | 12248  |
| ladybird.org  | 8878   | 2220   |
| react.dev     | 39074  | 24382  |
2024-10-11 17:26:54 +02:00
Aliaksandr Kalenik
4eec621d3a LibWeb: Remove translation from display list recorded state
...and add display list item that does translation instead. By doing
that we no longer need to map each coordinate in display list by
translation in recorder state.
2024-10-11 17:26:54 +02:00
Aliaksandr Kalenik
1892cac80b LibWeb: Remove unused clip_rect from display list recorder state 2024-10-11 17:26:54 +02:00
Aliaksandr Kalenik
35d0d11e65 LibWeb: Remove post_transform_translation for stacking context
There is no explanation why it's needed and removing it does not break
any of our tests.
2024-10-11 17:26:54 +02:00
rmg-x
10acf3f6c7 RequestServer: Set CURLOPT_CONNECTTIMEOUT instead of CURLOPT_TIMEOUT
Set the connection timeout which only limits the connection phase of the
request.

Previously, CURLOPT_TIMEOUT would apply to all transfer operations which
could result in legitimate upload or download operations being
cancelled.
2024-10-11 13:18:05 +02:00
Bastian Neumann
9650cf8b15 LibJS: Do not print large arrays
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
Printing the whole array causes wpt
console/console-log-large-array.any.html to crash.
This limits logged arrays to 100 elements and
truncates the rest with ...
2024-10-11 09:59:39 +01:00
Timothy Flynn
79365c9519 UI: Migrate headless-browser to be alongside other Ladybird chromes
The headless-browser source is getting a bit unwieldy. The ordering of
class and method definitions is fragile; e.g. the application and web
view classes each require full definitions of each other. So it has
reached the point where it makes sense to give headless-browser some
better file structure.

To prepare for that, this patch simply moves its source to live along-
side the other browser chromes. This location is a bit better prepared
for creating more files, as the Utilities folder doesn't even have its
own CMakeLists.txt.
2024-10-11 09:09:40 +02:00
Timothy Flynn
23d134708c LibWeb: Begin implementing the Element Send Keys endpoint 2024-10-11 09:09:23 +02:00
Timothy Flynn
922837f31b WebDriver: Generalize asynchronous event handling
Instead of having N functions all implement the same practice of looping
until an async event has arrived, this templatizes the bulk of the work.
2024-10-11 09:09:23 +02:00
Timothy Flynn
63b24e38fa LibWeb: Support appending files to <input type=file>
This isn't exposed to the Web, but WebDriver requires this feature.
2024-10-11 09:09:23 +02:00
Aliaksandr Kalenik
0dec2dc21c LibWeb: Improve grid area calculation for abspos items in GFC
- Add support for placement of abspos items into track formed by last
  line and padding edge of grid container
- Correctly handle auto-positioned abspos items by placing them between
  padding edges of grid container

Fixes crashing on https://wpt.live/css/css-grid/abspos/positioned-grid-descendants-001.html
2024-10-11 09:08:46 +02:00
Aliaksandr Kalenik
32c467cc0e LibWeb: Introduce axis-agnostic alignment type in GFC
Allows to reuse code for both dimensions instead of duplicating the
entire switch-case.
2024-10-11 09:08:46 +02:00
rmg-x
9dd7b901ab LibWeb/ResourceLoader: Display HTTP reason phrase in error status 2024-10-11 07:43:23 +01:00
Fernando Kiotheka
caf74e7ed6 LibWeb: Implement activation behavior on input[type=reset]
This fixes WPT html/semantics/forms/resetting-a-form/reset-form.html.
I added a test based on the WPT test, but simpler.
2024-10-11 07:40:49 +01:00
pheonixfirewingz
9456359f32 LibMedia: Disable ffmpeg on windows
Also don't try to find_package the library on Android while we're here.
2024-10-10 21:48:41 -06:00
Noah Bright
f23cc02603 LibWeb: Remove constexpr from service worker ==
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
Appeasing clang. The binary == wasn't constexpr and that
crashed compilation
2024-10-10 19:08:44 -06:00
Nico Weber
cc0cfd044b LibWeb: Add stroke-linecap attribute and plumb it to SVGGraphicsElement
SVGGraphicsElement then goes ahead and does nothing with it for now.
2024-10-11 00:27:47 +01:00
Ali Mohammad Pur
202bfabdc6 LibXML: Shift some rule acceptances to make errors nicer
Instead of saying "expected />", make the parser output the real cause
for the following ("unknown reference"):
    <foo>&unknown;</foo>
2024-10-10 23:53:48 +01:00
Ali Mohammad Pur
70e769a18a LibXML: Avoid ByteString::formatted() on static "expected" errors
This is a fairly significant (~8%) speedup when parsing references.
2024-10-10 23:53:48 +01:00
Ali Mohammad Pur
02b50d463b AK: Cache all the line positions in LineTrackingLexer
Also updates a LibWeb text test that used to report the wrong line
number.
2024-10-10 23:53:48 +01:00
rmg-x
db0dbb384e RequestServer: Set default timeout to 90 seconds for all requests 2024-10-10 19:56:11 +01:00
rmg-x
ff18114ae7 LibWeb+LibRequests+RequestServer: Report network error on request finish
This allows us to bubble up network errors to API consumers after
finishing a request.
2024-10-10 19:56:11 +01:00
Neil Viloria
9e2b70661e LibWeb/Layout: Unify grid justify-content handling for grid area
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-10 13:37:08 +02:00
Timothy Flynn
d6a8fc00c3 LibWeb: Implement dispatching WebDriver key down and key up actions
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-10 10:41:10 +02:00
Timothy Flynn
5b2633d90f LibWeb: Support non-required numpad code names
These aren't required to comply with the UIEvents spec, but they are
required by WebDriver.
2024-10-10 10:41:10 +02:00
Timothy Flynn
a11e5055c7 LibWeb: Allow multi-byte code point events to have their key field set
Multi-byte code point presses do not have a UIEvents::KeyCode value, so
we would previously set the event's key field to "Unidentified".
2024-10-10 10:41:10 +02:00
Timothy Flynn
96b5646fc1 LibWeb: Properly handle when (shift+)tab wraps around the page
We have support for using (shift+)tab to move focus to the next/previous
element on the page. However, there were several ways for this to crash
as written. This updates our implementation to check if we did not find
a node to move focus to, and to reset focus to the first/last node in
the document.

This doesn't seem to work when wrapping around from the first to the
last node. A FIXME has been added for that, as this would already not
work before this patch (the main focus here is not crashing).
2024-10-10 10:41:10 +02:00
Timothy Flynn
13fe3477ab WebContent: Wait for same-URL WebDriver navigations to complete
The spec says we don't need to await navigations if we navigate to the
same URL that we are already on, but at least in our implementation, we
should still await the page load. Otherwise, we will invoke WebDriver
endpoints on the wrong page.
2024-10-10 10:41:10 +02:00
Timothy Flynn
cbf8f1495c WebContent: Create an execution context when getting an element property
Calling Object::get requires a running execution context.
2024-10-10 10:41:10 +02:00
0x4261756D
96de4ef7e0 LibTextCodec: Add SingleByteEncoders
They are similar to their already existing decoder counterparts.
2024-10-10 10:39:28 +02:00
Andrew Kaster
7faebb2702 LibWeb: Implement most of Service Worker registration
Some checks are pending
Lint Code / lint (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
CI / Lagom (false, NO_FUZZ, ubuntu-24.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-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Push notes / build (push) Waiting to run
This approach will need some rework to be properly handled at the user
agent level instead of per renderer process, but it's a start.
2024-10-09 15:58:36 -06:00
Andrew Kaster
f4f70068a8 LibWeb: Teach AK how to hash StorageKeys 2024-10-09 15:58:36 -06:00
Andrew Kaster
2156de7172 LibWeb: Spoof the ESO's creation url in tests
This is necessary when we add more ServiceWorker capabilities, that
actually check this value. The more this spoof functionality is used,
the more we'll need to actually support serving test files over https.
2024-10-09 15:58:36 -06:00
Jelle Raaijmakers
25516e351e LibWeb: Clear grapheme segmenter when invalidating TextNode text
We only set the grapheme segmenter's text once after creating a new
segmenter, so we also need to clear it whenever we invalidate the text.
2024-10-09 23:07:13 +02:00
Timothy Flynn
4fcaeabe1a LibWeb+UI: Detect and handle left vs. right modifier keys
Some checks are pending
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
CI / Lagom (false, NO_FUZZ, ubuntu-24.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-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
Our handling of left vs. right modifiers keys (shift, ctrl, etc.) was
largely not to spec. This patch adds explicit UIEvents::KeyCode values
for these keys, and updates the UI to match native key events to these
keys (as best as we are able).
2024-10-09 19:10:02 +02:00
Timothy Flynn
448754d95d LibWeb: Only fire keypress events if the key press produced a character
For example, pressing just the shift key should not producde a keypress
event.
2024-10-09 19:10:02 +02:00
Timothy Flynn
3925317c11 LibWeb: Fire keydown and keypress events sooner
Fire the events before handling any close requests or selection changes.
Pages must have an opportunity to cancel the events.
2024-10-09 19:10:02 +02:00
Jelle Raaijmakers
a58f39c9e2 LibWeb: Implement selectionchange event according to spec 2024-10-09 19:08:47 +02:00
Totto16
aab5a9e944 LibWeb: Reject Promise in createImageBitmap for Not Implemented Types
If we don't reject the Promise, it lasts forever,
so rejecting non implemented Promises is essential,
to not timeout in e.g. WPT tests
2024-10-09 17:46:27 +01:00
Aliaksandr Kalenik
a8788e5abb LibWeb: Don't ignore non-positioned stacking contexts on step 8 of paint
...traversal. We've already fixed step 3 and 9 to not filter out
non-positioned stacking contexts, because modern CSS has more ways to
create stacking context besides being positioned with z-index (like by
using "transform", "filter" or "clip-path" properties).

See following spec issue for more details https://github.com/w3c/csswg-drafts/issues/2717

Visual improvement on https://basecamp.com/
2024-10-09 18:42:20 +02:00
Aliaksandr Kalenik
83b6bc4ccb LibWeb: Don't allow SVG boxes to create a stacking context
Prior to this change, SVGs were following the CSS painting order, which
means SVG boxes could have established stacking context and be sorted by
z-index. There is a section in the spec that defines what kind of SVG
boxes should create a stacking context
https://www.w3.org/TR/SVG2/render.html#EstablishingStackingContex
Although this spec is marked as a draft and rendering order described in
this spec does not match what other engines do.

This spec issue comment has a good summary of what other engines
actually do regarding painting order
https://github.com/w3c/svgwg/issues/264#issuecomment-246432360
"as long as you're relying solely on the default z-index (which SVG1
does, by definition), nothing ever changes order when you apply
opacity/filter/etc".

This change aligns our implementation with other engines by forbidding
SVGs to create a formatting context and painting them in order they are
defined in tree tree.
2024-10-09 18:42:20 +02:00
Sam Atkins
b645e26e9b LibWeb/CSS: Bring TokenStream in line with spec
When the TokenStream code was originally written, there was no such
concept in the CSS Syntax spec. But since then, it's been officially
added, (https://drafts.csswg.org/css-syntax/#css-token-stream) and the
parsing algorithms are described in terms of it. This patch brings our
implementation in line with the spec. A few deprecated TokenStream
methods are left around until their users are also updated to match the
newer spec.

There are a few differences:

- They name things differently. The main confusing one is we had
  `next_token()` which consumed a token and returned it, but the spec
  has a `next_token()` which peeks the next token. The spec names are
  honestly better than what I'd come up with. (`discard_a_token()` is a
  nice addition too!)

- We used to store the index of the token that was just consumed, and
  they instead store the index of the token that will be consumed next.
  This is a perfect breeding ground for off-by-one errors, so I've
  finally added a test suite for TokenStream itself.

- We use a transaction system for rewinding, and the spec uses a stack
  of "marks", which can be manually rewound to. These should be able to
  coexist as long as we stick with marks in the parser spec algorithms,
  and stick with transactions elsewhere.
2024-10-09 17:29:29 +01:00
Andreas Kling
5df6c6eecf LibWeb: Don't crash when encountering calc() inside a CSS rect() value
This allows us to run the WPT tests under quirks/unitless-length/
without crashing, giving us over 4600 new passing subtests. :^)
2024-10-09 14:14:08 +01:00
Andreas Kling
5e240f997c LibWeb: Don't crash when encountering border-spacing: calc(...)
This allows us to progress further on this WPT test:
https://wpt.live/quirks/unitless-length/quirks.html

...although it still crashes before finishing.
2024-10-09 14:14:08 +01:00
Timothy Flynn
10853898fc headless-browser: Restore ability to rebaseline new tests
This regressed in commit 6eca60504e.

If we are rebaslining tests, do not fail if we are unable to open the
expectation file for reading.
2024-10-09 07:26:44 -04:00
Timothy Flynn
d80d951991 LibWeb: Restore check to prevent closing a traversable twice
We removed this check as a workaround for a spec issue that was resolved
in:

https://github.com/whatwg/html/commit/3a8303ece44ed509928be626a6a65639fd
2024-10-09 06:59:33 -04:00
Ali Mohammad Pur
cc1f0c3af2 LibRegex: Restore checkpoints when restoring the state post-fork
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
Fixes the lockup/OOM in #968.
2024-10-09 11:20:58 +02:00
Timothy Flynn
6eca60504e headless-browser: Only rebaseline tests that would have failed
We have a bit of forgiveness around allowing tests to pass with varying
trailing newlines. Only write a rebaselined test to disk if it would not
have passed under those conditions.
2024-10-09 01:45:57 +02:00
Neil Viloria
b9e7c6a2f6 LibWeb/Layout: Implement align-content for grid layout 2024-10-08 21:30:03 +02:00
Arhcout
5d00211a86 LibWeb: Don't trigger onchange event when setting <select> value
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-08 19:03:51 +02:00
Jelle Raaijmakers
69f11fc1c6 LibWeb: Implement navigator.deviceMemory
Fixes at least 2 subtests in wpt/device-memory.
2024-10-08 19:02:27 +02:00
Jelle Raaijmakers
6189d1ac9d LibWeb: Add WebIDL::Double type 2024-10-08 19:02:27 +02:00
Jelle Raaijmakers
9515290fde LibCore: Add System::physical_memory_bytes() 2024-10-08 19:02:27 +02:00
Andreas Kling
274411db97 LibWeb: Support Document.onvisibilitychange
We don't have a way to trigger this from a test, but the fix is so
simple that we might as well get it in. :^)
2024-10-08 18:49:11 +02:00
Andreas Kling
26be8f865a LibWeb: Support Document.onreadystatechange
This is just a standard IDL event attribute handler.

Fixes at least one WPT test:
https://wpt.live/html/dom/documents/resource-metadata-management/document-readyState.html
2024-10-08 18:49:11 +02:00
Jelle Raaijmakers
cb21201550 LibWeb: Implement AudioNode.channelCount 2024-10-08 14:33:42 +02:00
Jelle Raaijmakers
7b4f0d13ee LibWeb: Implement AudioNode.numberOfInputs and .numberOfOutputs 2024-10-08 14:33:42 +02:00
Jelle Raaijmakers
d7a3bad2b4 LibWeb: Forward declare AudioDestinationNode to break header loop 2024-10-08 14:33:42 +02:00
Andreas Kling
94721385ce LibWeb: Ignore boxes wholly in the negative scrollable overflow region
This fixes an issue where https://hey.com/ was horizontally scrollable
even though it shouldn't be.
2024-10-08 14:33:35 +02:00
Jamie Mansfield
f610a12671 LibWeb/UIEvents: Implement TextEvent 2024-10-08 11:45:39 +02:00
Jamie Mansfield
86e20ea246 LibWeb/UIEvents: Implement CompositionEvent 2024-10-08 11:45:39 +02:00
Jamie Mansfield
9fce70069d LibWeb/UIEvents: Implement InputEvent 2024-10-08 11:45:39 +02:00
Jamie Mansfield
60d9c3929c LibWeb: Correct forward for UIEvents::UIEvent 2024-10-08 11:45:39 +02:00
Andreas Kling
13ba491924 LibWeb: Don't let input element placeholders influence line-height
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
Before this change, we transferred the input element's line-height to
both the editable text *and* the placeholder. This caused some strange
doubling of the effective line-height when the editable text was empty,
pushing down the placeholder.
2024-10-08 08:12:07 +02:00
Tim Ledbetter
e1eeb93cc6 LibWeb: Fire iframe load event on document close
This matches the behavior of other browsers.
2024-10-08 06:55:01 +02:00
Timothy Flynn
00487a7b25 LibWebView+LibWeb: Remove ResourceLoader and WebSocket adapters
These were used to provide a layer of abstraction between ResourceLoader
and the networking backend. Now that we only have RequestServer, we can
remove these adapters to make the code a bit easier to follow.
2024-10-08 06:52:51 +02:00
Timothy Flynn
3de86cf0fa LibRequests: Add a forwarding header 2024-10-08 06:52:51 +02:00
Timothy Flynn
1b324f3ae1 LibWebView+UI: Remove Qt networking infrastructure
Now that we use libcurl, there's no reason to keep Qt networking around.
Further, it doesn't support all features we need anyways, such as non-
buffered request handling for SSE.
2024-10-08 06:52:51 +02:00
Tim Ledbetter
fd8d350b47 LibWeb: Don't discard PostedMessage tasks when closing a worker
The spec expects `postMessage()` to act as if it is invoked
immediately. Since `postMessage()` isn't actually invoked immediately,
keep tasks with source `PostedMessage` in the task queue, so that these
tasks are processed. Fixes a hang when `WorkerGlobalScope.close()` is
called immediately after `postMessage()`.
2024-10-08 06:51:04 +02:00
Noah Bright
d30ae92b82 LibWeb: Define PerformanceEventTiming
https://www.w3.org/TR/event-timing/#sec-performance-event-timing

Add idl, header and stubs for PerformanceEventTiming interface.

Two missing `PerformanceEntry` types that have come up in issues
are the `first-input` and the `event` entryTypes. Those are both
this.

Also, because both of those are this same interface, the static
methods from the parent class are difficult to implement because
of instance-specific details. Might either need subclasses or to
edit the parent and also everything that inherits from it :/
2024-10-08 03:44:55 +02:00
Tim Ledbetter
d0008ae5e0 LibWeb: Don't print messages from workers to the console twice
Previously, any message logged to the console within a worker with a
log level greater than trace was printed twice.
2024-10-07 21:22:12 +02:00
Timothy Flynn
598fabbdd3 LibWebView: Increase the open file limit in a more central location
We don't create a ChromeProcess in headless-browser, so it is currently
not increasing it's open file limit. This is causing crashes on macOS,
which has a very low default limit.
2024-10-07 14:03:03 -04:00
Aliaksandr Kalenik
97066f09f4 LibWeb: Use PaintableBox::is_scrollable() while dispatching wheel event
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
With this change we use the same function to determine whether to render
scroll thumb and whether box wants to accept scroll UI events.
2024-10-07 18:35:24 +02:00
Aliaksandr Kalenik
a46c2a0887 LibWeb: Forbid scrolling of viewport if overflow=hidden
Before this change viewport was allowed to be scrolled whenever it has a
scrollable overflow, which is not correct when overflow is specified to
be hidden.
2024-10-07 18:35:24 +02:00
Khaled Lakehal
77761e123d LibWeb/CSS: Add support for unicode-bidi property 2024-10-07 14:57:15 +01:00
Gingeh
16f2f6aa42 LibWeb: Make empty media query lists evaluate to true 2024-10-07 14:50:57 +01:00