Commit Graph

34144 Commits

Author SHA1 Message Date
Luke Warlow
ce8d3d17c4 LibWeb: Implement unsafe HTML parsing methods
Both Element's and ShadowRoot's setHTMLUnsafe, and Document's static
parseHTMLUnsafe methods are implemented.
2024-06-26 06:13:29 +02:00
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