Commit Graph

34193 Commits

Author SHA1 Message Date
Ali Mohammad Pur
920f470735 LibCore: Fix some thread-related memory/object leaks 2024-06-26 05:47:16 +02:00
Luke Warlow
9171c35183 LibWeb: Refactor DOM parsing APIs
Multiple APIs have moved from the DOM Parsing and Serialization spec to
HTML.

Updates spec URLs and comments.

Delete InnerHTML file:
- Make parse_fragment a member of Element, matching serialize_fragment
on Node.
- Move inner_html_setter inline into Element and ShadowRoot as per the
spec.

Add FIXME to Range.idl for Trusted Types createContextualFragment
2024-06-26 05:41:00 +02:00
Andrew Kaster
a587eafbf4 CMake: Consistently use imported targets for third party dependencies 2024-06-25 17:15:42 -04:00
Tim Ledbetter
0879489084 LibMedia: Hide Matroska debug message behind a flag 2024-06-25 19:25:34 +02:00
Andreas Kling
fb9f3f10f3 LibWeb: Add Element.getHTML() and ShadowRoot.getHTML() 2024-06-25 19:22:35 +02:00
Andreas Kling
0c47b3ff97 LibWeb: Update innerHTML & co IDL definition to match spec
This stuff has moved from a mixin defined by the DOM Parsing spec, over
to the HTML spec, where they are now defined as partial interfaces for
Element and ShadowRoot.

There's also some new functionality that we don't implement yet, so
patch marks them as FIXME properties.
2024-06-25 19:22:35 +02:00
Andreas Kling
f4bdf56212 LibWeb: Rename Element::shadow_root_internal() to shadow_root()
And let the old shadow_root(), which was only supposed to be used by
bindings, be called shadow_root_for_bindings() instead.

This makes it much easier to read DOM code, and we don't have to worry
about when to use shadow_root_internal() or why.
2024-06-25 19:22:35 +02:00
Andreas Kling
c7d9c1c0b2 LibWeb: Update DOM cloning algorithm for declarative shadow DOM 2024-06-25 19:22:35 +02:00
Andreas Kling
a0e1112209 LibWeb: Add HTMLTemplateElement IDL attrs for declarative shadow DOM 2024-06-25 19:22:35 +02:00
Andreas Kling
8e68215d33 LibWeb: Add ShadowRoot.clonable and ShadowRoot.serializable 2024-06-25 19:22:35 +02:00
Andreas Kling
e62db9c118 LibWeb: Update HTML fragment serialization for declarative shadow DOM 2024-06-25 19:22:35 +02:00
Andreas Kling
9eb4b91168 LibWeb: Parse declarative shadow DOM template elements
We now honor the shadowrootmode attribute on template elements while
parsing, and instantiate a shadow tree as required by the spec.
2024-06-25 19:22:35 +02:00
Andreas Kling
043ad0eb76 LibWeb: Refactor Element.attachShadow() after spec changes
The bulk of this function is moved to a new "attach a shadow root"
helper, designed to be used both from here and the HTML parser.
2024-06-25 19:22:35 +02:00
Andreas Kling
f3070118b1 LibWeb: Add "allow declarative shadow roots" flag to Document 2024-06-25 19:22:35 +02:00
simonkrauter
e9001da8d6 LibWeb: Initial support for dashed lines in Canvas
Implement setLineDash() and getLineDash() in CanvasPathDrawingStyles,
which write/read from the CanvasState object.
This doesn't implement the actual drawing of a dashed line, but at least
sites using the Chart.js library no longer fail with an exception.
Unfortunately the Painter classes don't support dashed/dotted lines
based on segments yet.
2024-06-25 09:47:17 +02:00
Zaggy1024
c4c91f02b3 LibMedia: Remove the home-grown VP9 decoder 2024-06-24 12:41:32 -06:00
Zaggy1024
3cc1187036 LibMedia: Move VideoSampleData out of the Video namespace 2024-06-24 12:41:32 -06:00
Zaggy1024
8848ee775b LibMedia: Flush the video decoder when seeking
This allows H.264 videos to seek correctly.
2024-06-24 12:41:32 -06:00
Zaggy1024
c128a19903 LibMedia: Add a function to flush persistent data from video decoders
Any data that sticks around in a decoder, especially frames that
haven't been retrieved, may cause issues for playback.

