Commit graph

35339 commits

Author SHA1 Message Date
Andreas Kling
7d644ecd50 LibWeb: Distinguish parent/child on style invalidation for DOM insertion 2024-09-22 18:42:40 +02:00
Andreas Kling
f351f75a34 LibWeb: Don't try to invalidate style for character data nodes
Character data nodes like text and HTML comments don't have style,
so let's just exit invalidation immediately for those.
2024-09-22 18:42:40 +02:00
Andreas Kling
8beb7c7700 LibWeb: Cache whether there are any :has() selectors present
As useful as they may be to web developers, :has() selectors complicate
the style invalidation process quite a lot.

Let's have StyleComputer keep track of whether they are present at all
in the current set of active style sheets. This will allow us to
implement fast-path optimizations when there are no :has() selectors.
2024-09-22 18:42:40 +02:00
Andreas Kling
df048e10f5 LibWeb: Include siblings+descendants when invalidating style
When an element is invalidated, it's possible for any subsequent sibling
or any of their descendants to also need invalidation. (Due to the CSS
sibling combinators, `+` and `~`)

For DOM node insertion/removal, we must also invalidate preceding
siblings, since they could be affected by :first-child, :last-child or
:nth-child() selectors.

This increases the amount of invalidation we do, but it's more correct.

In the future, we will implement optimizations that drastically reduce
the number of elements invalidated.
2024-09-22 18:42:40 +02:00
Timothy Flynn
5d71758742 LibWeb: Move initial creation of Unicode segmenters to the Document
The expensive part of creating a segmenter is doing the locale and UCD
data lookups at creation time. Instead of doing this once per text node,
cache the segmenters on the document, and clone them as needed (cloning
is much, much cheaper).

On a profile loading Ladybird's GitHub repo, the following hot methods
changed as follows:

    ChunkIterator ctor: 6.08% -> 0.21%
    Segmenter factory:  5.86% ->    0%
    Segmenter clone:    N/A   -> 0.09%
2024-09-22 18:42:31 +02:00
Andreas Kling
42a1a0bd73 LibWeb: Put CSS transitions debug spam behind CSS_TRANSITIONS_DEBUG
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-22 10:46:54 +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
Mohamed amine Bounya
6fe43e9f73 LibWeb/HTML: Select html input elements with selectable text
only select input elements that select applies to and has a
selectable text.
2024-09-22 06:43:57 +02:00
Andreas Kling
d77843e2f0 LibHTTP: Remove the now-unused job classes
The request/response classes are still used in a couple places and will
need more careful removal.
2024-09-22 06:43:12 +02:00
Andreas Kling
504c80a202 RequestServer: Remove now-unused HTTP related code 2024-09-22 06:43:12 +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
Sam Atkins
e544166977 LibWeb: Parse transition values and cache them on Animatable elements
Co-authored-by: Matthew Olsson <matthewcolsson@gmail.com>
2024-09-22 06:41:55 +02:00
Matthew Olsson
392510c631 LibWeb: Store property transitions in Animatable
Co-authored-by: Sam Atkins <sam@ladybird.org>
2024-09-22 06:41:55 +02:00
Matthew Olsson
815a87100e LibWeb: Avoid copy when creating EasingStyleValue 2024-09-22 06:41:55 +02:00
Sam Atkins
70d99db992 LibWeb/CSS: Extract interpolation code into its own files
Apart from shrinking StyleComputer a little, we need the ability to get
the current value of a transition from outside of it.
2024-09-22 06:41:55 +02:00
Sam Atkins
a0b96280e4 LibWeb: Move "owning element" of Animation classes into Animation
There's no need to have a virtual method here when we can just store the
owning element pointer on the Animation instead.
2024-09-22 06:41:55 +02:00
Sam Atkins
3a10596136 LibWeb/CSS: Allow getting a property's computed value without animations
The algorithm for starting a transition requires us to examine the
before-change and after-change values of the property, without taking
any current animations into account.
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
Andreas Kling
32299e74cb LibWeb: Make CSS font loader tolerate WPT web server shenanigans
The web server for WPT has a tendency to just disconnect after sending
us a resource. This makes curl think an error occurred, but it's
actually still recoverable and we have the data.

