Commit graph

34030 commits

Author SHA1 Message Date
Liav A. 1e73a584a7 Userland: Move basic system init functionality out of SystemServer
Let's make SystemServer simpler by not involving it with the basic
system initialization sequence.
That initialization sequence can be done in another program that
theoretically can be put in another filesystem.

Co-authored-by: Tim Schumacher <timschumi@gmx.de>
2024-06-30 00:20:45 +02:00
Thomas Voss 96efa81dc6 Utilities/wc: Seek the input file(s) if only -c is passed
If the user only wants to get the byte count of a set of files, then for
each file we can simply seek it to get the byte count instead of
iterating over all the bytes.
2024-06-30 00:17:46 +02:00
Andreas Kling 225108c830 LibWeb: Set the correct prototype for SVGAElement instances
(cherry picked from commit 4db05ecf69bee07a060f2e4513e9d53b6110dcc4)
2024-06-28 23:43:59 +02:00
Luke Warlow cf5b1b7c10 LibWeb: Implement unsafe HTML parsing methods
Both Element's and ShadowRoot's setHTMLUnsafe, and Document's static
parseHTMLUnsafe methods are implemented.

(cherry picked from commit ce8d3d17c4f2fcca8fac0ff4a832c8f50a011fc7)
2024-06-28 10:56:27 +02:00
Edwin Hoksberg e2bf7d1a36 LibWeb: Add attribute list that must always be compared without casing
(cherry picked from commit 2b30414c1d8641eaf4212db69e40a4381005314c)
2024-06-28 10:56:14 +02:00
Luke Warlow 27ffaad882 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.

(cherry picked from commit d86a6e1bec858a35935ba6839c154ba2482d33e6)
2024-06-28 10:32:12 +02:00
Luke Warlow 47bc8ecb0e 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.

(cherry picked from commit 564e546ff0bd78cc7ba770b53377457bf1ef88d6)
2024-06-28 10:31:53 +02:00
Liav A. 972f7581e9 Utilities/nc: Add an option to test a TCP-listening service
Similarly to OpenBSD nc, an option to just connect without transmitting
any actual data is added.

However, we don't allow UDP-mode when testing a remote service, as it
will always succeed and has no technical meaning for the user if they're
not able to view the traffic on the remote machine.
2024-06-28 10:31:23 +02:00
Liav A. dcf7296929 Utilities/nc: Don't use LibC gethostbyname function
Instead, let's use the nicer Core::Socket API and resolve the hostname
this way.
2024-06-28 10:31:23 +02:00
Luke Warlow 1df32b7e1a 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.

(cherry picked from commit 5098ed6b1f881659dbdab10c74a0e17b362ce7a8)
2024-06-28 00:56:17 +02:00
Luke Warlow 33c315bad0 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.

