Commit graph

1670 commits

Author SHA1 Message Date
Andreas Kling 349b17cc7a LibWeb: Don't paint text fragments with CSS visibility:hidden
We *could* even skip creating a paintable for hidden nodes, but that
means that dynamic updates to the CSS visibility property would require
mutating the paint tree, so let's keep it simple for now.
2024-08-24 14:53:26 +02:00
Jamie Mansfield 2e9aec984c LibWeb/HTML: Implement DataTransferItem.webkitGetAsEntry() 2024-08-24 14:53:11 +02:00
Jamie Mansfield 169163b002 LibWeb/EntriesAPI: Implement FileSystemEntry 2024-08-24 14:53:11 +02:00
Andrew Kaster 33e50889f2 LibWeb: Add CustomStringConvertible extension for HTMLToken types 2024-08-23 19:17:20 -06:00
Andrew Kaster fb074f9d0c LibWeb: Add start of HTML Tokenizer in Swift
Currently it's just a Token class.
2024-08-23 19:17:20 -06:00
Timothy Flynn 181ece4d9c LibWeb: Implement DataTransferItem.prototype.getAsString() 2024-08-23 10:10:34 +01:00
Timothy Flynn b978dba8bd LibWeb: Implement DataTransferItem.prototype.getAsFile()
This is used on imgur after drag-and-dropping an image onto its page.
2024-08-23 10:10:34 +01:00
Andreas Kling 8eacfc8f10 LibWeb: Derive SVG root's natural size from width/height attributes
We were incorrectly looking at the CSS computed values for width and
height to determine the natural size of <svg> root elements.
This meant that elements where the attribute and computed value were
different values would end up with incorrect natural size.
2024-08-22 15:29:29 +02:00
Timothy Flynn 001d8384e5 LibWeb: Implement the DataTransferItem kind and type attributes 2024-08-22 14:21:13 +02:00
Timothy Flynn ceb9e30d42 LibWeb: Implement the DataTransferItemList indexed getter 2024-08-22 14:21:13 +02:00
Timothy Flynn 843f8f04a5 LibWeb: Implement the DataTransferItemList length attribute 2024-08-22 14:21:13 +02:00
Timothy Flynn 74d9cfbf2a LibWeb: Implement DataTransferItemList.prototype.add() 2024-08-22 14:21:13 +02:00
Timothy Flynn 5c9287aa99 LibWeb: Implement separate DataTransfer factories for IDL / internal use
The IDL constructor has to take separate steps than a DataTransfer that
is internally constructed. Notably, an IDL-created object has its own
drag data store, and that store is placed in a read-write mode.
2024-08-22 14:21:13 +02:00
Timothy Flynn 0b0d44da27 LibWeb: Implement the ClipboardEvent IDL interface
We don't actually generate any such events ourselves. But Google Lens
will create one with the DataTransfer attribute set to that of any drop
event we send it.
2024-08-22 14:21:13 +02:00
Tim Ledbetter 2c5d626b21 LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction
Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.
2024-08-22 13:49:41 +02:00
Andreas Kling bde2d3dc7b LibWeb: Adjust flex item intrinsic contributions through aspect ratio
When determining the intrinsic cross size contribution of a flex item
with a preferred aspect ratio, we have to account for any min/max
constraints in the main axis.
2024-08-21 13:38:39 +02:00
Kenneth Myhra 26fe7a628c LibWeb: Capture incoming reason argument
Capture the incoming reason argument to
transform_stream_default_source_cancel_algorithm() on the
on_fulfilled_callback() of WebIDL::react_to_promise() on step 7.
2024-08-21 11:21:54 +01:00
Khaled Lakehal 514a2a1757 LibWeb: Add setter implementation for location.search
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.
2024-08-21 10:52:19 +01:00
Sam Atkins 3af6a69f1e LibWeb: Introduce color-function-specific style values
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class
with subclasses for each different color function, to match the Typed-OM
spec. This means moving the color calculations from the parsing code to
the `to_color()` method on the style value.