So instead of just bailing, do what we already do for other kinds of
resources and try to parse the data we got. If it works out, great!

It would be nice to solve this in the networking layer instead, but
I'll leave that as an exercise for our future selves.
2024-09-21 19:20:30 +02:00
rmg-x
179641a297 LibJS: Add extra date format "d B Y"
This allows date strings like "01 February 2013" to be parsed.
auth0.com also loads now because of this :^)

Add test for date parsing
2024-09-21 18:17:04 +02:00
marcin mikołajczak
fc2141c852 RequestServer: Set request body for other methods that can have a body 2024-09-21 18:13:31 +02:00
Noah Bright
6862796d5e WebDriver: Implement Switch To Frame for null ID
Fill in a few lines from the spec :^)
2024-09-21 16:47:16 +01:00
Andreas Kling
44f672bacf LibIPC: Handle spurious wake-ups on the send queue thread
Fixes #1441
2024-09-21 15:50:11 +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
Aliaksandr Kalenik
74f6dce9e6 LibWeb: Use Gfx::Painter in CanvasRenderingContext2D::get_image_data()
...instead of directly mutating Gfx::Bitmap.

This change is preparation for using GPU-backend for canvas painting
where direct mutating of backing storage that bypasses painter is no
longer possible.
2024-09-21 08:59:00 +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
Andreas Kling
2064be708f LibWeb: Add StyleElementUtils::visit_edges()
Let's do this instead of making embedders visit every field of this
helper class.
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
f0270b92f1 LibWeb: Implement StorageKey and related AOs from Storage specification 2024-09-20 22:41:24 +01:00
Andrew Kaster
1d43d5b086 LibWeb: Use proper enums in WorkerOptions dictionary 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
Kevin Perdlich
a3472aef24 LibJS: Extend supported date string formats 2024-09-20 12:20:11 -04:00
Ali Mohammad Pur
5ac0e81c4a LibLine: Correctly slice completion substrings as unicode strings
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
Ports a fix from Serenity's LibLine.
cee0d979cc
2024-09-20 06:57:09 -04: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
ronak69
96335f31d5 LibWebView: Do floating-point-error-free zoom calculation using rounding
The current min/max zoom levels are supposed to be: 30% and 500%.
Before, due to floating point error accumulation in incremental addition
of zoom-step into zoom-level, one extra zoom step would get allowed,
enabling user to zoom 20%-to-510%.

Now, using rounding, the intermediate zoom-level values should be as
close to the theoretical value as FP32 can represent. E.g. zoom-level of
70% (theoretical multiplier 0.7) is 0.69... .
2024-09-20 07:15:02 +01:00
Aliaksandr Kalenik
15c47dc623 Meta+LibWeb: Update Skia to version 129 2024-09-19 14:07:16 -04:00
Aliaksandr Kalenik
f25676dea1 LibWeb: Remove workaround for header conflict in DisplayListPlayerSkia
No longer needed after we added AK prefix for Duration and FixedPoint.
2024-09-19 14:07:16 -04:00
Timothy Flynn
3332230cef LibWebView+WebContent+headless-browser: Make the page info IPCs async
The IPCs to request a page's text, layout tree, etc. are currently all
synchronous. This can result in a deadlock when WebContent also makes
a synchronous IPC call, as both ends will be waiting on each other.