This is especially the case with H.264, since its arbitrary frame
ordering to allow reference frames to precede B-frames causes it to
hold onto frames, and causes the playback manager to get back a frame
at a completely wrong timestamp after seeking.
2024-06-24 12:41:32 -06:00
Zaggy1024
ef99e701b7 LibMedia/Matroska: Handle negative timestamp offsets correctly
The timestamp offset of a block was being converted from i16 to u64, so
negative values would overflow and cause timestamps that fall before
the cluster's timestamp from being close to the minimum representable
i64.

The math is also now done using saturating operations to prevent any
other similar issues from occurring.
2024-06-24 12:41:32 -06:00
Zaggy1024
f6a4973578 LibMedia: Give frame timestamps to FFmpeg decoders
H.264 in Matroska can have blocks with unordered timestamps. Without
passing these as the presentation timestamp into the FFmpeg decoder,
the frames will not be returned in chronological order.

VideoFrame will now include a timestamp that is used by the
PlaybackManager, rather than assuming that it is the same timestamp
returned by the demuxer.
2024-06-24 12:41:32 -06:00
Zaggy1024
084cf68dd5 Tests/LibMedia: Add a test for H.264 decoding through FFmpeg 2024-06-24 12:41:32 -06:00
Zaggy1024
32714878ad LibMedia/Matroska: Make SampleIterator getters const 2024-06-24 12:41:32 -06:00
Zaggy1024
457a69786b LibMedia: Pass Matroska codec private data to the FFmpeg decoder
This is necessary to give the H.264 decoder the data it needs to
initialize, including frame size and profile.
2024-06-24 12:41:32 -06:00
Zaggy1024
81001b37ce LibMedia: Use FFmpeg to decode more video formats
VP9 continues to function, but this also allows AV1 to be decoded. With
this commit, H.264 is still non-functional, as the decoder requires
some extra initial data from the track definition in the Matroska file.
2024-06-24 12:41:32 -06:00
Zaggy1024
bf1e0fac94 LibMedia/Matroska: Move the definition get_codec_id_for_track up
The function is separated from the string-to-enum function it uses, and
the order is also inconsistent with header.
2024-06-24 12:41:32 -06:00
Zaggy1024
55fda2068b LibMedia/Matroska: Make track entries ref-counted
These aren't particularly small objects, but we were still copying them
around all over the place. When TrackEntry contains data buffers, they
won't need to be copied as well.
2024-06-24 12:41:32 -06:00
Zaggy1024
40fe0cb9d5 LibMedia: Store YUV planes as byte arrays with no padding for 8-bit
This should halve the size of frames in memory for frames with 8-bit
color components, which is the majority of videos.

Calculation of the size of subsampled planes has also been consolidated
into a struct. There are likely some places that will still need to
change over to this, but it should prevent issues due to differing
handling of rounding/ceiling.
2024-06-24 12:41:32 -06:00
Zaggy1024
b49d3dcf6f LibMedia: Split output bitmap size assertions to individual lines
Now Clang will stop complaining about DeMorgan's theorem.
2024-06-24 12:41:32 -06:00
Zaggy1024
fe2a63d485 LibMedia: Remove fixed-point path for BT.2020 matrix coefficients
BT.2020 will mainly be used with bit depths greater than 8, so having
this specialization is mostly pointless until we use fixed-point math
for higher bit depths.
2024-06-24 12:41:32 -06:00
Zaggy1024
6f8389c483 LibMedia: Ensure that buffers passed to SubsampledYUVFrame are moved 2024-06-24 12:41:32 -06:00
Zaggy1024
d3f88b4987 LibMedia/Matroska: Actually read out the video color range
Apparently I forgot to put read the value for this field, though this
generally doesn't matter since video bitstreams usually specify CICP as
well.
2024-06-24 12:41:32 -06:00
Zaggy1024
a99ff1fcb4 LibMedia: Add formatters for CICP and its components
This is often useful for debugging.
2024-06-24 12:41:32 -06:00
Zaggy1024
291c1c3bd0 LibMedia: Remove unused includes from VideoSampleData.h 2024-06-24 12:41:32 -06:00
circl
9f7f6aa80c LibTLS: Remove key-logging debug feature
This attempted to save data into /home/anon even on Linux
2024-06-24 09:45:41 -06:00
circl
f03e6fddf1 Meta: Remove SerenityOS-specific WASM test installer 2024-06-24 09:45:41 -06:00
circl
e5018d2a7a Utilities: Remove zip and unzip
They are not even being compiled
2024-06-24 09:45:41 -06:00
circl
84ed7e0a63 Userland: Remove unused CMakeLists.txt files
Seems that Meta/Lagon/CMakeLists.txt does their job instead, and that
this is a leftover from the SerenityOS build system.
2024-06-24 09:45:41 -06:00
Timothy Flynn
3c23ce9007 LibTimeZone: Remove entirely unused time zone methods
Evaluating third-party alternatives to LibTimeZone will be simpler with
unused functionality removed.
2024-06-24 15:04:58 +02:00
Timothy Flynn
be0dca8da3 LibTimeZone: Exclude from the tools build and switch to a shared library
It is not needed by code generators anymore, so it is not needed in the
Lagom tools build. And it is not needed as an object library anymore; it
was created this way so it could be included in Serenity's LibC.
2024-06-24 15:04:58 +02:00
Tim Ledbetter
0b753dcb44 LibWeb: Base the current find in page position on the current selection
Prior to this change, our find in page function always highlighted the
first match whenever the query was updated. After this change the
current match index is set such that it is the first match to occur
after the end of the current selection.

