Commit graph

7981 commits

Author SHA1 Message Date
Jean-Baptiste Boric
6165811081 LibC: Expose sig_sysname array 2021-08-18 10:33:48 +02:00
Jean-Baptiste Boric
77bec6b01d LibC: Move SIG_* definitions for sigprocmask into bits/sighow.h 2021-08-18 10:33:48 +02:00
Sam Atkins
b7aba70a28 LibWeb: Fix check for too many 'normal' values in font declaration
I had the values backwards, oops!
2021-08-18 10:32:32 +02:00
Sam Atkins
b64b97ef88 LibWeb: Implement font-fallback
If the font-family property is set to a StyleValueList, we now iterate
through it, looking up each font in turn until one is found.

StyleResolver no longer needs to handle FontFamily specifically, which
is a nice bonus.

Serenity's current dependence on bitmap fonts leads to some weirdness
here - for example, the `if (!found_font)` path can trigger even if a
generic font family like "sans-serif" is used, since our default
sans-serif font might not be available in the desired size or weight.
The `monospace` variable only exists for that reason.

This is not a complete solution, by a long way! Serenity's font support
is still quite basic, so more work needs to be done there before we can
start implementing the spec's font-matching algorithm. But this is still
an improvement. :^)
2021-08-18 10:32:32 +02:00
Sam Atkins
ceece1c75e LibWeb: Handle numeric font-weights
The code was assuming the font-weight would be a Length, apparently
since NumericStyleValue didn't exist at the time. Now, it's always a
numeric value, so treat it as such.

We also replace the hardcoded numbers with references to the FontWeight
enum.

Also, it was always setting the weight to 900, so that has been fixed.
2021-08-18 10:32:32 +02:00
Sam Atkins
3c541452b7 LibWeb: Calculate font-size in NodeWidthStyle::apply_style()
Previously, this made the same "everything is px" assumption as in
`StyleProperties::load_font()`, so I've replaced it with the calculation
from there.
2021-08-18 10:32:32 +02:00
Sam Atkins
8c39fee34d LibWeb: Handle non-px font sizes
The previous code assumed all font sizes were in px, but now we perform
the conversion. There is an existing bug with em sizes returning 0,
which seems to affect other places too - see
`NodeWithStyle::apply_style()`.

This also implements 'larger', 'smaller' and calc() font-sizes.
2021-08-18 10:32:32 +02:00
Sam Atkins
c990340c5a LibGfx: Mark Typeface::get_font() const, because it is const 2021-08-18 10:32:32 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
Timothy Flynn
325eabc770 LibRegex: Ensure the GoBack operation decrements the code unit index
This was missed in commit 27d555bab0.
2021-08-18 09:47:09 +04:30
Timothy Flynn
a9716ad44e LibRegex: In non-Unicode mode, parse \u{4} as a repetition pattern 2021-08-18 09:47:09 +04:30
Jesse Buhagiar
8ad42e6771 LibGL: Implement glGetIntegerv 2021-08-18 00:35:26 +02:00
Jesse Buhagiar
0b67369830 LibGL: Implenent glGetBooleanv 2021-08-18 00:35:26 +02:00
Linus Groh
90f7e01179 LibJS/Tests: Add Temporal.Calendar.from() tests for more object types 2021-08-17 23:06:05 +01:00
Linus Groh
0cdad283c0 LibJS: Reflect Record wording editorial change in the Temporal spec
See: https://github.com/tc39/proposal-temporal/commit/c8f14d0
2021-08-17 21:59:35 +01:00
Linus Groh
74ee1c9a8c LibJS: Add PlainDateTime fast path to various Calendar.prototype getters
This is a recent editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c3880a3
2021-08-17 21:59:35 +01:00
Linus Groh
d46c531023 LibJS: Add and use newly introduced ToIntegerThrowOnInfinity Temporal AO
See: https://github.com/tc39/proposal-temporal/commit/2ed58f4
2021-08-17 21:59:35 +01:00
Nico Weber
9fd2f97d27 echo: Implement -e flag
This lets you do things like `echo -e '\e[31mhello\e[m'` to print
red text, without having to resort to the tyranny of printf(1).
2021-08-17 19:59:23 +01:00
Linus Groh
1292d80b93 LibJS: Implement Temporal.Calendar.prototype.mergeFields() 2021-08-17 00:26:19 +01:00
Andreas Kling
4226b662cd Kernel+Userland: Remove global futexes
We only ever use private futexes, so it doesn't make sense to carry
around all the complexity required for global (cross-process) futexes.
2021-08-17 01:21:47 +02:00
kleines Filmröllchen
65c8fa9f91 AudioApplet: Persist settings and respect audio server settings
The audio applet uses the user configuration file "AudioApplet.ini" to
persist its settings, currently only whether the audio percentage should
be shown.

