Commit graph

27651 commits

Author SHA1 Message Date
Brian Gianforcaro c192c303d2 AK: Use default constructor/destructor instead of declaring an empty one
Default implementations allow for more optimizations.
See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-16 17:17:13 +02:00
Marcus Nilsson 9fe43041f5 PixelPaint: Tweak layer/tool properties widget heights
There's no use for these two to be larger than necessary when
resizing the window.
2021-09-16 16:54:34 +02:00
Marcus Nilsson b76fe6357a PixelPaint: Don't select the same layer twice in LayerListWidget
Without this check we would do an unnecessary partial second round
trip because of the call chain:
LayerListWidget::set_selected_layer() ->
LayerListWidget::on_layer_select() ->
ImageEditor::set_active_layer() ->
ImageEditor::on_active_layer_change() ->
LayerListWidget::set_selected_layer()
2021-09-16 16:54:34 +02:00
Marcus Nilsson eaa99968fb PixelPaint: Don't update ImageEditor in set_active_layer()
Setting the active layer does not cause anything to render differently.
Thus no update is needed and the call to layers_did_change() is
unnecessary.
2021-09-16 16:54:34 +02:00
Karol Kosek 8f36429cb5 ThemeEditor: Save theme metrics and paths to file
Prior this change, custom title metrics seen in the Basalt theme
and custom icon paths in Redmond themes were dropped when saving a file.

Now any entry, even empty, will be saved.  This may end up with slightly
larger files, but on other hand, users will be able to see every option
in a text editor, without a need to look at the code/docs.
2021-09-16 16:52:55 +02:00
Karol Kosek d1e1096bc0 LibGfx: Enumerate metric theme roles
This change does practically nothing except that you no longer have to
put new roles there, as they are now automatically read from the enum
list.
2021-09-16 16:52:55 +02:00
Karol Kosek 6f4333fca7 LibGfx: Add support for enumerating by Metric and Path roles
For Theme Editor.
2021-09-16 16:52:55 +02:00
sin-ack 220b7dd779 Kernel: Weakly hold on to the file in LocalSocket
Because we were holding a strong ref to the OpenFileDescription in
LocalSocket and a strong ref to the LocalSocket in Inode, we were
creating a reference cycle in the event of the socket being cleaned up
after the file description did (i.e. unlinking the file before closing
the socket), because the file description never got destructed.
2021-09-16 16:50:36 +02:00
sin-ack 0ccef94a49 Kernel: Drop the receive buffer when socket enters the TimeWait state
The TimeWait state is intended to prevent another socket from taking the
address tuple in case any packets are still in transit after the final
close. Since this state never delivers packets to userspace, it doesn't
make sense to keep the receive buffer around.
2021-09-16 16:50:23 +02:00
Ali Mohammad Pur f4d3c54c12 LibTLS: Close the underlying socket on EOF
This is 23febbed41 but without the bug
that makes the CI hang :^)
2021-09-16 16:42:51 +02:00
Tim Schumacher dda216c334 Ports: Add a gawk port 2021-09-16 16:42:40 +02:00
Tim Schumacher a1617faf44 LibC: Implement mbsinit and mbrtowc 2021-09-16 16:42:40 +02:00
Tim Schumacher 405f3d0aa3 LibC: Implement btowc() 2021-09-16 16:42:40 +02:00
Tim Schumacher e4fa9c917e LibC: Stub out a bunch of wchar functions 2021-09-16 16:42:40 +02:00
Tim Schumacher 230df61aef LibC: Define ptrdiff_t limits 2021-09-16 16:42:40 +02:00
Tim Schumacher 328818af97 LibC: Provide a dummy mbstate_t in wchar.h
POSIX just says that mbstate_t should be an "object type other than an
array type" that can hold the conversion state for converting between
(multi-byte) characters and wide characters.

Since no other information regarding the contents is given, this
apparently means that we should add whatever we need once we start
implementing that conversion.
2021-09-16 16:42:40 +02:00
Tim Schumacher 8f9af4a582 LibC: Implement CODESET for langinfo 2021-09-16 16:42:40 +02:00
Idan Horowitz 5ea1810ada LibJS: Convert PlainMonthDay AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz 229a5ce149 LibJS: Convert PlainTime AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz c57a78423d LibJS: Convert PlainYearMonth AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz cc00a726a8 LibJS: Convert TimeZone AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz 830d484d78 LibJS: Change GetISOPartsFromEpoch's return type to ISODateTime
This AO can't throw so its optional is never empty.
2021-09-16 13:53:37 +01:00
Idan Horowitz 1822b2938e LibJS: Convert ZonedDateTime AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz 5a4c90fcb1 LibJS: Convert ordinary_create_from_constructor<T> to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Brian Gianforcaro b61eff8730 Revert "LibTLS: Close the underlying socket on EOF"
This reverts commit 23febbed41.