This lets us have calc() inside a color function, instead of having to
fully resolve the color at parse time. The canvas fillStyle tests have
been updated to reflect this.

The other test change is Screenshot/css-color-functions.html: previously
we produced slightly different colors for an alpha of 0.5 and one of
50%, and this incorrect behavior was baked into the test. So now it's
more correct. :^)
2024-08-21 10:51:48 +01:00
Tim Ledbetter fe42e2719f LibWeb: Don't crash when parsing HTMLInputElement invalid time values 2024-08-20 23:30:35 +01:00
Jelle Raaijmakers e926b4cbfb LibWeb: Make new ImageData() use unpremultiplied color data
This was already the case for `context.createImageData()`, but I forgot
to do the same for `new ImageData()`. Add a regression test for both
cases.
2024-08-20 20:39:09 +02:00
Jelle Raaijmakers bd55e85027 LibGfx: Implement Gfx::AlphaType for SkiaPainter
Always assuming unpremultiplied color data only worked for PNGs (which
are specced as unpremultiplied) and bitmaps with alpha set to 100%.
Properly propagate the Gfx::AlphaType of a bitmap to Skia.

The reference tests were updated to reflect this change, but visually
it's practically impossible to see the difference. A new test was added
to clearly expose this issue.

Fixes #1104
2024-08-20 20:39:09 +02:00
Aliaksandr Kalenik bc20e3ac6c LibWeb: Do not allocate mask bitmap for CSS "clip-path" property
Instead, it could be applied directly as a clip path in Skia painter.

As a side bonus, we get rid of some DeprecatedPath and
AntiAliasingPainter usage.
2024-08-20 20:00:56 +02:00
Andreas Kling dd1b8de671 Ladybird+LibWeb+LibGfx: Add option to force use of fontconfig
This allows us to get identical metrics on macOS and Linux. Without
this, Skia will use CoreText on macOS and give us slightly different
text metrics. That causes layout tests to be slightly different on
different platforms, which is a huge headache. So let's not do that.

You can now launch Ladybird and headless-browser with --force-fontconfig
to load fonts through fontconfig. Tests run in this mode by default.
2024-08-20 09:30:05 +02:00
Andreas Kling ca2cd86999 Tests/LibWeb: Update screenshot test reference images for Skia changes 2024-08-20 09:30:05 +02:00
Andreas Kling 137038b185 LibWeb: Port painting to use the new Skia-backed Gfx::Path
SVG and and CSS border rendering now sits on top of SkPath instead of
the old Gfx::DeprecatedPath.

Due to an imperceptible (255, 255, 255) vs (255, 254, 255) color diff
in one ref test, I changed that test to not depend on border rendering
for a positive result, since that was incidental.
2024-08-20 09:30:05 +02:00
Timothy Flynn 099956a7cd LibWeb: Do not unconditionally prevent escape keys from being propagated
We should only block the escape key from being sent to the web page if
the CloseWatcherManager actually closed something.

We use the escape key in the Inspector to cancel editing a DOM field.
This unconditional early return broke this feature.
2024-08-20 09:29:48 +02:00
Timothy Flynn 4bb9168712 LibWeb: Implement the DataTransfer files attribute 2024-08-19 13:29:19 +02:00
Timothy Flynn 9f4e3c7e25 LibWeb: Implement the DataTransfer types attribute 2024-08-19 13:29:19 +02:00
Timothy Flynn e8a1b89447 LibWeb: Begin implementing the drag-and-drop processing model
The drag-and-drop processing model allows for users to drag around
either elements within the DOM or objects completely outside the DOM.
This drag event can either end without action (via cancellation or user
input), or in a drop event, where the dragged object is dropped onto
another element within the DOM.

