Commit graph

3489 commits

Author SHA1 Message Date
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
Braydn a94bf9bd09 LibThreading: ThreadPool deadlock test
Enable `LibThreading` tests and add a test to check for deadlocks in
`ThreadPool`s
2024-08-19 03:08:04 +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
Andrew Kaster 315a666e53 Tests: Add test to verify CxxSequence protocol conformance of containers
Building the test in debug mode currently crashes the swift frontend,
so we'll need to build this in release mode until that's fixed.
2024-08-17 17:44:37 -06:00
Andrew Kaster 756ef2c722 AK: Conform SimpleIterator to the random access iterator requirements
This requires pulling in some of the STL, but the result is that our
iterator is now STL Approved ™️ and our containers can be
auto-conformed to Swift protocols.
2024-08-17 17:44:37 -06: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
Timothy Flynn d57d14fc19 AK: Define FloatingPointExponentialForm comparator in the AK namespace
This isn't an issue now because this is only invoked from a macro that
is expanded within this file. But in an upcoming commit, it will be
invoked from a helper function in the Test namespace. At that point, the
compiler complains about the comparitor not being found (and helpfully
indicates we should move this one to the AK namespace to allow ADL to
succeed).
2024-08-13 14:11:05 +02:00
Timothy Flynn 831e5ed4e2 AK: Allow comparing spans of different constness
Otherwise, the following code would not compile:

    constexpr Array<int, 3> array { 4, 5, 6 };
    Vector<int> vector { 4, 5, 6 };

    if (array == vector.span()) { }

We do such comparisons in tests quite a bit. But it currently doesn't
become an issue because of the way EXPECT_EQ copies its input parameters
to non-const locals. In a future patch, that copying will be removed,
and the compiler would otherwise complain about not finding a suitable
comparison operator.
2024-08-13 14:11:05 +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
Shannon Booth b3bf5c4ea8 AK: Add BOM handling to String::from_utf8_with_replacement_character 2024-08-12 06:38:58 -04: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
Shannon Booth 033ea0e7fb AK: Add String::from_utf8_with_replacement_character
This takes a byte sequence and converts it to a UTF-8 string with the
replacement character.
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
BenJilks 0ca5675d59 LibTextCodec: Implement iso-2022-jp encoder
Implements the `iso-2022-jp` encoder, as specified by
https://encoding.spec.whatwg.org/#iso-2022-jp-encoder
2024-08-08 17:49:58 +01:00
BenJilks 08a8d67a5b LibTextCodec: Implement shift_jis encoder
Implements the `shift_jis` encoder, as specified by
https://encoding.spec.whatwg.org/#shift_jis-encoder
2024-08-08 17:49:58 +01:00
BenJilks d80575a410 LibTextCodec: Implement gb18030 and gbk encoders
Implements the `gb18030` and `gbk` encoders, as specified by
https://encoding.spec.whatwg.org/#gb18030-encoder
https://encoding.spec.whatwg.org/#gbk-encoder
2024-08-08 17:49:58 +01:00
BenJilks 34c8c559c1 LibTextCodec: Implement big5 encoder
Implements the `big5` encoder, as specified by
https://encoding.spec.whatwg.org/#big5-encoder
2024-08-08 17:49:58 +01:00
BenJilks 826292536c LibTextCodec: Implement euc-kr encoder
Implements the `euc-kr` encoder, as specified by
https://encoding.spec.whatwg.org/#euc-kr-encoder
2024-08-08 17:49:58 +01:00
BenJilks 72d0e3284b LibTextCodec+LibURL: Implement utf-8 and euc-jp encoders
Implements the corresponding encoders, selects the appropriate one when
encoding URL search params. If an encoder for the given encoding could
not be found, fallback to utf-8.
2024-08-08 17:49:58 +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
Diego Frias a58704296c LibWasm: Remove type information from Value
Gets fib(30) from 380ms to 340ms.
2024-08-07 01:10:20 +02: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
Shannon Booth fdf4f1e887 LibURL: Validate for invalid _domain_ code points for non-opaque domains
We were previously not checking for C0 control, U+0025 (%), or U+007F
DELETE.

This makes another good set of URL tests in WPT pass :^)
2024-08-04 18:29:06 +01:00
Shannon Booth f511c0b441 LibURL+LibWeb: Do not percent decode in password/username getters
Doing it is not part of the spec. Whenever needed, the spec will
explicitly percent decode the username and password.