It breaks the TestTLSHandshake test used in CI, it causes it
to hang, and all CI jobs have been hanging.
2021-09-16 09:11:32 +00:00
Brian Gianforcaro 9f50e288f7 LibJS: Fix Clang Toolchain CI build
Clang was failing because because it rightfully saw we were attempting
to call a deleted constructor of `MarkedValueList`. If you explicitly
called move(list) then GCC would complain that the move was unnecessary.

For what ever reason both tool chains accept when we construct the
ThrowCompletionOr explicitly that we move the list into and return that.
2021-09-16 10:05:45 +01:00
Andreas Kling d69e4f9ca7 LibWeb: Don't dump full data URLs in ResourceLoader logging
Some pages use *really* large data URLs. :^)
2021-09-16 01:39:47 +02:00
Andreas Kling 58b84f953c LibWeb: Add fast_is<HTMLTemplateElement>()
This was showing up as hot in profiles, as the HTML parser calls it
quite a lot.
2021-09-16 01:39:47 +02:00
Andreas Kling cb895edad4 LibWeb: Move Attribute into the DOM namespace 2021-09-16 01:39:47 +02:00
Linus Groh 2d4650714f LibJS: Use ThrowCompletionOr in get_prototype_from_constructor()
Also add spec step comments to it while we're here.
2021-09-15 23:46:53 +01:00
Linus Groh bc1b8f9cc8 LibJS: Use ThrowCompletionOr in get_function_realm() 2021-09-15 23:46:53 +01:00
Linus Groh 3d43eb0774 LibJS: Use ThrowCompletionOr in species_constructor()
Also add spec step comments to it as well as a missing exception check
while we're here.
2021-09-15 23:46:53 +01:00
Linus Groh c4c40f4cf3 LibJS: Use ThrowCompletionOr in create_list_from_array_like()
Also add spec step comments to it while we're here.
2021-09-15 23:46:53 +01:00
Linus Groh 568296d0cc LibJS: Use ThrowCompletionOr in require_object_coercible() 2021-09-15 23:46:53 +01:00
Linus Groh 33679a8445 LibJS: Add a JS::Completion class and JS::ThrowCompletionOr<T> template
We decided that we want to move away from throwing exceptions in AOs
and regular functions implicitly and then returning some
default-constructed value (usually an empty JS::Value) - this requires
remembering to check for an exception at the call site, which is
error-prone. It's also awkward for return values that cannot be
default-constructed, e.g. MarkedValueList.
Instead, the thrown value should be part of the function return value.

The solution to this is moving closer to the spec and using something
they call "completion records":
https://tc39.es/ecma262/#sec-completion-record-specification-type

This has various advantages:

- It becomes crystal clear whether some AO can fail or not, and errors
  need to be handled and values unwrapped explicitly (for that reason
  compatibility with the TRY() macro is already built-in, and a similar
  TRY_OR_DISCARD() macro has been added specifically for use in LibJS,
  while the majority of functions doesn't return ThrowCompletionOr yet)
- We no longer need to mix "valid" and "invalid" values of various types
  for the success and exception outcomes (e.g. null/non-null AK::String,
  empty/non-empty JS::Value)
- Subsequently it's no longer possible to accidentally use an exception
  outcome return value as a success outcome return value (e.g. any AO
  that returns a numeric type would return 0 even after throwing an
  exception, at least before we started making use of Optional for that)
- Eventually the VM will no longer need to store an exception, and
  temporarily clearing an exception (e.g. to call a function) becomes
  obsolete - instead, completions will simply propagate up to the caller
  outside of LibJS, which then can deal with it in any way
- Similar to throw we'll be able to implement the functionality of
  break, continue, and return using completions, which will lead to
  easier to understand code and fewer workarounds - the current
  unwinding mechanism is not even remotely similar to the spec's
  approach

The spec's NormalCompletion and ThrowCompletion AOs have been
implemented as simple wrappers around the JS::Completion constructor.
UpdateEmpty has been implemented as a JS::Completion method.

There's also a new VM::throw_completion<T>() helper, which basically
works like VM::throw_exception<T>() - it creates a T object (usually a
JS::Error), and returns it wrapped in a JS::Completion of Type::Throw.

Two temporary usage patterns have emerged:

1. Callee already returns ThrowCompletionOr, but caller doesn't:

    auto foo = TRY_OR_DISCARD(bar());

2. Caller already returns ThrowCompletionOr, but callee doesn't:

    auto foo = bar();
    if (auto* exception = vm.exception())
        return throw_completion(exception->value());

Eventually all error handling and unwrapping can be done with just TRY()
or possibly even operator? in the future :^)