This means the current match position is not lost if the user modifies
their existing query.

This matches the behavior of find in page in other browsers.
2024-06-24 13:58:30 +02:00
Tim Ledbetter
0b33331f36 LibWeb: Ensure a repaint occurs when the current selection is cleared
This fixes an issue where clearing the find in page query would not
always visually clear the selection.
2024-06-24 13:57:02 +02:00
Aliaksandr Kalenik
760dfdcc1a LibWeb: Rename CommandExecutor to DisplayListPlayer
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
854b269338 LibWeb: Rename RecordingPainter to DisplayListRecorder
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
5570e6b648 LibWeb: Rename CommandList to DisplayList
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
c92f8ab1ea Everywhere: Use IOSurface as backing store on macOS
Using mmap-allocated memory for backing stores does not allow us to
benefit from using GPU-accelerated painting, because all the performance
increase we get is mostly negated by reading the GPU-allocated texture
back into RAM, so it can be shared with the browser process.

With IOSurface, we get a framebuffer that is both shareable between
processes and can be used as underlying memory for an OpenGL/Metal
texture.

This change does not yet benefit from using IOSurface and merely wraps
them into Gfx::Bitmap to be used by the CPU painter.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
e37071ae05 LibCore: Add a wrapper for IOSurface
Going to be used for backing store in upcoming changes.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
c46bea479c Everywhere: Hand pid of new process to client in launch_server_process()
Allows WebContentClient to get pid of WebContent process right after
creation, so there is no window between forking and
notify_process_information() IPC response, when client doesn't know the
pid.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
3110411c60 LibGfx: Add release callback for Bitmap
In upcoming changes, bitmap is going to be used to wrap the memory of
the IOSurface, and we will want to release the corresponding IOSurface
along with the bitmap.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
be2c484bb6 LibWebView+WebContent: Move backing store allocation into WebContent
In the upcoming changes, we are going to switch macOS to using an
IOSurface for the backing store. This change will simplify the process
of sharing an IOSurface between processes because we already have the
MachPortServer running in the browser, and WebContent knows how to
locate the corresponding server.
2024-06-24 13:09:08 +02:00
Aliaksandr Kalenik
cbbe49cdf0 WebContent: Move screenshot requests handling into repaint loop
This change ensures that if a screenshot is requested between teardown
of paintable tree and relayout, we will wait for layout to complete
before taking a screenshot.
2024-06-24 13:09:08 +02:00
Luke Warlow
6014727c20 LibWebView: Allow data URLs in sanitize_url
Allow navigation to data URLs from browser UI.
2024-06-24 06:31:17 -04:00
Timothy Flynn
ebdb92eef6 LibUnicode+Everywhere: Merge LibLocale back into LibUnicode
LibLocale was split off from LibUnicode a couple years ago to reduce the
number of applications on SerenityOS that depend on CLDR data. Now that
we use ICU, both LibUnicode and LibLocale are actually linking in this
data. And since vcpkg gives us static libraries, both libraries are over
30MB in size.

This patch reverts the separation and merges LibLocale into LibUnicode
again. We now have just one library that includes the ICU data.