This fixes some URL WPT tests.
2024-08-04 12:59:02 +01:00
Andreas Kling a10610a1ca LibWeb: Don't crash on CSS all: revert
Not every value in a StyleProperties will be non-null by the time we
perform `revert`, so let's make a specialized function for reverting a
property instead of using the path that requires the value to be
non-null.
2024-08-04 11:49:44 +02:00
Tim Ledbetter 96c0cbf584 LibWeb: Ensure ParentNode.getElementsByClassName() matches all classes 2024-08-04 10:39:17 +02:00
Colin Reeder 14267b5d63 LibWeb: Add stub implementation of performance.navigation 2024-08-04 10:38:42 +02:00
Shannon Booth a661daea71 LibURL: Don't consider file:// URL hosts as always opaque
Which was resulting in file URL hosts not being correctly percent
decoded.
2024-08-04 10:37:33 +02:00
Aliaksandr Kalenik fa605ef225 LibWeb: Fix OOB access in "text-overflow: ellipsis" clip
Fixes out of bound access to glyph run when `last_glyph_index` is 0.

Fixes crashing on https://github.com/LadybirdBrowser/ladybird/pulls
2024-08-03 19:45:41 +02:00
Tim Ledbetter c0f30f31d1 LibXML: Include line and column numbers in parse error messages 2024-08-03 18:23:36 +02:00
Tim Ledbetter 82ed253477 LibWeb: Match class selectors case insensitively in quirks mode
This align our implementation with the CSSWG Selectors Level 4
specification.
2024-08-03 16:45:23 +02:00
Tobias Christiansen e2c9e34050 Tests: Add ref-test for "text-overflow" 2024-08-03 10:04:38 +01:00
Tobias Christiansen da7f0897d1 LibWeb: Implement "text-overflow" property
The "text-overflow" property affects text that may get clipped if it is
larger than its container and does not do any line breaks.
The ellipsis character gets added to the end and the rest of the text
gets trunctated if the property is set to "ellipsis".
This patch implements this behavior in the InlineFormattingContext. :^)

The "text-overflow" property is also added  to the
getComputedStyle-print-all test.
2024-08-03 10:04:38 +01:00
BenJilks 963cf1c2c4 LibWeb: Add additional padding to the end of the scrollable overflow
Adds additional padding to the end-side of the scrollable overflow
rectangle as necessary to enable a scroll position that satisfies
the requirements of `place-content: end` alignment.
2024-08-02 08:07:56 +02:00
Aliaksandr Kalenik bbc89a383d LibWeb: Fix overflow clip when "complicated" CSS transform is used
Overflow clipping is currently implemented as:
1. Create clip frame for each box with hidden overflow
2. Calculate clip rect for each clip frame by intersecting padding boxes
   of all boxes with hidden overflow in containing block chain
3. Assign enclosing clip frame (closest clip frame in containing block
   chain) to each PaintableBox
4. Apply clip rect of enclosing clip frame in Paintable::before_paint()

It breaks when any CSS transform other than simple translation is lying
between box with hidden overflow and a clipped box, because clip
rectangle will be applied when transform has already changed.

The fix is implemented by relying on the following rule:
"For elements whose layout is governed by the CSS box model, any value
other than none for the transform also causes the element to establish
a containing block for all descendants."

It means everything nested into a stacking context with CSS transform
can't escape its clip, so it's safe to apply its clip for all children.
2024-08-01 12:03:13 +02:00
Shannon Booth 9f24176cac HTML: Partially implement HTMLInputElement's selection{Start,End}
Now that the implementation is in FormAssociatedElement, the
implementation in HTMLInputElement is effectively just a passthrough,
with some minor differences to handle small behavioural quirks between
the two (such as the difference in nullability of types).
2024-08-01 11:42:39 +02:00
Aliaksandr Kalenik 2cc2646f55 LibWeb: Apply scroll offset and clip rectangle to table borders
Moves paint_table_borders() call into PaintableBox::paint() to make
scroll offset and clip rectangle of enclosing scrollable be applied
in ::before_paint().
2024-07-31 21:43:17 +02:00
Timothy Flynn 7a17c654d2 AK: Add a method to compute UTF-16 length from a UTF-8 string 2024-07-31 05:55:34 -04:00
Sam Atkins 7daf5cdaff LibWeb: Invalidate layout if pseudo-element style changes
Pseudo-elements' style is only computed while building the layout tree.
This meant that previously, they would not have their style recomputed
in some cases. (Such as when :hover is applied to an ancestor.)

Now, when recomputing an element's style, we also return a full
invalidation if one or more pseudo-elements would exist either before or
after style recomputation.

This heuristic produces some false positives, but no false negatives.
Because pseudo-elements' style is computed during layout building, any
computation done here is then thrown away. So this approach minimises
the amount of wasted style computation. Plus it's simple, until we have
data on what approach would be faster.

