Commit graph

63176 commits

Author SHA1 Message Date
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
Aliaksandr Kalenik 40742d95e6 LibWeb: Call set_needs_display() if navigable is scrolled or resized
`m_needs_repaint = true` is not enough because it doesn't schedule
repaint of a parent navigable.

Fixes the bug when an iframe is not repainted after scrolling.
2024-08-08 12:38:15 +02: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
Shannon Booth 2e884ff140 LibJS: Add Value::to_well_formed_string 2024-08-08 10:50:06 +01:00
Ali Mohammad Pur d2ff92077b LibWasm: Use braces to initialize Reference::Foo classes
These have no declared constructor, so apple clang and clang clang seem
to disagree on some versions.
2024-08-07 23:39:46 +02: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
Jelle Raaijmakers a430ae6dcf LibGfx: Mark PNG bitmaps as having unpremultiplied alpha 2024-08-07 18:51:12 +02:00
Jelle Raaijmakers b193fe658d LibGfx: Store alpha type information in Gfx::Bitmap
We use instances of `Gfx::Bitmap` to move pixel data all the way from
raw image bytes up to the Skia renderer. A vital piece of information
for correct blending of bitmaps is the alpha type, i.e. are we dealing
with premultiplied or unpremultiplied color values?

Premultiplied means that the RGB colors have been multiplied with the
associated alpha value, i.e. RGB(255, 255, 255) with an alpha of 2% is
stored as RGBA(5, 5, 5, 2%).

Unpremultiplied means that the original RGB colors are stored,
regardless of the alpha value. I.e. RGB(255, 255, 255) with an alpha of
2% is stored as RGBA(255, 255, 255, 2%).

It is important to know how the color data is stored in a
`Gfx::Bitmap`, because correct blending depends on knowing the alpha
type: premultiplied blending uses `S + (1 - A) * D`, while
unpremultiplied blending uses `A * S + (1 - A) * D`.

This adds the alpha type information to `Gfx::Bitmap` across the board.
It isn't used anywhere yet.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 99dd063c58 LibGfx: Factor out alpha type from GradientPainting
Knowing whether pixel color data is premultiplied or unpremultiplied is
useful in more places; factor it out so we can use the enum elsewhere.

Implement support for premultiplied alpha in `Color::with_alpha()` and
`::set_alpha()`.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 56ff36a0ee LibGfx: Prefix class members with m_ in EdgeTable
No functional changes.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers f5d838b64c LibGfx: Fix "coverage" typos in EdgeFlagPathRasterizer
No functional changes.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 3eb4da514c LibGfx: Remove unused ColorRole forward from Color.h 2024-08-07 18:51:12 +02:00
Aliaksandr Kalenik ee4dd5a17c LibWeb: Remove unused image-rendering param for stacking context
Previously it was accounted for by LibGfx while applying scale
transformation, but is no longer needed for Skia.
2024-08-07 18:50:44 +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
Aliaksandr Kalenik 1163ff21d7 LibWeb: Don't wrap result in optional in enclosing_scroll_frame_offset()
Instead return (0, 0) if a box does not have an offset.
2024-08-07 18:14:41 +02:00
Sam Atkins 4ec3968178 WebContent+LibWeb: Display resolved pseudo-element style in inspector
This also now uses the cached computed style for them, instead of
computing it fresh each time.
2024-08-07 16:14:49 +02:00
Sam Atkins 173daec9db LibWeb: Show pseudo-elements in DOM whose parent has no other children
If a DOM node is an element with pseudo-elements, but it has no child
DOM nodes and is not a shadow host, then the code that serializes its
pseudo-elements would get skipped, making them not show up in the
inspector.
2024-08-07 16:14:49 +02:00
Sam Atkins 9738070676 Base: Make it clear that the chonky quotation marks do in fact work now 2024-08-07 16:14:49 +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
Sam Atkins dae9c9be40 LibWeb/CSS: Add quick-and-dirty parsing for pseudo-element selectors
As noted, this is hacky because the parser wasn't written to allow
parsing an individual component of a selector. (Fox example, the
convenient-sounding `parse_pseudo_simple_selector()` assumes the first
colon has already been consumed...) So until that changes, this parses
the input as an entire selector-list, and then throws it away if it's
not a single pseudo-element selector.

