Commit graph

39361 commits

Author SHA1 Message Date
sin-ack
5744211001 AK: Remove StringView(char const*) :^)
This constructor relied on running strlen implicitly on its argument,
thereby potentially causing out-of-bound reads (some of which were
caught a few days ago). The removal of this constructor ensures that the
caller must explicitly pass the size of the string by either:

1) Using operator""sv on literal strings; or
2) Calling strlen explicitly, making it clear that the size of the view
   is being calculated at runtime.
2022-07-12 23:11:35 +02:00
sin-ack
d16544100f Tests: Remove StringView char const* initialization test
We now explicitly disallow this.
2022-07-12 23:11:35 +02:00
sin-ack
604aac531c AK+Userland+Tests: Remove URL(char const*) constructor
The StringView(char const*) constructor is being removed, and there was
only a few users of this left, which are also cleaned up in this commit.
2022-07-12 23:11:35 +02:00
sin-ack
3f8060d859 AK: Remove String <-> char const* comparison operators
During the removal of StringView(char const*), all users of these
functions were removed, and they are of dubious value (relying on
implicit StringView conversion).
2022-07-12 23:11:35 +02:00
sin-ack
5422691f07 LibRegex: Remove RegexStringView(char const*) constructor
This allowed passing in a nullptr for the StringView which will not be
possible once StringView(char const*) is removed.
2022-07-12 23:11:35 +02:00
sin-ack
87f5e0bcda LibCore: Add FIXME note about converting Core::Account to use StringView
This prevents a bunch of utilities from using StringView for their
arguments.
2022-07-12 23:11:35 +02:00
sin-ack
fbc771efe9 Everywhere: Use default StringView constructor over nullptr
While null StringViews are just as bad, these prevent the removal of
StringView(char const*) as that constructor accepts a nullptr.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
sin-ack
e3da0adfe6 LibC: Convert getopt and getopt_long to new StringView usage 2022-07-12 23:11:35 +02:00
sin-ack
828060e631 LibCore: Add convenience templates for System::{unveil,pledge}
These convenience templates allow the following to be written as before:

    TRY(Core::System::pledge("promises..."));
    TRY(Core::System::pledge("promises...", "execpromises..."));
    TRY(Core::System::unveil("path", "permissions"));
    TRY(Core::System::unveil(nullptr, nullptr));

Other uses must now append sv to any literal string passed to pledge and
unveil.
2022-07-12 23:11:35 +02:00
sin-ack
a4c251f858 LibX86: Convert register names to StringViews 2022-07-12 23:11:35 +02:00
sin-ack
a3eeeaa6a1 Userland: Remove erroneous String -> char* -> StringView conversions
These were accidental (or leftover) uses of String::characters() to
construct StringViews through its StringView(char const*) constructor.
Since this constructor is due to be removed, this will no longer work.
Plus this prevents strlen from being run on these strings unnecessarily.
2022-07-12 23:11:35 +02:00
sin-ack
60f6bc902b Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc
functions which expect null-terminated strings, so String objects were
used there instead.
2022-07-12 23:11:35 +02:00
sin-ack
fded8f861d Tests: Convert TestQuotedPrintable decode test to use StringViews 2022-07-12 23:11:35 +02:00
sin-ack
f6b1db37fc Tests: Convert TestBase64 decode test to use StringViews directly
Previously it would rely on the implicit StringView conversions. Now the
decode_equal function will directly use StringViews.
2022-07-12 23:11:35 +02:00
sin-ack
3e1d0d9425 Tests: Make TestSourceLocation basic_scenario specify StringView length 2022-07-12 23:11:35 +02:00
sin-ack
3d656ba600 LibJS: Emit StringViews for ErrorType instances
This removes the need for calculating each string's length during
ErrorType use at the cost of storing it within the binary.
2022-07-12 23:11:35 +02:00
sin-ack
6c46383e23 LibChess: Add convenience constructor for Chess::Square
It didn't feel right to add sv suffixes to 2-character strings, so I
added this convenience constructor.
2022-07-12 23:11:35 +02:00
sin-ack
7456904a39 Meta+Userland: Simplify some formatters
These are mostly minor mistakes I've encountered while working on the
removal of StringView(char const*). The usage of builder.put_string over
Format<FormatString>::format is preferrable as it will avoid the
indirection altogether when there's no formatting to be done. Similarly,
there is no need to do format(builder, "{}", number) when
builder.put_u64(number) works equally well.

Additionally a few Strings where only constant strings were used are
replaced with StringViews.
2022-07-12 23:11:35 +02:00
sin-ack
7da00bfa8d AK: Add string literal helpers to AK::SourceGenerator
Since all uses of SourceGenerator are with literal strings, there is no
need to burden generators with the sv suffix.
2022-07-12 23:11:35 +02:00
sin-ack
6eecc65787 AK: Explicitly calculate length of char* when printing
This moves out the calculation of the char* out to the formatter.
Additionally, we now print (null) when a null pointer is passed.
2022-07-12 23:11:35 +02:00
sin-ack
52d017c611 AK: Make CheckedFormatString pass the char array size to StringView
This makes the assumption that we never pass a stack-allocated char
array to CheckedFormatString arguments (dbgln, outln, warnln). This
assumption seems to hold true for the current state of Serenity code, at
least. :^)
2022-07-12 23:11:35 +02:00
Liav A
4771917184 Kernel/Graphics: Simplify initialization flow explanation comment
Most of it was not relevant anymore to what we do in the initialization
method anyway, and now it represents it quite well and "to the point".
2022-07-12 19:54:48 +01:00
Liav A
5824f30752 Kernel/Graphics: Fix comparison of framebuffer type in initialization 2022-07-12 19:54:48 +01:00
Liav A
3bd0106755 Kernel/Graphics: Remove VGA folder and its content
We never supported VGA framebuffers and that folder was a big misleading
part of the graphics subsystem.