This fixes the Acid2 nose becoming blue when the .nose div is hovered.
2024-07-30 09:45:45 +02:00
Timothy Flynn 657bbd1542 LibWeb: Append attributes to the correct element
The spec indicates we should append attributes to the top element of the
stack of open elements. We were appending the attribute to the bottom.
2024-07-30 09:41:35 +02:00
Timothy Flynn 9fe35ddddf LibWeb: Use an infallible method to add attributes to nodes
In the HTML parser spec, there are 2 instances of the following text:

    add the attribute and its corresponding value to that element

The "add the attribute" text does not have a corresponding spec link to
actually specify what to do. We currently use `set_attribute`, which can
throw an exception if the attribute name contains an invalid character
(such as '<'). Instead, switch to `append_attribute`, which allows such
attribute names. This behavior matches Firefox.

Note we cannot yet make the unclosed-html-element.html test match the
expectations of the unclosed-body-element.html due to another bug that
would prevent checking if the expected element has the right attribute.
That will be fixed in an upcoming commit.
2024-07-30 09:41:35 +02:00
Sam Atkins 5abe246385 LibWeb/CSS: Treat counters() function with 1 argument as invalid
Fixes #887.
2024-07-29 12:57:43 -04:00
Jamie Mansfield 75216182c9 LibWeb: Implement DOMStringList 2024-07-29 11:19:00 +02:00
Tim Ledbetter 354e5a6624 LibWeb: Set correct prototype for WorkerLocation 2024-07-28 21:40:30 +02:00
Ángel Carias 9624e0d2a2 LibWeb/DOM: Implement Node.lookupPrefix
Adds https://dom.spec.whatwg.org/#dom-node-lookupprefix
2024-07-28 00:51:55 +01:00
Sam Atkins 9e32c9329a LibWeb: Reserve enough space for span>1 columns in BorderConflictFinder
This code previously only allocated enough space in
m_col_elements_by_index for 1 slot per column, meaning that columns
with a span > 1 would write off the end of it.
2024-07-27 20:23:14 +01:00
Sam Atkins 0cec68ea99 LibWeb: Correct logic for removing end nodes from HTMLOptionsCollection
This test case would previously crash.

Found with domato.
2024-07-27 20:23:14 +01:00
Sam Atkins 6ae2b8c3d9 LibWeb/CSS: Parse custom-idents more consistently
These have a few rules that we didn't follow in most cases:
- CSS-wide keywords are not allowed. (inherit, initial, etc)
- `default` is not allowed.
- The above and any other disallowed identifiers must be tested
  case-insensitively.

This introduces a `parse_custom_ident_value()` method, which takes a
list of disallowed identifier names, and handles the above rules.
2024-07-27 14:45:33 +02:00
Aliaksandr Kalenik 1bd0871ed8 LibWeb+LibGfx: Use Skia for text rasterization
The main incentive is much better performance. We could have gone a bit
further in optimizing the Skia painter to blit glyphs produced by LibGfx
more efficiently from the glyph atlas, but eventually, we also want Skia
to improve correctness.

This change does not completely replace LibGfx in text handling. It's
still used at all stages, including layout, up until display list
replaying.
2024-07-27 08:18:54 +02:00
Andreas Kling 273593afba LibWeb: Don't proceed with Element.click() on disabled form controls
Fixes an infinite reload loop on some of the dom/events/ tests in WPT.
2024-07-26 14:25:04 +02:00
Sam Atkins 696ccc1aa9 LibWeb: Prevent elements with no layout box from modifying counters 2024-07-26 11:04:30 +01:00
Sam Atkins 898e3bd898 Last: LibWeb: Add counter() and counters() functions to content property
These let you format counters' current values as strings for use in
generated content.
2024-07-26 11:04:30 +01:00
Sam Atkins 017d6c3314 LibWeb: Implement counter-[increment,reset,set] properties
These control the state of CSS counters.

