Commit graph

7659 commits

Author SHA1 Message Date
Andrew Kaster
d809637023 Userland: Resolve tautological-constant-out-of-range-compare warnings
Stop comparing platform-specific sized integer types to max() values of
other interger types. Enable the warning everywhere.
2022-01-04 07:51:31 +00:00
Andrew Kaster
a103a85ae6 Userland: Locally suppress -Wc99-designator and re-enable globally
There's only two places where we're using the C99 feature of array
designated initalizers. This feature seemingly wasn't included with
C++20 designated initalizers for classes and structs. The only two
places we were using this feature are suitably old and isolated that
it makes sense to just suppress the warning at the usage sites while
discouraging future array designated intializers in new code.
2022-01-04 07:51:31 +00:00
Andrew Kaster
c8cfd6661a Userland: Resolve -Woverloaded-virtual in LibGUI and SoundPlayer
Enable the warning project-wide. It catches when a non-virtual method
creates an overload set with a virtual method. This might cause
surprising overload resolution depending on how the method is invoked.
2022-01-04 07:51:31 +00:00
Andrew Kaster
170a7e263c Userland: Fail Core::find_executable_in_path on empty inputs
Before this patch, `which ""` or `type ""` would say that the empty
string is `/usr/local/bin/`.

Convert callers to consistently call is_empty() on the returned string
while we're at it, to support eventually removing the is_null() String
state in the future.
2022-01-04 07:38:42 +00:00
mjz19910
91f5fc796b LibCore: Add an ErrorOr wrapper for uname 2022-01-04 07:33:23 +00:00
Jesse Buhagiar
eefad5ccd7 LibC: Include strings.h in string.h
Certain C Libraries have (unfortunately) included strings.h as a
part of string.h, which violates the POSIX spec for that specific
header. Some applications rely on this being the case, so let's
include it in our string.h
2022-01-04 07:27:04 +00:00
Linus Groh
143465b23a LibJS: Propagate errors from TypedArray for_each_item{,_from_last} calls
Another mistake uncovered by moving away from manual exception checks
and relying on correct completion types instead :^)
2022-01-03 22:11:35 +01:00
Linus Groh
044c70fb46 LibJS: Add a ton of spec comments to AST.cpp 2022-01-03 21:50:50 +01:00
Linus Groh
da856d7742 LibJS: Update AST to use completions :^)
This is another major milestone on our journey towards removing global
VM exception state :^)
Does pretty much exactly what it says on the tin: updating
ASTNode::execute() to return a Completion instead of a plain value. This
will *also* allow us to eventually remove the non-standard unwinding
mechanism and purely rely on the various completion types.
2022-01-03 21:50:50 +01:00
Linus Groh
95acb1ce88 LibJS: Don't assume non-empty [[Value]] in Completion TRY() helpers 2022-01-03 21:50:50 +01:00
Linus Groh
032e6a2d28 LibJS: Remove redundant abrupt completion check
A throw completion is always an abrupt completion, no need to check :^)
2022-01-03 21:50:50 +01:00
Linus Groh
85f0fc2b83 LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}()
and having to check those first, and then making another Optional from
the unwrapped value:

    completion.has_value() ? completion.value() : Optional<Value> {}
    //                       ^^^^^^^^^^^^^^^^^^
    //         Implicit creation of non-empty Optional<Value>

This way we need to unwrap the optional ourselves, but can easily pass
it to something else as well.

This is in anticipation of the AST using completions :^)
2022-01-03 21:50:50 +01:00
martinfalisse
452150c632 LibGUI: Bring entire cell into view after auto scroll into view
On account of row and column headers, when a user navigates to
a cell (for example in the spreadsheet application) that is
outside of the view, the cell is not properly aligned and so
is partially cut-off. This fix takes into account the row and
column headers when calculating the Rect to pass to the
scroll_into_view function.
2022-01-03 15:49:07 +01:00
Timothy Flynn
022b416570 LibJS: Implement the Extend TimeZoneName Option Proposal
This is a stage 4 proposal that was recently merged into the main
ECMA-402 spec. See:

https://github.com/tc39/ecma402/commit/1ba5ee7
2022-01-03 15:11:59 +01:00
Timothy Flynn
126a3fe180 LibUnicode: Add minimal support for generic & offset-based time zones
ECMA-402 now supports short-offset, long-offset, short-generic, and
long-generic time zone name formatting. For example, in the en-US locale
the America/Eastern time zone would be formatted as:

    short-offset: GMT-5
    long-offset: GMT-05:00
    short-generic: ET
    long-generic: Eastern Time