Since the audio server now may have specific settings when it starts,
the audio applet respects them by reading these same settings once when
it starts. Therefore, the audio server settings are not immediately
overridden by the audio applet defaults, as was the case before this
change.

A minor change was done to the way that the audio volume is calculated;
doubles are now used.
2021-08-17 01:21:17 +02:00
kleines Filmröllchen
d1b0143ba5 AudioServer: Persist audio settings with a config file
AudioServer loads its settings, currently volume and mute state, from a
user config file "Audio.ini". Additionally, the current settings are
stored every ten seconds, if necessary. This allows for persistent audio
settings in between boots.
2021-08-17 01:21:17 +02:00
davidot
47bc72bcf6 LibJS: Correctly handle Unicode characters in JS source text
Also recognize additional white space characters.
2021-08-16 23:20:04 +01:00
davidot
4d6502de42 LibJS: Disallow standalone super expression 2021-08-16 23:20:04 +01:00
davidot
a8b25d6c36 LibJS: Handle '++' and '--' more correctly within expression 2021-08-16 23:20:04 +01:00
davidot
5f344f7ca3 LibJS: Check that 'let' is followed by declaration before matching it
Since 'let' is a valid variable name (in non-strict mode) let may not be
the start of a declaration but just an identifier.
2021-08-16 23:20:04 +01:00
davidot
179c48e1a4 LibJS: Add optional extra strict checks in parse_binding_pattern 2021-08-16 23:20:04 +01:00
davidot
f1f338edcd LibJS: Tighten default values in formal parameter parsing
Disallow default parameter for rest parameters.
Disallow yield expressions as default values.
2021-08-16 23:20:04 +01:00
davidot
4989e79c45 LibJS: Allow yielding a class 2021-08-16 23:20:04 +01:00
davidot
19582ccad8 LibJS: Treat yield as an identifier in more non-generator contexts
And disallow some cases where we are in a generator context.
2021-08-16 23:20:04 +01:00
davidot
26177b1826 LibJS: Add more duplicated declarations detection
This is a small step in the right direction although the amount of
different checks is becoming unsustainable. In the future we probably
want to have the current_scope handle all declarations.
2021-08-16 23:20:04 +01:00
davidot
085c7df895 LibJS: Be more strict about the lhs of a for in/of loop
This is not entirely correct as really Object- and ArrayExpressions are
not allowed but that requires a bigger refactoring of for statement
parsing.
2021-08-16 23:20:04 +01:00
davidot
106f9e30d7 LibJS: Force the lexer to parse a regex when expecting a statement 2021-08-16 23:20:04 +01:00
davidot
05444103e3 LibJS: Treat arrow expression as function and stop parsing after 2021-08-16 23:20:04 +01:00
davidot
e31b715808 LibJS: Make functions reset break and continue context 2021-08-16 23:20:04 +01:00
davidot
be3b4a68d2 LibJS: Allow class methods named "get", "set" or "static" 2021-08-16 23:20:04 +01:00
davidot
b16c02d6b4 LibJS: Allow labelled functions in certain contexts
Also disallow duplicated labels.
2021-08-16 23:20:04 +01:00
davidot
4cc95ae39d LibJS: Fix that a windows-style new line was not escaped properly 2021-08-16 23:20:04 +01:00
kleines Filmröllchen
ba622cffe4 LibAudio: Fix overflow on 24-bit FLAC LPC data
When computing sample values from a linear predictor, the repeated
multiplication and addition can lead to very large values that may
overflow a 32-bit integer. This was never discovered with 16-bit FLAC
test files used to create and validate the first version of the FLAC
loader. However, 24-bit audio, especially with large LPC shifts, will
regularly exceed and overflow i32. Therefore, we now use 64 bits
temporarily. If the resulting value is too large for 32 bits, something
else has gone wrong :^)