Parsing code for `reversed(counter-name)` is implemented, but disabled
for now until we are able to resolve values for those.
2024-07-26 11:04:30 +01:00
Kemal Zebari c5f1e47883 LibWeb: Implement Blob::bytes()
Implements https://w3c.github.io/FileAPI/#dom-blob-bytes.
2024-07-26 10:21:32 +02:00
Timur Sultanov 1ce9bbdd6d Tests: Add test for selection option in <select>
Verify that we can select option using JS
2024-07-26 09:15:39 +01:00
Timur Sultanov ad7b2b7c26 LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec
2024-07-26 09:15:39 +01:00
doctortheemh 9cbb3fac12 LibWeb: Parse fill and stroke values
Use the CSS color data type using the CSS parser.
2024-07-26 09:14:09 +01:00
Jamie Mansfield 793248aec9 LibWeb/HTML: Implement HTMLMediaElement.addTextTrack
Removes some noise from the console when browsing bbc.co.uk :^)
2024-07-26 09:30:19 +02:00
Tim Ledbetter 97436e7d65 Tests: Add test for Node.nodeName 2024-07-26 07:19:23 +02:00
Andrew Kaster 15d60779a9 Tests: Update ClangPlugins tests for current clang version
Something is up with the plugin option and the current version of lit,
so XFAIL the test for that for now.
2024-07-25 18:35:57 -06:00
Andreas Kling de2b9eebe6 LibWeb: Inherit CSS variables across shadow boundaries
This fixes a bunch of issues on https://wpt.fyi/
2024-07-25 21:38:32 +02:00
Tim Schumacher ffc03eb25a Tests: Do not install LibMedia test files 2024-07-25 13:25:09 -06:00
Andreas Kling d49ae5af32 LibWeb: Make offsetTop and offsetLeft behave more like other browsers
We now follow the rules from the spec more closely, along with an
unspecified quirk for when the offsetParent is a non-positioned body
element. (Spec bug linked in a comment.)

This fixes a whole bunch of css-flexbox tests on WPT, which already had
correct layout, but the reported metrics from JS API were wrong.
2024-07-25 18:52:04 +02:00
Timur Sultanov 2bf37cb914 Tests: Add tests for <select> element behavior
Check that `<select>` element has options available immediately
2024-07-25 16:58:12 +02:00
Tim Ledbetter 3802d9ccc4 LibWeb: Calculate length for all CharacterData type nodes correctly
We now ensure that `Node::is_character_data()` returns true for all
nodes of type character data.

Previously, calling `Node::length()` on `CDataSection` or
`ProcessingInstruction` nodes would return an incorrect value.
2024-07-25 15:57:21 +01:00
Tim Ledbetter 72ed62a560 LibWeb: Don't crash when cloning a CDATASection node 2024-07-25 15:57:21 +01:00
Andreas Kling 007c292af3 LibWeb: Execute the correct script in XMLDocumentBuilder::element_end()
We were mistakenly executing the current node's script instead of the
document's pending parsing-blocking script.

This caused ~1000 WPT tests to time out, since we never ended up firing
a load event for XHTML pages that load multiple external scripts.
2024-07-25 15:05:28 +02:00
Aliaksandr Kalenik 67d68eac64 LibWeb: Save "background-clip: text" mask as a nested display list
Before this change, "background-clip: text" was implemented by saving a
Vector<Gfx::Path> of all glyphs needed to paint a mask for the
background. The issue with this approach was that once glyphs were
extracted into vector paths, the glyph rasterization cache could no
longer be utilized.

With this change, all text required for mask painting is saved in a
nested display list and rasterized as a regular text.
2024-07-25 14:33:33 +02:00
Tim Ledbetter 5a796629c6 LibWeb: Make document.createElementNS() case-sensitive
Previously, when creating a HTML element with
`document.createElementNS()` we would convert the given local name to
lowercase before deciding which element type to return. We now no
longer perform this lower case conversion, so if an uppercase local
name is provided, an element of type `HTMLUnknownElement` will be
returned. This aligns our implementation with the specification.
2024-07-25 13:12:34 +02:00
Edwin Hoksberg e5deaa1c07 LibWeb: Implement grid-template function fit-content() 2024-07-25 13:12:26 +02:00
Jamie Mansfield f774d75f89 LibWeb/DOM: Check if name is valid in Element.toggleAttribute
This resolves a test in https://wpt.live/dom/nodes/attributes.html.
2024-07-25 06:46:28 +02:00
Tim Ledbetter 0127190dcf LibWeb: Perform DOMTokenList token validation in the correct order 2024-07-25 06:43:31 +02:00
Tim Ledbetter ec1f7779cb LibWeb: Follow the specification steps to serialize a DOMTokenList
This ensures that calling `element.classList.toString()` always
produces the correct value.
2024-07-25 06:43:31 +02:00
Tim Ledbetter 21e21abeed LibWeb: Update Element class list is when class attribute is removed 2024-07-25 06:43:31 +02:00
Shannon Booth 5eb80b8697 WebAudio: Add IDL interface for AudioDestinationNode
This is an AudioNode representing the final audio destination and is
what the user will ultimately hear.

This node is used as one of the connecting nodes in athenacrisis.com

Add a placeholder for the interface without anything backing it for now.
2024-07-24 11:14:46 +02:00
Aliaksandr Kalenik c5afe70f77 LibWeb: Add optimized painting command for repeated background
With this change, instead of recording a display list item for each
instance of a repeated background, a new DrawRepeatedImmutableBitmap
type is used. This allows the painter to use optimized repeated image
painting and, when the GPU backend is used, avoid re-uploading the image
texture for each repetition.

