Commit graph

63067 commits

Author SHA1 Message Date
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
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
Andreas Kling faf097bb41 LibWeb: Sync with spec in "destroy a document and its descendants"
The only real change here is that we make the document unsalvageable.
Everything else is fixing up spec comments.
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
Aliaksandr Kalenik f574e2b03a LibWeb: Resolve background size and offset only after style invalidation
This change fixes layering violation by moving to_px() calls to happen
before display list recording. Also it should make display list
recording a bit faster by resolving background properties beforehand.
2024-08-06 09:40:34 +02:00
Shannon Booth 2995a57f63 LibHTTP: Don't double percent encode path in HTTPRequst::to_raw_request
This was a goof in cc55732332 which
resulted in the URL path getting double percent encoded. Since the path
already comes out percent encoded following the rules in the URL spec -
we don't need to percent encode again.

Fixes: #978
2024-08-06 08:18:20 +01: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