This replaces the page info IPCs with a single, asynchronous IPC. This
new IPC is promise-based, much like our screenshot IPC.
2024-09-19 18:07:17 +02:00
Andreas Kling
3ef0fc89b3 RequestServer: Fix assertion on exit when curl had pending timeouts
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 already destroyed our timer during destruction, and then curl
tries to flush its timeouts when we tear down the multi, we can just
ignore the timer callbacks.
2024-09-19 11:45:15 +02:00
Andreas Kling
3e6448efcf RequestServer: Use CURLOPT_PRIVATE to store pointer to our own data
This is a lot nicer than scanning through our list of requests. :^)
2024-09-19 11:45:15 +02:00
Andreas Kling
6f34758947 LibWeb: Don't invalidate layout tree on all DOM node removals
DOM nodes that didn't have a layout node before being removed from the
DOM are not going to change the shape of the layout tree after being
removed.

Observing this, we can avoid a full layout tree rebuild on some DOM node
removals.

This avoids a bunch of tree building work when loading https://x.com/
2024-09-19 10:12:44 +02:00
Andreas Kling
aa8f17aea4 LibWeb: Rename invalidate_layout() => invalidate_layout_tree()
I believe this is slightly less confusing, since what the function does
is trigger a full layout tree *rebuild*, not just a relayout.
2024-09-19 10:12:44 +02:00
Andreas Kling
e205723b95 RequestServer: Make WebSocket IPC APIs asynchronous
This fixes deadlocking when interacting with WebSockets while
RequestServer is trying to stream downloaded data to WebContent.
2024-09-19 07:37:46 +02:00
Andreas Kling
853a75c4ab RequestServer: Remove download progress updates that nobody used 2024-09-19 07:37:46 +02:00
Andreas Kling
f0fc516cf2 LibIPC: Increase the local socket buffer size to 128 KiB if possible
This makes a big difference on macOS, where the default buffer size
for local sockets is 8 KiB. With bigger buffers, we don't have to
block on IPC nearly as often.
2024-09-19 07:37:46 +02:00
Andreas Kling
4bc5d6a681 LibIPC: Send IPC messages on a secondary thread
To prevent deadlocks when both IPC peers are trying to send to each
other but both sides have too much in their buffer already, we now
move the send operation to a secondary thread where it can block until
the peer is able to handle it.
2024-09-19 07:37:46 +02:00
Andreas Kling
6d91c42214 RequestServer: Remove "dump connection info" mechanism and UI
This is not relevant anymore when we use CURL.
2024-09-19 07:37:46 +02:00
Andreas Kling
e483bb70f0 RequestServer: Use libcurl for HTTP and HTTPS downloads
This replaces the use of our home-grown implementations inherited
from SerenityOS.
2024-09-19 07:37:46 +02:00
Aliaksandr Kalenik
9772afcd29 LibGfx: Remove unused Bitmap::fill() 2024-09-19 06:21:33 +02:00
Aliaksandr Kalenik
a499ece16c LibGfx+LibWeb: Replace usages of Bitmap::fill() with Gfx::Painter
Let's always mutate a bitmap using painter, because Skia likely could
do it faster than our own implementation.
2024-09-19 06:21:33 +02:00
Aliaksandr Kalenik
f2d3f8bc42 LibGfx: Remove unused Gfx::Bitmap scaling functions 2024-09-19 06:21:33 +02: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
Timothy Flynn
47e9357243 WebContent: Search all known navigables when WebDriver switches windows
We were only looking at the current top-level navigable and its children
when searching for the specified window handle. We need to search *all*
known navigables if the handle belongs to a window not in the current
tree.
2024-09-19 00:01:56 +01:00
Timothy Flynn
4ce05e5ccf LibWebView: Disable persisted SQL storage when forcing new UI processes
We very much assume that the SQL storage backend runs in a singleton
process. When this is not the case, and multiple UI processes try to
write to the database at the same time, one of them will fail.

