Commit graph

45665 commits

Author SHA1 Message Date
Andrew Kaster
f5d253dcfa Everywhere: Fully qualify IsLvalueReference in TRY() macros
If USING_AK_GLOBALLY is not defined, the name IsLvalueReference might
not be available in the global namespace. Follow the pattern established
in LibTest to fully qualify AK types in macros to avoid this problem.
2023-01-15 00:56:31 +00:00
Lucas CHOLLET
56512caa73 LibCore: Don't reject an empty buffer with ENOBUFS
Instead, we just return the empty buffer.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET
4402720a15 LibCore: Don't rely on \n detection to populate the buffer
We don't need to call `can_read_line()` as the buffer will be populated
by `find_and_populate_until_any_of()`. The change is also beneficial as
the buffer will be populated until a candidate is found and not
necessarily a new line.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET
8252436c18 LibCore: Resume search in find_and_populate_until_any_of
The search used to go through the buffer from the start, even if we just
appended a small number of bytes at the end. It now remembers the last
stop and resume the search from it.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET
b21ea54af0 LibCore: Merge two search implementations in Stream::BufferedStream
`can_read_line()` and `read_until_any_of` used to have two different
implementations to search for a needle. This commit factorizes both
algorithms.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET
9a7accddb7 AK: Add an optional starting offset to CircularBuffer::offset_of
This parameter allows to start searching after an offset. For example,
to resume a search.