(cherry picked from commit b216046234560df531e1a32269e5dfa18f8f240c,
manually amended to replace a single `UIEvents::KeyCode::Key_Escape`
with `KeyCode::Key_Escape` in EventHandler.cpp since we don't have
the second commit of https://github.com/LadybirdBrowser/ladybird/pull/86)
2024-06-28 00:55:43 +02:00
Luke Warlow 1739111d17 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

(cherry picked from commit 9171c3518358cd2d146ffbd7582e4c1247a1daa7)
2024-06-28 00:55:22 +02:00
Jamie Mansfield d586afbf73 LibWeb: Don't set hashChange for classic history navigate events
See:
- https://github.com/whatwg/html/pull/10393

(cherry picked from commit 4c5fa102a381c3687e677f9b6b13752c2bcea867)
2024-06-28 00:55:02 +02:00
Tim Ledbetter 850859f645 LibWeb: Disallow pasting into non-editable text nodes
(cherry picked from commit 8969f2e34af196e935c57257ef7eec8f00b45d33)
2024-06-27 22:54:03 +02:00
Tim Ledbetter b62c572154 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.

(cherry picked from commit 31d7fa244232c2a2239dbf6017ba9e3dd191ec2e)
2024-06-27 22:53:15 +02:00
Tim Ledbetter 2554d766bc LibWeb: Add Internals.middleClick
This simulates click of the middle mouse button, which is necessary for
testing whether the `auxevent` fires correctly.

(cherry picked from commit 728fca1b1ffd8b472bc8524e5e8ec8443de011a5)
2024-06-27 22:53:15 +02:00
Aliaksandr Kalenik 030ea71dff LibWeb: Use button layout for input elements with button type
(cherry picked from commit b2dcdf009605d50503592789ac14a8406b0d3983)
2024-06-27 19:02:45 +02:00
Aliaksandr Kalenik c6e3c0a339 LibWeb: Create BlockContainer layout node for <input type="button">
...and shadow tree with TextNode for "value" attribute is created.
This means InlineFormattingContext is used, and button's text now
respects CSS text-decoration properties and unicode-ranges.

(cherry picked from commit 8feaecd5c8d02a2fdb989a9a9671e008d1c3a7de)
2024-06-27 19:02:45 +02:00
Ali Mohammad Pur 7b47c57c54 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.

(cherry picked from commit 8c9d3b30cf62016ffb03e425f1e7e3f2461262bf)
2024-06-27 19:02:24 +02:00
Luke Warlow d29cef8d5f LibWebView: Allow data URLs in sanitize_url
Allow navigation to data URLs from browser UI.

(cherry picked from commit 6014727c20ad108e8345e89cba8e9eace3c157b3)
2024-06-27 17:14:22 +02:00
Shannon Booth 4033776fb5 LibWeb: Add stub for ValidityState
This fixes https://html5test.com/ as previously an exception was being
thrown after trying to access this attribute which would then result in
a popup about the test failing (and none of the test results being
shown).

(cherry picked from commit e0bbbc729b6aad04ceff5f67c3e2868b65970047,
manually amended with the output of `git clang-format master`)
2024-06-27 17:13:16 +02:00
Hexeption 928576e0ac LibWeb: Added HTMLLinkElement.as
(cherry picked from commit 2f4668edce2effb38563b9da229d00d3ba5dc508,
manually amended to move `||` at the start of the line to appease
clang-format)
2024-06-27 14:49:29 +02:00
Matthew Olsson 5e4e39d84a LibWeb: Remove TimingFunction in favor of EasingStyleValue::Function
Now that EasingStyleValue is a lot nicer to use, there isn't much reason
to keep TimingFunction around.

(cherry picked from commit 7950992fc21e2428a7f32954bbe893a2b2d58cf7,
manually amended with the output of `git clang-format master`)
2024-06-27 14:49:14 +02:00
Matthew Olsson 6c0859d412 Meta: Remove GenerateCSSEasingFunctions
(cherry picked from commit ac35f76e67f9a393ed5a2e5c8b7e7f56809a2a56)
2024-06-27 14:49:14 +02:00
Matthew Olsson e301c1d038 LibWeb: Parse easing values manually
The values aren't that complex, so it doesn't make much sense to have a
dedicated generator for them. Parsing them manually also allows us to
have much more control over the produced values, so as a result of this
change, EasingStyleValue becomes much more ergonomic.

(cherry picked from commit 667e313731f06fabf2a3f75893c3e8f15a4172be,
manually amended with the output of `git clang-format master`)
2024-06-27 14:49:14 +02:00
Tim Ledbetter 2519dadbb3 LibURL: Convert ASCII only URLs to lowercase during parsing
This fixes an issue where entering EXAMPLE.COM into the URL bar in the
browser would fail to load as expected.

(cherry picked from commit 1a4b042664f8fddbfa70f009c5873b1f8575bf0b)
2024-06-27 14:00:51 +02:00
Tim Ledbetter 7561a48ec6 LibWebView: Don't query public suffix list when sanitizing URLs
Previously, part of the procedure we used to sanitize URLs entered via
the command line would check the host against the public suffix
database. This led to some valid, but not publicly accessible URLs
being treated as invalid.

(cherry picked from commit e9f34c7bd1e72da9a57a721d4ad501e8208cc986)
2024-06-27 14:00:51 +02:00
Matthew Olsson fa46393e27 LibWeb: Do not clamp the output of the cubic bezier timing function
It is fine for timing function to be outside of the range [0, 1]

(cherry picked from commit 7925efda5fbc755b3fff00dcbba301fe4f8bc1c9)
2024-06-27 13:44:46 +02:00
Matthew Olsson ae4c5512af LibWeb: Prevent overrunning loop bounds in cubic bezier calculation
(cherry picked from commit 7f902fa2dc787bd1212d977babf7ea9eedd328f0)
2024-06-27 13:44:46 +02:00
Matthew Olsson 3434572089 LibWeb: Correct observable property access order in KeyframeEffect
Apparently these are supposed to be accessed in alphabetical order

(cherry picked from commit 31618abf151180391720ba527541cca86190cc3e)
2024-06-27 13:44:46 +02:00
Matthew Olsson e8034cb476 LibWeb: Only read enumerable keyframe properties
(cherry picked from commit c85f00e373405623ecd255c36ba63c907b44de86)
2024-06-27 13:44:46 +02:00
Simon Wanner 92600b3171 LibTextCodec: Use generated lookup tables for all single byte decoders
(cherry picked from commit 0ab4722cee11d27da79bb05c1d53693f39938cf6)
2024-06-27 00:27:56 +02:00
Simon Wanner c90963161e LibTextCodec: Fix ISO-8859-1 vs. windows-1252 handling in web contexts
The Encoding specification maps ISO-8859-1 to windows-1252 and expects
the windows-1252 translation table to be used, which differs from
ISO-8859-1 for 0x80-0x9F.

Other contexts expect to get the actual ISO-8859-1 encoding, with 1-to-1
mapping to U+0000-U+00FF, when requesting it.

`decoder_for_exact_name` is introduced, which skips the mapping from
aliases to the encoding name done by `get_standardized_encoding`.

(cherry picked from commit 6b2c4599017f512279cb26c0d3c48aa5a9453007)
2024-06-27 00:27:56 +02:00
Simon Wanner dc2e64c5b0 LibTextCodec: Fix some incorrect encoding aliases
(cherry picked from commit 46d5cf0443a7061bd7a8a9e495c3f3ee54614f1e)
2024-06-27 00:27:56 +02:00
Simon Wanner 328552a269 LibTextCodec: Bring TextCodec::get_standardized_encoding closer to spec
(cherry picked from commit 09f2d79cb10f84dfaedea61264d8a9d91bdfa17c)
2024-06-27 00:27:56 +02:00
Simon Wanner 30609289b5 LibWeb: Bring TextDecoder constructor closer to spec
(cherry picked from commit 987910ad0f9978a9a618d13b3e1d299a81ce4906)
2024-06-27 00:27:56 +02:00
circl 98a5fff68b LibWeb: Restrict fetching file: and resource: URLs to internal pages
They are now blocked on pages which:
- Don't have an opaque origin (should be only user-initiated or about:)
- Aren't other file: pages
- Aren't other resource: pages

(cherry picked from commit 1f3285eb0410ff5c902e148932205d9e4b7fbd9b)
2024-06-26 23:11:35 +02:00
circl 8287790913 LibWeb: Consider resource: URLs to be trustworthy and non-opaque
This makes icons once again load in the directory listings

(cherry picked from commit d14888f31a8378f319efa18028083ff605105101)
2024-06-26 23:11:35 +02:00
Enver Balalic 18d589c520 LibWeb: Implement HTMLImageElement::decode with a few FIXMEs
Implements enough of HTMLImageElement::decode for it to not break
websites and actually load an image :)