Since --force-new-process is a testing mode flag, let's just disable the
SQL backend when that flag is present.
2024-09-19 00:01:56 +01:00
mierenhoop
259e798a26 LibWeb: Implement CanvasDrawPath::isPointInPath() 2024-09-18 21:21:57 +01:00
mierenhoop
18bc5972f4 LibGfx: Add Path::contains()
With this new method, it is possible to check whether a 2D point is
inside of the path.
2024-09-18 21:21:57 +01:00
Sam Atkins
76daba3069 LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue
This matches the name in the CSS Typed OM spec. There's quite a lot
still to do to make it match the spec behavior, but this is the first
step.
2024-09-18 20:38:41 +01:00
Sam Atkins
35cb6badc2 LibWeb/CSS: Remove unused checks for calculated dimension types
These are a remnant of when Length itself could hold a pointer to a
CalculatedStyleValue. That hasn't been the case for a long time now.
2024-09-18 20:38:41 +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
Sam Atkins
d757c8b78d LibWeb/DOM: Implement spec changes to dir=auto directionality
Computing the "contained text auto directionality" is now its own
algorithm, with an extra parameter, and is additionally called from
step 2.1.3.2 instead of calling "auto directionality".
2024-09-18 15:18:07 +02:00
Sam Atkins
2a5390ef4f LibWeb/DOM: Move "text node directionality" algorithm into DOM::Text 2024-09-18 15:18:07 +02: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
d6a31d80c0 LibWeb: Resolve floating box's paddings before width calculation
...because calculate_inner_width() assumes layout state has resolved
paddings that could be used to account for "box-sizing: border-box".

Fixes regression introduced in 5f74da6ae8
2024-09-18 10:07:14 +02:00
Tim Ledbetter
21897c8ed0 LibIPC: Wait until socket is writable when transferring IPC messages 2024-09-18 10:06:47 +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
c875cdae64 LibWeb: Avoid layout run to calculate auto height of FC child in BFC
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
Before this change, each BFC child that established an FC root was laid
out at least twice: the first time to perform a normal layout, and the
second time to perform an intrinsic layout to determine the automatic
content height. With this change, we avoid the second run by querying
the formatting context for the height it used after performing the
normal layout.
2024-09-17 07:58:07 +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
Timothy Flynn
c7db1204ca WebContent: Protect the switch-to-window endpoint against null BCs
This is one of the few endpoints that does not ensure a top-level BC is
open. It's a bit of an implementation-defined endpoint, so let's protect
against a non-existent BC explicitly.
2024-09-17 00:04:33 +01:00
Timothy Flynn
30ec88dce0 WebContent: Implement the switch-to-parent-frame endpoint 2024-09-17 00:04:33 +01:00
Tim Ledbetter
b4aff45854 LibWeb/WebDriver: Use correct dimensions for WPT reftest screenshots
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
Reftest screenshots are now captured using the dimensions specified in
the draw a bounding box from the framebuffer AO defined in the
WebDriver specification.
2024-09-16 09:11:52 -04:00
Arhcout
b4d996680a LibJS: Allow date format "YYYY-M-DD"
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-15 12:24:39 -04: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
e3499c7953 LibWeb: Use grid area as available space for abspos grid items
Our abspos layout code assumes that available space is containing block
size, so this change aligns us with the spec by using grid area for this
value.