It is unfortunately a breaking change in API so this patch also modifies
one user and one test.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET
34922c0cc0 AK: Default move operators for CircularBuffer
The previously defined operator was swap-based. With the defaulted
implementation, both integers are now copied, but it doesn't matter as
only the `ByteBuffer` allocates memory (i.e. non-null integers values
won't affect the destruction).
2023-01-14 16:15:31 -07:00
Ben Wiederhake
23d111a459 LibWeb: Implement value_id_from_string by hash lookup
The old approach was basically a linear scan, which is slower than a
hash map for the currently 303 elements, as evidenced by the new
benchmark in TestCSSIDSpeed.

Before: Completed benchmark 'value_id_from_string' in 3238ms
After: Completed benchmark 'value_id_from_string' in 193ms
2023-01-14 15:43:27 -07:00
Ben Wiederhake
b3d2fdceb1 LibWeb+Tests: Demonstrate slowness of CSS::value_id_from_string 2023-01-14 15:43:27 -07:00
Ben Wiederhake
0687a75eaa LibWeb: Run tests in lagom if ENABLE_LAGOM_LIBWEB is set 2023-01-14 15:43:27 -07:00
Ben Wiederhake
79b9dd6248 AK+Tests: Make CaseInsensitiveStringViewTraits work with HashMap again 2023-01-14 15:43:27 -07:00
Timothy Flynn
822e32eb11 LibJS: Reword and reorder some steps of the Intl ResolveLocale AO
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/4c55823
2023-01-14 19:12:48 +00:00
Timothy Flynn
0ff4d8100f LibJS: Consistently use spaces / parentheses in NumberFormat operations
These are editorial changes in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/1508825
https://github.com/tc39/ecma402/commit/760f23a
2023-01-14 19:12:48 +00:00
Timothy Flynn
0ffad2a2d1 LibJS: Refer to String elements as code units rather than characters
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/d6b3435
2023-01-14 19:12:48 +00:00
Timothy Flynn
95cef87a9c LibJS: Update syntax for invoking the GetOption AO from Intl objects
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/0ac2e10
2023-01-14 19:12:48 +00:00
Timothy Flynn
2cca5d6676 LibJS: Fix assignment of "isNegative" in FormatNumericToString
These are normative changes in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/5a2b1d1
https://github.com/tc39/proposal-intl-numberformat-v3/commit/cd48a3d
2023-01-14 19:12:48 +00:00
Timothy Flynn
d30e96a209 LibJS: Renumber Intl.NumberFormat v3 prototypes and AOs
These are editorial changes in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/82e2f92
https://github.com/tc39/proposal-intl-numberformat-v3/commit/ce6c33e
https://github.com/tc39/proposal-intl-numberformat-v3/commit/b982783
https://github.com/tc39/proposal-intl-numberformat-v3/commit/96010f4
https://github.com/tc39/proposal-intl-numberformat-v3/commit/9dd123f
https://github.com/tc39/proposal-intl-numberformat-v3/commit/0c2834f
https://github.com/tc39/proposal-intl-numberformat-v3/commit/31c72f3
2023-01-14 19:12:48 +00:00
Timothy Flynn
d1881da2be LibJS: Set approximate number range format result's "source" to "shared"
This is a normative change in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/7510e7f
2023-01-14 19:12:48 +00:00
Aliaksandr Kalenik
9b6fcd8591 LibWeb: Stop using percentage column widths in compute_table_measures 2023-01-14 19:22:08 +01:00
Aliaksandr Kalenik
b44d977bf8 LibWeb: Propagate layout mode of table formatting context to table cells 2023-01-14 19:22:08 +01:00
Aliaksandr Kalenik
80578ead45 LibWeb: Table box width should be relative to wrapper containing block 2023-01-14 19:22:08 +01:00
Aliaksandr Kalenik
709fe01f52 LibWeb: Override width calculation for table wrappers
Introduce `TableWrapper` type so table wrappers could be
distinguished from block containers and override width
calculation for table wrappers (CSS 2.2 spec, section 17.5.2)
 inside BFCs in the way that their width should be equal to
width of table box they wrap.
2023-01-14 19:22:08 +01:00
Tim Schumacher
7526f9a8b7 AK: Remove CircularDuplexStream 2023-01-14 12:05:52 -05:00
nipos
f15aa539be LibSQL: Don't do fchmod on OpenBSD 2023-01-14 16:32:14 +01:00
nipos
b510747e22 LibCore: On OpenBSD, handle anon_create() like on MacOS 2023-01-14 16:31:59 +01:00
MacDue
fc7099b032 LibWeb: Use failable StringBuilder methods in StyleValue
This is quite verbose... but the errors must flow!
2023-01-14 12:37:00 +01:00
MacDue
2366265c53 AK: Add StringBuilder::try_join()
This is a failable version of StringBuilder::join().
2023-01-14 12:37:00 +01:00
MacDue
0c688fa117 LibWeb: Remove some unnecessary .release_value()s in StyleValue
And instead propagate these errors.
Also while here add my copyright (I've touched these files a lot)
2023-01-14 12:37:00 +01:00
Arda Cinar
93c1fb0b76 LibGemini: Disallow cases forbidden in the spec
The gemini spec at <https://gemini.circumlunar.space/docs/specification.gmi>
does not allow status lines and meta messages to start with a byte order
mark. It also forbids meta messages longer than 1024 bytes.
2023-01-14 12:28:02 +01:00
Arda Cinar
ba9fa59355 LibGemini: Do not loop in Gemini::Job in case of error
Previously, the job was shutdown only on a deferred invoke while there
was still data to be read. This meant that the read callback would get
called again and again, and, potentially throw the error again and again

This patch introoduces a failed state for the protocol parser and
returns early from the read callback if it has already failed
2023-01-14 12:28:02 +01:00
Arda Cinar
083802d41a LibGemini: Propagate errors in Job::read_line and Job::receive
This patch removes a FIXME
2023-01-14 12:28:02 +01:00
Arda Cinar
f883dc3eb0 RequestServer: Do not crash on Gemini responses
Starting a gemini request creates a pipe for the output stream for the
response, and a Core::Stream::File object is created from that pipe.
Previously, the length of the response was computed by calling
output_stream.size() which used lseek on the file descriptor. Doing that
returned an error from lseek. Computing the value by counting the
received bytes (via Gemini::Job::response_length) avoids that crash.
2023-01-14 12:28:02 +01:00
Arda Cinar
0245a62f81 LibGemini: Add a response length helper to Gemini::Job
Unlike HTTP responses, Gemini responses do not have a length header or a
delimiter for the end of a response. A response simply continues until
the connection is closed and its length is the number of bytes received.
So, the response length method only returns the result if it has
finished
2023-01-14 12:28:02 +01:00
nipos
5b45b26613 LibSQL: Don't do fchmod on FreeBSD 2023-01-14 12:27:00 +01:00
Liav A
7aebbe52b9 Meta: Fix copyright header in Kernel/Syscalls/jail.cpp file
I wrote that file in 2022, not Andreas in 2018.
2023-01-14 09:57:04 +01:00
Tim Schumacher
87c64834ca LibDNS: Use AllocatingMemoryStream in DNS package construction 2023-01-13 18:41:05 -07:00
Tim Schumacher
202175cf4c LibCore: Add helper functions to read/write trivial values from streams
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2023-01-13 18:41:05 -07:00
Niklas Poslovski
19bae983e4 LibCore: Enable file descriptor passing on FreeBSD
Ladybird currently doesn't render any webpages on FreeBSD and throws
hundreds of errors,beginning with this:
IPC::ConnectionBase (0x0000000805bf2b00) had an error (File descriptor
passing not supported on this platform), disconnecting.
WebContent process crashed!
2023-01-13 17:36:32 -07:00
Tim Schumacher
c4da1be32c LibCompress: Remove all leftover AK::Stream headers 2023-01-13 17:34:45 -07:00
Tim Schumacher
46a53dc6e0 LibCompress: Switch the deflate seekback buffer to CircularBuffer 2023-01-13 17:34:45 -07:00
Tim Schumacher
35548cab75 LibCompress: Remove DuplexMemoryStream from GzipDecompressor 2023-01-13 17:34:45 -07:00
Tim Schumacher
0d69fbd19f LibCompress: Remove DuplexMemoryStream from DeflateDecompressor 2023-01-13 17:34:45 -07:00
Tim Schumacher
100112134d LibCore: Allow zero-sized spans in Stream::*_entire_buffer
There is no particular reason why we shouldn't allow zero-sized reads or
writes here, and this actually might cause issues with our common
stream-to-stream copy pattern if we end up at an unfortunate offset
where the next read would be zero-sized and trigger EOF only after that.
2023-01-13 17:34:45 -07:00
Tim Schumacher
d23f0a7405 LibCompress: Switch DeflateDecompressor to a fallible constructor
We don't have anything fallible in there yet, but we will soon switch
the seekback buffer to the new `CircularBuffer`, which has a fallible
constructor.

We have to do the same for the internal `GzipDecompressor::Member`
class, as it needs to construct a `DeflateCompressor` from its received
stream.
2023-01-13 17:34:45 -07:00
Tim Schumacher
d717a08003 AK: Add CircularBuffer::read_with_seekback 2023-01-13 17:34:45 -07:00
Timothy Flynn
afc0e461e1 AK+Everywhere: Disallow returning a reference from a fallible expression
This will silently make a copy. Rather than masking this behavior, let's
explicitly disallow it.
2023-01-13 18:50:47 -05:00
Timothy Flynn
3de75f6436 LibJS: Explicitly disallow references in ThrowCompletionOr
This will be disallowed by TRY soon, but the compile error produced by
this requirement will pinpoint the errant line more accurately.
2023-01-13 18:50:47 -05:00
Timothy Flynn
a59ebdac2d LibJS+Everywhere: Return strings by value from PrimitiveString
It turns out return a ThrowCompletionOr<T const&> is flawed, as the GCC
expansion trick used with TRY will always make a copy. PrimitiveString
is luckily the only such use case.
2023-01-13 18:50:47 -05:00
MacDue
9a120d7243 AK: Add support for "debug only" formatters
These are formatters that can only be used with debug print
functions, such as dbgln(). Currently this is limited to
Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr
values (good for debugging), but trying to use them in any
String::formatted() call will fail (which prevents .to_string()
errors with the new failable strings being ignored).

You make a formatter debug only by adding a constexpr method like:
static constexpr bool is_debug_only() { return true; }
2023-01-13 21:09:26 +00:00
MacDue
1388375310 strace: Fix ignored errors in formatting 2023-01-13 21:09:26 +00:00