The processing model is rather large. This implements enough of it to
allow the UI process to specifically handle dragging objects outside of
the DOM onto the DOM. For example, dragging an image from the OS file
manager onto a file-upload input element. This does not implement the
ability to drag DOM elements.
2024-08-19 13:29:19 +02:00
Timothy Flynn dcb76572e4 LibWeb: Add an empty DataTransferItemList IDL implementation 2024-08-19 13:29:19 +02:00
Timothy Flynn 9e3c6921ab LibWeb: Add an empty DataTransferItem IDL implementation 2024-08-19 13:29:19 +02:00
Andrew Kaster c367063823 Tests: Add first test for LibWeb Swift bindings
Just to sanity check that we can import the library, and that it at
least interprets the generated enumeration values properly, let's
do some simple testing of the swift integration.
2024-08-19 12:56:55 +02:00
Aliaksandr Kalenik c87214d79c LibWeb: Skip documents of decoded SVGs while processing HTML event loop
None of HTML event loop processing steps are relevant for decoded SVGs,
so we can simply skip them while collecting documents for processing.
2024-08-19 09:03:33 +02:00
Tim Ledbetter 00f03f3e90 LibWeb: Match attribute selectors case insensitively in XML documents
The values of attribute selectors are now compared case insensitively
by default if the attribute's document is not a HTML document, or the
element is not in the HTML namespace.
2024-08-19 09:03:22 +02:00
Tim Ledbetter 353e3e75dc LibWeb: Limit HTMLProgressElement.max to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a
negative value.
2024-08-19 09:02:21 +02:00
Diego Frias 3be7e88903 LibWeb/WebIDL: Throw correct error when converting integers
When an integer doesn't fit within the range of an integral type
defined by WebIDL, the spec says to throw a `TypeError`, not a
`RangeError`.
2024-08-18 23:35:02 +02:00
Bastiaan van der Plaat f2034270f1 LibWeb: Add URL reflection to obsolete HTMLImageElement lowsrc property 2024-08-17 17:31:14 +01:00
Tim Ledbetter 1369fc5069 LibWeb: Change attribute type to USVString where applicable
Also mark USVString attributes as containing a URL, where applicable.
2024-08-17 07:45:00 +02:00
Shannon Booth d56da8cf9a LibWeb: Sort URLSearchParams using UTF-16 code units
We were previously sorting using code points which could give the wrong
result for certain inputs.

Fixes the last two failing tests on:

https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-17 07:44:13 +02:00
Shannon Booth cff3e78a14 LibWeb: Strip trailing spaces from opaque URL path on query change
This was added in https://github.com/whatwg/url/commit/fdaa0e5a
to fix a case where roundtrips could fail. We had already partially
implemented these steps - but it seems this was missed in the update of
URLSearchParams.

Fixes the last failing WPT test for:

https://wpt.live/url/urlsearchparams-delete.any.html
2024-08-17 07:44:13 +02:00
Jamie Mansfield ea61e189eb LibWeb/SVG: Add missing SVGGElement IDL file 2024-08-17 07:41:04 +02:00
Jamie Mansfield e2f599ebee LibWeb/SVG: Implement <metadata> element 2024-08-17 07:40:45 +02:00
Tim Ledbetter 1365289d98 LibWeb: Implement the setter for location.protocol 2024-08-17 07:39:58 +02:00
Shannon Booth 07940a89ca LibWeb: Handle cases with <template> on the HTML parsing stack
This appears to have been a bug in the spec which was later corrected -
so to fix the crash we can simply remove this assertion.