(cherry picked from commit 862fc91b2cf9bee9b7f180cdf930c6c99b5dd053)
2024-06-26 23:09:54 +02:00
Andreas Kling 69514c8a18 LibWeb: Improve FIXME message about getComputedStyle() properties
Let's log which property we're trying to look up, since that's the most
interesting part!

(cherry picked from commit f7a83e57554c7a98cda165ea1fa18356a6ee54d9)
2024-06-26 23:07:42 +02:00
Andreas Kling 7cd1114f05 LibWeb: Remove unnecessary FIXME marker for CSSStyleDeclaration.cssFloat
(cherry picked from commit 4c94202e9734099b6e2839f5495b8280eec2ab2f)
2024-06-26 23:07:42 +02:00
Andreas Kling 99851591b5 LibWeb: Make CSSKeyframeRule.parentRule actually point to parent rule
(cherry picked from commit 19fa630fa7e8342673b2aaa23e451f221533f12c)
2024-06-26 23:07:42 +02:00
Andreas Kling ea2876bc6f LibWeb: Implement CSSKeyframesRule.cssRuleList
To make this straightforward, CSSKeyframesRule now uses a CSSRuleList
for internal storage.

(cherry picked from commit 7f2c833a39e150c7372299dcfe4d2d5590ae779f)
2024-06-26 23:07:42 +02:00
Andreas Kling da836c344a LibWeb: Implement CSSStyleDeclaration.parentRule
This readonly attribute returns the containing CSS rule, or null (in the
case of element inline style).

(cherry picked from commit a12d28fd3053638ce6f4215bed2d8d45cda86375)
2024-06-26 23:07:42 +02:00
Diego 0520de42f1 LibWasm: Check source and destination offsets in memory.init
Overflows are no longer possible.

(cherry picked from commit 3b40667413ce0885d10491589207b9556d5161d0)
2024-06-26 22:13:13 +02:00
Diego da3aaac7ea LibWasm: Check exports for valid ref.func targets
(cherry picked from commit 0e705f431eab80635dd24857aaa4606b7907c325)
2024-06-26 22:13:13 +02:00
Diego 145fb50fe0 LibWasm: Ensure that global.get only accesses imports in const exprs
(cherry picked from commit bd97091cbb4fd12cd323cedfa11f4c6f33250958)
2024-06-26 22:13:13 +02:00
Diego f7bebbe5a8 LibWasm: Read indices as LEB128 u32s
Every type of index was previously being read as a size_t.

(cherry picked from commit 20d8ea4db13490b3a63acd1dfefcc1bdbc79deae)
2024-06-26 22:13:13 +02:00
Diego ef9f3fd091 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.

(cherry picked from commit 78c56d80f90f913e4cbc14c865af308c6af9aeae)
2024-06-26 22:13:13 +02:00
Diego d7413560f8 LibWasm: Report start function traps during instantiation
(cherry picked from commit c2a0c4f58126e9db833e482b7611c3cea18622f6)
2024-06-26 22:13:13 +02:00
Diego a91f00fed7 LibWasm: Improve element validation and instantiation
(cherry picked from commit 3225e6fad2b077a160d682ec3953a9d8fb49ffec)
2024-06-26 22:13:13 +02:00
Diego 9605b0f28d LibWasm: Implement rest of table instructions
(cherry picked from commit 4c3071c7c209c2e53c73862be72c9b493f263e78)
2024-06-26 22:13:13 +02:00
Tim Ledbetter 166130e12d LibWeb: Avoid null dereference when performing mixed content checks
Previously, navigating to or from `about:newtab` caused a crash due to
inadvertent null dereferences when checking whether a request or
response to a request should be blocked as mixed content.

(cherry picked from commit 572ebe00eacd5aaeecc17207c75c6bf2327a3897)
2024-06-26 20:03:57 +02:00
Andrew Kaster 3d467182bc LibWeb: Check for navigable destruction in declarative refresh timer
If the Document's navigable has been destroyed since we started this
timer, or it's no longer the active document of its navigable, we
shouldn't navigate to it.

