Commit graph

3649 commits

Author SHA1 Message Date
Gingeh
57ba720fb1 AK: Avoid returning null StringViews instead of empty views
This was error-prone and most users were just checking the length anyway
2024-11-05 14:01:45 +00:00
Gingeh
c67ecf37f7 LibWeb: Implement linear easing according to latest spec 2024-11-05 10:41:29 +00:00
Timothy Flynn
cfcb29bdfd AK+LibUnicode: Add a method to trim non-ASCII whitespace from a String
Required by WebDriver.
2024-11-03 20:42:46 -05:00
Timothy Flynn
c3dfef3861 AK: Allow creating a JsonArray with an initial size 2024-11-03 17:51:58 +01:00
Jonne Ransijn
755b83c01a LibJS: Implement tc39/proposal-atomics-microwait (Atomics.pause)
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Implements the https://github.com/tc39/proposal-atomics-microwait
proposal which has recently hit Stage 3.

This commit passes all relevant tests in `test262`.
2024-11-03 08:05:58 -05:00
Grubre
a8a81342bb LibUnicode: Implement to_fullwidth() in String
The implementation uses the transliterator class from icu.
2024-11-01 07:48:17 -04:00
Jelle Raaijmakers
c7773d0312 Meta: Update my email address everywhere 2024-11-01 12:14:53 +01:00
Jonne Ransijn
2457118024 AK: Add template specializations for Optional<{,Fly}String>
Slice the size of `Optional<{,Fly}String>` in half by introducing
`UINTPTR_MAX` as an invalid bit pattern for these values.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
fcdf3014f1 AK: Move "conditional xtor" pattern into a macro
`Optional` and `Variant` both use essentially the same pattern of only
declaring a copy constructor/move constructor/destructor and copy/move
assignment operator if all of their template parameters have one.

Let's move these into a macro to avoid code duplication and to give a
name to the thing we are trying to accomplish.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
a70ed6a2ad AK: Add OptionalBase class to reduce code duplication
Using CRTP and `static_cast`s because "deducing this" is
still not fully supported yet.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
04920d06f0 AK: Use simdutf when appending UTF-16 to StringBuilder
Adds a fast path for valid UTF-16 using `simdutf`, and fall back to
the slow path for unmatched surrogates.
2024-10-30 10:28:24 +01:00
Jonne Ransijn
22a66bb1c2 AK: Pass (Deprecated)FlyString::is_one_of arguments by reference
This avoid unnecessairy reference counting.
2024-10-27 12:03:04 -04:00
Jonne Ransijn
7f3269fb02 AK: Add ASCII fast path for Utf8View::contains
This also makes `Utf8View::trim` significantly faster, since most
strings start and end with ASCII.
2024-10-27 16:13:36 +01:00
Jonne Ransijn
e636f3976d AK: Fix ambiguity in AK::Optional specialization
The specialization for the destructor of `AK::Optional` is ambiguous
when `T` is neither TriviallyDestructible nor Destructible.
The fix adds an additional check for `Destructible` when generating the
destructor of `AK::Optional`, since it calls the destructor of `T`, and
therefore already required `T` to be `Destructible` anyway.
2024-10-27 13:26:30 +01:00
Jonne Ransijn
e76064e67f AK: Allow Optional<T&> to be constructed from Optional<T>&
Attempting this resulted in an error because the `m_pointer` field does
not exist on `Optional<T>`. Creating a shared `ptr()` function and
adding the necessairy overloads solves this issue.
2024-10-27 13:26:30 +01:00
Andreas Kling
b6e28ff807 AK: Add ASCII fast path in StringBuilder::append(Utf16View)
And let's at least try to pre-allocate an appropriate amount of
buffer space in the builder instead of appending and growing one
code point at a time.
2024-10-25 15:10:12 +02:00
Jelle Raaijmakers
0de403fede AK+LibJS: Add [[nodiscard]] to operator* in common types
The order of precedence with the `*` operator sometimes makes it a bit
harder to detect whether or not the result is actually used. Let's fail
compilation if anyone tries to discard the result.
2024-10-25 09:15:28 +02:00
Ali Mohammad Pur
08ec58f347 AK: Add OrderedHashMap::take_first()
This is just a convenience shortcut for *take(begin()->key).
2024-10-24 20:55:08 +02:00
Timothy Flynn
0703ba118b AK: Add a comparison operator for Utf32View 2024-10-20 08:50:01 +02:00
Timothy Flynn
cf9693169c AK: Allow constructing Utf32 from a span of u32 2024-10-20 08:50:01 +02:00
Cameron Youell
94601e1ffd LibCore: Add Windows version of DirIterator
Co-authored-by: stasoid <stasoid@yahoo.com>
2024-10-19 18:14:48 -06:00
stasoid
9d15b3bbb7 AK: Fix lld-link : error : undefined symbol: __udivti3 on Windows 2024-10-16 12:15:31 -06:00
Cameron Youell
958ffad706 AK: Provide more complete definitions for AK_OS_WINDOWS
MSG_NOSIGNAL is a no-op for Windows, so we can define it to 0.