This fixes playback noise on 24-bit FLACs.
2021-08-17 00:16:00 +02:00
kleines Filmröllchen
c974be91ab LibAudio: Rescale integer samples correctly in FLAC loader
The FLAC samples are signed, so we need to rescale them not by their bit
depth, but by half of the bit depth. For example, a 24-bit sample
extends from -2^23 to 2^23-1, and therefore needs to be rescaled by 2^23
to conform to the [-1, 1] double sample range.
2021-08-17 00:16:00 +02:00
kleines Filmröllchen
442aa48a61 LibAudio: Use size_t in loops
This is more idiomatic :^)
2021-08-17 00:16:00 +02:00
Sam Atkins
0fba71a655 LibWeb: Replace is_inherited_property() with generated code
We already include the inheritance for each property in Properties.json,
so made sense to use that instead of a list in StyleResolver.

Added `inherited: true` to a couple of properties to match the previous
code's behavior. One of those had a FIXME which I've moved to the JSON
file, which is hacky, but it works.
2021-08-16 23:26:16 +02:00
Linus Groh
cbe7015c0c LibJS: Add missing spec link to YearMonthFromFields 2021-08-16 20:40:21 +01:00
Linus Groh
795e077eb8 LibJS: Implement Temporal.PlainDate.prototype.toPlainMonthDay() 2021-08-16 20:40:21 +01:00
Linus Groh
31f65b8c50 LibJS: Implement Temporal.Calendar.prototype.monthDayFromFields() 2021-08-16 20:40:21 +01:00
pyunbiwi
68d07320cf Userland: Add as-user execution to the pls utility
Commands may be executed as a specific user by passing the user's UID to
the '-u' flag in pls.
2021-08-16 21:16:30 +02:00
Linus Groh
c1ffc17134 LibJS: Implement Temporal.Calendar.prototype.fields() 2021-08-16 20:02:02 +01:00
Linus Groh
6709c915aa LibJS: Implement Temporal.PlainDate.prototype.toPlainYearMonth() 2021-08-16 14:10:41 +01:00
Linus Groh
ed9d37bd40 LibJS: Implement Temporal.Calendar.prototype.yearMonthFromFields() 2021-08-16 14:10:41 +01:00
Samuel Bowman
7089135a07 LibTLS: Add DHE_RSA AES GCM cipher suites
This adds the following cipher suites:
  * DHE_RSA_WITH_AES_128_GCM_SHA256
  * DHE_RSA_WITH_AES_256_GCM_SHA384
2021-08-16 03:50:53 +04:30
Samuel Bowman
b288016bbc LibTLS: Implement the DHE_RSA key exchange algorithm
This adds two methods, handle_dhe_rsa_server_key_exchange and
build_dhe_rsa_pre_master_secret, to TLSv12 and a struct,
server_diffie_hellman_params, to Context, which are used to implement
the DHE_RSA key exchange algorithm. This grants us the benefits of
forward secrecy and access to sites which support DHE_RSA.

