Commit graph

1994 commits

Author SHA1 Message Date
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
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
301502a3a1 LibWeb: Add coverage test for calc() usage
Ignoring the fact that we should serialize a simplified form of calc()
expressions, the following are wrong:

- grid-auto-columns
- grid-auto-rows
- grid-template-columns
- grid-template-rows
- transform-origin

Generated in part with this python script (though I've since iterated on
the output repeatedly so it's quite different):

```py
import json
properties_file = open("./Userland/Libraries/LibWeb/CSS/Properties.json")
properties = json.load(properties_file)
for (key, value) in properties.items():
    if not 'valid-types' in value:
        continue
    if 'longhands' in value:
        continue
    valid_types = value['valid-types']
    for type_string in valid_types:
        name, *suffix = type_string.split(None, 1)
        match name:
            case 'integer' | 'number':
                print(f'{key}: calc(2 * var(--n));')
            case 'angle':
                print(f'{key}: calc(2deg * var(--n));')
            case 'flex':
                print(f'{key}: calc(2fr * var(--n));')
            case 'frequency':
                print(f'{key}: calc(2hz * var(--n));')
            case 'length':
                print(f'{key}: calc(2px * var(--n));')
            case 'percentage':
                print(f'{key}: calc(2% * var(--n));')
            case 'resolution':
                print(f'{key}: calc(2x * var(--n));')
            case 'time':
                print(f'{key}: calc(2s * var(--n));')
```
2024-10-16 08:34:02 +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
Andrew Kaster
9d0ce4df0f LibWeb: Add support for parsing comments in the Swift HTML tokenizer 2024-10-16 08:31:42 +02: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
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
Andrew Kaster
10a2cc3781 Tests: Use Swift.String extension instead of manual conversion
This fixes a build error with Swift 6.0 on macOS.
2024-10-14 16:55:09 -04: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
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
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
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
64308c8c06 LibWeb: Test for parseFromString parsererror
This tests if the parsed xml string gets tagged with a parsererror.
2024-10-14 16:20:57 +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
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
Sam Atkins
9241f37823 LibWeb: Add a CSS parsing test for selectors containing ':' in @media
While updating the parser to the latest spec algorithms, this started
parsing incorrectly as a declaration, and we had no tests covering it.
2024-10-14 08:08:37 +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
justus2510
55f0dc823f LibWeb: Handle unpaired surrogates in USVStrings
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, 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 should fix (at least) the last two remaining WPT test failures in
FileAPI/unicode.html.
2024-10-13 22:24:28 +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
Cory Virok
6a5bca1302 LibWeb: Added tests for missing xmlns during XHMTL parsing
The main culprit for the following WPT test failure is that we
weren't using the HTML namespace for XHTML docs unless one was
explicitly provided.
2024-10-13 00:24:25 +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
d5948709cd BindingsGenerator: Handle global interfaces without named properties
DedicatedWorkerGlobalScope is an object with a Global extended
attribute, but does not define any named property getters. This needs to
be handled by setting the prototype chain to:

    DedicatedWorkerGlobalScope
    ^ DedicatedWorkerGlobalScopePrototype
    ^ WorkerGlobalScopePrototype

(This is different from something like Window, where there is an
intermediate WindowProperties object for named properties.)

Previously, we treated the GlobalMixin object as if it was a simple
prototype object, accidentally setting DedicatedWorkerGlobalScope's
prototype to WorkerGlobalScopePrototype. This caused the expression

    self instanceof DedicatedWorkerGlobalScope

to return false inside workers.

This makes us pass many more of the "/xhr/idlharness.any.worker" WPT
tests than before, rather than failing early.
2024-10-12 19:21:59 +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
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
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
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
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
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
Timothy Flynn
512cea5a87 LibWeb: Bring back the test video for LibWeb tests
The video was accidentally removed in commit d5ba665f89.

This adds the video back to the LibWeb/Text/data folder, and validates
that the video loads in the test that depends on it loading.
2024-10-10 17:52:58 -04: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
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
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
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
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
43a07a0fde LibWeb: Rebaseline HTMLSelectElement-value-change-trigger-onchange.html
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
The PR which added this test was opened before the headless-browser
change to only test the inner text of the <pre> node containing println
output.
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
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
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
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
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
Timothy Flynn
be9071834e LibWeb: Wait for the iframe load before completing the beforeunload test
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 test caused some flakiness due to the about:blank load it triggers.
It causes headless-browser to receive a load event for about:blank. If
we have moved onto the next test before that event arrived, that test
would ultimately time out, as its own load will have been dropped while
the about:blank load is still ongoing.

This patch makes us wait for that iframe load event before completing
the test.

We may want to consider never sending subframe load events to the UI
process as well. We really only care about top-level page loads in the
receivers of that event.
2024-10-07 16:03:42 -04: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
Shannon Booth
30377e6e35 LibWeb: Do not spin the event loop on processing iframe attributes
Partially reverting a3149c1ce9

Spinning the event loop was causing a crash on:

https://wpt.live/url/percent-encoding.window.html

As it was turning what is meant to be a synchronous operation into an
asynchronous one.

The sequence demonstrated by the reproducing test is as follows:
  * A src attribute is changed for the iframe
  * process_the_iframe_attributes entered with valid content navigable
  * Event loop is spun, allowing the queued iframe removal to execute
  * process_the_iframe_attributes continues with null content navigable
  * 💥
2024-10-07 15:10:41 +02:00
Andreas Kling
2fdf2b9215 LibWeb: Allow SVG root elements to have visible overflow
We were overly aggressive in clipping SVG roots, which effectively made
them behave as if they always had `overflow: hidden`.

This fixes incorrect clipping of the logo on https://basecamp.com/
2024-10-07 09:31:25 +02:00
Timothy Flynn
b1718f5691 LibWeb: Disable remaining Worker tests for now
These time out on macOS CI.
2024-10-06 19:24:25 +02:00
Shannon Booth
ea971792b5 LibWeb: Throw a SyntaxError on invalid URL for Location href setter
Aligning with a spec update, fixing 195 tests for:

https://wpt.live/url/failure.html
2024-10-06 10:06:26 -04:00
Andreas Kling
59ed823724 LibWeb: Resolve flex item % main size to 0 during min-content sizing
When the flex container is sized under a min-content constraint in the
main axis, any flex items with a percentage main size should collapse
to zero width, not take up their own intrinsic min-content size.

This is not in the spec, but matches how other browsers behave.

Fixes an issue where the cartoons on https://basecamp.com/ were way
too large. :^)
2024-10-06 16:04:00 +02:00
Timothy Flynn
aa1df95b31 LibWeb: Implement window.close and window.closed 2024-10-06 01:42:24 +01:00
Andreas Kling
077bc68a4c LibWeb: Allow intrinsic width layout to see definite heights
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 were already allowing intrinsic height layout to see definite widths,
and I can't think of a reason *not* to allow it the other way around.