We do support bare-bones VGA text console (80x25), but that only happens
to be supported because we can't be 100% sure we can always initialize
framebuffer so in the worst scenario we default to plain old VGA console
so the user can still use its own machine.

Therefore, the only remaining parts of VGA is in the GraphicsManagement
code to help driving the VGA text console if needed.
2022-07-12 19:54:48 +01:00
Idan Horowitz
e39514721e LibWeb: Add missing break to avoid fallthrough in FlexFormattingContext
This silences a Clang warning.
2022-07-12 18:11:21 +03:00
Idan Horowitz
c70359ac04 LibWeb: Remove unused variable in FlexFormattingContext 2022-07-12 17:54:55 +03:00
Andreas Kling
dc13ced1a7 LibWeb: Express flex item cross axis alignment as offsets-from-center
This allows us to perform cross axis alignment without knowing the final
cross size of the flex container.
2022-07-12 15:55:43 +02:00
Andreas Kling
5f78e780f5 LibWeb: Actually clamp flex line cross size to min/max-size
We were dropping the result of css_clamp() on the floor, oops!
Let's also mark it [[nodiscard]] so it won't happen again.
2022-07-12 15:55:43 +02:00
Andreas Kling
f1576160d7 LibWeb: Don't crash when failing to create WebGL context on non-Serenity
This makes Ladybird stop panicking on websites that try to use WebGL.
2022-07-12 15:55:43 +02:00
ferhatgec
b56282d4b2 DevTools/HackStudio: Fix 'enabled' property of 'build' and 'run' buttons 2022-07-12 11:56:23 +01:00
ferhatgec
00075afb07 DevTools/HackStudio: Add verify_make_is_installed() 2022-07-12 11:56:23 +01:00
Andreas Kling
31fc1990fa LibWeb: Set up both containing block sizes before intrinsic sizing
When calculating e.g the min-content height of some box, we would only
set its containing block's height to 0 in the temporary formatting
state. The containing block width was not touched at all.

This patch aims to do a bit better by resolving indefinite containing
block sizes to INFINITY before performing intrinsic sizing. We should
probably also find a way to resolve definite containing block sizes,
but I'll leave that for our future selves.
2022-07-12 02:46:21 +02:00
Andreas Kling
c81e5c9d82 LibWeb: Floor scaled flex shrink factor at 1 when spec asks us to 2022-07-12 02:46:21 +02:00
Andreas Kling
6ecf7db87b LibWeb: Take margin box into account when justifying flex items
Before this patch, we were justifying based on the content box only,
which led to misalignments along the main axis when items had non-zero
padding, borders or margins.
2022-07-12 02:46:21 +02:00
Andreas Kling
96c9ca502b LibWeb: Add safety mechanism to guard against non-finite layout sizes
Due to some yet-to-be-found bug(s) in intrinsic sizing, we can sometimes
end up deciding that some box has a non-finite intrinsic size.

This will create unpleasant results, and may lead to some layout
algorithms looping infinitely, so this patch adds a safeguard where
we simply turn non-finite intrinsic sizes into zero (and complain a
little bit in the debug log.)
2022-07-12 02:46:21 +02:00
Andreas Kling
2f0657739b LibWeb: Honor align-self over align-items when non-auto on flex item 2022-07-12 02:46:21 +02:00
Tim Schumacher
3b3af58cf6 Kernel: Annotate all KBuffer and DoubleBuffer with a custom name 2022-07-12 00:55:31 +01:00
Obinna Ikeh
d6d1ae667d LibJS: Add test case for %TypedArray%.prototype.toSpliced 2022-07-12 00:44:34 +01:00
Obinna Ikeh
45d07f648e LibJS: Add %TypedArray%.prototype.toSpliced 2022-07-12 00:44:34 +01:00
Timothy Flynn
f089c11b5b LibJS: Implement Intl.PluralRules.prototype.selectRange 2022-07-12 00:43:34 +01:00
Timothy Flynn
a337b059dd LibUnicode: Parse and generate per-locale plural ranges 2022-07-12 00:43:34 +01:00
Luke Wilde
a718c62c01 LibWeb: Implement all "attributes" mutation records for MutationObserver 2022-07-11 22:35:08 +02:00
Luke Wilde
1ca8782c99 LibWeb: Implement "characterData" mutation record for MutationObserver 2022-07-11 22:35:08 +02:00
Luke Wilde
56cfd5ced8 LibWeb: Implement all "childList" mutation records for MutationObserver 2022-07-11 22:35:08 +02:00
Luke Wilde
c9ba5531e0 LibWeb: Introduce Mutation{Record,Observer} and observer microtasks 2022-07-11 22:35:08 +02:00
Luke Wilde
116a7b74fe LibWeb: Wrap DOM::Attribute in NodeWrapperFactory 2022-07-11 22:35:08 +02:00