At the same *time*, none of the CLOCK_* macros are defined on
Windows, as clock_gettime does not exist. Put AK_OS_WINDOWS in the
same category of the BSDs for the COARSE versions of those macros.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
Cameron Youell
e1710939ce AK: Implement now_time_from_clock for Windows
Monotonic uses QueryPerformanceCounter, while realtime uses
GetSystemTimeAsFileTime. These should approximate clock_gettime
fairly accurately. The QPC implementation only grabs microseconds,
but if we have actual use cases for nanos, we can bump that up.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
Andreas Kling
073bcfd386 AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
2024-10-14 20:47:35 +02:00
Andreas Kling
dd419b5a8d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.
2024-10-14 20:47:35 +02:00
Andreas Kling
797902229c AK: Make the main Utf8View workhorse methods inline
The call overhead of these functions was actually showing up quite
hot in profiles on macOS.
2024-10-14 09:51:13 +02:00
Andrew Kaster
90bb8ed33e AK: Use process name on Windows for dbgln() 2024-10-10 21:48:41 -06:00
Ali Mohammad Pur
02b50d463b AK: Cache all the line positions in LineTrackingLexer
Also updates a LibWeb text test that used to report the wrong line
number.
2024-10-10 23:53:48 +01:00
Ali Mohammad Pur
e5f87eb12b AK: Make TemporaryChange not copy the old value twice
This is necessary for the next commit (and might even help performance
in some very weird cases).
2024-10-10 23:53:48 +01:00
Jelle Raaijmakers
f88acedc8f AK: Remove unused floating point conversion code
Currently I don't expect this code to be ever used in Ladybird.
2024-10-08 19:02:51 +02:00
Andreas Kling
cc4b3cbacc Meta: Update my e-mail address everywhere
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-10-04 13:19:50 +02:00
Saleem Abdulrasool
5a35ee08d3 AK: Address MSVC/Windows portability for logging
`STDERR_FILENO` is pretty common but not part of the standard. On
Windows, in order to get a file number, one must use `_fileno` to
convert the `FILE *` to a file number. Adopt this pattern similar
to the Android path which uses platform specific operations.
2024-10-02 17:04:42 -06:00
Jelle Raaijmakers
233b4f2ca8 LibMedia+everywhere: Remove superfluous and unused audio code
We had numerous NiH-based implementations of audio formats and metadata
that we now no longer need because we either don't make use of the code,
or we replaced its implementation by FFmpeg.
2024-09-30 18:48:12 +02:00
Timothy Flynn
7b3b608caf AK: Do not coerce i64 and u64 values to i32 and u32
First, this isn't actually helpful, as we no longer store 32-bit values
in JsonValue. They are stored as 64-bit values anyways.