It's only temporary though, I promise. 😅
2024-08-07 16:14:49 +02:00
Sam Atkins 521cd161a8 LibWeb: Store pseudo-element layout nodes as NodeWithStyle
We were already guaranteed to return a NodeWithStyle from
`create_layout_node_for_display_type()`, so make use of that knowledge.
2024-08-07 16:14:49 +02:00
Andrew Kaster 7758875cfd AK+LibGfx: Only generate clang module map if ENABLE_SWIFT
The script pulls in a dependency on the `yaml` python package. Instead
of updating all the docs and CI jobs to account for this, let's guard
calling the script behind our experimental flag instead.
2024-08-07 09:04:09 +02:00
Andrew Kaster 5a31fed1da LibGfx: Generate clang module map 2024-08-06 18:28:10 -06:00
Andrew Kaster 2d6a65884c AK: Generate clang module map 2024-08-06 18:28:10 -06:00
Andrew Kaster cb55f65328 Meta: Add a script and CMake function to generate a clang module map
In theory the clang module map should not have absolute paths for the
headers. Other Swift projects seem to use the -ivfsoverlay feature of
clang to work around this, but it seems difficult to get to work.
2024-08-06 18:28:10 -06:00
Andrew Kaster 54c7bb1e9d LibGfx: Include implicit header files from EdgeFlagPathRasterizer
This ensures that we aren't relying on transitive dependencies for
AK::log2(integral_value) and WindingRule
2024-08-06 18:28:10 -06:00
Andrew Kaster e7a9126f81 CMake: Silence the loudest warnings for generating Swift interop headers
And modernize the cmake_parse_arguments() call at the top.

Ideally, we would pull these flags from the target we're generating
for, but the current CMake setup makes that prohibitively infeasible.
2024-08-06 18:28:10 -06:00
Andrew Kaster 1dff3ca0c4 CMake: Apply C++ compile options to Swift compilations
This ensures that we can get all the proper warnings on/off to get the
same diagnostics and other options when loading C++ headers into the
Swift frontend.
2024-08-06 18:28:10 -06:00
Andrew Kaster 15f25d56b8 AK: Disable -Wunqualified-std-cast-call explicitly in CMake
When importing libraries with swiftc, the pragma to ignore this
warning isn't respected. So apply it on the command line.
2024-08-06 18:28:10 -06: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
Diego Frias a2448308fd LibWasm: Directly remove from the stack when clearing a label
Theoretically, the previous "pop, then push" method should be faster,
but it's actually faster to just remove from the stack directly.
2024-08-07 01:10:20 +02:00
Diego Frias b73b17aab4 LibWasm: Inline bytecode interpreter instruction interpretation
Gets fib(30) from 480ms to 380ms.
2024-08-07 01:10:20 +02:00
Diego Frias a3b077c641 LibWasm: Split main interpreter stack into three
Instead of one stack to hold frames, labels, and values, there is now
three separate stacks. This speeds up fib(30) from 580ms to 480ms.
2024-08-07 01:10:20 +02:00
Diego Frias 15510fb42e LibWasm: Simplify downcasting in bytecode interpreter 2024-08-07 01:10:20 +02:00
dependabot[bot] 0743afbb3c CI: Bump gradle/actions from 3 to 4
Bumps [gradle/actions](https://github.com/gradle/actions) from 3 to 4.
- [Release notes](https://github.com/gradle/actions/releases)
- [Commits](https://github.com/gradle/actions/compare/v3...v4)

---
updated-dependencies:
- dependency-name: gradle/actions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-06 17:06:40 -06: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
Shannon Booth d161602b6d LibURL: Fix method name in debug logging 2024-08-06 23:08:12 +01:00
Shannon Booth d9927d128c LibURL: Remove unused URL::create_with_help_scheme
This is unused since the SerenityOS split.
2024-08-06 23:08:12 +01:00
Aliaksandr Kalenik 672ff7e45e LibWeb: Define bounding rect for AddMask display list item
This allows display list player to skip masks that would not be visible.
2024-08-06 22:16:17 +02:00
Aliaksandr Kalenik 9f4deb57c8 LibWeb: Skip AddMask in display list player if destination rect is empty
...because otherwise Skia will fail to allocate empty surface.

Fixes crashing on https://null.com/games/chainstaff
2024-08-06 22:16:17 +02: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 861d46be3e LibWeb: Use a HashTable when querying SessionHistoryTraversalQueue
Instead of asking "do you have an entry not in this Vector", let's ask
"do you have an entry not in this HashTable".
2024-08-06 16:33:23 +02:00
Andreas Kling a1519e67fb LibWeb: Fire navigation event as required in History.pushState() 2024-08-06 16:33:23 +02:00