We currently only support the UTC time zone, however. Therefore, this
very minimal implementation does not consider GMT offset or generic
display names. Instead, the CLDR defines specific strings for UTC.
2022-01-03 15:11:59 +01:00
kleines Filmröllchen
b48badc3b6 LibAudio: Remove frame-wise copys from FlacLoader
Previously, FlacLoader would read the data for each frame into a
separate vector, which are then combined via extend() in the end. This
incurs an avoidable copy per frame. By having the next_frame() function
write into a given Span, there's only one vector allocated per call to
get_more_samples().

This increases performance by at least 100% realtime, as measured by
abench, from about 1200%-1300% to (usually) 1400% on complex test files.
2022-01-02 22:18:37 +01:00
kleines Filmröllchen
30130904f5 LibAudio: Alow creating a Buffer from a FixedArray
A FixedArray, due to its non-allocation guarantee, is great for audio
programming, so it's natural to have it interface with Buffer.
2022-01-02 22:18:37 +01:00
Linus Groh
dc60774ac4 LibCore: Mark 'Read options' parameter [[maybe_unused]] in Account.cpp
This broke the macOS clang CI build.
2022-01-02 22:02:16 +01:00
Linus Groh
cbb7329d69 LibJS: Fix two typos in comments in AST.cpp 2022-01-02 21:44:19 +01:00
Linus Groh
7565b1fda8 LibJS: Let Completion::update_empty() take an Optional<Value>
It also needs to be able to take what the spec calls 'empty', which is
an Optional<Value> in this case (*not* an empty JS::Value). The common
use case is updating a completion with another completion, that may also
have an empty [[Value]] slot.
2022-01-02 20:48:38 +01:00
Linus Groh
13777d4886 LibJS: Move provided Optional<Value> argument in normal_completion() 2022-01-02 20:47:14 +01:00
Timothy Flynn
f16f3c4677 LibJS: Update ToRawPrecision / ToRawFixed AO spec comments
This is a normative change in the Intl spec:
https://github.com/tc39/ecma402/commit/f0f66cf

There are two main changes here:
1. Converting BigInt/Number objects to mathematical values.
2. A change in how ToRawPrecision computes its exponent and significant
   digits.

For (1), we do not yet support BigInt number formatting, thus already
have coerced Number objects to a double. When BigInt is supported, the
number passed into these methods will likely still be a Value, thus can
be coereced then.

For (2), our implementation already returns the expected edge-case
results pointed out on the spec PR.
2022-01-02 20:07:03 +01:00
Timothy Flynn
a3149c11e5 LibJS: Explicitly handle postive/negative infinity in Intl.NumberFormat
This is a normative change in the Intl spec:
https://github.com/tc39/ecma402/commit/f0f66cf

Our implementation is unaffected by this change. LibUnicode pre-computes
positive, negative, and signless format patterns, so we already format
negative infinity correctly. Also, the CLDR does not contain specific
locale-dependent strings for negative infinity anyways.
2022-01-02 20:07:03 +01:00
Andreas Kling
950784b5a6 LibGUI: Increase vertical padding on GUI::IconView item labels by 2px
Let's give the text a tiny bit of breathing room.
2022-01-02 18:08:02 +01:00
Andreas Kling
63e8cf8d59 LibCore: Enforce correct mode when creating new passwd and shadow files
- Use umask() to prevent the parent process from tampering with the mode
  bits of replacement passwd and shadow files.
- Use fchmod() to set new shadow files to mode 0600.
2022-01-02 18:08:02 +01:00
Andreas Kling
edd8f19a1b LibCore: Add Core::UmaskScope to set and unset a temporary umask 2022-01-02 18:08:02 +01:00
Andreas Kling
c6ce606e47 LibCore+id: Make more use of Core::System wrappers in Core::Account 2022-01-02 18:08:02 +01:00
Andreas Kling
431bd069f0 LibCore: Add Core::System wrappers for getspent() and getspnam() 2022-01-02 18:08:02 +01:00
Andreas Kling
7008f74214 LibCore: Add syscall wrappers for getpwuid() and getgrgid() 2022-01-02 18:08:02 +01:00
Andreas Kling
1e4117f1e1 LibCore: Add syscall wrapper for getgroups()
This wrapper does all the grunt work of figuring out how many extra GIDs
there are, and then returning them nicely wrapped in a Vector<gid_t>.
2022-01-02 18:08:02 +01:00
Andreas Kling
f95fc91e4f LibCore: Reset errno before using LibC pwd functions
We should not expect LibC functions to clear `errno` on success,
so if we want to use it for error checking after a call, we need
to clear it before the call.
2022-01-02 18:08:02 +01:00
Sam Atkins
416033a660 LibWeb: Support range syntax for media queries
This means you can now do queries like:

