Commit graph

3370 commits

Author SHA1 Message Date
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
Diego 906fa04822 LibWasm: Properly check for indeterminate NaNs in SIMD tests
Because `nan:arithmetic` and `nan:canonical` aren't bound to a single
bit pattern, we cannot check against a float-containing SIMD vector
against a single value in the tests. Now, we represent `v128`s as
`TypedArray`s in `testjs` (as opposed to using `BigInt`s), allowing us
to properly check `NaN` bit patterns.
2024-07-12 18:27:47 +02:00
Diego 524e09dda1 LibWasm: Check for correct NaN bit patterns in tests
Some spec-tests check the bit pattern of a returned `NaN` (i.e.
`nan:canonical`, `nan:arithmetic`, or something like `nan:0x200000`).
Previously, we just accepted any `NaN`.
2024-07-12 18:27:47 +02:00
simonkrauter 191531b7b1 LibWeb: Use correct default value for <input type=range>
Previously the input element was displayed with value 0, when no value
was set in the HTML. Now it uses `value_sanitization_algorithm()`, which
will calculate the default value.
In `value_sanitization_algorithm()` there was a logical mistake/typo.
The comment from the spec says "unless the maximum is less than the
minimum".
The added layout test would fail without the code changes.
Fixes #520
2024-07-11 11:56:13 +02:00
Kenneth Myhra 907dc84c1e LibWeb: Implement min option for ReadableStreamBYOBReader.read()
When the min option is given the read will only be fulfilled when there
are min or more elements available in the readable byte stream.

When the min option is not given the default value for min is 1.
2024-07-11 11:55:15 +02:00
BenJilks bee42160c5 LibWeb: When solving abspos lengths, use min max constrained height
Solving using the unconstrained height, when solving for bottom, would
either leave a gap over overflow its container.
2024-07-10 19:41:12 +02:00
Colin Reeder 449f81bfbe LibWeb: Add support for -webkit-text-fill-color 2024-07-10 10:25:04 -06:00
Dennis Camera 033057683c Everywhere: Don't install code generators and test binaries 2024-07-10 10:13:21 -06:00
Colin Reeder d427344f39 LibWeb: Handle inline-start and inline-end as float values
Should resolve #449 for LTR languages at least
2024-07-10 17:41:18 +02:00
Jamie Mansfield 9d1ea4c7e0 LibWeb: Implement SVGElement.className 2024-07-10 10:28:43 +02:00
Andreas Kling 4e7558c88b LibWeb: Don't fire resize event until document actually resizes once
The first time Document learns its viewport size, we now suppress firing
of the resize event.

This fixes an issue on multiple websites that were not expecting resize
events to fire so early in the loading process.
2024-07-10 10:27:31 +02:00
rmg-x 629068c2a7 LibWeb: Ensure normal line-height on HTMLInputElement
Previously, setting CSS `line-height: 0` on an `input` element would
result in no text being displayed.

Other browsers handle this by setting the minimum height to the
"normal" value for single line inputs.
2024-07-10 07:05:52 +02:00
Diego e8fd8982f8 LibWasm: Give names to functions exported to JS via ref.func
https://webassembly.github.io/spec/js-api/index.html#name-of-the-webassembly-function
2024-07-10 00:37:18 +02:00
Maciej d890be6e0f LibWeb: Prepare script when src is set the first time
From https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:
When a script element el that is not parser-inserted experiences one
of the events listed in the following list, the user agent must
immediately prepare the script element el:
- [...]
- The script element is connected and has a src attribute set where
  previously the element had no such attribute.
2024-07-09 20:30:27 +01:00
Diego 5382fbb617 LibWasm: Remove Wasm::ValueType::Kind::Null* variants
As far as I know, they're not in the spec and don't serve any purposes
in the internals of LibWasm.
2024-07-09 14:22:00 +02:00
Maciej 65d8d205ee LibWeb: Implement HTML DragEvent class
This just defines the class, drag events aren't actually fired yet.
2024-07-09 11:28:32 +01:00
doctortheemh 4ef76f3198 LibGfx: Decode AVIF images
Use libavif to decode AVIF images in LibGfx.
2024-07-09 08:15:47 +02:00
Diego c103001f16 LibWasm: Fix lossy NaN bit pattern conversions in spec-test gen 2024-07-08 15:12:16 +02:00
Diego 6493acf2f4 LibWasm: Preserve sign bit across JS boundary in test-wasm
A `Uint8Array` can now be passed in the Wasm testjs files to be
transmuted into a Wasm value.
2024-07-08 15:12:16 +02:00
Luke Warlow 63a5ff70e5 LibWeb: Implement :modal pseudo class
Adds the :modal pseudo class which matches dialogs opened with
showModal().
2024-07-08 11:34:06 +02:00