Some screenshot tests are affected, but there are no visible
regressions.

https://null.com/games/chainstaff works a lof faster with this change.
2024-07-24 11:13:04 +02:00
Andreas Kling 4c326fc5f6 LibWeb: Implement :host and :host(<compound-selector>) selector matching
The :host family of pseudo class selectors select the shadow host
element when matching against a rule from within the element's shadow
tree.

This is a bit convoluted due to the fact that the document-level
StyleComputer keeps track of *all* style rules, and not just the
document-level ones.

In the future, we should refactor style storage so that shadow roots
have their own style scope, and we can simplify a lot of this.
2024-07-23 18:03:46 +02:00
Sam Atkins 64d45afd8a LibWeb: Check CanvasTextDrawingStyles.font assignment is valid
Checking that the string parsed for the `font` property is not enough,
the spec also wants to rule out CSS-wide keywords like `inherit`. The
simplest way to do so is to check if it's a ShorthandStyleValue, which
also rules out use of `var()`; this matches other browsers' behaviour.

The newly-added test would previously crash, and now doesn't. :^)
2024-07-23 18:00:12 +02:00
Andreas Kling 3b7534b362 LibWeb: Use correct scope when removing style sheet inside a shadow tree
Before this change, removing a style element from inside a shadow tree
would cause it to be unregistered with the document-level list of sheets
instead of the shadow-root-level list.

This would eventually lead to a verification failure if someone tried to
update the text contents of that style element, since it was still in
the shadow-root-level list, but now with a null owner element.

Fixes a crash on https://www.swedbank.se/
2024-07-23 11:12:18 +02:00
bbb651 7b10eb7225 LibWeb: Add new expected window properties to test
Adds `AudioBufferSourceNode` and `BiquadFilterNode` to the
all-window-properties test.
2024-07-23 09:02:43 +02:00
Kenneth Myhra 92f6336fe8 Tests/LibWeb: Move existing Fetch tests in under the Fetch folder 2024-07-23 09:02:21 +02:00
Kenneth Myhra b8fa572c67 LibWeb: Implement formData() method steps for x-www-form-urlencoded
The Response interface of the Fetch API can now parse form urlencoded
bodies when Content-Type is set to 'application/x-www-form-urlencoded'.
2024-07-23 09:02:21 +02:00
Tim Ledbetter e40352b6b5 LibWeb: Ensure document.getElementsByName("") returns no elements
Previously, if a document had any element with a name attribute that
was  set to the empty string, then `document.getElementsByName("")` and
`element.getElementsByName("")` would return a collection including
those elements.
2024-07-23 08:58:22 +02:00
Tim Ledbetter 0fceede029 LibWeb: Ensure document.getElementsByClassName("") returns no elements
Previously, `document.getElementsByClassName("")` would return a
collection containing all elements in the given document.
2024-07-23 08:58:22 +02:00
Tim Ledbetter f666d967d6 LibWeb: Ensure document.getElementById("") returns null
Previously, if a document had an element whose id was the empty string,
then `document.getElementById("")` and `element.getElementById("")`
would return that element.
2024-07-23 08:58:22 +02:00
Aliaksandr Kalenik 2ead999f2b LibGfx+LibWeb: Remove typeface classes for WOFF fonts
This change removes wrappers inherited from Gfx::Typeface for WOFF and
WOFF2 fonts. The only purpose they served is owning of ttf ByteBuffer
produced by decoding a WOFF/WOFF2 font. Now new FontData class is
responsible for holding ByteBuffer when a font is constructed from
non-externally owned memory.
2024-07-22 15:05:04 +02:00
Lucas CHOLLET 1039561280 LibGfx: Use libjxl to decode JPEG XL images
It currently doesn't support animated image.

Note that Gfx::Bitmap has no support for get_pixel when the format is
RGBA8888. This is why it has been removed from the tests.
2024-07-22 09:15:16 +02:00
Tim Ledbetter d417b75683 LibWeb/SVG: Ensure SVG transform has an inverse before using it
This avoids a crash that occurred when calling `getBBox()` on an SVG
element that had a transform with no inverse.

Found by Domato.
2024-07-22 09:13:25 +02:00
Tim Ledbetter 4cdafea363 LibWeb: Don't crash when SVG viewbox has a width of 0
Previously, `SVGSVGBox` would have a natural aspect ratio of 0 if it
had a viewbox with zero width. This led to a division by zero, causing
a crash.

Found by Domato.
2024-07-22 09:13:25 +02:00
Tim Ledbetter 604f6040a1 LibWeb: Clamp paintable box maximum scroll offset to 0
Previously calling `PaintableBox::set_scroll_offset()` with a
PaintableBox whose content size was larger than its scrollble overflow
rect would cause a crash.

