Commit graph

24534 commits

Author SHA1 Message Date
Lenny Maiorani
2cf4781d14 AK: Reimplement all_of in terms of find_if
Problem:
- Now that a generic free-function form of `find_if` is implemented
  the code in `all_of` is redundant.

Solution:
- Follow the "don't repeat yourself" mantra and make the code DRY by
  implementing `all_of` in terms of `find_if`.
- One tricky part is that since captures are not permitted in
  `constexpr` lambdas, the lambda created to negate the predicate
  needs to be created by a function which does not capture and takes
  the predicate at run-time instead. This allows `all_of` to continue
  to work in a `constexpr` context.
2021-07-24 13:11:13 +04:30
Gamerappa
497a9afaaf Hearts: Redesign the icon
This does not fix the issue where there's no indication for when
hearts are broken. But since the original icon for Hearts was
a placeholder. This should be better. :^)

Fixes #7373
2021-07-24 07:30:47 +02:00
Liav A
3645861f31 Kernel: Put a note about the unconditional unblanking of bochs-display
This removes the FIXME note and explains why it's not so bad to do this.
2021-07-24 01:42:10 +02:00
Gunnar Beutner
3c1797c42d Solitaire: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Gunnar Beutner
58d1e46628 Spider: Use AK::get_random_uniform() instead of rand()/srand()
This also has the added benefit that after a restart we don't get the
same random numbers all the time because we forgot to initialize the
RNG with srand().
2021-07-24 01:40:51 +02:00
Gunnar Beutner
807b79d89e Spider: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
d76b42599e Hearts: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
5201c17d9b Hearts: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Phoenix
1621311d73 GML Playground: Add Vim emulation 2021-07-24 01:13:42 +02:00
Tobias Christiansen
78757845bb Base: Add a test page for CSS 'calc()' values 2021-07-24 03:02:07 +04:30
Tobias Christiansen
9c65c10245 LibWeb: Add calc() resolution to CSS::Length
This patch finally adds the actual calculation that goes into calc()
expressions. When the resolution of a Length that is a calculated value
the parsed CalculatedStyleValue gets traversed and appropriate values
get calculated.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
20667dfff5 LibWeb: Plumb calculated StyleValues into CSS::Length
This is a bit hackish, but this way the existance of the calc()
becomes transparent to the user who just wants a Length and doesn't
care where it came from.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
328afa32c6 LibWeb: Add the parsing to the calc() handling
This patch adds the parsing of previously tokenized calc() expressions
into the CSS-Parser. The tokens are processed into a complete
CalculatedStyleValue.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
e3b68039bf LibWeb: Move type derivation of CSS::Length into seperate function
That way this can (and will) be used in other places.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
7a4c8e0b76 LibWeb: Add tokenization of calc expression
Here the first step in understanding a calc() expression is taken:
Finding the start of an expression  and tokenizong it.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
f8bf6ae911 LibWeb: Add CalculatedStyleValue to the CSS StyleValues
This adds the CalculatedStyleValue and all the structs needed to work
with the calc() expressions.
2021-07-24 03:02:07 +04:30
Tobias Christiansen
14640692b7 LibWeb: Use Length::resolved() in FlexFormattingContext
It brew it's own tea resolving undefined and percentages. Let's use the
API already in place rather to keep it flexible.
2021-07-24 03:02:07 +04:30
Timothy Flynn
8c2b8fd001 LibJS: Remove UTF-8 RegExpExec and AdvanceStringIndex overrides
All interested parties are now UTF-16 capable, so these are unused.
2021-07-23 23:06:57 +01:00
Timothy Flynn
5a8f870594 LibJS: Implement RegExp.prototype [ @@replace ] with UTF-16 code units
This also converts the GetSubstitution abstract operation take its input
strings as UTF-16 now that all callers are UTF-16 capable. This means
String.prototype.replace (and replaceAll) no longer needs UTF-8 and
UTF-16 copies of these strings.
2021-07-23 23:06:57 +01:00
Timothy Flynn
ee7b04f7bb LibJS: Implement RegExp.prototype [ @@split ] with UTF-16 code units 2021-07-23 23:06:57 +01:00
Timothy Flynn
66c31a0c07 LibJS: Implement RegExp.prototype [ @@search ] with UTF-16 code units 2021-07-23 23:06:57 +01:00
Timothy Flynn
2c023157e9 LibJS: Implement RegExp.prototype [ @@match ] with UTF-16 code units 2021-07-23 23:06:57 +01:00
Timothy Flynn
b1ea9c20b0 LibJS: Implement RegExp.prototype.{exec,test} with UTF-16 code units
This converts RegExpExec to perform matching with UTF-16 strings. As a
very temporary stop-gap, this adds overloads to RegExpExec and friends
for both UTF-8 and UTF-16 strings. This is only needed until the rest
of RegExp.prototype is UTF-16 capable.

