Commit graph

46069 commits

Author SHA1 Message Date
Ali Mohammad Pur
7d4a30af56 LibCore: Avoid logical OOB read in AllocatingMemoryStream::offset_of()
The previous impl was trimming the last chunk to the free space instead
of the used space, which yielded an OOB read if the needle wasn't found.
2023-01-20 20:34:31 +00:00
Timothy Flynn
c8e25a71e0 AK: Disable use of consteval in String::from_utf8_short_string for Apple
This causes an ICE on older versions of clang, and Apple's clang is
currently based on such a version.
2023-01-20 20:33:04 +00:00
Timothy Flynn
95d1678553 LibJS: Mark infallible operations that may throw only due to OOM 2023-01-20 20:31:38 +00:00
Timothy Flynn
52b76060f9 LibJS: Add a macro for infallible operations that may throw OOM
If a spec step hasn't been marked as fallible, but might throw due to
OOM, this is to make it clear that OOM is the only thing that may cause
a failure.
2023-01-20 20:31:38 +00:00
Timothy Flynn
f1de4f8872 Everywhere: Convert known short-strings to the infallible String factory
For now, this is limited to strings that are 3 bytes or less. We can use
7 bytes on 64-bit platforms, but we do not yet assume 64-bit for Lagom
hosts (e.g. wasm).
2023-01-20 14:24:12 -05:00
Timothy Flynn
d48266a420 AK: Support creating known short string literals at compile time
In cases where we know a string literal will fit in the short string
storage, we can do so at compile time without needing to handle error
propagation. If the provided string literal is too long, a compilation
error will be emitted due to the failed VERIFY statement being a non-
constant expression.
2023-01-20 14:24:12 -05:00
Timothy Flynn
e634778679 CI: Install a more up-to-date version of emscripten
This is to allow using more recent C++20 features in upcoming commits.
Version 3.1.6 is what is installed on Ubuntu 22.10 and works with the
C++20 features we want.
2023-01-20 14:24:12 -05:00
Sam Atkins
93ca5d4772 Tests: Use AK::shuffle() for shuffling 2023-01-20 17:45:33 +00:00
Sam Atkins
4b525fc98e ColorLines: Use AK::shuffle() for shuffling 2023-01-20 17:45:33 +00:00
Liav A
5b273f3823 LibGfx: Fix TGA decoder being out of boundary after calling frame method
This happened because the reader was incrementing the byte index of it
after each read of a byte from the Span, so by the end of the frame
method, we could be at the end of the mapped file, so the next call
on the same decoder will just resume from that point and will be quickly
out of boundary.
To ensure this doesn't happen we only set the bitmap to m_context member
at the end of the method, and call to that method again will just give
the already-generated bitmap.
In case of setting the bitmap as volatile, we test for that case and
re-generate a reader to read the frame again correctly.
2023-01-20 17:05:09 +00:00
Liav A
20033d06d8 Tests/LibGfx: Fix test_gif test case
We should expect the GIF image to be animated, therefore fix that
condition.
2023-01-20 17:05:09 +00:00
Liav A
da525ccc43 Tests/LibGfx: Fix test_not_ico test case
We should expect the sniffing method and the initialize method to fail
because this test case is testing that the ICO image decoder should not
decode random data within it.
2023-01-20 17:05:09 +00:00
Aliaksandr Kalenik
87f0e835eb LibWeb: Improve auto height calculation for tables
Change `compute_auto_height_for_block_level_element` to use max height
(`m_automatic_content_height` produced from TFC) for tables with auto
height which is more correct behaviour than treating them like block
containers.
2023-01-20 18:04:17 +01:00
Aliaksandr Kalenik
addfa4ed58 LibWeb: Include table intrinsic offsets in child boxes position
Table's border and padding should be taken in account while
calculating child boxes x and y offsets.
2023-01-20 18:04:17 +01:00
Liav A
57e19a7e56 LibGfx: Re-structure the whole initialization pattern for image decoders
When trying to figure out the correct implementation, we now have a very
strong distinction on plugins that are well suited for sniffing, and
plugins that need a MIME type to be chosen.

Instead of having multiple calls to non-static virtual sniff methods for
each Image decoding plugin, we have 2 static methods for each
implementation:
1. The sniff method, which in contrast to the old method, gets a
    ReadonlyBytes parameter and ensures we can figure out the result
    with zero heap allocations for most implementations.
2. The create method, which just creates a new instance so we don't
    expose the constructor to everyone anymore.