Further, this will let LibUnicode share the locale cache that previously
would only exist in LibLocale.
2024-06-23 19:52:45 +02:00
Timothy Flynn
c9d9e1bb1f Meta: Exclude LibCore, LibUnicode, and LibURL from the lagom-tools build
We only need LibCoreMinimal for the lagom-tools build. In particular, by
removing LibUnicode, we remove the lagom-tools dependence on the system
ICU package, as we do not have vcpkg hooked into this build. (We could
probably add vcpkg here, but since this libraries aren't even needed, we
don't need to bother).
2024-06-23 19:52:45 +02:00
Timothy Flynn
546f740772 LibCore: Reduce the size of LibCoreMinimal slightly
A couple of files no longer needed after forking from Serenity and
removing a bunch of code generators.
2024-06-23 19:52:45 +02:00
Timothy Flynn
ec36d7122f LibIDL: Depend on LibCoreMinimal instead of LibCore
When any LibCore file (or any of its dependents) changes, we have to
regenerate all IDL bindings. By depending on LibCoreMinimal, the number
of impacting files greatly reduces.

As an example, changing a .cpp file in LibUnicode would previously cause
about 1800 ninja targets to rebuild. This is now reduced to about 200.
2024-06-23 19:52:45 +02:00
Andreas Kling
85a4cfc59b LibWeb: Add the bare minimum to render SVGAElement (<a>) 2024-06-23 19:15:24 +02:00
Andreas Kling
ae906ca497 LibWeb: Treat width: {min,max,fit}-content as auto if ratio unresolvable
This appears to match other engines.
2024-06-23 19:15:24 +02:00
Andreas Kling
db1faef786 LibWeb: Fix overeager fallback to stretch-fit width for some flex items
If a flex item has a preferred aspect ratio and the flex basis is not
definite, we were falling back to using stretch-fit for the main size,
since that appeared to match other browsers.

However, we missed the case where we actually have a definite cross size
through which the preferred aspect ratio can be naturally resolved.
2024-06-23 19:15:24 +02:00
Andreas Kling
9c02ace897 LibWeb: Allow flex-basis: {min,max,fit}-content 2024-06-23 19:15:24 +02:00
Luke Warlow
d86a6e1bec LibWeb: Implement dialog element's close watcher
Dialog elements now correctly establish a close watcher when
shown modally.

This means modal dialogs now correctly close with an escape key press.
2024-06-23 14:30:13 +02:00
Tim Ledbetter
8969f2e34a LibWeb: Disallow pasting into non-editable text nodes 2024-06-23 10:31:00 +02:00
Andreas Kling
a3c8e60710 LibWeb: Implement very basic in-memory HTTP caching
This patch adds a simple in-memory HTTP cache to each WebContent
process.

It's currently off by default (turn it on with --enable-http-cache)
since the validation logic is lacking and incomplete.
2024-06-23 09:37:23 +02:00
Andreas Kling
47169db452 LibWeb: Make HTTP response directive parsing more robust 2024-06-23 09:37:23 +02:00
Diego
3b40667413 LibWasm: Check source and destination offsets in memory.init
Overflows are no longer possible.
2024-06-22 20:52:32 +02:00
Andreas Kling
0d22e0703f LibWebSocket: Use HTTP::HeaderMap in WebSocket code 2024-06-22 18:53:24 +02:00
Jamie Mansfield
4c5fa102a3 LibWeb: Don't set hashChange for classic history navigate events
See:
- https://github.com/whatwg/html/pull/10393
2024-06-22 17:40:24 +02:00
Luke Warlow
b216046234 LibWeb: Implement CloseWatcher API
This implements most of the CloseWatcher API from the html spec.

AbortSignal support is unimplemented.

Integration with dialogs and popovers is also unimplemented.
2024-06-22 17:39:53 +02:00
Edwin Hoksberg
2b30414c1d LibWeb: Add attribute list that must always be compared without casing 2024-06-22 15:52:04 +02:00
Jamie Mansfield
68d84755f4 LibWeb: Implement IDBRequest.onerror 2024-06-22 14:57:47 +02:00
Jamie Mansfield
5ebc09c83b LibWeb: Implement IDBRequest.onsuccess 2024-06-22 14:57:47 +02:00
Jamie Mansfield
fe3962a64d LibWeb: Implement IDBOpenDBRequest.onupgradeneeded 2024-06-22 14:57:47 +02:00
Jamie Mansfield
30db7fb323 LibWeb: Implement IDBOpenDBRequest.onblocked 2024-06-22 14:57:47 +02:00
Jamie Mansfield
1114bbf2f1 LibWeb: Implement HTMLStyleElement.disabled 2024-06-22 14:57:47 +02:00
Jamie Mansfield
be08abbf8a LibWeb: Remove is_media_feature_name function
This was made redundant in GH-12971 (SerenityOS), and removing it drops
a FIXME :^)