Found by Domato.
2024-07-22 09:13:25 +02:00
Timothy Flynn 74d644a216 AK: Explicitly check for null data in Utf16View
The underlying CPU-specific instructions for operating on UTF-16 strings
behave differently for null inputs. Add an explicit check for this state
for consistency.
2024-07-21 19:57:07 +02:00
Timothy Flynn 144452d638 AK: Explicitly check for null data in Utf8View
The underlying CPU-specific instructions for operating on UTF-8 strings
behave differently for null inputs. Add an explicit check for this state
for consistency.
2024-07-21 19:57:07 +02:00
Edwin Hoksberg ac6126e263 LibWeb: Support percentage values in SVG line element 2024-07-21 19:56:38 +02:00
Edwin Hoksberg 356bddbdbb LibWeb: Support percentage values in SVG text positioning element 2024-07-21 19:56:38 +02:00
Andreas Kling 98f88d49de LibWeb: Make getElementById() always return first match in tree order
We had a const and non-const version of this function, with slightly
different behavior (oops!)

This patch consolidates the implementations and keeps only the correct
behavior in there.

Fixes an issue where comments were not collapsible on Hacker News.
2024-07-21 11:42:53 +01:00
Aliaksandr Kalenik 3627329bed Everywhere: Use Skia painter by default
Skia painter is visibly faster than LibGfx painter and has more complete
CSS transforms support. With this change:
- On Linux, it will try to use Vulkan-backend with fallback to
  CPU-backend
- On macOS it will try to use Metal-backend with fallback to
  CPU-backend
- headless-browser always runs with CPU-backend in layout mode
2024-07-21 10:36:17 +02:00
Aliaksandr Kalenik 9ab25c47a4 Tests: Transform some ref tests into screenshot tests
These test work with LibGfx painter but won't longer work after
switching to Skia, because it produces slightly different antialiasing,
rounding in color blending, etc.
2024-07-21 10:36:17 +02:00
Ángel Carias 69da6a0ce4 LibWeb: Implement Text.wholeText
This getter returns the concatenation of the data of the contiguous
Text nodes of `this` (being this plus its siblings) in tree order.
2024-07-20 18:02:51 +01:00
Andreas Kling 3faff34bf6 LibWeb: Make details and summary elements display:block in the UA style
This is the expected behavior per the HTML spec. Fixes an issue where
styling these elements wouldn't have the expected effect unless you also
set the display property.
2024-07-20 13:09:28 +02:00
Edwin Hoksberg 5f154ba372 LibWeb: Implement Element::check_visibility 2024-07-20 09:14:50 +01:00
Andreas Kling 33207174a9 LibWeb: Allow splitting surrogate pairs in CharacterData.replaceData()
We're expected to handle this situation gracefully, and certainly not
by falling apart like we were.

Found by Domato.
2024-07-20 06:41:25 +02:00
Andreas Kling 416c478876 LibWeb: Don't try to set selection with anchor/focus in different roots
If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.

Found by Domato.
2024-07-20 06:41:25 +02:00
Andreas Kling 4e0edd42b9 LibWeb: Cap HTML dimension values at 17895700 (same as Firefox)
Instead of allowing arbitrarily large values (which could eventually
overflow an i32), let's just cap them at the same limit as Firefox does.

Found by Domato.
2024-07-20 06:41:25 +02:00
Andreas Kling 093f1dd805 LibWeb: Propagate exceptions from setAttribute() in DOMStringMap setter
We were incorrectly assuming that setAttribute() could never fail here,
even when passed an invalid name.

Found by Domato.
2024-07-20 06:41:25 +02:00
Andreas Kling 1c00e5688d LibWeb: Fix StringView OOB access when parsing 3-character legacy color
Found by Domato.
2024-07-20 06:41:25 +02:00
Aliaksandr Kalenik 0be57df54d LibWeb: Subtract left inset from size_available_for_margins for abspos
Fixes https://github.com/LadybirdBrowser/ladybird/issues/712
2024-07-19 13:29:20 +01:00
Aliaksandr Kalenik 715f033007 Tests+headless-browser: Move screenshot ref-tests into own directory
This change will make it easier to disable screenshot comparison tests
on a specific platform or have per-platform expectations.