Fixes: #868
2024-08-16 22:38:18 +01:00
BenJilks 0d63269cb7 LibGfx+LibWeb: Use harfbuzz for text shaping
This replaces glyph positioning system with harfbuzz's shaping
algorithm. Adding support for bidirectional encoded text.
2024-08-16 22:28:34 +02:00
Jamie Mansfield 1b84062c74 LibWeb: Stub StorageManager idl interface 2024-08-16 11:22:09 -04:00
Colin Reeder 97d5cf4eef LibWeb: Add support for SVG display attribute 2024-08-16 12:12:09 +02:00
Sam Atkins 6a74b01644 LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
2024-08-15 13:58:38 +01:00
Tim Ledbetter c61262684b LibWeb: Return empty string if object element data URL is invalid 2024-08-15 09:44:35 +02:00
Tim Ledbetter 4f7a4d9c57 LibWeb: Return empty string if image element currentSrc URL is invalid 2024-08-15 09:44:35 +02:00
Jelle Raaijmakers 124779a376 LibWeb: Implement the "fire a focus event" spec
We weren't setting the focus event's composed flag and view field
correctly.
2024-08-14 20:53:33 +01:00
Jamie Mansfield 9c4e80a3ec LibWeb/SVG: Implement default_tab_index_value for a element
Another FIXME bites the dust :^)
2024-08-14 20:39:35 +01:00
Aliaksandr Kalenik f9f39477a4 LibWeb: Fix clip for boxes nested into a stacking context with transform
Modifies a loop that collects clip rectangles to stop once a box with a
CSS transform is encountered, as its clip still needs to be considered.
2024-08-14 21:04:46 +02:00
BenJilks 1537d589ca LibWeb: Add start and end values to text-align
The `start` and `end` value set the text alignment based on the computed
value of `direction`. The default value of `text-align` is now `start`
instead of `left`.
2024-08-13 15:19:51 +01:00
BenJilks 82989554ab LibWeb: Use reverse direction on flex containers with rtl direction
If a flex container has `direction: rtl` set, reverse the row direction.
2024-08-13 15:19:51 +01:00
Colin Reeder c6975a1680 LibWeb: Use base URL for link loading 2024-08-13 14:34:15 +01:00
Shannon Booth ff71d8f2c9 LibURL+LibWeb: Pass a mutable reference URL to URL parser
If given, the spec expects the input URL to be manipulated on the fly
as it is being parsed, and may ignore any errors thrown by the URL
parser.

Previously, we were not exactly following the specs assumption here
which resulted in us needed to make awkward copies of the URL in these
situations.

For most cases this is not an issue. But it does cause problems for
situations where URL parsing would result in a failure (which is
ignored by the caller), and the URL is _partially_ updated
while parsing.

Such a situation can occur when setting the host of an href alongside a
port number which is not valid. It is expected that this situation will
result in the host being updates - but not the port number.

Adjust the URL parser API so that it mutates the URL given (if any), and
adjust the callers accordingly.

Fixes two tests on https://wpt.live/url/url-setters-a-area.window.html
2024-08-13 14:14:34 +02:00
Colin Reeder 00f75648e5 LibWeb: Update stylesheet media value when changing link media attribute 2024-08-13 14:12:55 +02:00
Shannon Booth d755a83c09 LibWeb: Actually set empty serialized query to OptionalNone
Because the type returned by to_string is a String, _not_ an
Optional<String>, the following code:

if (serialized_query.is_empty())
    serialized_query = {};

Was achieving nothing at all! Make sure that the type is an
Optional<String> so that we're not just setting an empty string to an
empty string.
2024-08-12 23:01:29 +01:00
Shannon Booth 1ba6dbd86c LibWeb: Use a stable sort for searching URLSearchParams
Quick sort is not a stable sort. This meant we had a subtle issue
implementing this portion of the spec comment:

 > The relative order between name-value pairs with equal names must
 > be preserved.

Switch to insertion sort which is a stable sort, and properly handles
keys which are the same.

Fixes 8 tests on  https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-12 23:01:29 +01:00
Shannon Booth 264b5160c2 LibWeb: Implement value argument of URLSearchParams.has 2024-08-12 23:01:29 +01:00
Shannon Booth 5637dc43b2 LibWeb: Implement value argument of URLSearchParams.delete 2024-08-12 23:01:29 +01:00
Shannon Booth e2fb24c9b8 LibWeb/Tests: Relocate search params test into URL folder
This is where I have been trying to put all of the URL tests.
2024-08-12 23:01:29 +01:00
Gasim Gasimzada 4a42c97f4d LibJS: Set empty prototype for console object 2024-08-12 17:21:01 +01:00
Gasim Gasimzada c5b8e75204 LibJS: Set configurable toStringTag property for console 2024-08-11 20:06:27 +01:00
Tim Ledbetter 00eca78d28 Tests+CI: Remove WPT CI job
This currently fails on CI, but gives no indication that it has failed.
2024-08-11 07:52:55 +02:00
Alisson Lauffer d38b28b57b LibWeb: Replace "+" in value with a space while decoding search params 2024-08-10 10:39:43 +02:00
Shannon Booth 9c72fc9642 LibWeb: Actually run UTF-8 decode without BOM
This fixes a crash using URLSearchParams when provided a percent encoded
string which does not percent decode to valid UTF-8.