See:
- https://github.com/SerenityOS/serenity/pull/12971
2024-06-22 14:57:47 +02:00
Tim Ledbetter
31d7fa2442 LibWeb: Fire auxclick event on middle click
Previously, no event was fired on middle click. This change also allows
the UI to open a link in a new tab on middle click.
2024-06-22 14:57:36 +02:00
Tim Ledbetter
728fca1b1f LibWeb: Add Internals.middleClick
This simulates click of the middle mouse button, which is necessary for
testing whether the `auxevent` fires correctly.
2024-06-22 14:57:36 +02:00
Timothy Flynn
9220a89d2f CI+LibUnicode: Remove the UCD from the system 2024-06-22 14:56:39 +02:00
Timothy Flynn
2ba7b4c529 LibUnicode: Remove now-unused code generator facilities 2024-06-22 14:56:39 +02:00
Timothy Flynn
069bed5d47 LibUnicode+LibGfx: Remove superfluous emoji metadata
For SerenityOS, we parse emoji metadata from the UCD to learn emoji
groups, subgroups, names, etc. We used this information only in the
emoji picker dialog. It is entirely unused within Ladybird.

This removes our dependence on the UCD emoji file, as we no longer
need any of its information. All we need to know is the file path to
our custom emoji, which we get from Meta/emoji-file-list.txt.
2024-06-22 14:56:39 +02:00
Timothy Flynn
aa3a30870b LibUnicode: Replace code point bidirectional classes with ICU 2024-06-22 14:56:39 +02:00
Timothy Flynn
e77dafc987 LibUnicode: Replace code point scripts and script extensions with ICU 2024-06-22 14:56:39 +02:00
Timothy Flynn
986ff984cc LibUnicode: Replace code point general categories with ICU 2024-06-22 14:56:39 +02:00
Timothy Flynn
c804bda5fd LibUnicode: Replace code point properties with ICU 2024-06-22 14:56:39 +02:00
Luke Warlow
a0561ea9b2 LibWeb: Implement type attribute validation for image loading
This change fixes image loading where unsupported image types are
included in the list of source elements.
2024-06-21 17:29:25 +01:00
Andreas Kling
d3a8f9ba9a LibGfx: Remove unused GrayscaleBitmap class 2024-06-21 10:31:13 +02:00
Andreas Kling
345ae18929 LibGfx: Remove Gfx::Painter::draw_text() and helpers 2024-06-21 10:31:13 +02:00
Andreas Kling
23f6280817 LibWeb: Remove the now-unused DrawText display list command 2024-06-21 10:31:13 +02:00
Andreas Kling
63f8feb9a4 LibWeb: Implement RecordingPainter::draw_text() via draw_text_run()
To get away from the ancient (and buggy) text layout code in
Gfx::Painter, we want to remove all the uses of Painter::draw_text().

As a first step towards this, we implement the draw_text() display list
command in terms of the draw_text_run() command by performing the very
simple necessary layout in draw_text() beforehand.
2024-06-21 10:31:13 +02:00
Andreas Kling
8a3dc5ea0a LibGfx: Remove home-grown PNG codec in favor of libpng+apng 2024-06-21 07:31:37 +02:00
Andreas Kling
fed4668fb1 LibGfx: Remove unused CharacterBitmap class 2024-06-20 15:23:09 +02:00
Timothy Flynn
ab56b8c8dc LibUnicode: Remove the locale-unaware text segmentation implementation 2024-06-20 13:46:54 +02:00
Timothy Flynn
3974996e95 LibLine: Port text segmentation to the ICU text segmenter 2024-06-20 13:46:54 +02:00
Timothy Flynn
12f177e9e9 LibWeb: Port text segmentation to the ICU text segmenter 2024-06-20 13:46:54 +02:00
Timothy Flynn
14071c52f9 LibJS: Port Intl.Segmenter to the ICU text segmenter
This also lets us fully implement detecting if a segment is word-like,
although that is not tested by test262.
2024-06-20 13:46:54 +02:00
Timothy Flynn
3fe0a27fbd LibLocale: Implement an ICU-based text segmenter
Our current segmenter implementation lives in LibUnicode, and is not
locale-aware. We will need such awareness for ECMA-402, and so LibLocale
will be the new home for text segmentation.

The tests here are ported directly from LibUnicode/TestSegmentation.cpp.
2024-06-20 13:46:54 +02:00
Timothy Flynn
5cf818e305 LibUnicode: Replace case transformations and comparison with ICUs
There are a couple of differences here due to using ICU:

1. Titlecasing behaves slightly differently. We previously transformed
   "123dollars" to "123Dollars", as we would use word segmentation to
   split a string into words, then transform the first cased character
   to titlecase. ICU doesn't go quite that far, and leaves the string
   as "123dollars". While this is a behavior change, the only user of
   this API is the `text-transform: capitalize;` CSS rule, and we now
   match the behavior of other browsers.