Additionally, it's nice to be able to tell if a ref-test uses a
screenshot as an expectation by looking at the test path.
2024-07-19 13:52:00 +02:00
Edwin Hoksberg 0ae048102c LibWeb: Resolve content-visibility fixme in html details element 2024-07-19 09:04:30 +01:00
Edwin Hoksberg 020b20d817 LibWeb: Support content-visibility css 2024-07-19 09:04:30 +01:00
Tim Ledbetter 7e8d71f7fc Tests/LibWeb: Add some tests for Node.isEqualNode 2024-07-19 09:22:08 +02:00
Timothy Flynn 368dad54ef LibTextCodec: Use AK facilities to validate and convert UTF-16 to UTF-8
This allows LibTextCodec to make use of simdutf, and also reduces the
number of places with manual UTF-16 implementations.
2024-07-18 19:43:57 +02:00
Timothy Flynn 71c29504af AK: Support non-native endianness in Utf16View
Utf16View currently assumes host endianness. Add support for specifying
either big or little endianness (which we mostly just pipe through to
simdutf). This will allow using simdutf facilities with LibTextCodec.
2024-07-18 19:43:57 +02:00
Timothy Flynn 0c14a9417a AK: Replace converting to and from UTF-16 with simdutf
The one behavior difference is that we will now actually fail on invalid
code units with Utf16View::to_utf8(AllowInvalidCodeUnits::No). It was
arguably a bug that this wasn't already the case.
2024-07-18 14:46:25 +02:00
Tim Ledbetter 055c902a37 LibWeb: Implement Node.isDefaultNamespace()
This method accepts a namespace URI as an argument and returns true if
the given URI is the default namespace on the given node, false
otherwise.
2024-07-18 12:41:01 +03:00
Tim Ledbetter 27d429a85f LibWeb: Implement Node.lookupNamespaceURI()
This method takes a prefix and returns the namespace URI associated
with it on the given node, or null if no namespace is found.
2024-07-18 12:41:01 +03:00
Andrew Kaster 88044f59c6 AK: Stop exporting AK::FixedPoint into the global namespace
This declaration has conflicts with the macOS SDK, which becomes a
problem when trying to interact with system clang modules.
2024-07-18 09:43:38 +01:00
Andrew Kaster bf600c8e1d AK: Stop exporting AK::Duration into the global namespace
This has conflicts with MacTypes.h from the Apple macOS SDKs, which
becomes a huge problem when trying to interact with system clang modules
2024-07-18 09:43:38 +01:00
Andrew Kaster 2fa9ec20bd LibUnicode: Prefix AK::Duration with AK Namespace 2024-07-18 09:43:38 +01:00
Andrew Kaster c1681931ba LibMedia: Prefix AK::Duration with AK Namespace 2024-07-18 09:43:38 +01:00
Aliaksandr Kalenik 7a1f3f7ae3 LibWeb: Change grid item placement to look for area by boundary lines
Areas are disassembled into boundary lines on `build_grid_areas()` step,
so we can always use them to find grid item's position during placement.
This way we support both ways to define area: `grid-template-areas` and
implicitly using `-start` and `-end` boundary line names.
2024-07-18 09:05:37 +02:00
Daniel Bertalan c62240aa80 Everywhere: Warn on function definitions without prototypes
If no header includes the prototype of a function, then it cannot be
used from outside the translation unit it was defined in. In that case,
it should be marked as `static`, in order to avoid possible ODR
problems, unnecessary exported symbols, and allow the compiler to better
optimize those.

If this warning triggers in a function defined in a header, `inline`
needs to be added, otherwise if the header is included in more than one
TU, it will fail to link with a duplicate definition error.

The reason this diff got so big is that Lagom-only code wasn't built
with this flag even in Serenity times.
2024-07-17 21:51:29 +02:00
doctortheemh 0140e5e9cc LibGfx: Decode WebP images with libwebp 2024-07-17 10:04:25 -06:00
Nico Weber 83d0452e69 LibGfx/WebPLoader: Use transparent black as animation background color
This matches libwebp (see ZeroFillCanvas() call in
libwebp/src/demux/anim_decode.c:355 and ZeroFillFrameRect() call
in line 435, but in WebPAnimDecoderGetNext()) and makes files
written e.g. by asesprite look correct -- even though the old
behavior is also spec-compliant and arguably makes more sense.
Now nothing looks at the background color stored in the file.

See PR for an example image where it makes a visible difference.

Cherry-picked from serenityos master
276a904d20ffe260b5544a9ace9841d083e0243
2024-07-17 10:04:25 -06:00
Aliaksandr Kalenik 3270df476d LibWeb: Fix flexible track sizing in GFC
- Change min track sizing function to be "auto" when flex size is
  specified.
- Never check if min track sizing funciton is flexible, because only
  max is allowed to be flexible.
- Address FIXME in automatic_minimum_size to avoid regressions after
  making two fixes mentioned above.