Fixes a crash running https://wpt.live/url/urlencoded-parser.any.html
2024-08-10 10:39:43 +02:00
Aliaksandr Kalenik ea8d0304e9 LibWeb: Create clip and scroll frame trees separately for each navigable
While introducing clip and scroll frame trees, I made a mistake by
assuming that the paintable tree includes boxes from nested navigables.
Therefore, this comment in the code was incorrect, and clip/scroll
frames were simply not assigned for iframes:
// NOTE: We only need to refresh the scroll state for traversables
//       because they are responsible for tracking the state of all
//       nested navigables.

As a result, anything with "overflow: scroll" is currently not
scrollable inside an iframe

This change fixes that by ensuring clip and scroll frames are assigned
and refreshed for each navigable. To achieve this, I had to modify the
display list building process to record a separate display list for each
navigable. This is necessary because scroll frame ids are local to a
navigable, making it impossible to call
`DisplayList::apply_scroll_offsets()` on a display list that contains
ids from multiple navigables.
2024-08-10 10:38:12 +02:00
Jelle Raaijmakers 7a783d3a89 LibWeb: Account for intrinsic width or height in flex base size
In calculating the base size of a flex item, we have a piece of ad-hoc
code that deals with an item that does have an instrinsic aspect ratio,
but not a cross size to resolve that ratio against. In determining the
actual flex item size however, we also take into account the minimum
content width and height, which assumes the box' intrinsic width or
height when available. This would break having an image as a flex item,
which gets stretched to its maximum size within the flex container
instead of the flex item being shrunk to the instrinsic size of the
image.

Fix this by only stretching flex items that do not have an instrinsic
width nor height set.
2024-08-09 17:01:50 +01:00
Shannon Booth deff8df2c7 LibWeb: Actually perform "update the href steps"
We completely missed this step, which made setters not actually do
anything!

Fixes 336 test failures on:

https://wpt.live/url/url-setters-a-area.window.html
2024-08-08 14:59:42 +01:00
Tim Ledbetter 087d400472 LibWeb: Avoid division by zero in SourceSet width descriptor calculation 2024-08-08 12:20:04 +02:00
Shannon Booth aa32bfa448 LibWeb: Implement USVString scalar value handling
USVString is defined in the IDL spec as:

> The USVString type corresponds to scalar value strings. Depending on
> the context, these can be treated as sequences of either 16-bit
> unsigned integer code units or scalar values.

This means we need to account for surrogate code points by using the
replacement character.

This fixes the last test in https://wpt.live/url/url-constructor.any.html
2024-08-08 10:50:06 +01:00
Aliaksandr Kalenik 9def582fba LibWeb: Apply enclosing scroll frame offset to iframe's position
Fixes iframe painting when it's nested into a scrollable box.
2024-08-07 20:16:02 +02:00
Jelle Raaijmakers 5865cf5864 LibWeb: Use bitmap's alpha type instead of assuming unpremultiplied
When converting a `Gfx::Bitmap` to a Skia bitmap, we cannot assume the
color data is unpremultiplied. For example, everything canvas-related
uses premultiplied color data:

  https://html.spec.whatwg.org/multipage/canvas.html#premultiplied-alpha-and-the-2d-rendering-context

We were probably assuming unpremultiplied since that is what the PNG
decoder gives us. Since we now make `Gfx::Bitmap` identify what alpha
type is being used, we can instruct Skia a bit better :^)

Update our `EdgeFlagPathRasterizer` to use premultiplied alpha instead
of unpremultiplied so we can apply alpha correctly for path masks.

This fixes the dark borders sometimes visible when SVGs are blended
with a colored background.