More importantly, this fixes an issue where things with an aspect ratio
didn't have a height to resolve against before.

Makes the logo show up on https://basecamp.com/ :^)
2024-10-05 19:24:20 +02:00
Neil Viloria
4bda65c8b3 LibWeb/Layout: Implement justify-content for column spacing in grid 2024-10-05 19:21:49 +02:00
Shannon Booth
088b659abd LibURL: Do not treat port of 0 as a null port in Origin
It is not treated as the same thing in the specification, or by us in
other places too. This fixes 8 more origin related URL tests on WPT.
2024-10-05 10:46:30 +02:00
Shannon Booth
501f92b54e LibWeb+LibURL: Consolidate Origin parsing and serialization into LibURL
Because of the previous awkward factoring of Origin we had two
implementations of Origin serializing and creation. Move the
implementation of DOMURL::url_origin into URL::origin, and
instead use the implemenation of URL::Origin::serialize for
serialization (replacing URL::serialize_origin).

This happens to fix 8 URL subtests as the two implemenations had
diverged, and URL::serialize_origin was previously missing the spec
changes of: whatwg/url@eee49fd and whatwg/url@fff33c3
2024-10-05 10:46:30 +02:00
Shannon Booth
e9dd05b2b5 LibWeb: Correct attributes on IDL interface 'operations'
This fixes four tests for the IDL harness for URL under:

https://wpt.live/url/idlharness.any.html
and https://wpt.live/url/idlharness.any.worker.html

But probably some tests in other places too :^)
2024-10-05 10:46:30 +02:00
Totto16
abe1172d70 LibWeb: Make HTMLVideoElement part of CanvasImageSource union
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-05 09:20:58 +02:00
Andrew Kaster
8edaec79de LibWeb: Add a feature to LibWeb tests to fail on unhandled exceptions
Previously, if there was an unhandled exception in an async test, it
might fail to call done() and timeout. Now we have a default "error"
handler to catch unhandled exceptions and fail the test. A few tests
want to actually test the behavior of window.onerror, so they need an
escape hatch.
2024-10-05 09:18:32 +02:00
Tim Ledbetter
1fa948f114 LibWeb: Implement the "check if unloading is canceled" AO
This method is responsible for firing `beforeunload` events.
2024-10-05 09:17:34 +02:00
Tim Ledbetter
99ef078c97 LibWeb: Implement BeforeUnloadEvent
This is required to support legacy behavior of the `returnValue`
attribute.
2024-10-05 09:17:34 +02:00
scorpion-26
d00adabc3c LibWeb: Preserve order of HTMLCollection property names
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
The supported property names should be ordered in "tree order", though
m_cached_name_to_element_mappings doesn't preserve this ordering, which
breaks Object.getOwnPropertyNames.

Fixes at least the following WPT tests:
 - https://wpt.live/dom/nodes/Element-children.html
 - https://wpt.live/dom/collections/HTMLCollection-live-mutations.window.html
 - https://wpt.live/dom/collections/HTMLCollection-supported-property-names.html
2024-10-04 22:43:44 +01:00
Andreas Kling
cd0e4a49b8 LibWeb: Make SVGImageElement part of CanvasImageSource union
This is very janky at the moment but it also more correct. :^)
2024-10-04 20:01:22 +02:00
Andreas Kling
902586a21d LibWeb: Fail CSS color parse for "rgba(123, 123, 123, "
This matches the behavior of other browsers and fixes a WPT test.
2024-10-04 20:01:22 +02:00
Andreas Kling
4590c081c2 LibWeb+LibGfx: Serialize HTML canvas fill/strokeStyle colors correctly
Before this change we were serializing them in a bogus 8-digit hex color
format that isn't actually recognized by HTML.

This code will need more work when we start supporting color spaces
other than sRGB.
2024-10-04 20:01:22 +02:00
Tim Ledbetter
d0b97873d4 LibWeb: Follow spec steps to set the selectionDirection attribute value 2024-10-04 19:42:33 +02:00
Aliaksandr Kalenik
e0cd2edccb Tests/LibWeb: Disable cross-origin-window-properties.html test for now
After https://github.com/LadybirdBrowser/ladybird/pull/1616 got merged
this test started to occasionaly timeout on Linux CI:
https://github.com/LadybirdBrowser/ladybird/actions/runs/11174338933/job/31063881592
https://github.com/LadybirdBrowser/ladybird/actions/runs/11177347649/job/31072646967?pr=1623