(cherry picked from commit 7b67fa706fd2dabfda3c72a752ac70d8c95bb060;
amended commit message to say "LibWeb:" instead of "DOM:")
2024-06-26 20:03:34 +02:00
Luke Warlow 39a8974840 LibWeb: Implement stub for ElementInternals
This implements a stub ElementInternals object which implements the
shadowRoot getter only.

Also implement attachInternals function.

(cherry picked from commit a65f1ecc375fa02deeab5d0e7ab4702972ffa72e)
2024-06-26 20:02:46 +02:00
Torstennator 490d61d694 PixelPaint: Fix broken "Color Masking" selection
This change solves a problem where the color selection via mouse click
on the color wheel was computing a wrong hue angle.
2024-06-26 20:02:27 +02:00
Torstennator bb0bfb7944 PixelPaint: Fix Color Masking crash
This change solves a crash where it was possible that the
"Color Masking" could try to access pixel coordinates that where beyond
the boundaries of the image.
2024-06-26 20:02:27 +02:00
Andreas Kling ff49762eb4 LibWebSocket: Use HTTP::HeaderMap in WebSocket code
(cherry picked from commit 0d22e0703f4d668fab78b6e4960dfdc2b607369d)
2024-06-26 18:50:27 +02:00
Tim Ledbetter 36630bf859 LibIDL+LibWeb: Mark [FIXME] interfaces as [[Unimplemented]]
Methods and attributes marked with [FIXME] are now implemented as
direct properties with the value `undefined` and are marked with the
[[Unimplemented]] attribute. This allows accesses to these properties
to be reported, while having no other side-effects.

This fixes an issue where [FIXME] methods broke feature detection on
some sites.

(cherry picked from commit 2f5cf8ac204a58dc2a6f722dd95015c6c2fb7a78)
2024-06-26 16:34:37 +02:00
Tim Ledbetter c98bcd0a10 LibJS: Add the [[Unimplemented]] attribute
Properties marked with the [[Unimplemented]] attribute behave as normal
but invoke the `VM::on_unimplemented_property_access callback` when
they are accessed.

(cherry picked from commit 88d425f32b3b49d5dfa8d86e6e4e2c263cd450d4)
2024-06-26 16:34:37 +02:00
Andreas Kling f72805398b LibWeb: Add the bare minimum to render SVGAElement (<a>)
(cherry picked from commit 85a4cfc59bc901e860ba60c51ad1fc9c0cf4e669)
2024-06-26 14:13:40 +02:00
Andreas Kling 19e4b138af LibWeb: Treat width: {min,max,fit}-content as auto if ratio unresolvable
This appears to match other engines.

(cherry picked from commit ae906ca4974da309c362e61ce7b6b393b8c4aed1)
2024-06-26 14:13:40 +02:00
Andreas Kling 97edca4e4e 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.

(cherry picked from commit db1faef786dbd1722bbe6a1f4a5616f3069bdb6a)
2024-06-26 14:13:40 +02:00
Andreas Kling 47d7a3648e LibWeb: Allow flex-basis: {min,max,fit}-content
(cherry picked from commit 9c02ace89785cbc185553dc2711f79c4ad1bf389)
2024-06-26 14:13:40 +02:00
Jamie Mansfield ef7d593463 LibWeb: Implement IDBRequest.onerror
(cherry picked from commit 68d84755f4b745351d3d494759d59ba6719b8ad8)
2024-06-26 14:13:20 +02:00
Jamie Mansfield 6d268be6fc LibWeb: Implement IDBRequest.onsuccess
(cherry picked from commit 5ebc09c83b5ffd75341f8ddca9db3a49f587ed8d)
2024-06-26 14:13:20 +02:00
Jamie Mansfield 2f0b9c6dab LibWeb: Implement IDBOpenDBRequest.onupgradeneeded
(cherry picked from commit fe3962a64d1ab019b36965ecc60fe495adfd9295)
2024-06-26 14:13:20 +02:00
Jamie Mansfield aec46809fe LibWeb: Implement IDBOpenDBRequest.onblocked
(cherry picked from commit 30db7fb323c6041367155e646270e2a58f4233ea)
2024-06-26 14:13:20 +02:00
Jamie Mansfield 214797a69a LibWeb: Implement HTMLStyleElement.disabled
(cherry picked from commit 1114bbf2f155aeaa8d6b368a4eb567469c5d4fe3)
2024-06-26 14:13:20 +02:00
Jamie Mansfield 33262421a2 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

(cherry picked from commit be08abbf8a0a62ae46275c3133f711c27b2efa02)
2024-06-26 14:13:20 +02:00
Andreas Kling 83d0599d1c LibWeb: Add Element.getHTML() and ShadowRoot.getHTML()
(cherry picked from commit fb9f3f10f3090cc2822d2c681bd7350dda17830e)
2024-06-26 08:48:11 +02:00
Andreas Kling e4feb43e86 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.

(cherry picked from commit 0c47b3ff971437c4bd3923134d26ad086b5f6a75)
2024-06-26 08:48:11 +02:00
Andreas Kling c8206fa070 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.