In addition to that, we have a new virtual method called initialize,
which has a per-implementation initialization pattern to actually ensure
each implementation can construct a decoder object, and then have a
correct context being applied to it for the actual decoding.
2023-01-20 15:13:31 +00:00
Liav A
6e6999ce57 LibGfx: Re-work the abstractions of sending image for decoding over IPC
Originally I simply thought that passing file paths is quite OK, but as
Linus pointed to, it turned out that passing file paths to ensure some
files are able to be decoded is awkward because it does not work with
images being served over HTTP.

Therefore, ideally we should just use the MIME type as an optional
argument  to ensure that we can always fallback to use that in case
sniffing for the correct image type has failed so we can still detect
files like with the TGA format, which has no magic bytes.
2023-01-20 15:13:31 +00:00
Liav A
fedd18eb89 LibCore: Add MIME type string for TGA files 2023-01-20 15:13:31 +00:00
Liav A
e77b110541 LibCore: Return StringView from guess_mime_type_based_on_filename method 2023-01-20 15:13:31 +00:00
Jelle Raaijmakers
2428ba3832 Kernel: Remove dbgln when unregistering an unhandled x86_64 interrupt
A lot of interrupt numbers are initialized with the unhandled interrupt
handler. Whenever a new handler is registered on one of these
interrupts, the old handler is unregistered first. Let's not be verbose
about this since it is perfectly normal.
2023-01-20 15:22:42 +01:00
Jelle Raaijmakers
5f85f1abaa Kernel: Simplify (un)registering interrupt logic
Lose a level of indentation and remove a superfluous `handler_slot`
check.
2023-01-20 15:22:42 +01:00
Jelle Raaijmakers
100c8f9bcf CI: Add GitHub author presence check in commit linter
If GitHub is unable to match a commit's author to a GitHub user, the
`.author` object is set to `null` in the API's response.
2023-01-19 23:48:57 +00:00
Timothy Flynn
be8907e6bb LibJS: Return OptionalNone in fallible functions in the Intl namespace 2023-01-19 23:13:44 +00:00
Timothy Flynn
5349972f41 LibJS: Add a special ThrowCompletionOr constructor for OptionalNone
Currently, if you have a fallible function with an Optional return type
and try to return OptionalNone like this:

    ThrowCompletionOr<Optional<SomeType>> { return OptionalNone {}; }

Then ThrowCompletionOr's m_value (whose type is an Optional<ValueType>)
will be set to empty, rather than containing an empty Optional. This is
due to the ThrowCompletionOr's WrappedValueType constructor.

This patch adds a constructor specifically for OptionalNone. If someone
attempts to construct a ThrowCompletionOr with OptionalNone, but the
ValueType is not an Optional, a compile error like the following will
occur:

    ThrowCompletionOr<String> foo() { return OptionalNone {}; }

    error: no matching constructor for initialization of 'AK::String'

Otherwise, it will fill ThrowCompletionOr's m_value with an empty
Optional.
2023-01-19 23:13:44 +00:00
Timothy Flynn
d901a9989d LibLocale: Remove now-unused [LanguageID,LocaleID]::to_deprecated_string 2023-01-19 20:57:30 +00:00
Timothy Flynn
bb4b6d8ce3 LibJS: Port Intl locale resolution to String 2023-01-19 20:57:30 +00:00
Timothy Flynn
2f1184ccdb LibJS: Do not fully qualify references to CanonicalizeUnicodeLocaleId
This might've been needed at some point to disambiguate between another
function of the same name that is in LibLocale. But now that it takes a
VM parameter, it is for sure clear to the compiler what is being called.
2023-01-19 20:57:30 +00:00
Timothy Flynn
1e6e719592 LibJS: Propagate OOM errors from the PartitionPattern Abstract Operation 2023-01-19 20:57:30 +00:00
Timothy Flynn
bff0e25ebe LibJS: Propagate OOM errors from Intl Abstract Operations
This excludes the PartitionPattern AO as that has a much larger foot-
print and will be handled separately.
2023-01-19 20:57:30 +00:00
Timothy Flynn
ca62aeb6bd LibLocale+LibJS: Port locale parsing and processing to String
In order to prevent this commit from having to refactor almost all of
Intl, the goal here is to update the internal parsing/canonicalization
of locales within LibLocale only. Call sites which are already equiped
to handle String and OOM errors do so, however.
2023-01-19 20:57:30 +00:00
Timothy Flynn
618714e29a LibLocale: Add a method to convert LocaleID to a String 2023-01-19 20:57:30 +00:00
Karol Kosek
f3c6510b83 Ladybird: Accept file drops 2023-01-19 19:22:03 +00:00
Karol Kosek
731fec525e Ladybird: Add URL and 'open in background' parameters to new_tab()
This will avoid loading starting about:blank page in places when we know
exactly what we want to load.