Since it's only this test that is timing out, I'm concluding that the
event loop processing change is working fine and the issue lies with the
test itself, so let's disable it for now.
2024-10-04 17:56:08 +02:00
Andrew Kaster
29416befe6 LibWeb: Add ServiceWorker job registration and execution
Now we can register jobs and they will be executed on the event loop
"later". This doesn't feel like the right place to execute them, but
the spec needs some updates in this regard anyway.
2024-10-04 07:08:08 +02:00
Andreas Kling
0b403d30d7 LibWeb: Don't swallow args when forwarding cross-origin WindowProxy call
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 at least one WPT test that was previously timing out:
- html/semantics/document-metadata/the-base-element/base_target_does_not_affect_iframe_src_navigation.html
2024-10-03 20:49:45 +02:00
Timothy Flynn
d33a87c8c4 LibWeb+Documentation: Remove the rebaseline-libweb-test script
This is superseded by the headless-browser --rebaseline flag.
2024-10-03 09:15:45 -04:00
Timothy Flynn
bf668696de LibWeb+WebContent: Do not include DOM HTML in text test expectations
For example, in the following abbreviated test HTML:

    <span>some text</span>
    <script>println("whf")</script>

We would have to craft the expectation file to include the "some text"
segment, usually with some leading whitespace. This is a bit annoying,
and makes it difficult to manually craft expectation files.

So instead of comparing the expectation against the entire DOM inner
text, we now send the inner text of just the <pre> element containing
the test output when we invoke `internals.signalTextTestIsDone`.
2024-10-03 07:07:28 -04:00
Timothy Flynn
f3f7f77dbc LibWeb: Wait for the correct condition in Stream tests
We were signaling that the test is complete too early in some Stream
tests.
2024-10-03 07:07:28 -04:00
Timothy Flynn
c9cbaeb59d LibWeb: Convert some sync tests to be async
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.
2024-10-03 07:07:28 -04:00
Timothy Flynn
96082d6ae1 LibWeb: Port some manually async tests to use asyncTest
These tests were mostly async tests written in a manual way. This ports
them to use the standard asyncTest() infrastructure.

This is mostly just to reduce calls to internals.signalTextTestIsDone,
which will have a required parameter in an upcoming test.
2024-10-03 07:07:28 -04:00
Jelle Raaijmakers
2106617f5b LibWeb: Implement history.scrollRestoration 2024-10-02 17:08:17 -06:00
Kemal Zebari
b8a5e18a01 LibWeb/MimeSniff: Update the MIME type sniffing algo to meet specs
The spec moved/added the xml and html checks to the beginning and
removed sniffing resource feeds.
2024-10-02 16:15:23 -04:00
Sam Atkins
ea95e32539 Tests: Use .invalid TLD for invalid requests
RFC2606 and RFC6761 define .invalid as a guaranteed-invalid TLD, so
let's use it. Theoretically this should make the request fail much
faster.
2024-10-02 16:04:17 -04:00
Sam Atkins
c497e5f850 LibWeb: Serialize more @font-face descriptors
Adapt the existing `font-face-src-local-serialization.html` test into a
more general test for these.
2024-10-02 16:28:55 +01:00
Sam Atkins
95c17dfab5 LibWeb/CSS: Parse and propagate font-feature-settings property 2024-10-02 16:28:55 +01:00
Sam Atkins
55812aaed2 LibWeb/CSS: Parse and propagate font-variation-settings property 2024-10-02 16:28:55 +01:00
Aliaksandr Kalenik
94b3b84dd8 LibWeb: Make sure style is up-to-date in getAnimations()
StyleComputer is responsible for assigning animation targets, so we
have to make sure there are no pending style updates before querying
animations of an element.

This change also introduces a version of getAnimations() that does not
check style updates and used by StyleComputer to avoid mutual recursion.
2024-10-02 16:28:37 +01:00
Kostya Farber
68a28ff33a LibWeb/CSS: Parse the tab-size property 2024-10-02 10:27:15 +01:00
Tim Ledbetter
140dc95e67 LibWeb: Map dimension attributes for table elements 2024-10-02 09:50:54 +02:00
Tim Ledbetter
728236f4d2 LibWeb: Map embedded content element attributes to dimension properties 2024-10-02 09:50:54 +02:00
Tim Ledbetter
baca0e5e55 Libweb: Map marquee attributes to dimension properties 2024-10-02 09:50:54 +02:00
Tim Ledbetter
4c3101e021 LibWeb: Map hr width attribute to the width dimension property 2024-10-02 09:50:54 +02:00
Andrew Kaster
d96c7edfb6 LibWeb: Add more HTML tokenization states to Swift implementation
This patch adds support for start and end tags, as well as script tag
rules.
2024-10-02 09:44:38 +02:00
Andrew Kaster
951f4f0984 Tests: Run swift-format on TestLibWebSwiftBindings 2024-10-01 13:33:05 -06:00
Andrew Kaster
7aa0165fe7 LibWeb: Deduplicate attributes when emitting start and end tags
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
The HTML tokenizer specification says that we're supposed to do this
when leaving the Attribute name or when emitting the token, as
appropriate.