(cherry picked from commit f4bdf562127c12a7af18029777a88d4260af82d3)
2024-06-26 08:48:11 +02:00
Andreas Kling 1c5f0e8daf LibWeb: Update DOM cloning algorithm for declarative shadow DOM
(cherry picked from commit c7d9c1c0b21ad54894984dd73c775e225f82af09)
2024-06-26 08:48:11 +02:00
Andreas Kling 6217ebe33c LibWeb: Add HTMLTemplateElement IDL attrs for declarative shadow DOM
(cherry picked from commit a0e111220913ec1bf8d51dde37174120781b0a5f)
2024-06-26 08:48:11 +02:00
Andreas Kling 020764b204 LibWeb: Add ShadowRoot.clonable and ShadowRoot.serializable
(cherry picked from commit 8e68215d333963eeb63cccde171dba6ea77651d7)
2024-06-26 08:48:11 +02:00
Andreas Kling 88d9dc148c LibWeb: Update HTML fragment serialization for declarative shadow DOM
(cherry picked from commit e62db9c1181f5af49242656d3e065ceb0db800b9)
2024-06-26 08:48:11 +02:00
Andreas Kling a5189537e9 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.

(cherry picked from commit 9eb4b91168145def5677cd41057d34ecf369372b)
2024-06-26 08:48:11 +02:00
Andreas Kling 34a4b28b89 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.

(cherry picked from commit 043ad0eb7644a529c1ffbd4de9a4b89771808c84,
and amended to make `is_valid_shadow_host_name()` static.
2024-06-26 08:48:11 +02:00
Andreas Kling 3a2260b28b LibWeb: Add "allow declarative shadow roots" flag to Document
(cherry picked from commit f3070118b1fabda4a35f283a3bcf8086e32a25a9)
2024-06-26 08:48:11 +02:00
FujiBookPro 728f42f8f5 LibAudio: Replace DeprecatedFlyString with FlyString 2024-06-25 18:32:45 -06:00
Ali Mohammad Pur 3b05c81070 LibIPC: Allow sync messages to completely block the event loop
The expectation with these messages is that no other code is allowed to
run while we're waiting for the response to arrive.
Not meeting this requirement did not degrade any (observable)
functionality, however.
2024-06-25 18:30:03 -06:00
Daniel Bertalan 8d2a8dbb8b 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.

(cherry picked from commit bf1f631f257e90e91b0b45a6454d731b4b98914c)
2024-06-25 17:42:49 +02:00
Daniel Bertalan d1f1a6eef0 Everywhere: Remove usages of template keyword with no parameter list
These were made invalid with P1787, and Clang (19) trunk started warning
on them with https://github.com/llvm/llvm-project/pull/80801.

(cherry picked from commit 397774d42272fff8dbc6d8d53616d79667d6608a)
2024-06-25 17:42:49 +02:00
Timothy Flynn 46ce6decfe LibProtocol: Exit fatally if the connection to RequestServer disappears
The default implementation of die() causes the client process to simply
exit cleanly. This prevents any tests from recognizing that something
went wrong, as the process exits with a code of 0. With this patch, we
still just exit when the connection dies, but with a fatal signal. In
the future, we will want to launch a new RequestServer process and
re-establish client connections.

(cherry picked from commit d1ec32e28feee10c2c36f4cd0d496b8a95d375f8)
2024-06-25 17:42:49 +02:00
Nico Weber 7e2c8693b1 LibJS: Initialize fields of on-stack buf structure
We pass all fields of `buf` to `add_possible_value()`, and at least
on Linux `setjmp()` does not initialize all fields.

Fixes #24560.
2024-06-25 17:40:17 +02:00
Liav A. 393c886c24 Utilities: Introduce the sizefmt utility
This utility takes a human-readable size and converts it into a raw
integer that can be used on commandline utilities.
2024-06-25 09:24:55 +02:00
Andreas Kling 93253e3701 LibJS/Bytecode: Give TypeofBinding instructions a lookup cache
These can use an EnvironmentCoordinate for caching, just like normal
binding lookups. Saves a bunch of time for repeated typeof checks.

(cherry picked from commit 60a05ef414f804fe0c44d20fe13c795800826368)
2024-06-24 16:38:47 +02:00
Andreas Kling 3a7da923e6 LibJS/Bytecode: Rename TypeofVariable => TypeofBinding
(cherry picked from commit 4302e073463c403f8d7ab09c42e7644089fc33a2)
2024-06-24 16:38:47 +02:00
Andreas Kling cd7a151aef LibJS: Allow let and const to create locals in global code
This is actually safe everywhere but in the topmost program scope.
For web compatibility reasons, we have to flush all top-level bindings
to the environment, in case a subsequent separate <script> program
comes looking for them.

(cherry picked from commit 9d21d88374cf440ddf381e02a597a59ad329ed62)
2024-06-24 16:38:47 +02:00
Andreas Kling 776e5d38cd LibJS/Bytecode: Display local variable names in bytecode dumps
Instead of displaying locals as "locN", we now show them as "name~N".
This makes it a lot easier to follow bytecode dumps, especially in
longer functions.

Note that we keep displaying the local index, to avoid confusion in case
there are multiple separate locals with the same name in one executable.

(cherry picked from commit 0aa8cb7dac60c88eac3bb7674e3fe575cf1da60b)
2024-06-24 16:38:47 +02:00
Andreas Kling 63d8a1821e 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

(cherry picked from commit a91bb72dabe54849657720e36e19a3d3b737055f)
2024-06-24 16:38:47 +02:00
Tim Ledbetter 0b1adf784f SystemMonitor: Add an action to manually refresh process statistics 2024-06-23 21:20:37 +01:00
Tim Ledbetter 4091d7fc05 SystemMonitor: Add an action to pause updates 2024-06-23 21:20:37 +01:00
Liav A. 5cb1d2a63e Utilities/pkg: Move ports database handling from AvailablePort{.h,.cpp}
Instead, let's create a new class called AvailablePortDatabase that will
handle updating (from the Internet, by using our repository) of the list
and instantiating an object that could be used for querying.
2024-06-23 00:59:54 +02:00
Liav A. 1e13d758a2 Utilities/pkg: Move ports database handling from InstalledPort{.h,.cpp}
Instead, let's create a new class called InstalledPortDatabase that will
handle reading, and adding new entries as needed to such database.
2024-06-23 00:59:54 +02:00
Liav A. b201a91e72 Utilities/pkg: Rename ports_database => default_ports_database_path 2024-06-23 00:59:54 +02:00
Ali Mohammad Pur a711bb63b7 LibHTTP+LibCore+RequestServer: Use async streams for HTTP
We no longer use blocking reads and writes, yielding a nice performance
boost and a significantly cleaner (and more readable) implementation :^)
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur be2bf055dd LibCore: Fix some thread-related memory/object leaks 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 1c31dbd110 LibJS: Make emsdk's clang happy 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 9f4f319277 RequestServer+LibCore+LibTLS: Use coroutines for socket connection
This allows RS to start connections in parallel without actively waiting
for any possible handshakes.
Doing so gives us a nearly-3x speedup on the average connection latency.
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 30c41835e6 LibIPC: Actually yield to the event loop when EMSGSIZE or EAGAIN
Previously this just yielded the time slice, which blocked the event
loop until the other side read some data from the socket.
This "fixed" impl is still equally bad, but at least it doesn't block
the event loop.
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur ba54c9adb2 LibCore: Add a couple coroutine-related helper functions 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 8691d1b885 LibCrypto: Milk some more performance out of galois_multiply()
This simple change makes AES-GCM 5% faster :^)
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur ea15ccdae3 LibCrypto: Remove select individual Vector/Span::at() calls
These were showing up on profiles as quite hot (>5%), we can avoid all
the unnecessary assertions by doing them once in advance and using
pointers for the rest of the function.
This makes AES-GCM about 6% faster.
2024-06-19 15:45:02 +02:00
Nico Weber 1cc4d29d20 LibGfx/WebPWriter: Use align_up_to()
No behavior change.
2024-06-16 14:50:32 -04:00
Nico Weber 8c7a0e6334 LibGfx/WebPWriter: Use count_required_bits()
This is slightly longer than doing it manually, but arguably easier
to read. (And we don't need to convert to float and back.)

No behavior to change.
2024-06-16 14:50:32 -04:00
Liav A. 5133c9d4cb Utilities/du: Add options to filter files with min and max sizes
These options supplements the original threshold option, because it's
now possible to specify a threshold and add either minimum/maximum size
for additional filtering.

It's also possible to not use the old threshold option (that Tim
Schumacher told me it was inherited from coreutils) and only specify the
2 new options to create a filtering.
2024-06-15 09:36:39 +02:00
circl ec7d44d635 Revert "LibWeb: Use memcpy() in CanvasRenderingContext2D.getImageData()"
This reverts commit 59cb7994c6.