This change does not have attached test because it is required for
upcoming fix in calculate_inner_height() that will reveal the problem.
2024-09-15 18:00:08 +02:00
Aliaksandr Kalenik
ea04500bb2 LibWeb: Remove unreachable abspos width calculation in BFC
compute_width() could never be invoked for abspos boxes because they
are skipped during normal layout and processed in
parent_context_did_dimension_child_root_box()
2024-09-15 16:57:20 +02:00
Aliaksandr Kalenik
17f4ed6ea1 LibGfx+LibWeb: Simplify text shaping API by removing per glyph callback
All places where text shaping happens, the callback is used to simply
append a glyph into the end of glyphs vector. This change removes the
callback parameter and makes the text shaping function return a glyph
run.
2024-09-15 15:42:36 +02:00
Timothy Flynn
60fa3752ee LibWeb+WebContent: Partially implement the switch-to-frame endpoint
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 needed by the cookie tests for WPT.
2024-09-15 00:56:21 +01:00
Timothy Flynn
bf60765903 LibWeb+WebContent: Implement the WebDriver JSON clone steps for elements
This is needed by WPT to serialize NodeList instances.
2024-09-15 00:56:21 +01:00
Timothy Flynn
2dc8cad785 LibWeb+WebContent: Move element reference WebDriver AOs to a helper file
These will be needed outside of WebDriverConnection.cpp.
2024-09-15 00:56:21 +01:00
Timothy Flynn
5fc51b2ff9 WebContent+WebDriver: Update the current BC when switching windows
We had only implemented this step in the WebDriver process, but we need
to update the remote WebContent process as well.
2024-09-15 00:56:21 +01:00
Timothy Flynn
4a6d0e0f90 LibWeb+WebContent: Use the current window to execute WebDriver scripts
Rather than using the page's top-level window, we must use the window
that is currently active in the WebDriver session.
2024-09-15 00:56:21 +01:00
Timothy Flynn
c4da022864 WebContent: Implement the WebDriver concept of current browsing context
When we create a WebDriverConnection object, we currently hand it the
page client for which it was opened, and perform all actions on that
client. However, some WebDriver endpoints change the browsing context
(and therefore page client) on which future commands should be executed.
For example, the switch-frame endpoint will switch the current browsing
context to a frame/iframe context.

This patch implements the current browsing context (and current top-
level browsing context) concepts. They are initialized to that of the
original page. Most of this patch is making sure we execute actions on
the correct context.
2024-09-15 00:56:21 +01: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
d17f94e7cc LibWeb: Don't create dummy formating context for internal table boxes
Internal table boxes are managed by TFC and do not need a dummy FC. We
still need to keep dummy FC for <math> though.
2024-09-14 15:04:08 +02:00
Arhcout
20f18d6ec2 LibWeb: Defined all the keycodes
I did this to respond to the issue #974.
I changed the other keys to not have problems with two keys having the
same keycode.
2024-09-14 10:38:33 +01:00
Aliaksandr Kalenik
6199870528 LibWeb: Reset a vector of contained abspos before collecting them again
Fixes a bug when a vector with contained absolutely positioned boxes
keeps growing, resulting in more duplicated work on each subsequent
layout.
2024-09-13 16:48:51 +02:00
Timothy Flynn
c2cf65adac WebDriver: Handle script execution results without spinning event loops
We currently spin the platform event loop while awaiting scripts to
complete. This causes WebContent to hang if another component is also
spinning the event loop. The particular example that instigated this
patch was the navigable's navigation loop (which spins until the fetch
process is complete), triggered by a form submission to an iframe.

So instead of spinning, we now return immediately from the script
executors, after setting up listeners for either the script's promise to
be resolved or for a timeout. The HTTP request to WebDriver must finish
synchronously though, so now the WebDriver process spins its event loop
until WebContent signals that the script completed. This should be ok -
the WebDriver process isn't expected to be doing anything else in the
meantime.

Also, as a consequence of these changes, we now actually handle time
outs. We were previously creating the timeout timer, but not starting
it.
2024-09-13 10:11:21 -04:00
Timothy Flynn
6f31a19c5f LibWeb: Spin the HTML event loop when awaiting a navigable fetch
Spinning the HTML event loop allows microtasks to run (i.e. Promise
completions).
2024-09-13 10:11:21 -04:00
Andreas Kling
bdb67d2bcb LibWeb: Use LayoutState::UsedValues::containing_block_used_values() more
Use this cached pointer to the containing block's used values when
obviously possible. This avoids a hash lookup each time, and these
hash lookups do show up in profiles.
2024-09-13 15:59:11 +02:00
Simon Wanner
77610db58c LibWeb: Handle http-equiv pragmas without insertion requirements
These pragmas are either ignored or handled elsewhere
2024-09-13 12:11:07 +02:00
Simon Wanner
d828d80b75 LibWeb: Use correct http-equiv keywords for comparisons
Previously `#keyword` was used in the macro, meaning all keywords
gained `""` around them
2024-09-13 12:11:07 +02:00