It is worth noting that the signature of the server provided
Diffie-Hellman parameters is not currently validated. This will need to
be addressed to prevent man-in-the-middle attacks.
2021-08-16 03:50:53 +04:30
davidot
020bfc9d93 LibJS: Parse and partially execute import and export statements
We produce the import and export entries as per the spec. However we do
not yet verify that named things that are exported are declared
somewhere.
2021-08-15 23:51:47 +01:00
davidot
7613c22b06 LibJS: Add a mode to parse JS as a module
In a module strict mode should be enabled at the start of parsing and we
allow import and export statements.
2021-08-15 23:51:47 +01:00
Jesse Buhagiar
8157e7740b LibGL: Implement glColorMask 2021-08-15 19:04:10 +01:00
Linus Groh
fa8e9cb683 LibJS/Tests: Skip flaky FinalizationRegistry.prototype.cleanupSome test 2021-08-15 16:44:01 +01:00
Tetsui Ohkubo
2edf4b7f61 LibWeb: Return correct selection_rect when the node is at the end
When the selection state of the node is SelectionState::End, the end
position of the selection within the fragment is not properly
calculated, because it forgets to subtract m_start from index_in_node,
unlike SelectionState::StartAndEnd. This resulted in a wrong selection
shadow being painted when the node is at the end of the selection.

This change resolves #5880.
2021-08-15 15:14:37 +02:00
DoubleNegation
0fdfdbed9f LibWeb: Ensure inline CSS loaded from HTML is ElementInline
This commit changes inline CSS loaded from style attributes of HTML
elements to be loaded as CSS::ElementInlineCSSStyleDeclaration instead
of CSS::CSSStyleDeclaration, fixing a crash when the style of that
element is changed from JavaScript.
2021-08-15 15:11:59 +02:00
Andreas Kling
1b739a72c2 Kernel+Userland: Remove chroot functionality
We are not using this for anything and it's just been sitting there
gathering dust for well over a year, so let's stop carrying all this
complexity around for no good reason.
2021-08-15 12:44:35 +02:00
Timothy Flynn
9509433e25 LibRegex: Implement and use a REPEAT operation for bytecode repetition
Currently, when we need to repeat an instruction N times, we simply add
that instruction N times in a for-loop. This doesn't scale well with
extremely large values of N, and ECMA-262 allows up to N = 2^53 - 1.

Instead, add a new REPEAT bytecode operation to defer this loop from the
parser to the runtime executor. This allows the parser to complete sans
any loops (for this instruction), and allows the executor to bail early
if the repeated bytecode fails.

Note: The templated ByteCode methods are to allow the Posix parsers to
continue using u32 because they are limited to N = 2^20.
2021-08-15 11:43:45 +01:00
Timothy Flynn
a0b72f5ad3 LibRegex: Remove (mostly) unused regex::MatchOutput
This struct holds a counter for the number of executed operations, and
vectors for matches, captures groups, and named capture groups. Each of
the vectors is unused. Remove the struct and just keep a separate
counter for the executed operations.
2021-08-15 11:43:45 +01:00
Timothy Flynn
f1ce998d73 LibRegex+LibJS: Combine named and unnamed capture groups in MatchState
Combining these into one list helps reduce the size of MatchState, and
as a result, reduces the amount of memory consumed during execution of
very large regex matches.

Doing this also allows us to remove a few regex byte code instructions:
ClearNamedCaptureGroup, SaveLeftNamedCaptureGroup, and NamedReference.
Named groups now behave the same as unnamed groups for these operations.
Note that SaveRightNamedCaptureGroup still exists to cache the matched
group name.

This also removes the recursion level from the MatchState, as it can
exist as a local variable in Matcher::execute instead.
2021-08-15 11:43:45 +01:00
Timothy Flynn
fea181bde3 LibRegex: Reduce RegexMatcher's BumpAllocator chunk size
Before the BumpAllocator OOB access issue was understood and fixed, the
chunk size was increased to 8MiB as a workaround in commit:
27d555bab0.

The issue is now resolved by: 0f1425c895.

We can reduce the chunk size to 2MiB, which has the added benefit of
reducing runtime of the RegExp.prototype.exec test.
2021-08-15 11:43:45 +01:00
Timothy Flynn
1a173be29d LibRegex: Disallow unescaped quantifiers in Unicode mode 2021-08-15 11:43:45 +01:00
Timothy Flynn
c3e1f1f687 LibRegex: Use correct source characters for Unicode identity escapes 2021-08-15 11:43:45 +01:00
Timothy Flynn
6a485f612f LibRegex: Implement legacy octal escape parsing closer to the spec
The grammar for the ECMA-262 CharacterEscape is:

  CharacterEscape[U, N] ::
    ControlEscape
    c ControlLetter
    0 [lookahead ∉ DecimalDigit]
    HexEscapeSequence
    RegExpUnicodeEscapeSequence[?U]
    [~U]LegacyOctalEscapeSequence
    IdentityEscape[?U, ?N]