This change caused a bug where getImageData returned the image in
BGRA8888 format instead of RGBA8888.

(cherry picked from commit d2f9ba7db1d8dd1dd611e6a3f40b9125b5aa054d)
2024-06-14 18:18:40 -04:00
Diego cafc66f272 LibWasm: Tighten validation algorithm
The big improvement included in this commit is stack height mismatch
validation. There are other minor improvements included (related to the
validation algorithm). The method of supporting stack polymorphism has
changed to be more like the spec, which was necessary for confidently
handling stack height mismatches.

See:
https://webassembly.github.io/spec/core/appendix/algorithm.html
(cherry picked from commit 9b58271f8b6de2dbfff416780a54e0322f9c6799)
2024-06-13 23:14:39 +02:00
Diego cdf15887db LibWasm: Refactor validator to use one stack for frame information
Previously, the validator had a lot of extraneous information related to
frames. Now, there's just one stack with all the necessary information
derived from it.

(cherry picked from commit ad54b69de9df6ccd44178cbe49779e313f95f273)
2024-06-13 23:14:39 +02:00
Diego f6d7702411 LibWasm: Make loops work
This commit should hopefully allow for `loop.wast` to be run in CI.

(cherry picked from commit 6ca6fd248a14ab394f11131c3df029b486952d54)
2024-06-13 23:14:39 +02:00
Diego 1c86b8146a LibWasm: Make memory.fill fill with single bytes
Previously, `memory.fill` filled memory with 4-byte values, even though
`memory.fill` should fill with just one byte. Also fixes some other
issues with some of the bulk memory instructions, like `memory.init`.