Co-authored-by: Andreas Kling <kling@serenityos.org>
2021-09-15 23:46:53 +01:00
Linus Groh cbdd069279 AK: Rename the local variable in the TRY() macro to avoid name clashes
"result" is a tad bit too generic to provide a clash-free experience -
we found instances in LibJS where this breaks already. Essentially this
doesn't work:

    auto foo = TRY(bar(result));

Because it expands to the following within the TRY() scope:

    {
        auto result = bar(result);
        ...
    }

And that of course fails:

    error: use of ‘result’ before deduction of ‘auto’

The simple solution here is to use a name that is much less likely to
clash with anything used in the expression ("_temporary_result"). :^)
2021-09-15 23:46:53 +01:00
Ali Mohammad Pur e5fde795e0 LibTLS: Increase the maximum socket read size to 4MiB
There's no reason to limit ourselves to 4KiB, this socket is not
blocking anyway.
2021-09-15 22:29:47 +02:00
Ali Mohammad Pur 23febbed41 LibTLS: Close the underlying socket on EOF
There's no reason to keep waiting when there's nothing else to come.
This makes RequestServer not spin on Core::Socket::read() (in some
scenarios).
2021-09-15 22:29:47 +02:00
Tobias Christiansen ef22a1b2dc LibWeb: Avoid setting definite {width,height} when "auto" is specified
Auto is not specified at all.
2021-09-15 22:28:28 +02:00
Tobias Christiansen 6c15eeb367 LibWeb: Flexbox: Somewhat suppport "align-items"
There probably are a lot of edge cases missing but this moves us forward
at least a bit.
2021-09-15 22:28:28 +02:00
Tobias Christiansen 67bf553fad LibWeb: Flexbox: Make step 11 of the layout algorithm more align aware 2021-09-15 22:28:28 +02:00
Tobias Christiansen 307f90b675 LibWeb: Add proper parsing of the AlignItems property
This teaches all the relevant places about 'align-items'.
2021-09-15 22:28:28 +02:00
Ben Wiederhake 51b42e0463 Meta: Make QtCreator aware of all CMake files 2021-09-15 20:21:19 +00:00
Andreas Kling b6efd66d56 Kernel: Use move semantics in sys$sendfd()
Avoid an unnecessary NonnullRefPtr<OpenFileDescription> copy.
2021-09-15 21:09:47 +02:00
Andreas Kling 422d725c79 LibWeb: Support "c" and "C" curves in SVG <path> data
These instructions now generate cubic Bézier curves.
2021-09-15 20:57:43 +02:00
Andreas Kling 09d13e437b LibGfx: Add Path::cubic_bezier_curve_to()
This is pretty unsophisticated as it will simply add a fixed number of
of line segments approximating the curve. Still better than nothing.
2021-09-15 20:57:43 +02:00
Andreas Kling 139fdcc2cf LibGfx: Add some interpolation helpers for Gfx::Point<T>
- linear_interpolate
- quadratic_interpolate
- cubic_interpolate
2021-09-15 20:57:43 +02:00
Andreas Kling c4f2976d83 LibWeb: Remove unused SVGSVGElement::m_bitmap 2021-09-15 20:57:43 +02:00
Linus Groh 1a7828a9f3 LibJS: Return default-constructed values instead of the INVALID constant
This is much more common across the whole codebase and even these two
files. The same is used to return an empty JS::Value in an exception
check, for example.
2021-09-15 18:41:33 +01:00
Linus Groh 657d17ace3 LibJS: Remove two unused includes from AbstractOperations.cpp 2021-09-15 18:36:06 +01:00