This also addresses a FIXME regarding code point index correction in
RegExpExec when the Unicode flag is set.
2021-07-23 23:06:57 +01:00
Timothy Flynn
a0c19deb80 LibJS: Implement RegExpCreate/RegExpInitialize closer to the spec
RegExpInitialize specifies how the pattern string should be created
before passing it to [[RegExpMatcher]]. Rather than passing it as-is,
the string should be converted to code points and back to a "List" (if
the Unicode flag is present), or as a "List" of UTF-16 code units.
Further. the spec requires that we keep both the original pattern string
and this parsed string in the RegExp object.

The caveat is that the LibRegex parser further requires any multi-byte
code units to be escaped (as "\unnnn"). Otherwise, the code unit is
recognized as individual UTF-8 bytes.
2021-07-23 23:06:57 +01:00
Timothy Flynn
345ef6abba LibRegex: Support ECMA-262 Unicode escapes of the form "\u{code_point}"
When the Unicode flag is set, regular expressions may escape code points
by surrounding the hexadecimal code point with curly braces, e.g. \u{41}
is the character "A".

When the Unicode flag is not set, this should be considered a repetition
symbol - \u{41} is the character "u" repeated 41 times. This is left as
a TODO for now.
2021-07-23 23:06:57 +01:00
Timothy Flynn
0e6375558d AK+LibRegex: Partially implement case insensitive UTF-16 comparison
This will work for ASCII code points. Unicode case folding will be
needed for non-ASCII.
2021-07-23 23:06:57 +01:00
Timothy Flynn
47f6bb38a1 LibRegex: Support UTF-16 RegexStringView and improve Unicode matching
When the Unicode option is not set, regular expressions should match
based on code units; when it is set, they should match based on code
points. To do so, the regex parser must combine surrogate pairs when
the Unicode option is set. Further, RegexStringView needs to know if
the flag is set in order to return code point vs. code unit based
string lengths and substrings.
2021-07-23 23:06:57 +01:00
Timothy Flynn
2e45e52993 AK: Add UTF-16 helper methods required for use within LibRegex
To be used as a RegexStringView variant, Utf16View must provide a couple
more helper methods. It must also not default its assignment operators,
because that implicitly deletes move/copy constructors.
2021-07-23 23:06:57 +01:00
Idan Horowitz
1d76be97f5 LibJS: Implement Temporal.PlainDate.prototype.inLeapYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
c9ae7e1af1 LibJS: Implement Temporal.Calendar.prototype.inLeapYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
dd15fc471c LibJS: Implement Temporal.PlainDate.prototype.monthsInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
342172da37 LibJS: Implement Temporal.Calendar.prototype.monthsInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
b1dd09840b LibJS: Implement Temporal.PlainDate.prototype.daysInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
7f27035342 LibJS: Implement Temporal.Calendar.prototype.daysInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
3160540d0e LibJS: Implement Temporal.PlainDate.prototype.daysInMonth 2021-07-23 22:00:23 +01:00
Idan Horowitz
69c8b8e8bd LibJS: Implement Temporal.Calendar.prototype.daysInMonth 2021-07-23 22:00:23 +01:00
Idan Horowitz
2150f5b374 LibJS: Implement Temporal.PlainDate.prototype.daysInWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
623df361e6 LibJS: Implement Temporal.Calendar.prototype.daysInWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
2cf582436f LibJS: Implement Temporal.PlainDate.prototype.weekOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
d22fe25643 LibJS: Implement Temporal.Calendar.prototype.weekOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
d561535ac9 LibJS: Implement Temporal.PlainDate.prototype.dayOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
c0e7761758 LibJS: Implement Temporal.Calendar.prototype.dayOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
bcbfd5b280 LibJS: Implement Temporal.PlainDate.prototype.dayOfWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
339b0a17e8 LibJS: Implement Temporal.Calendar.prototype.dayOfWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
59dc0e8421 LibJS: Implement Temporal.PlainDate.prototype.day 2021-07-23 22:00:23 +01:00
Idan Horowitz
8a20f258f0 LibJS: Implement Temporal.Calendar.prototype.day 2021-07-23 22:00:23 +01:00
Idan Horowitz
d9414e465a LibJS: Implement Temporal.PlainDate.prototype.monthCode 2021-07-23 22:00:23 +01:00
Idan Horowitz
9d9ba29cae LibJS: Implement Temporal.Calendar.prototype.monthCode 2021-07-23 22:00:23 +01:00
Idan Horowitz
a0af9b11fb LibJS: Implement Temporal.PlainDate.prototype.month 2021-07-23 22:00:23 +01:00
Idan Horowitz
3bec18432a LibJS: Implement Temporal.Calendar.prototype.month 2021-07-23 22:00:23 +01:00