2. There isn't an API to compare strings with case insensitivity without
   allocating case-folded strings for both the left- and right-hand-side
   strings. Our implementation was previously allocation-free; however,
   in a benchmark, ICU is still ~1.4x faster.
2024-06-20 10:59:55 +02:00
Tim Ledbetter
a3a7a65b1c LibWeb: Don't search non-visible text for find in page results
Elements which are `display: none` or `visibility: hidden` are no
longer included in find in page results.
2024-06-20 10:59:32 +02:00
Tim Ledbetter
23166b85d2 LibWeb: Don't match text across block elements for find in page queries
Find in page will no longer match text that spans across block elements.
Previously, given the markup `WH<div>F</div>`, the query `WHF` would
find a match. We would now match `WH` and `F` separately, but not `WHF`.
2024-06-20 10:59:32 +02:00
Tim Ledbetter
6f5ccaecbd LibWeb: Update current find in page match after performing query
Previously, the `Page::find_in_page_next_match()` needed to be called
twice before the match index would be updated.
2024-06-20 10:59:32 +02:00
Andreas Kling
a91bb72dab LibJS: Don't overwrite cached this value on async/generator reentry
When resuming execution of a suspended function, we must not overwrite
any cached `this` value with something from the ExecutionContext.

This was causing an empty JS::Value to leak into the VM when resuming
an async arrow function, since the "this mode" for such functions is
lexical and thus ExecutionContext will have an empty `this`.

It became a problem due to the bytecode optimization where we allow
ourselves to assume that `this` remains cached after we've executed a
ResolveThisBinding in this (or the first) basic block of the executable.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/138
2024-06-20 10:17:18 +02:00
Timothy Flynn
ad10705615 LibLocale: Move definition of Range structure to dedicated header
We were redefining a Range type in a few formatters. Move it to its own
header to avoid ODR violations (and give it a more descriptive name).
2024-06-19 13:11:38 -04:00
Aliaksandr Kalenik
8a509a8023 LibWeb: Take into account specified winding rule in Skia painter 2024-06-19 16:51:52 +02:00
Aliaksandr Kalenik
0b48c1ea3f Everywhere: Remove AffineCommandExecutorCPU
No need to have it after introduction of Skia painter that supports
transforms.
2024-06-19 17:22:30 +03:00
Aliaksandr Kalenik
de6d99e940 LibWeb: Respect selected painter in SVGDecodedImageData
Now SVGDecodedImageData uses Skia painter, if it's selected.
2024-06-19 16:26:37 +03:00
Aliaksandr Kalenik
6dd124fc87 LibWeb+WebContent+WebWorker: Allow to query painter type from PageClient
Now it's possible to query selected type from SVGPageClient.
2024-06-19 16:26:37 +03:00
Ali Mohammad Pur
8c9d3b30cf LibWeb/CSS: Avoid capturing structured binding in generic lambda
Apple Clang doesn't like this, rather than waiting for their version of
random-clang-commit-to-call-a-release to catch up with llvm trunk, just
work around the issue.

Fixes #186.
2024-06-19 12:46:27 +02:00
Andreas Kling
847243b706 LibWeb: Only inject "User-Agent"/"Accept" headers when they're missing
...otherwise we send out HTTP requests with duplicates of these headers.
2024-06-19 08:09:10 +02:00
Aliaksandr Kalenik
bd16648b71 LibWeb: Support bitmap scaling mode in Skia painter
Co-authored-by: Andreas Kling <kling@serenityos.org>
2024-06-19 07:52:14 +02:00
Aliaksandr Kalenik
ef1f54b6b0 LibWeb: Accept value by reference in Skia type conversion helpers 2024-06-19 07:52:14 +02:00
Aliaksandr Kalenik
8f721e5b1a LibWeb: Drop gfx_{type} prefix from helpers that convert LibGfx to Skia
Having it was unnecessary verbosity.
2024-06-19 07:52:14 +02:00
Aliaksandr Kalenik
e9658356c4 LibWeb: Skip missing glyphs in Skia painter
Port fbc42e7d42
2024-06-19 07:52:14 +02:00
Zaggy1024
5a6950be8e LibMedia: Make Media::Sample final using Variant for auxiliary data
We don't need to allocate these little things onto the heap, that's
silly.
2024-06-19 07:51:55 +02:00
Zaggy1024
7c10e1a08d LibMedia: Rename LibVideo to LibMedia
This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.
2024-06-19 07:51:55 +02:00
Timothy Flynn
8d7216f4e0 LibUnicode: Replace IDNA ASCII conversion with ICU 2024-06-18 21:07:56 +02:00
Timothy Flynn
83475c5380 LibUnicode: Replace Unicode string normalization with ICU
In a benchmark, ICU's implementation was over 3x faster than ours.
2024-06-18 21:07:56 +02:00
Timothy Flynn
187349e4db LibLocale: Inline a couple of ICU string conversion methods
This just allows using the ICU header within LibUnicode, without having
to link against LibLocale.