Hopefully 'as appropriate' can mean only when emitting the token, as
that's the easiest place to insert this logic without complicating the
tokenizer any more.
2024-10-01 11:04:28 +02:00
Aliaksandr Kalenik
814fa0682a LibWeb: Delete public constructor of FontFaceSet
The IDL definition in the spec does not have a public constructor, and
our test that relies on it was failing to run in other browsers.
2024-09-30 08:07:59 +02:00
Timothy Flynn
ee7b90b789 LibWeb: Disable worker-crypto test for now
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
This times out on macOS CI.
2024-09-29 16:51:52 -04:00
Timothy Flynn
dd5a0361f2 LibWeb: Dispatch click events using the correct button/buttons
We were generating click events always using the primary mouse button
instead of the provided button, and with the buttons field set to that
provided button.
2024-09-29 19:30:27 +02:00
Andreas Kling
f1be662f68 LibWeb: Always blockify the root element
This is what the spec tells us to do:

    The root element’s display type is always blockified,
    and its principal box always establishes an independent
    formatting context.

    Additionally, a display of contents computes to block
    on the root element.

Spec link: https://drafts.csswg.org/css-display/#root

Fixes #1562
2024-09-29 11:46:13 +02:00
Sam Atkins
1d8867d9ae LibWeb/CSS: Parse and propagate the font-language-override property 2024-09-28 14:42:26 +02:00
Sam Atkins
4a67b28600 LibWeb/CSS: Make font-stretch a legacy alias for new font-width
CSS Fonts level 4 renames font-stretch to font-width, with font-stretch
being left as a legacy alias. Unfortunately the other specs have not yet
been updated, so both terms are used in different places.
2024-09-28 14:42:26 +02:00
Aliaksandr Kalenik
3a5e78780e LibWeb: Implement "The percentage height calculation quirk" in BFC
See https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk

Basically, it means that in quirks mode, percentage height needs to be
resolved against nearest ancestor in the containing block chain that
does not have height=auto.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/365
2024-09-28 14:41:26 +02:00
Aliaksandr Kalenik
9098e39a43 LibWeb: Resolve not auto height before child box layout in BFC
It's possible to resolve box's height without doing inner layout, when
computed value is not auto. Doing that fixes height resolution, when box
with percentage height has containing block with percentage height.

Before:
- resolve used width
- layout box's content
- resolve height