(cherry picked from commit d8ee2e343df25d12637e08d54908b4fd86a22dc3)
2024-06-13 23:14:39 +02:00
Diego 510bfbbbc3 LibWasm: Validate imports
(cherry picked from commit a1ed3e5d8f4f7b9f44ec4d3e15432d60cba9f2ee)
2024-06-13 23:14:39 +02:00
Diego 15effbaf2a LibWasm: Validate that function and code sections match
(cherry picked from commit cda0d6d27746672058b26b0e61d0900dc73b1fb3)
2024-06-13 23:14:39 +02:00
Diego 985c4c590d LibWasm: Validate that data section exists for some instructions
(cherry picked from commit 5e5df136849c1d450a6e0dd4af3805f7e56f6e76)
2024-06-13 23:14:39 +02:00
Diego be3bc9bd7c LibWasm: Disallow multiple start sections
(cherry picked from commit 6b9977a265b8175cf4da68d601ded427cb49e44e)
2024-06-13 23:14:39 +02:00
Diego 96fb79bb98 LibWasm: Make sure no duplicate export names are possible
(cherry picked from commit c51c018fb13f4fb182da5b12e9e3fda69f6b72ef)
2024-06-13 23:14:39 +02:00
Diego 5502c1a1f8 LibWasm: Validate number of data sections
(cherry picked from commit f7d3ab8e160a61abddfe4db9c8d79260e890bb41)
2024-06-13 23:14:39 +02:00
Dan Klishch 7d1d0fe6ad LibHTTP: Support chunked transfer encoding in async HTTP client
This uses AK::{Generator,AsyncStreamTransform,AsyncStreamBuffer} added
in the previous commits.
2024-06-13 17:40:24 +02:00
Dan Klishch 77be5254e1 LibHTTP: Implement bare-bones HTTP/1.1 client using coroutines
We don't have asynchronous TCP socket implementation, so its usefulness
is a bit limited currently but we can still test it using memory
streams. Additionally, it serves as a temporary {show,test}case for the
asynchronous streams machinery.
2024-06-13 17:40:24 +02:00
Dan Klishch 205bfcc6c8 LibTest: Add Test::AsyncMemory{Input,Output}Stream
They are useful for unit testing other asynchronous streams. They have
to be tested themselves in the first place though.
2024-06-13 17:40:24 +02:00
Dan Klishch 7fb6d24402 LibTest: Support asynchronous tests 2024-06-13 17:40:24 +02:00
Dan Klishch 8263e0a619 AK: Introduce AK::Coroutine 2024-06-13 17:40:24 +02:00
Nico Weber bb2d80a2bb Everywhere: Gently remove the ladybird android port
With Ladybird now being its own repository, there's little reason
to keep the Ladybird Android port in the SerenityOS repository.

(The Qt port is useful to be able to test changes to LibWeb in lagom
so it'll stay around. Similar for the AppKit port, since getting
Qt on macOS is a bit annoying. But if the AppKit port is too much
pain to keep working, we should toss that too.

Eventually, the lagom browser ports should move out from Ladybird/
to Meta/Lagom/Contrib, but for now it might make sense to leave them
where they are to keep cherry-picks from ladybird easier.)
2024-06-11 19:40:08 -04:00
Tim Ledbetter ce11613677 CrashReporter: Don't update window progress if window has been closed
This prevents a crash that could happen if crash reporter was closed
while generating a crash report.
2024-06-10 23:44:09 -04:00
MacDue 860804baa5 LibWeb: Add support for text in the AffineCommandExecutorCPU 2024-06-10 17:41:33 -04:00
MacDue 0ca71009d0 LibGfx: Add Path::transform()
This applies an affine transform to a path in-place.
2024-06-10 17:41:33 -04:00
MacDue dae6015431 LibGfx: Add cache for glyph paths
These are only cached via the `append_glyph_path_to()` API, so uses of
fonts that only care about bitmaps do not pay for this cache.
2024-06-10 17:41:33 -04:00
MacDue d62d5079f4 LibGfx: Add relative to last point mode to Path::append_path() 2024-06-10 17:41:33 -04:00
Kenneth Myhra 702ff7eb46 LibWeb: Implement and wire up TransformStream's cancel callback
(cherry picked from commit e70886595ab83d650662f46be2ac2e147603c790)
2024-06-10 08:23:32 -04:00
Kenneth Myhra 8f8d577b52 LibWeb: Update steps for transform_stream_default_sink_abort_algorithm
Updating these steps enables the writable side of a TransformStream to
raise the cancel callback when it's aborted.

(cherry picked from commit 6d7885e25036bf08e31f2ad7a13db31767deabaf)
2024-06-10 08:23:32 -04:00
Kenneth Myhra 99d5f1ca2e LibWeb: Update cancel_algorithm steps in AO initialize_transform_stream
(cherry picked from commit 38142eaf53bfc5bb97adbc46d0ce0687716b7df5)
2024-06-10 08:23:32 -04:00
Kenneth Myhra 30c5bc3db4 LibWeb: Implement AO transform_stream_default_source_cancel_algorithm
(cherry picked from commit e848249b8d15fe722e569c22c06f6e92482f35bf)
2024-06-10 08:23:32 -04:00
Kenneth Myhra e072913bac LibWeb: Add internal slots [[cancelAlgorithm]] and [[finishPromise]]
This adds internal slots [[cancelAlgorithm]] and [[finishPromise]] to
TransformStreamDefaultController.