Eventually, I think it will make sense to combine LibUnicode & LibLocale
back into a single library. They were separated to remove the large CLDR
data library from LibUnicode since most users did not need it. But that
is not much of a concern now.
2024-06-18 21:07:56 +02:00
Timothy Flynn
1feef17bf7 LibUnicode: Remove completely unused code point name & block name data
These were used for e.g. the Character Map on Serenity, but are not used
at all for Ladybird.
2024-06-18 21:07:56 +02:00
Timothy Flynn
9c3a775395 LibJS: Update AOs involved in locale resolution to the latest ECMA-402
There have been a number of changes to the locale resolution AOs that
we've fallen behind on. Mostly editorial, but includes one normative
change to canonicalize Unicode extension keywords in the Intl.Locale
constructor.
2024-06-18 21:06:50 +02:00
Timothy Flynn
2c311448c7 LibLocale+LibJS: Make a locale canonicalization API a bit more ergonomic
Instead of taking an out-parameter, return the canonicalization result.
This allows the API to be used where specs want to store the result and
the original values in separate variables.
2024-06-18 21:06:50 +02:00
Aliaksandr Kalenik
d292152e2e LibWeb: Add Skia painting command executor
This change introduces Skia painter available under a flag. It's not
yet match capabilities of Gfx::Painter and is not ready to replace it.

Motivation:
- The current CPU painter is a performance bottleneck on most websites.
  Our own GPU painter implementation is very immature and has received
  relatively little attention.
- There is ongoing effort on building painter that supports affine
  transforms (AffineCommandExecutorCPU) but it is far from being on par
  with the default CPU painter. Skia will allow us to immediately get
  full transformation support for all painting commands.

GPU painting:
I experimented with Ganesh GPU-backend, however profiling revealed that
without sharing viewport texture between WebContent and Browser
processes, it won't bring much performance improvement compared to
CPU-backend. Therefore, I decided to keep this PR focused on
implementing most of painting commands and switch to GPU-backend in
future changes.

Text rendring:
Skia painter uses glyph bitmaps produced by LibGfx. Using Skia for text
rendering will require large refactoring of the font rendering
subsystem. Currently, it's impossible to construct SkFont right before
rendering because Gfx::VectorFont can't be serialized back into sequence
of bytes.

There is a problem with ugly include paths like:
`#include <core/SkBitmap.h>`.
I would prefer to have skia prefix in the path. There was an attempt to
fix that but PR was rejected https://github.com/microsoft/vcpkg/pull/32660

Regressions compared to Gfx::Painter:
- DrawText is not implemented
- PaintTextShadow is not implemented
- PaintRadialGradient and PaintLinearGradient do not support "transition
  hints" and repeat length
- PaintConicGradient is not implemented
- DrawTriangleWave is not implemented
- DrawLine does not account for line style property
- DrawScaledBitmap and DrawScaledImmutableBitmap do not account for
  scaling mode property
2024-06-18 21:05:50 +02:00
Aliaksandr Kalenik
25c4355406 Ladybird+LibWeb+WebContent: Add an option to enable Skia painter 2024-06-18 21:05:50 +02:00
Aliaksandr Kalenik
8a7cd8055f LibWeb: Add save and restore commands in recording painter
This change is a preparation before introducing Skia painter in an
upcoming change. It's needed because Skia does not have an API to
implement ClearClipRect command. It only allows to return previous
clip rect by popping from its internal state stack.

