Commit graph

3370 commits

Author SHA1 Message Date
Timothy Flynn 181ece4d9c LibWeb: Implement DataTransferItem.prototype.getAsString() 2024-08-23 10:10:34 +01:00
Timothy Flynn b978dba8bd LibWeb: Implement DataTransferItem.prototype.getAsFile()
This is used on imgur after drag-and-dropping an image onto its page.
2024-08-23 10:10:34 +01:00
Andreas Kling 8eacfc8f10 LibWeb: Derive SVG root's natural size from width/height attributes
We were incorrectly looking at the CSS computed values for width and
height to determine the natural size of <svg> root elements.
This meant that elements where the attribute and computed value were
different values would end up with incorrect natural size.
2024-08-22 15:29:29 +02:00
Timothy Flynn 001d8384e5 LibWeb: Implement the DataTransferItem kind and type attributes 2024-08-22 14:21:13 +02:00
Timothy Flynn ceb9e30d42 LibWeb: Implement the DataTransferItemList indexed getter 2024-08-22 14:21:13 +02:00
Timothy Flynn 843f8f04a5 LibWeb: Implement the DataTransferItemList length attribute 2024-08-22 14:21:13 +02:00
Timothy Flynn 74d9cfbf2a LibWeb: Implement DataTransferItemList.prototype.add() 2024-08-22 14:21:13 +02:00
Timothy Flynn 5c9287aa99 LibWeb: Implement separate DataTransfer factories for IDL / internal use
The IDL constructor has to take separate steps than a DataTransfer that
is internally constructed. Notably, an IDL-created object has its own
drag data store, and that store is placed in a read-write mode.
2024-08-22 14:21:13 +02:00
Timothy Flynn 0b0d44da27 LibWeb: Implement the ClipboardEvent IDL interface
We don't actually generate any such events ourselves. But Google Lens
will create one with the DataTransfer attribute set to that of any drop
event we send it.
2024-08-22 14:21:13 +02:00
Tim Ledbetter 2c5d626b21 LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction
Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.
2024-08-22 13:49:41 +02:00
Ali Mohammad Pur a60ecea16a LibWasm+LibWeb+test-wasm: Refcount Wasm::Module for function references
Prior to funcref, a partial chunk of an invalid module was never needed,
but funcref allows a partially instantiated module to modify imported
tables with references to its own functions, which means we need to keep
the second module alive while that function reference is present within
the imported table.
This was tested by the spectests, but very rarely caught as our GC does
not behave particularly predictably, making it so the offending module
remains in memory just long enough to let the tests pass.

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

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

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

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

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

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

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

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

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

The processing model is rather large. This implements enough of it to
allow the UI process to specifically handle dragging objects outside of
the DOM onto the DOM. For example, dragging an image from the OS file
manager onto a file-upload input element. This does not implement the
ability to drag DOM elements.
2024-08-19 13:29:19 +02:00
Timothy Flynn dcb76572e4 LibWeb: Add an empty DataTransferItemList IDL implementation 2024-08-19 13:29:19 +02:00
Timothy Flynn 9e3c6921ab LibWeb: Add an empty DataTransferItem IDL implementation 2024-08-19 13:29:19 +02:00
Andrew Kaster c367063823 Tests: Add first test for LibWeb Swift bindings
Just to sanity check that we can import the library, and that it at
least interprets the generated enumeration values properly, let's
do some simple testing of the swift integration.
2024-08-19 12:56:55 +02:00
Aliaksandr Kalenik c87214d79c LibWeb: Skip documents of decoded SVGs while processing HTML event loop
None of HTML event loop processing steps are relevant for decoded SVGs,
so we can simply skip them while collecting documents for processing.
2024-08-19 09:03:33 +02:00
Tim Ledbetter 00f03f3e90 LibWeb: Match attribute selectors case insensitively in XML documents
The values of attribute selectors are now compared case insensitively
by default if the attribute's document is not a HTML document, or the
element is not in the HTML namespace.
2024-08-19 09:03:22 +02:00
Tim Ledbetter 353e3e75dc LibWeb: Limit HTMLProgressElement.max to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a
negative value.
2024-08-19 09:02:21 +02:00
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