(cherry picked from commit ff5be1fd363c4cb9ba510679b1ee65a0c0b10bc2)
2024-06-10 08:23:32 -04:00
Kenneth Myhra 44bc3a54a3 LibWeb: Implement AO transform_stream_unblock_write
(cherry picked from commit afb74eca52fda83475a863b307db50a7a9f86f7a)
2024-06-10 08:23:32 -04:00
Andreas Kling 8994dcb4f9 Everywhere: Use HTTP::HeaderMap for request headers
No longer just for response headers! The same type is obviously useful
and ergonomic when making requests as well.

(cherry picked from commit 260c5c50ad19f19d0d4c30984e512f56c055ecff)

Updated various SerenityOS components to make it build.
2024-06-10 12:01:57 +02:00
Andreas Kling bec8d73cb3 LibHTTP+LibWeb: Stop bundling "Set-Cookie" headers as JSON
Before we had HTTP::HeaderMap (which preserves multiple headers with the
same name), we collected multiple "Set-Cookie" headers and bundled them
together as a JSON array.

This was a huge hack, and now we can stop doing that, since LibWeb gets
access to the full set of headers now.

(cherry picked from commit 5ac093885922246529a467054888e598f8832450)
2024-06-10 12:01:57 +02:00
Andreas Kling c9a1eebcb9 Everywhere: Add HTTP::HeaderMap and use for response headers
Instead of using a HashMap<ByteString, ByteString, CaseInsensitive...>
everywhere, we now encapsulate this in a class.

Even better, the new class also allows keeping track of multiple headers
with the same name! This will make it possible for HTTP responses to
actually retain all their headers on the perilous journey from
RequestServer to LibWeb.

(cherry picked from commit e636851481eabdf00953573a5eb459ee52feeacc)

Updated various SerenityOS components to make it build.

Fetch: Make sure we iterate over HeaderMap's headers()

This fixes a build failure when built with CMake option
'-DENABLE_ALL_THE_DEBUG_MACROS=ON'.

(cherry picked from commit c51d01bea712d75f9b2cd700be942935044e49b4)
2024-06-10 12:01:57 +02:00
Ali Mohammad Pur bf5c2d0859 Utilities: Add a crypto benchmarking tool 2024-06-10 11:59:14 +02:00
Abhishek Raturi ceec7cd537 Hackstudio: Add a window title when diff is opened
Set window title when a diff is opened from Git
widget in HackStudio.
2024-06-09 14:13:29 -04:00
MacDue 9597403bf8 LibWeb: Slightly simplify popping SCs in AffineCommandExecutorCPU 2024-06-09 14:12:06 -04:00
MacDue d30350e951 LibWeb: Make methods for common AffineCommandExecutorCPU operations 2024-06-09 14:12:06 -04:00
MacDue 318f2925d3 LibGfx+LibWeb: Move generally useful path methods to LibGfx
This adds:

  - Path::rect()
  - Path::quad()
  - Path::rounded_rect()

Moving the corresponding implementations from LibWeb.
2024-06-09 14:12:06 -04:00
MacDue f9c944cc85 LibWeb: Support opacity in the AffineCommandExecutorCPU
This supports opacity via the standard method of painting stacking
context to a new bitmap, then blitting it back when popping the stacking
context.

One extra complication is we have to ensure clipping is flushed between
any change of the target bitmap. But other than that is all standard.
2024-06-09 14:12:06 -04:00
MacDue b2f63632f1 LibWeb: Support clipping in the AffineCommandExecutorCPU
This adds two paths for clipping. If the clip rect is known to be
rectangular (and axis-aligned), then normal/fast painter clipping is
used. Otherwise, a temporary buffer is made for 'expensive' clipping
(i.e. clipping by an arbitrary quadrilateral). All draw commands are
then redirected to the temporary buffer until the clipping needs to be
flushed. Clipping is flushed when the clip rect or target bitmap
changes. Flushing expensive clipping requires applying a clip mask to
the temporary buffer, and then blitting it to the target bitmap.

Note: If the bounds of a draw command are known to be within the current
clip 'expensive' clipping can be elided.

In future, it may be possible to avoid some of this masking by applying
path-clipping algorithms (but that's fairly tricky, and normally
requires stronger guarantees about paths than we currently have).
2024-06-09 14:12:06 -04:00
Kenneth Myhra 7cbe5c9d4a LibWeb: Implement static method ReadableStream.from(asyncIterable)
(cherry picked from commit 0ec0e92b100faf92256e704b9e94e9c90a04b642)
2024-06-09 16:24:09 +01:00
Kenneth Myhra 2e45967127 LibWeb: Implement AO readable_stream_from_iterable
(cherry picked from commit 01a8b5ee542c006665a0623c23df59bc6a94cb22)
2024-06-09 16:24:09 +01:00
Kenneth Myhra 9d016f5c7e LibWeb: Add non-standard AO set_up_readable_stream
This AO can be used instead of CreateReadableStream in cases where we
need to set up a newly allocated ReadableStream before initialization of
said ReadableStream, i.e. ReadableStream is captured by lambdas in an
uninitialized state.

(cherry picked from commit ce521a196dc3a50b5a7e35a09917e435b78da1d4)
2024-06-09 16:24:09 +01:00
Diego 11d81d6487 LibWasm: Validate that names are UTF-8 2024-06-09 16:30:09 +02:00