```css
@media (400px <= width < 800px) { }
```

Chromium and Firefox which I tested with both don't support this yet, so
that's cool. :^)
2022-01-02 15:43:51 +01:00
Sam Atkins
c3bf9e5b79 LibWeb: Rewrite media-query parsing to match spec grammar
Past me decided that the grammar was overly verbose and I could do it
better myself. Which seemed fine until the spec changed and I didn't
know how to integrate the changes. Lesson learned! :^)

Rather than have a function for every single part of the grammar, I have
written some as lambdas, and combned `<media-condition>` and
`<media-condition-without-or>` into one function. But otherwise it's
close to the spec, with comments listing the part of the grammar being
parsed, so hopefully it will be easier to make future adjustments!

This does not add any new functionality.
2022-01-02 15:43:51 +01:00
Sam Atkins
b6fe7cc324 LibWeb: Make MediaCondition a top-level type and add factory methods 2022-01-02 15:43:51 +01:00
Sam Atkins
ae4f0000c8 LibWeb: Make MediaFeature a top-level class and add factory methods
Web::CSS::MediaQuery::MediaFeature::Type was getting a bit ridiculous!
Also, this moves the detection of "min-" and "max-" media-features into
the MediaFeature itself, since this is an implementation detail, not
part of the spec.
2022-01-02 15:43:51 +01:00
Sam Atkins
d470e7e817 LibWeb: Remove media-query-related identifiers from identifiers.json
Having these in here was a hack to support the other hack of making
media-queries use StyleValues. Now they don't do that, so we can remove
these again and keep things hygienic.
2022-01-02 15:43:51 +01:00
Sam Atkins
6299d68e45 LibWeb: Introduce MediaFeatureValue type for use in media queries
Previously, we were using StyleValues for this, which was a bit of a
hack and was brittle, breaking when I modified how custom properties
were parsed. This is better and also lets us limit the kinds of value
that can be used here, to match the spec.
2022-01-02 15:43:51 +01:00
Sam Atkins
0a8e289f37 LibWeb: Update <general-enclosed> definition to match spec change
See https://github.com/w3c/csswg-drafts/pull/6799
2022-01-02 15:43:51 +01:00
sin-ack
d8ee3839e4 LibM: Count fractions when exponent < -1 with mantissa == 0
Without this change, floor(-0.125) returned 0.
This is because the number has a fraction part even if mantissa is zero
while the unbiased exponent is negative.

The names of some variables were also made clearer.

Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-01-02 12:44:31 +03:30
Jesse Buhagiar
2de7f2021d LibC: Support X modifier for scanf
This was currently crashing Half-Life because it was a considered an
"Unknown" specifier. We can use the same case statement as the regular
hex format conversion (lower case 'x'), as the backend
to convert the number already supports upper/lower case input, hence
we get it for free :^)
2022-01-02 08:10:08 +02:00
Filiph Sandström
35dac843b4 Theming: Add alignment section
This commit removes the IsTitleCenter property and replaces it with
the TitleAlignment property that supports "Left", "Right" & "Center".
2022-01-01 22:51:53 +01:00
Filiph Sandström
c4b78bee45 LibGfx: Remove VERIFY in draw_rect_with_thickness
draw_line with thickness already supports scaling so that verify isn't
needed anymore. This fixes a scaling chrash introduced in 8a1d77f.
2022-01-01 20:30:09 +00:00
Xavier Defrang
8b95423b50 LibCore: Add FilePermissionsMask
This class parses UNIX file permissions definitions in numeric (octal)
or symbolic (ugoa+rwx) format and can apply them on a given file mode.
2022-01-01 17:33:43 +00:00
Michel Hermier
0f729cebf4 LibVideo/VP9: Do not null guard calls to free 2022-01-01 17:30:25 +00:00
Ben Wiederhake
3013e74d3a LibWeb: Avoid unnecessary copies in StyleInvalidator 2022-01-01 15:40:39 +01:00
Ben Wiederhake
0c365fdfd3 LibJS: Avoid unnecessary copies in MergeBlocks codegen pass 2022-01-01 15:40:39 +01:00
Ben Wiederhake
a1aea5b9e0 LibJS: Avoid unnecessary copies in PlaceBlocks codegen pass 2022-01-01 15:40:39 +01:00
Ben Wiederhake
182a85c895 LibSQL: Avoid unnecessary copies in Heap 2022-01-01 15:40:39 +01:00
Ben Wiederhake
5c4b2e8447 LibLine: Avoid unnecessary copies in Editor 2022-01-01 15:40:39 +01:00
Ben Wiederhake
13acf603d8 LibGUI: Avoid unnecessary copies in FileIconProvider 2022-01-01 15:40:39 +01:00