But more imporatantly, there was a bug here when trying to coerce an i64
to an i32. All negative values were cast to an i32, without checking if
the value is below NumericLimits<i32>::min.
2024-09-27 09:46:55 +01:00
Andreas Kling
42a1a0bd73 LibWeb: Put CSS transitions debug spam behind CSS_TRANSITIONS_DEBUG
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-09-22 10:46:54 +02:00
Timothy Flynn
d19b31529f AK+Meta: Update simdutf to version 5.5.0
Contains many fixes found upstream by fuzzers. Also includes fixes for
CPU-specific inconsistencies with null inputs.
2024-09-19 15:48:57 -04:00
Andreas Kling
af68771dda AK+LibURL: Move CopyOnWrite<T> from LibURL to AK 2024-09-10 13:51:28 +02:00
Andreas Kling
ddbfac38b0 LibWeb: Note what's causing a style invalidation to happen
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.

I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.
2024-09-08 09:45:31 +02:00
Jamie Mansfield
48366ddddf LibWeb/WebAssembly: Use a debug flag for dbgln calls
This prevents the horrendous console spam when functions are resolved,
e.g. on the Royal Albert Hall website.
2024-09-07 19:44:23 +02:00
Aliaksandr Kalenik
a9d5a99568 LibGfx+LibWeb: Replace remaining OpenType implementation with Skia
This change should move us forward toward emoji support, as we are no
longer limited by our own OpenType implementation, which was failing
to parse the TrueType Collection format used to store emoji fonts
(at least on macOS).
2024-09-05 19:21:52 +02:00
Timothy Flynn
d265575269 AK: Add a Base64 decoder to decode into an existing buffer
Some callers (LibJS) will want to control the size of the output buffer,
to decode up to a maximum length. They will also want to receive partial
results in the case of an error. This patch adds a method to provide
those capabilities, and makes the existing implementation use it.
2024-09-03 17:43:03 +02:00
Timothy Flynn
35d8e7e63f AK: Add a public helper to count the decoded length of a Base64 string 2024-09-03 17:43:03 +02:00
Timothy Flynn
41e14e3fc3 AK: Add an option to the base64 encoder to omit padding
Will be used by an upcoming JS prototype
2024-09-03 17:43:03 +02:00
Timothy Flynn
408532c910 AK: Use new simdutf option to add padding to Base64URL encodings
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-08-30 15:08:25 -04:00
Andrew Kaster
01c4625a42 AK: Tell Swift how to construct AK.StringView from string literals 2024-08-29 06:31:25 +02:00
Andrew Kaster
a3e6856b56 AK+Swift: Remove Foundation.Data footgun for AK.StringView
Also give the Swift.String init routines an explict label when
constructing from AK String types, as this caused issues in a later
commit to have them both with `_ data`.
2024-08-29 06:31:25 +02:00
Andrew Kaster
c5153cb398 Meta+Libraries+AK: Append Cxx to imported library module names in swift
At the same time, simplify CMakeLists magic for libraries that want to
include Swift code in the library. The Lib-less name of the library is
now always the module name for the library with any Swift additions,
extensions, etc. All vfs overlays now live in a common location to make
finding them easier from CMake functions. A new pattern is needed for
the Lib-less modules to re-export their Cxx counterparts.
2024-08-27 17:22:31 -06:00
Andrew Kaster
c1c7e5ff3e AK+Meta: Add SwiftAK module to add helpers to construct swift Strings
This allows constructing Foundation.Data and Swift.String without
unnecessary copies from AK.StringView and AK.String respectively.
2024-08-24 19:14:09 -06:00
Andrew Kaster
b03b13b720 AK+LibGfx+LibWebView: Add wrapper header around swift/bridging
When using a configuration without a swift compiler, we need to no-op
the swift annotations. Other, cleverer solutions beyond the has include
all fell flat in the face of the clang modules implementation used by
swift to parse-once use-everywhere each module.
2024-08-19 12:56:55 +02:00