The opening in background part might be useful for future things like
file drops and right-click open in new tab.
2023-01-19 19:22:03 +00:00
Karol Kosek
194ddca24f Ladybird: Move the initial blank page load to BrowserWindow
Takes care of a FIXME :^)
2023-01-19 19:22:03 +00:00
Karol Kosek
5e89773937 Ladybird: Don't prepend 'about:' urls with an http:// scheme 2023-01-19 19:22:03 +00:00
Karol Kosek
4f36893fda Ladybird: Set initial page when NOT connected to WebDriver
This flips an if check condition, making the JS console work in new tabs
again.
2023-01-19 19:22:03 +00:00
Sam Atkins
5ac57f9d41 Meta: Use existing test-sources lists for Lagom instead of globbing
...mostly.

This creates and uses an override for the `serenity_test()` function, so
that Lagom can make use of the existing `Tests/LibFoo/CMakeLists.txt`
files instead of having to GLOB for test source files and manually copy
any data files.

Some GLOBs remain but this is most of them.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2023-01-19 11:50:10 +00:00
Sam Atkins
73350b8492 Tests: Mark TestCommonmark as DISABLED
This has no effect right now, but will allow us to use this same cmake
file from Lagom.
2023-01-19 11:50:10 +00:00
Sam Atkins
7b82f37ba3 Tests: Add missing library dependency for LibTimeZone tests 2023-01-19 11:50:10 +00:00
Sam Atkins
c0c700ed11 Tests: Add missing library dependencies for LibGL tests
These are required for running on Lagom.
2023-01-19 11:50:10 +00:00
Sam Atkins
1910dc8976 Tests: Move test PDF files into Tests/LibPDF
Let's put test files with the tests themselves, instead of a random user
directory. (But still copy them so they appear in the user directory
for convenience.)
2023-01-19 11:50:10 +00:00
Sam Atkins
71af0c296f Meta/Lagom: Make sure that libraries are always linked as PRIVATE 2023-01-19 11:50:10 +00:00
Sam Atkins
a4c8353472 Tests: Correct serenity_test() invocation for LibTTF
Putting the LibTTF tests into the LibGfx directory worked fine before,
but causes issues if we try and call this from Lagom. Also, it's tidier
to put LibTTF tests in a LibTTF directory. :^)
2023-01-19 11:50:10 +00:00
Timothy Flynn
0dce7b72f9 LibCore: Implement FileWatcher for macOS
The macOS FileWatcher depends on macOS dispatch queues, which run on a
different thread than the Core::EventLoop. This implementation handles
filesystem events on its dispatch queue, then forwards the event back to
the main Core::EventLoop for notifying the FileWatcher owner.
2023-01-19 11:29:48 +00:00
Timothy Flynn
8438c509e9 LibCore: Make the FileWatcher test resilient against outside events
The test currently watches /tmp, which the OS can create/modify files
under at any time outside of our control. So just ignore events that we
aren't interested in.

Also test removing an item from the FileWatcher.
2023-01-19 11:29:48 +00:00
Timothy Flynn
0e7a48bd7d LibCore: Allow subclassing FileWatcher
This will be handy for platforms which need to be able to store extra
OS-specific members. For example, macOS needs to store a dispatch queue,
and event stream, etc.
2023-01-19 11:29:48 +00:00
Timothy Flynn
5063e218af AK: Move the AK::FixedPoint formatter to FixedPoint.h
This does not need to be defined in Format.h. This causes FixedPoint.h
to be included everywhere. This is particularly going to be an issue
when trying to include <CoreServices/CoreServices.h> on macOS. The macOS
SDK defines its own FixedPoint structure which will conflict with ours.
2023-01-19 11:29:48 +00:00
Timothy Flynn
027aee2c66 Userland: Add missing Math.h and IntegralMath.h header includes
These are currently being implicitly including by FixedPoint.h by way of
Format.h. The former will soon be removed from the latter, which would
otherwise cause a compile error in these files.
2023-01-19 11:29:48 +00:00
Peter Elliott
b217045f8f AK: Don't write trailing zeros with %g 2023-01-19 12:22:24 +01:00
Peter Elliott
5efcec308a Utilities: Rewrite sort(1) to be more posixy 2023-01-19 12:22:24 +01:00
Peter Elliott
d50de8e4ef Utilities: Replace fgrep with grep --fixed-strings 2023-01-19 12:22:24 +01:00