After:
- resolve used width
- resolve height if treated as not auto
- layout box's content
- resolve height if treated as auto
2024-09-27 20:25:25 +02:00
Sam Atkins
fdcece2e88 LibWeb/CSS: Implement legacy name aliases for properties
When a property is a "legacy name alias", any time it is used in CSS or
via the CSSOM its aliased name is used instead.
(See https://drafts.csswg.org/css-cascade-5/#legacy-name-alias)

This means we only care about the alias when parsing a string as a
PropertyID - and we can just return the PropertyID it is an alias for.
No need for a distinct PropertyID for it, and no need for LibWeb to
care about it at all.

Previously, we had a bunch of these properties, which misused our code
for "logical aliases", some of which I've discovered were not even
fully implemented. But with this change, all that code can go away, and
making a legacy alias is just a case of putting it in the JSON. This
also shrinks `StyleProperties` as it doesn't need to contain data for
these aliases, and removes a whole load of `-webkit-*` spam from the
style inspector.
2024-09-27 17:16:23 +01:00
Tim Ledbetter
579a289d3d LibWeb: Fire error event when script has an execution error
We now use the "report an exception" AO when a script has an execution
error. This has mostly replaced the older "report the exception" AO in
various specifications. Using this newer AO ensures that
`window.onerror` is invoked when a script has an execution error.
2024-09-27 07:02:20 -04:00
Andreas Kling
795471ce31 LibWeb: Render CSS and SVG masks on the GPU if possible
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
Instead of converting images to alpha masks on the CPU, we now delegate
that work to the GPU if possible, by way of SkSL shaders.

This noticeably speeds up https://vercel.com/ which has a ton of SVG
masking going on. The old implementation used 15% of CPU time when
loading the page, this one uses basically none.
2024-09-26 16:30:50 +02:00
Andreas Kling
ef9208047d LibJS: Don't infinite loop on unknown console.log formatting specifiers 2024-09-26 10:14:09 +02:00
Sam Atkins
bea47a2554 LibWeb/CSS: Correct behavior of revert inside a @layer
`revert` is supposed to revert to the previous cascade origin, but we
previously had it reverting to the previous layer. To support both,
track them separately during the cascade.

As part of this, we make `set_property_expanding_shorthands()` fall back
to `initial` if it can't find a previous value to revert to. Previously
we would just shrug and do nothing if that happened, which only works
if the value you want to revert to is whatever is currently in `style`.
That's no longer the case, because `revert` should skip over any layer
styles that have been applied since the previous origin.
2024-09-26 08:08:38 +02:00
Jamie Mansfield
973f774e56 LibWeb/WebVTT: Implement VTTCue idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
1a012f279a LibWeb/WebVTT: Implement VTTRegion idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
cfec88feb3 LibWeb/HTML: Implement TextTrackCueList idl interface 2024-09-24 23:48:56 +01:00
Jamie Mansfield
0b2449d8d2 LibWeb/HTML: Implement TextTrackCue idl interface 2024-09-24 23:48:56 +01:00
Andreas Kling
9765a733d0 LibWeb: Don't extrapolate transition properties for unknown properties
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
If we don't recognize a given transition-property value as a known CSS
property (one that we know about, not necessarily an invalid one),
we should not extrapolate the other transition-foo values for it.

Fixes #1480
2024-09-24 21:53:43 +02:00
Andreas Kling
e40ad73ae7 LibWeb: Allow setting shorthand CSS properties via CSSStyleDeclaration
We now expand shorthands into their respective longhand values when
assigning to a shorthand named property on a CSSStyleDeclaration.

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

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

Note that multi-level recursive shorthands like `border` don't work
100% correctly yet. We're going to need a bunch more logic to properly
serialize e.g `border-width` or `border` itself.
2024-09-22 09:45:59 +02:00
Sam Atkins
a1fca1a7f3 LibWeb: Start transitions when affected properties change
Co-authored-by: Matthew Olsson <matthewcolsson@gmail.com>
2024-09-22 06:41:55 +02:00
Aliaksandr Kalenik
91b2cd7d31 LibWeb: Account for x-axis in static position for inline items
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
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
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (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
..and delay static position calculation in IFC until trailing
whitespace are removed, because otherwise it's not possible to correctly
calculate x offset.
2024-09-21 20:10:49 +02:00
Aliaksandr Kalenik
19afc5b11b LibWeb: Align to padding edge only auto positioned abspos grid items
Containing block for abspos grid items depends on their grid placement:
- if element has definite grid position, then corresponding grid area
  should be used as a containing block
- if element does not have definite grid position, then padding edge of
  grid container should be used as a containing block

So offset should be adjusted for paddings only for boxes without
definite grid position.
2024-09-21 20:10:49 +02:00
Timothy Flynn
2303142386 LibWeb: Always call document.close after document.write
This ensures the HTML parser completes running if it previously stopped
at an insertion point during a call to `document.write`.
2024-09-21 18:42:17 +02:00
Andreas Kling
a0ed12e839 LibWeb: Always flush character insertions before exiting HTML parser
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
This fixes an issue where document.write() with only text input would
leave all the character data as unflushed text in the parser.

This fixes many of the WPT tests for document.write().
2024-09-21 10:05:48 +02:00
Tim Ledbetter
089139f09d LibWeb: Return a WindowProxy from document.defaultView
This aligns our implementation with the most recent specification steps.
2024-09-21 10:05:34 +02:00
Timothy Flynn
f0105b473b LibWeb: Iterate over text chunks using a grapheme-aware segmenter
Our current text iterator is not aware of multi-code point graphemes.
Instead of simply incrementing an iterator one code point at a time, use
our Unicode grapheme segmenter to break text into fragments.
2024-09-21 08:57:54 +02:00
Andreas Kling
8543b8ad6a LibWeb: Let style elements remember which StyleSheetList they live in
Instead of trying to locate the relevant StyleSheetList on style element
removal from the DOM, we now simply keep a pointer to the list instead.

This fixes an issue where using attachShadow() on an element that had
a declarative shadow DOM would cause any style elements present to use
the wrong StyleSheetList when removing themselves from the tree.
2024-09-21 08:56:01 +02:00
Pavel Panchekha
9075f64cac LibWeb: Change inline float clearance to not reset margin collapsing
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (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 (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 a block container has `clear` set and some clearance is applied,
that clearance prevents margins from adjoining and therefore resets
the margin state. But when a floating box has `clear` set, that
clearance only goes between floating boxes so should not reset margin
state. BlockFormattingContexts already do that correctly, and this PR
changes InlineFormattingContext to do the same.

Fixes #1462; adds reduced input from that issue as test.
2024-09-21 01:55:43 +02:00
Andrew Kaster
c77d9a2732 LibWeb: Start implementing serviceWorker.register
This is mostly the fun boilerplate. Actually creating the Job queue
to do the heavy lifting is next.
2024-09-20 22:41:24 +01:00
Andrew Kaster
acd604c5e1 LibWeb: Add a test-only API to spoof the current URL and origin
This is not that easy to use for test developers, as forgetting to set
the url back to its original state after testing your specific API will
cause future navigations to fail in inexplicable ways.
2024-09-20 22:41:24 +01:00
Andrew Kaster
a0c07d1bb2 LibWeb: Add stub of ServiceWorker interface 2024-09-20 22:41:24 +01:00
Annya
75c7dbc5d2 LibWeb: Implement Range's extension method
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
This patch implements `Range::getClientRects` and
`Range::getBoundingClientRect`. Since the rects returned by invoking
getClientRects can be accessed without adding them to the Selection,
`ViewportPaintable::recompute_selection_states` has been updated to
accept a Range as a parameter, rather than acquiring it through the
Document's Selection.

With this change, the following tests now pass:

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

Note: The test
"css/cssom-view/range-bounding-client-rect-with-display-contents.html"
still fails due to an issue with Element::getClientRects, which will
be addressed in a future commit.
2024-09-20 19:58:20 +02:00
Tim Ledbetter
087fcb84cb LibWeb: Don't crash when resolving grid properties of inline elements
Previously, attempting to get the computed value for a
grid-template-rows or grid-template-columns property would cause a
crash for inline elements.
2024-09-20 08:16:33 +02:00
Aliaksandr Kalenik
15c47dc623 Meta+LibWeb: Update Skia to version 129 2024-09-19 14:07:16 -04:00
Timothy Flynn
e74d2b1762 LibWeb+LibWebView: Set the default path for invalid cookie Path values
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
We were missing this spec step when parsing the Path attribute.
2024-09-19 00:01:56 +01:00
Timothy Flynn
ba1189cd1c LibWeb: Support cookie Max-Age attributes that exceed i64 limits
Attributes have a max value length of 1024. So we theoretically need to
support values in the range -${"9".repeat(1023)} to ${"9".repeat(1024)}.
These obviously do not fit in an i64, so we were previously failing to
parse the attribute.

We will now cap the parsed value to the numeric limits of an i64, after
ensuring that the attribute value is indeed a number.
2024-09-19 00:01:56 +01:00
Tim Ledbetter
779de840af LibWeb: Don't crash when resolving style of grid template properties
Previously, attempting to get the computed value for a
grid-template-rows or grid-template-columns property would cause a crash
if the element had no associated paintable.
2024-09-18 17:38:20 +01:00
Aliaksandr Kalenik
fa907029ee LibWeb: Print FIXME instead of crashing in abspos SVG element layout
Currently we are crashing in `verify_cast<BlockContainer>(box)` on
attempt to create BFC for SVG box.
2024-09-18 15:50:05 +02:00
Aliaksandr Kalenik
e3e0041c7f Tests/LibWeb: Add layout test for float box with box-sizing=border-box
Adds a test for d6a31d80c0 that was
mistakenly ommited in the first place.
2024-09-18 15:49:40 +02:00
Sam Atkins
eaea80007c Tests: Make rebaseline's build-dir check unambiguous
At least on my Linux machine using zsh, this line was interpreted as

  ( cd "$build_dir" || echo ... ) && exit 1

instead of the intended

  cd "$build_dir" || ( echo ... && exit 1 )

...meaning that it always exited regardless of whether it found the
build dir or not. So, let's make the intended precedence explicit.
2024-09-18 12:41:57 +01:00
Tim Ledbetter
89b6cd3fb1 LibWeb: Expose crypto object to workers
This change moves the `crypto()` getter from `Window` to
`WorkerOrWindowGlobalScope`. This aligns our implementation with the
WebCrypto specification.
2024-09-18 10:09:01 +02:00
Aliaksandr Kalenik
41e37f0079 LibWeb: Use correct resolved type for round() CSS function
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
Function is defined as `round(<rounding-strategy>?, A, B?)`

With this change resolved type is `typeof(resolve(A))`, instead of
`typeof(A)`.

For example `round(up, 20%, 1px)` with 200px percentage basis is now
correctly resolved in 40px instead of 40%.

Progress on https://www.notion.so/ landing page.
2024-09-17 20:02:29 +02:00
Aliaksandr Kalenik
5f74da6ae8 LibWeb: Fix "box-sizing: border-box" resolution for abspos items
The `calculate_inner_width()` and `calculate_inner_height()` resolve
percentage paddings using the width returned by
`containing_block_width_for()`. However, this function does not account
for grids where the containing block is defined by the grid area to
which an item belongs.

This change fixes the issue by modifying `calculate_inner_width()` and
`calculate_inner_height()` to use the already resolved paddings from the
layout state. Corresponding changes ensure that paddings are resolved
and saved in the state before box-sizing is handled.

As a side effect, this change also improves abspos layout for BFC where
now paddings are resolved using padding box of containing block instead
of content box of containing block.
2024-09-17 07:56:18 +02:00
Aliaksandr Kalenik
805b0fed13 LibWeb: Use grid area size for abspos grid items alignment
Fixes yet another case of GFC bug, where Node::containing_block() should
not be used for grid items, because their containing block is grid area
which is not represented in layout tree.
2024-09-17 07:51:50 +02:00
Timothy Flynn
fce003a8f5 LibWeb+LibWebView: Implement the latest cookie draft RFC
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (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 (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
We currently implement the official cookie RFC, which was last updated
in 2011. Unfortunately, web reality conflicts with the RFC. For example,
all of the major browsers allow nameless cookies, which the RFC forbids.

There has since been draft versions of the RFC published to address such
issues. This patch implements the latest draft.

Major differences include:
* Allowing nameless or valueless (but not both) cookies
* Formal cookie length limits
* Formal same-site rules (not fully implemented here)
* More rules around cookie domains
2024-09-17 00:04:33 +01:00
Aliaksandr Kalenik
6481ef821d LibWeb: Use available size in calculate_inner_height()
Although the parameter is named "available size," it is always supposed
to represent the containing block size whenever it has a definite value.
Therefore, it is possible to simply use this value instead of performing
a containing block lookup.

This change actually improves correctness for grid items whose
containing block is defined by the grid area, as
`Node::containing_block()` does not account for this.
2024-09-15 18:00:08 +02:00
Aliaksandr Kalenik
9621439db0 LibWeb: Assign static position for abspos boxes nested into TFC
TFC is not aware of how to correctly calculate a static position for
abspos boxes, but assigning (0, 0) is better than crashing during abspos
item layout.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/1382
2024-09-14 15:04:08 +02:00
Aliaksandr Kalenik
3d63549ede Tests/Layout: Update expectation for abspos-box-with-replaced-element
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
Updates expectation file for test that has been affected by
6199870528
2024-09-13 17:13:36 +02:00
Aliaksandr Kalenik
de3c007d79 LibWeb: Fix min-width and max-width resolution for grid items
Change try_compute_width() to check whether min-width/max-width or width
is auto instead of always using `computed_values.width()`.

`grid/min-max-content.html` test is affected but it's progression.
2024-09-13 11:59:51 +02:00
Aliaksandr Kalenik
a64d182583 LibWeb: Use grid area as available size for abspos contained in GFC
Fixes incorrect percentage length resolution for abspos boxes contained
by a grid.
2024-09-12 21:07:41 +02:00
Gingeh
1d9c404b8c LibWeb: Don't move focus when setting input value
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-12 11:45:34 +02:00
Aliaksandr Kalenik
863416e3ac LibWeb: Make FC of containing block responsible for abspos layout
Before this change, a formatting context was responsible for layout of
absolutely positioned boxes whose FC root box was their parent (either
directly or indirectly). This only worked correctly when the containing
block of the absolutely positioned child did not escape the FC root.
This is because the width and height of an absolutely positioned box are
resolved based on the size of its containing block, so we needed to
ensure that the containing block's layout was completed before laying
out an absolutely positioned box.

With this change, the layout of absolutely positioned boxes is delayed
until the FC responsible for the containing block's layout is complete.
This has affected the way we calculate the static position. It is no
longer possible to ask the FC for a box's static position, as this FC's
state might be gone by the time the layout for absolutely positioned
elements occurs. Instead, the "static position rectangle" (a concept
from the spec) is saved in the layout state, along with information on
how to align the box within this rectangle when its width and height are
resolved.
2024-09-12 07:36:32 +02:00
Annya
bea7eec518 LibWeb/CSS: Implement revert-layer
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
With the introduction of the cascade layer, the 5th CSS-wide keyword,
`revert-layer`, has been added.
2024-09-11 22:30:20 +01:00
Tim Ledbetter
67981af276 LibWeb: Don't group radio buttons from different trees together
Previously, we were searching for other radio buttons from the document
root, rather than the element root.
2024-09-11 07:59:29 +02:00
Tim Ledbetter
f9282f65d3 LibWeb: Treat dates and times with repeated separators as invalid
These would previously be treated as valid by the value sanitization
algorithm.
2024-09-10 15:59:30 -04:00
Tim Ledbetter
0de3145071 LibWeb: Don't crash when determining slot element auto directionality 2024-09-10 15:59:01 -04:00
Tim Ledbetter
1b74104c17 LibWeb: Make input type state change handling specification compliant
This change ensures that the value sanitization algorithm is run and
the text cursor is set to the correct position when the type attribute
of an input is changed.
2024-09-10 16:12:58 +01:00
Tim Ledbetter
eb4e40bc49 LibWeb: Use correct value when parsing datetime-local input type 2024-09-10 16:12:58 +01:00
Gingeh
1d30d84f41 LibWeb: Add tests for justify-*: left/right 2024-09-10 10:40:07 +01:00
Aliaksandr Kalenik
ee41dbfec3 LibWeb: Fix wrong assumption that repeat() is always first track [GFC]
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
Fixes crashing in
https://wpt.live/css/css-grid/grid-definition/grid-auto-fit-columns-001.html
2024-09-09 22:05:30 +02:00
Aliaksandr Kalenik
1d7c9cd1e1 LibWeb: Return computed grid-template-rows/columns if there's no used
If grid-template-rows or grid-template-columns queried for a box that is
not a grid container, the result should be computed value instead of
null.

Fixes crashing in inspector.
2024-09-09 20:12:20 +02:00
Tim Ledbetter
3ae4ea7b10 LibWeb: Abort dependent signals before firing abort event
Previously, there was a bug in the specification that would cause an
assertion failure, due to the abort event being fired before all
dependent signals were aborted.
2024-09-09 12:48:30 +02:00
Aliaksandr Kalenik
68fcc37531 LibWeb: Return used values for grid tracks in getComputedStyle()
That's awkward, but getComputedStyle needs to return used track values
for gridTemplateColumns and gridTemplateRows properties. This change
implements it by saving style values with used values into layout state,
so it could be assigned to paintables during LayoutState::commit() and
later accessed by style_value_for_property().

I haven't seen it used in the wild, but WPT grid tests extensively use
it. For example this change helps to go from 0/10 to 8/10 on this test:
https://wpt.live/css/css-grid/layout-algorithm/grid-fit-content-percentage.html
2024-09-09 12:48:06 +02:00
Aliaksandr Kalenik
07aa25ce50 LibWeb: Clamp growth limit after adding planned increase in GFC
Fixes implementation of the following line from the spec:
"However, limit the growth of any fit-content() tracks by their
fit-content() argument."

Now we correctly apply a limit to increased growth limit rather than to
the planned increase.

Change in "Tests/LibWeb/Layout/input/grid/fit-content-2.html" is a
progression and "Item as wide as the content." is actually as wide as a
content.
2024-09-09 11:41:10 +02:00
Tim Ledbetter
2c8fb49578 LibWeb: Don't attempt to set selection if control has no selectable text 2024-09-09 11:04:07 +02:00
sideshowbarker
0c77b3bf59 Tests: Allow specifying a build preset for rebaseline-libweb-test
This change enables using the rebaseline-libweb-test script with Debug
and Sanitizer builds — and allows specifying which build to use when
using rebaseline-libweb-test to generate new test-expectations files.

The mechanism used is to check the BUILD_PRESET environment variable.

Otherwise, without this change, there’s no way to use the
rebaseline-libweb-test script with Debug and Sanitizer builds — except
by manually hacking the script locally to hardcode a directory name.
2024-09-08 09:46:56 +02:00
Tim Ledbetter
48e5d28ec9 LibWeb: Resolve HTMLFormElement.action relative to document base URL
Rather than returning a relative URL, an absolutized URL is now
returned relative to the document base URL
2024-09-08 09:45:57 +02:00
Tim Ledbetter
33c62be7f9 LibWeb: Implement HTMLInputElement.formAction 2024-09-08 09:45:57 +02:00
Tim Ledbetter
c25dda767e LibWeb: Return document URL if formAction attribute is missing or empty
This change also ensures that relative URLs are resolved relative to
the document's base URL.
2024-09-08 09:45:57 +02:00
Andreas Kling
1f5c49f40d LibWeb: Make CSS::is_inherited_property(PropertyID) go fast
Instead of switching on the PropertyID and doing a boatload of
comparisons, we reorder the PropertyID enum so that all inherited
properties are in two contiguous ranges (one for shorthands,
one for longhands).

This replaces the switch statement with two simple range checks.

Note that the property order change is observable via
window.getComputedStyle(), but the order of those properties is
implementation defined anyway.

Removes a 1.5% item from the profile when loading https://hemnet.se/
2024-09-08 09:45:31 +02:00
Tim Ledbetter
b140206a91 LibWeb: Don't crash when calling getBBox() on the outermost SVG element 2024-09-07 14:35:02 +02:00
Andreas Kling
95bd0602ba LibWeb: Keep custom properties from all cascade layers
Before this change, we were cascading custom properties for each layer,
and then replacing any previously cascaded properties for the element
with only the set from this latest layer.

The patch fixes the issue by making each pass of the custom property
cascade add to the same set, and then finally assigning that set of
properties to the element.
2024-09-07 12:37:15 +02:00
Gingeh
74e12a9c97 LibWeb: Add tests for ellipses with varying angles and directions 2024-09-07 11:11:31 +02:00
Timothy Flynn
5233f9c8e6 LibWeb: Disable worker-blob and worker-location tests for now
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
These frequently time out on macOS CI.
2024-09-06 16:58:52 -04:00
sideshowbarker
6f5d0de5e7 Tests: Add some colorful pass/fail emoji to a test case
This change adds green and red pass/fail emoji indicators to an in-tree
test — to make it easier to manually scan through the test results and
quickly see which cases are passing, and which are failing.
2024-09-06 16:55:57 +02:00
sideshowbarker
a924e8747a Tests: Add an in-tree test for ARIA attribute reflection
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
This is a straightforward port to our test harness of the WPT test at
https://wpt.fyi/results/html/dom/aria-attribute-reflection.html
2024-09-06 13:34:40 +01:00
Sam Atkins
a50da405e9 LibWeb/CSS: Implement cascade layers (aka @layer)
This is done quite simply for now, there are certainly optimizations
that can and should be made later.

With this we now pass:
- http://wpt.live/css/css-cascade/layer-basic.html
- http://wpt.live/css/css-cascade/layer-important.html
- http://wpt.live/css/css-cascade/layer-statement-copy-crash.html
- http://wpt.live/css/css-cascade/layer-stylesheet-sharing-important.html
- http://wpt.live/css/css-cascade/layer-stylesheet-sharing.html
- http://wpt.live/css/css-cascade/layer-vs-inline-style.html
2024-09-06 07:49:55 +02:00
Sam Atkins
1c6133aa52 LibWeb/CSS: Add CSSOM types for @layer rules
Depending on usage, `@layer` has two forms, with two different CSSOM
types. One simply lists layer names and the other defines a layer with
its contained rules.
2024-09-06 07:49:55 +02:00
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
Jamie Mansfield
4c5a176354 LibWeb: Stub MediaCapabilities IDL interface 2024-09-05 14:52:26 +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
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
Colin Reeder
45e4ab69d6 LibWeb: Add background color to input fields 2024-09-03 10:16:13 +01:00
sideshowbarker
1975640e31 LibWeb: Make “create an event” set the event’s isTrusted to true
This change ensures that when then the code corresponding to the “create
an event” operation at https://dom.spec.whatwg.org/#concept-event-create
is called, the event’s isTrusted is set to true — as the spec requires.

That causes the failures for the following WPT tests to pass:

- https://wpt.fyi/results/html/semantics/forms/the-input-element/checkbox.html?run_id=5080423051034624
- https://wpt.fyi/results/html/semantics/interactive-elements/the-dialog-element/dialog-close.html?run_id=5080423051034624

…and there are likely a number of similar WPT tests that hit this same
code path which this commit will cause to be changed to passes.

Otherwise, without this change, the “create event” implementation
doesn’t conform to the spec requirements – nor behave interoperably with
other existing engines — and those WPT test would continue to fail.

This change also ensures that isTrusted continues to be set to false for
synthetic events.
2024-09-03 00:14:31 -06:00
BenJilks
46649fbe1b LibWeb: Add support for flex-wrap: wrap-reverse
Reverse the order of flex lines, when the `flex-wrap` property is set to
`wrap-reverse`. This will also swap the cross-start and cross-end
directions.
2024-09-02 17:42:11 +02:00
BenJilks
e2c1fe7255 LibWeb: Only reverse each line of a reverse flex-direction
When a flex container with a reverse `flex-direction` is wrapped. Only
each line should be reversed, not all items.
2024-09-02 17:42:11 +02:00
Andreas Kling
0f9444fa06 LibJS: Fix mix-up when re-exporting an imported symbol with a new name
This makes https://cling.com/ load, and more of the animated elements
on https://shopify.com/ start appearing.
2024-09-02 17:14:21 +02:00
Aliaksandr Kalenik
427e6cec7b LibWeb: Use border box to position sticky elements
Fixes https://github.com/LadybirdBrowser/ladybird/issues/1245
2024-09-02 15:23:04 +02:00
Aliaksandr Kalenik
20f68106a7 LibWeb: Fix getBoundingClientRect() for elements with "position: sticky"
Use offset from ScrollFrame which is an actual value a box is shifted by
while painting.

Also change `update_paint_and_hit_testing_properties_if_needed()` to
refresh scroll frames state, because `getBoundingClientRect()` now
depends on them.

Fixes wrong file tree sidebar location and excessive layout
invalidations caused by some miscalculation on JS-side when wrong
bounding client rect is provided on Github PR pages like
https://github.com/LadybirdBrowser/ladybird/pull/1232/files
2024-09-02 13:10:22 +02:00