It's important to parse the standalone "\0 [lookahead ∉ DecimalDigit]"
before parsing LegacyOctalEscapeSequence. Otherwise, all standalone "\0"
patterns are parsed as octal, which are disallowed in Unicode mode.

Further, LegacyOctalEscapeSequence should also be parsed while parsing
character classes.
2021-08-15 11:43:45 +01:00
Timothy Flynn
0c8f2f5aca LibRegex: Ensure escaped hexadecimals are exactly 2 digits in length 2021-08-15 11:43:45 +01:00
Timothy Flynn
2e4b6fd1ac LibRegex: Ensure escaped code points are exactly 4 digits in length 2021-08-15 11:43:45 +01:00
Timothy Flynn
e887314472 LibRegex: Fix ECMA-262 parsing of invalid identity escapes
* Only alphabetic (A-Z, a-z) characters may be escaped with \c. The loop
  currently parsing \c includes code points between the upper/lower case
  groups.
* In Unicode mode, all invalid identity escapes should cause a parser
  error, even in browser-extended mode.
* Avoid an infinite loop when parsing the pattern "\c" on its own.
2021-08-15 11:43:45 +01:00
Carlos César Neves Enumo
51b3fb5532 Assistant: Bundle UI updates to avoid flickering
While typing, we get the results from each provider asynchronously.

Previously, we were updating the UI for each result size,
which was causing a lot of flickering.

This fix creates a small timer to bundle the results
and reduce the number of UI updates per input.
2021-08-15 12:24:57 +02:00
Robert Stefanic
e26cfd313e LibJS: Prevent stack overflow in flatten_into_array()
The check for stack space in VM from push_execution_context has been
moved to a method on VM called did_reach_stack_space_limit. This
allows us to check the stack size in other places besides
push_execution_context.