2024-07-17 18:00:18 +02:00
sideshowbarker cc6d502e88 Tests: Enable WPT/run.sh to run an arbitrary subset of tests
The change causes Tests/LibWeb/WPT/run.sh to run an arbitrary subset of
tests you give it as arguments. If you don’t specify any arguments, it
has the same behavior as it does without this patch: It just runs an
explicit subset of test names hardcoded into the script.

Otherwise without this change, Tests/LibWeb/WPT/run.sh doesn’t have the
ability to run any tests other than the explicit subset of test names
hardcoded into the script
2024-07-17 09:55:11 -06:00
Jamie Mansfield 6ca4c2beb0 LibWeb/SVG: Implement SVGAElement.relList 2024-07-16 21:43:53 +02:00
Jamie Mansfield 6f3c5f5ae9 LibWeb/SVG: Implement SVGElement.ownerSVGElement 2024-07-16 21:43:53 +02:00
circl 89531fb115 Tests/LibWeb: Add test for MouseEvent and WheelEvent bubbling 2024-07-16 21:10:16 +03:00
Colin Reeder 99824eae14 LibWeb: Add support for indexed setter of HTMLOptionsCollection 2024-07-16 10:59:59 +01:00
Timothy Flynn bfc9dc447f AK+LibWeb: Replace our home-grown base64 encoder/decoders with simdutf
We currently have 2 base64 coders: one in AK, another in LibWeb for a
"forgiving" implementation. ECMA-262 has an upcoming proposal which will
require a third implementation.

Instead, let's use the base64 implementation that is used by Node.js and
recommended by the upcoming proposal. It handles forgiving decoding as
well.

Our users of AK's implementation should be fine with the forgiving
implementation. The AK impl originally had naive forgiving behavior, but
that was removed solely for performance reasons.

Using http://mattmahoney.net/dc/enwik8.zip (100MB unzipped) as a test,
performance of our old home-grown implementations vs. the simdutf
implementation (on Linux x64):

                Encode    Decode
AK base64       0.226s    0.169s
LibWeb base64   N/A       1.244s
simdutf         0.161s    0.047s
2024-07-16 10:27:39 +02:00
sideshowbarker e797ea816b Tests: Drop --enable-qt-networking arg in WPT/run.sh
--enable-qt-networking doesn't exist on the AppKit chrome
2024-07-15 21:09:29 +01:00
BenJilks 3c897e7cf3 LibWeb: Propagate margin and offset when computing a box's baseline
When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.
2024-07-15 21:31:51 +02:00
Ali Mohammad Pur 4ef909c308 Tests/LibWasm: Mark two static functions "static"
-Wmissing-declarations would complain about these.
2024-07-15 18:39:24 +02:00
Colin Reeder 5c315b532e LibWeb: Add more legacy -webkit- aliases 2024-07-15 15:45:33 +01:00
Diego Frias f63a945ba0 LibWeb: Implement the :has() pseudo-class
See https://drafts.csswg.org/selectors-4/#relational.
2024-07-15 11:52:03 +01:00
Maciej 9eb568eacb LibWeb: Make innerHTML for XML nodes actually return inner HTML
The spec says to just call the XML serialization algorithm, but it
returns the "outer serialization", and we need the "inner" one. Let's
just concatenate serializations of children; then the result produced is
similar to one from Blink or Gecko.
2024-07-14 11:49:31 +02:00
Maciej cad3b085a8 LibXML: Set XMLNS namespace for xmlns attribute
This is what Blink and Gecko do, and is required for serialization
(innerHTML etc.) of XML elements to work.
2024-07-14 11:49:31 +02:00
Jamie Mansfield d4a7cfb68f LibWeb: Stub BroadcastChannel interface
This is enough to get the 1Password login page to load :^)
2024-07-13 19:53:02 +02:00
Tim Ledbetter 0a0651f34e LibWeb: Implement Node.normalize()
This method puts the given node and all of its sub-tree into a
normalized form. A normalized sub-tree has no empty text nodes and no
adjacent text nodes.
2024-07-13 09:35:54 +02:00
Tim Ledbetter e18501f67f LibWeb: Don't dispatch click events to disabled FormAssociatedElements
Disabled FormAssociatedElements also no longer receive focus when
clicked.
2024-07-13 09:33:16 +02:00
Aliaksandr Kalenik c09b5b8df0 LibGfx+LibWeb: Rename Gfx::WOFF2::Font to Gfx::WOFF2::Typeface
It's a leftover from VectorFont -> Typeface renaming
2024-07-13 09:31:02 +02:00
Aliaksandr Kalenik 1d2e559e13 LibGfx+LibWeb: Rename Gfx::WOFF::Font to Gfx::WOFF::Typeface
It's a leftover from VectorFont -> Typeface renaming
2024-07-13 09:31:02 +02:00