This also exposed an issue with our `CanvasRenderingContext2D`, which is
supposed to hold a bitmap with premultiplied alpha internally but expose
a bitmap with unpremultiplied alpha in `CanvasImageData`. Expand our C2D
test to include the alpha channel as well.

Finally, this also exposed an off-by-one issue in
`EdgeFlagPathRasterizer` which caused the last scanlines for edges to
render incorrectly. We had some reference images which included these
corruptions (they were almost unnoticeable), so update them as well.
2024-08-07 18:51:12 +02:00
Aliaksandr Kalenik 53ef0e2e88 LibWeb: Adjust stacking context position by scroll offset in hit-testing
Fixes a bug when stacking contexts nested inside scrollable box are
treated as fixed positioned during hit-testing.
2024-08-07 18:14:41 +02:00
Sam Atkins 14611de362 LibWeb: Implement getComputedStyle() pseudoElement parameter
Right now, we deviate from the CSSOM spec regarding our
CSSStyleDeclaration classes, so this is not as close to the spec as I'd
like. But it works, which means we'll be able to test pseudo-element
styling a lot more easily. :^)
2024-08-07 16:14:49 +02:00
Jamie Mansfield fa5800ebc5 LibWeb: Implement HTMLTableCellElement.cellIndex
See:
 - http://wpt.live/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
2024-08-07 00:53:38 +01:00
Shannon Booth 6cac2981fb LibURL: Fail parsing IPV4 URLs starting with 0x that overflow
Parsing last as an IPV4 number was not returning true in "ends with a
number" as the parsing of that part was overflowing. This means that the
URL is not considered to be an IPv4 address, and is treated as a valid
domain.

Helpfully, the spec also points out in a note that this step is
equivalent to simply checking that the last part ends with 0x followed
by only hex digits - which doesn't suffer from any overflow problem!

Arguably this is an editorial issue in the spec where this should be
clarified a little bit. But for now, fixing this fixes 3 sub tests in
WPT for:

https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth db3f118046 LibURL: Fix heuristic for URL domain parsing IDNA fast path
Our heuristic was a bit too simplistic and would not run through the
ToASCII unicode algorithm which performs some extra validation. This
would cause invalid URLs that should fail to be parsed be mistakenly
accepted.

This fixes 8 tests in: https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth fd4e943e12 LibWeb: Don't strip leading '?' in query initializing a URL
In our implementation of url-initialize, we were invoking the
constructor of URLSearchParams:

https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams

Instead of the 'initialize' AO:

https://url.spec.whatwg.org/#urlsearchparams-initialize

This has the small difference of stripping any leading '?' from the
query (which we are not meant to be doing!).
2024-08-06 23:08:12 +01:00
Shannon Booth d7b19b3278 LibWeb/Tests: Also verify URL search params in constructor tests 2024-08-06 23:08:12 +01:00
Shannon Booth 1dc4959e91 LibURL: Don't return early parsing a URL with an empty input
We can't simply use the base URL as it may need to be modified in some
form. For example - for the included test, the fragment was previously
being included in the resulting URL.

This fixes 1 test on https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Aliaksandr Kalenik a8f4ea5226 LibWeb: Fix "background-clip: text" for elements nested in scrollable
Instead of carrying the display list for a mask in each command that
might potentially be affected by "background-clip: text", this change
introduces a new AddMask command that is applied once for all
background layers within one box.

The new AddMask command includes a rectangle for the mask destination
that is translated by the corresponding scroll offset.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/857
2024-08-06 21:14:47 +02:00
Andreas Kling a1519e67fb LibWeb: Fire navigation event as required in History.pushState() 2024-08-06 16:33:23 +02:00
Andreas Kling e3408c4a7f LibWeb: Allow changing the query of file:// URL via history.pushState()
The spec didn't match how other browsers behave, and we dutifully did
what the spec said. A spec bug has been filed, so let's fix this locally
for now with a FIXME.
2024-08-06 16:33:23 +02:00
Aliaksandr Kalenik 0fe84e89b2 LibWeb: Use padding box to get background rect for inline paintable
Fixes regression introduced by f574e2b03a
2024-08-06 16:25:45 +02:00
Jamie Mansfield c891b83fc0 LibWeb: Don't crash with invalid import maps
See:
 - http://wpt.live/import-maps/multiple-import-maps/with-errors.html