We can now verify that we have enough space on the stack before calling
flatten_into_array to ensure that we don't cause a stack overflow error
when calling the function with a large depth.
2021-08-15 11:24:30 +01:00
Brian Gianforcaro
da51b8f39d LibCore: Move EventLoop to AK::Time 2021-08-15 12:20:38 +02:00
Brian Gianforcaro
188e5f018f ddate: Use DateTime::now() for time 2021-08-15 12:20:38 +02:00
Brian Gianforcaro
3870f4160d date: Use DateTime::now() for time, cleanup duplicate returns 2021-08-15 12:20:38 +02:00
Linus Groh
4520863c0e LibJS/Tests: Add test for PlainMonthDay default reference year 2021-08-15 10:36:36 +01:00
Linus Groh
8f7a9e1e5c LibJS/Tests: Add test for PlainYearMonth default reference day 2021-08-15 10:36:36 +01:00
Linus Groh
1549845389 LibJS: Implement Temporal.PlainMonthDay.prototype.getISOFields() 2021-08-15 10:36:36 +01:00
Linus Groh
7fb05eb878 LibJS: Implement Temporal.PlainMonthDay.prototype.valueOf() 2021-08-15 10:36:36 +01:00
Linus Groh
c2ed3ad66b LibJS: Implement Temporal.PlainMonthDay.prototype.day 2021-08-15 10:36:36 +01:00
Linus Groh
9551aa17d3 LibJS: Implement Temporal.PlainMonthDay.prototype.monthCode 2021-08-15 10:36:36 +01:00
Linus Groh
1382be1707 LibJS: Implement Temporal.PlainMonthDay.prototype.calendar 2021-08-15 10:36:36 +01:00
Linus Groh
37b5a0715e LibJS: Implement Temporal.PlainMonthDay.prototype[@@toStringTag] 2021-08-15 10:36:36 +01:00
Linus Groh
0cf526d0c4 LibJS: Handle PlainMonthDay in the Calendar.prototype getters 2021-08-15 10:36:36 +01:00
Linus Groh
b76bae13fd LibJS: Handle PlainMonthDay in ISO{Year,Month,MonthCode,Day} 2021-08-15 10:36:36 +01:00
Linus Groh
ec00d4729a LibJS: Handle PlainMonthDay in GetTemporalCalendarWithISODefault 2021-08-15 10:36:36 +01:00
Linus Groh
1e54e37228 LibJS: Handle PlainMonthDay in ToTemporalCalendar 2021-08-15 10:36:36 +01:00
Linus Groh
be07e2e91b LibJS: Start implementing Temporal.PlainMonthDay
This commit adds the PlainMonthDay object itself, its constructor and
prototype (currently empty), and the CreateTemporalMonthDay abstract
operations.
2021-08-15 10:36:36 +01:00
Linus Groh
301d622b46 LibJS/Tests: Tweak PlainYearMonth Infinity test values
Since we want to test that +/- Infinity fails as an argument, we should
provide valid arguments for everything else - 0 for month isn't :^)
2021-08-15 10:36:36 +01:00
Nico Weber
f25be94487 LibCore: Make --version print same version as in LibGUI's About dialogs
Making every binary's behavior depend on the current git hash seems a
bit questionable to me, but we should be self-consistent about this.
2021-08-15 01:22:45 +02:00
Nico Weber
faa2c74b49 LibGUI: Simplify AboutDialog::version_string()
No behavior change.
2021-08-15 01:22:45 +02:00
Nico Weber
a45b6dbc07 LibCore: Include math.h instead of defining isnan() in ArgsParser.cpp 2021-08-15 01:22:45 +02:00
Idan Horowitz
04359995a7 LibJS: Exclude FinalizationRegistries with queued cleanup jobs from GC
This is done by just adding them to the list of GC roots, which
prevents the VM from trying to run cleanup job of garbage collected
registries.
2021-08-14 22:32:31 +01:00
Kenneth Myhra
f8d27303d0 LibC: Add stubs for several functions in xattr.h
The following functions are stubbed out:
- getxattr
- lgetxattr
- fgetxattr
- setxattr
- lsetxattr
- fsetxattr
- listxattr
- llistxattr
- flistxattr
2021-08-14 22:32:00 +01:00
Kenneth Myhra
04733ccb56 LibC: Add stub for res_query 2021-08-14 22:32:00 +01:00
Kenneth Myhra
8abfcb976d LibC: Add stub for fnmatch and a set of defined values
This adds a stub for fnmatch and the following defined values:
- FNM_PATHNAME
- FNM_NOESCAPE
- FNM_PERIOD
- FNM_FILE_NAME
- FNM_LEADING_DIR
- FNM_CASEFOLD
- FNM_EXTMATCH
2021-08-14 22:32:00 +01:00
Kenneth Myhra
8d19d8861a LibC: Add FIONREAD to ioctl.h 2021-08-14 22:32:00 +01:00
Kenneth Myhra
78eba1271f LibC: Add function fdopendir
This adds the function fdopendir and refactors opendir so that opendir
just opens a file descriptor and passes the file descriptor onto
fdopendir.
2021-08-14 22:32:00 +01:00
Nico Weber
1f71d7bf22 LibCore: Add --version flag to ArgsParser
`--version` always prints "git" for now.

The motivation is that the neofetch port calls `Shell --version` and
adds the output to its output. And if `Shell --version` prints a long
error message about it not knowing the flag, neofetch's output looks a
bit ugly. Per Discord discussion, just add the flag to ArgsParser
instead of only to Shell.
2021-08-14 22:46:34 +04:30
Andreas Kling
286a7ecd92 LibJS: Call base class visit_edges() in various Temporal objects
When overriding visit_edges() in a JS::Object subclass, we must make
sure to call the base class visit_edges(), or the object's Shape (and
any properties) will not get marked.
2021-08-14 20:12:22 +02:00
Andreas Kling
e1273a8ff7 Kernel+LibC: Share definitions for sys/statvfs.h 2021-08-14 19:58:11 +02:00