A bit more context: initially we had save and restore commands, but
their frequent use led to many reallocations of vector during painting
commands recording. To resolve this, we switched to SegmentedVector to
store commands list, which allows fast appends. Now, having many save
and restore commands no longer causes noticeable performance issue.
2024-06-18 21:05:50 +02:00
Diego
0e705f431e LibWasm: Check exports for valid ref.func targets 2024-06-18 16:58:33 +02:00
Diego
bd97091cbb LibWasm: Ensure that global.get only accesses imports in const exprs 2024-06-18 16:58:33 +02:00
Diego
20d8ea4db1 LibWasm: Read indices as LEB128 u32s
Every type of index was previously being read as a size_t.
2024-06-18 16:58:33 +02:00
Diego
78c56d80f9 LibWasm: Check data segment offset at correct time during instantiation
The data segment offset should be checked _before_ checking if the
contents of the segment are non-existent.
2024-06-18 16:58:33 +02:00
Diego
c2a0c4f581 LibWasm: Report start function traps during instantiation 2024-06-18 16:58:33 +02:00
Luke Warlow
099b77d60f LibWeb: Add motion preference
This adds a motion preference to the browser UI similar to the existing
ones for color scheme and contrast.
Both AppKit UI and Qt UI has this new preference.
The auto value is currently the same as NoPreference, follow-ups can
address wiring that up to the actual preference for the OS.
2024-06-18 10:31:54 -04:00
Luke Warlow
564e546ff0 LibWeb: Prevent select.click() opening the dropdown
No other browser allows opening the select element dropdown with the
select.click() function.
This change stops this happening in Ladybird.
2024-06-18 09:37:07 +02:00
Tim Ledbetter
5ca2f4dfd7 Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Timothy Flynn
de99dd2c89 LibJS+LibLocale: Change ListFormat to be created once per Intl object
ListFormat was the first formatter I ported to ICU. This patch makes it
match the style of subsequently ported formatters, where we create the
formatter once per Intl object, rather than once per prototype
invocation.
2024-06-17 18:46:22 -04:00
Timothy Flynn
1c51ac4763 LibJS: Remove unused PartitionPattern AO and related types
And move some headers around that are no longer needed in the AO header.
2024-06-17 18:46:22 -04:00
Timothy Flynn
638a6c8c00 LibJS: Support non-Gregorian calendars for Intl.DateTimeFormat
This almost worked out of the box, but we need to be sure we pass the
full locale (e.g. en-u-ca-hebrew) and not just the data locale (en) to
ICU.
2024-06-17 21:59:59 +02:00
Timothy Flynn
4598a505b1 LibJS: Differentiate between undefined and null locale keys
We were previously treating undefined and null as the same (an empty
Optional). However, there are edge cases in ECMA-402 where we must treat
them differently. Namely, the hour cycle (hc) keyword. An undefined hc
value has no effect on the resolved locale, whereas a null hc value can
actively override any hc specified in the locale string. For example:

    new Intl.DateTimeFormat("en-u-hc-h11", { hour12: false });

In that object, the hour12 option does not match the u-hc-h11 value. So
the spec dictates we remove the hc value by setting it to null.
2024-06-17 21:59:59 +02:00
Andreas Kling
1039acca8c LibGfx: Remove JPEG2000 image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
a34a5af939 LibGfx: Remove ILBM image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
b6daddb088 LibGfx: Remove JBIG2 image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
b7f8d7aec5 LibGfx: Remove TGA image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
681a2ac14e LibGfx: Remove support for the various "portable" image formats
These formats are not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
7141319a7c LibGfx: Remove DDS image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
4b4254c3d0 LibGfx: Remove QOI image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
2a888ca626 LibGfx: Remove home-grown JPEG codec in favor of libjpeg-turbo 2024-06-17 17:59:54 +02:00
Luke Warlow
5098ed6b1f LibWeb: Add HTMLSelectElement showPicker()
Adds the showPicker() function for select elements.
This doesn't do the check for "being rendered" which is in the spec.
2024-06-17 07:01:26 -06:00
Diego
3225e6fad2 LibWasm: Improve element validation and instantiation 2024-06-17 01:55:42 +02:00
Diego
4c3071c7c2 LibWasm: Implement rest of table instructions 2024-06-17 00:58:31 +02:00
Timothy Flynn
06ed0dfcc1 LibWeb: Run clang-format
We mistakenly did not add the clang-format linter to the new repo's CI,
and some unformatted code made its way into the repo.
2024-06-16 15:30:28 -04:00
Andreas Kling
fbc42e7d42 LibGfx: Don't try to paint glyphs that aren't in a font
Fixes https://github.com/LadybirdBrowser/ladybird/issues/88
2024-06-16 13:24:36 +02:00
Andreas Kling
1bde774918 LibGfx: Remove unused cruft 2024-06-16 13:24:36 +02:00
Daniel Bertalan
bf1f631f25 Everywhere: Write dtors for types with incomplete members out-of-line
These are rejected by Clang (19) trunk as a result of
https://github.com/llvm/llvm-project/pull/77753.
2024-06-16 07:19:56 -04:00