2024-08-06 09:40:44 +02:00
Aliaksandr Kalenik 040653311e LibWeb: Fix background clip for elements nested into scrollable boxes
add_clip_rect() accepts a rectangle in viewport-relative coordinates,
so it must be translated by the enclosing scroll offset to be displayed
correctly inside a scrollable box.
2024-08-06 09:40:34 +02:00
Shannon Booth 8723f72f0f LibURL: Remove unspecified steps in URL file slash parsing state
There were some extra steps in there which produced wrong results for
relative file URLs.

Fixes 7 test cases in: https://wpt.live/url/url-constructor.any.html

We also need to adjust the test results in TestURL. The behaviour tested
does not match how URL is specified to work as an absolute relative is
given.
2024-08-06 07:58:07 +01:00
Jamie Mansfield 1d12cb69d4 LibWeb: Implement HTMLTrackElement.readyState 2024-08-06 07:57:33 +01:00
Shannon Booth d6af5bf5eb LibURL: Allow inputs containing only whitespace
The check for:

```
    if (start_index >= end_index)
        return {};
```

To prevent an out of bounds when trimming the start and end of the input
of whitespace was preventing valid URLs (only having whitespace in the
input) from being parsed.

Instead, prevent start_index from ever getting above end_index in the
first place, and don't treat empty inputs as an error.

Fixes one WPT test on:

https://wpt.live/url/url-constructor.any.html
2024-08-05 17:21:26 +01:00
Andreas Kling 1e7b17f150 LibWeb: Don't crash on getClientRects() in document without navigable
I previously believed there was no way a detached document should have
layout information, but it turns out there is a way: getComputedStyle().

So we need to account for cases where we have a layout node, but no
navigable, since that is a state we can get into at this moment.

Fixes #354
2024-08-05 14:56:04 +02:00
Shannon Booth 41cf9f6fe3 LibURL: Also remove carriage returns from URL input
The definition of an "ASCII tab or newline" also includes U+000D CR.

This fixes 3 subtests in:

https://wpt.live/url/url-constructor.any.html
2024-08-05 11:27:05 +02:00
Shannon Booth cc55732332 LibURL+Everywhere: Only percent decode URL paths when actually needed
Web specs do not return through javascript percent decoded URL path
components - but we were doing this in a number of places due to the
default behaviour of URL::serialize_path.

Since percent encoded URL paths may not contain valid UTF-8 - this was
resulting in us crashing in these places.

For example - on an HTMLAnchorElement when retrieving the pathname for
the URL of:

http://ladybird.org/foo%C2%91%91

To fix this make the URL class only return the percent encoded
serialized path, matching the URL spec. When the decoded path is
required instead explicitly call URL::percent_decode.

This fixes a crash running WPT URL tests for the anchor element on:

https://wpt.live/url/a-element.html
2024-08-05 09:58:13 +02:00
Tim Ledbetter ea68bdef26 LibWeb: Return error on modification of a computed CSS style declaration
Previously, calling `setProperty` or `removeProperty` from JS on a
CSSStyleDeclaration returned from `getComputedStyle()` would return
null. We now return a NoModificationAllowedError instead, which aligns
our implementation with the specification.
2024-08-05 09:55:50 +02:00
Andreas Kling 0e1256e5a4 LibWeb: Make requestAnimationFrame() callback IDs sequential
This is required by the spec, so let's stop returning random IDs in
favor of a simple sequential integer sequence.
2024-08-05 09:12:07 +02:00
Jamie Mansfield bedb626c29 LibWeb: Set script force async to false when async changes 2024-08-04 19:25:29 +01:00
Jamie Mansfield 77c41a82be LibWeb: Script force async flag should default to true
See:
 - http://wpt.live/html/semantics/scripting-1/the-script-element/async_001.htm
2024-08-04 19:25:29 +01:00