Commit graph

31202 commits

Author SHA1 Message Date
Timothy Flynn b17c6ab661 LibUnicode: Fix typo in format pattern parser
See: https://unicode.org/reports/tr35/tr35-dates.html#dfst-day
2021-12-09 23:43:04 +00:00
Linus Groh bdb8fc54f2 LibJS: Update spec comment in balance_duration_relative()
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/665871e
2021-12-09 23:18:01 +00:00
Linus Groh 82efbfcf3d LibJS: Update spec comment in Temporal.Duration.prototype.round()
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/513c05b
2021-12-09 23:14:36 +00:00
scwfri 8d0143a380 HackStudio+TextEditor: Persist EditingEngineType across editors
Persist EditingEngine mode in HackStudio and TextEditor when opening new
files or editing splits. Previously, the EditingEngine defaulted to a
RegularEditingEngine for a new Editor, even if Vim Emulation had been
selected in the existing Editor.
2021-12-09 21:31:06 +01:00
scwfri fa94978a7e LibGUI: Add EngineType to EditingEngine classes
This will allow users of EditingEngine classes to determine current type
of EditingEngine (currently either vim or regular).
2021-12-09 21:31:06 +01:00
Sam Atkins c9062b4ed5 LibWeb: Remove now-unused CustomStyleValue 2021-12-09 21:30:31 +01:00
Sam Atkins 10aa06f16f Base: Add more test cases to CSS var() test page 2021-12-09 21:30:31 +01:00
Sam Atkins c3437bccb3 LibWeb: Handle dependency cycles in CSS var()s :^)
We now detect situations like this, where variables infinitely recur,
without crashing:

```css
div {
  --a: var(--b);
  --b: var(--a);
  background: var(--a);
}

p {
  --foo: var(--foo);
  background: var(--foo);
}
```
2021-12-09 21:30:31 +01:00
Sam Atkins 3df0bf2c8d LibWeb: Mitigate the billion-laughs attack on CSS variables
We now stop processing variables once a length of 16384 tokens is
reached. This is an arbitrary number, but should be far beyond what
anyone will reasonably use, and small enough to not crash.
2021-12-09 21:30:31 +01:00
Sam Atkins 67e1125b4c LibWeb: Handle fallback values for CSS variables :^) 2021-12-09 21:30:31 +01:00
Sam Atkins 23dc0dac88 LibWeb: Parse and resolve UnresolvedStyleValues
If a property is custom or contains a `var()` reference, it cannot be
parsed into a proper StyleValue immediately, so we store it as an
UnresolvedStyleValue until the property is compute. Then, at compute
time, we resolve them by expanding out any `var()` references, and
parsing the result.

The implementation here is very naive, and involves copying the
UnresolvedStyleValue's tree of StyleComponentValueRules while copying
the contents of any `var()`s it finds along the way. This is quite an
expensive operation to do every time that the style is computed.
2021-12-09 21:30:31 +01:00
Sam Atkins 000fb5a70d LibWeb: Add new UnresolvedStyleValue class
This represents a property value that hasn't been converted to a
"proper" StyleValue yet. That is, it's either a custom property's value,
or a value that includes `var()` references, (or both!) since neither of
those can be fully resolved at parse time.
2021-12-09 21:30:31 +01:00
Sam Atkins d2f9d2fe51 LibWeb: Make StyleBlockRule more accessible to outsiders
For our naive var() implementation, we need to be able to create
StyleBlockRules outside of the Parser, and these changes make that
possible.
2021-12-09 21:30:31 +01:00
Sam Atkins 1d5d27aa22 LibWeb: Include custom properties in CSS dump 2021-12-09 21:30:31 +01:00
Andreas Kling c268d0fa13 LibWeb: Make CSS::Screen forward its ref count to DOM::Window 2021-12-09 21:28:52 +01:00
Andreas Kling 7fc770cfac LibWeb: Make DOM::NamedNodeMap forward its ref count to DOM::Element
This allows JS to keep an element alive by retaining a reference to
element.attributes
2021-12-09 21:28:52 +01:00
Andreas Kling d368b08698 LibWeb: Make DOMImplementation forward its ref count to DOM::Document
This allows document.implementation to keep the underlying document
alive for as long as we need it (for example, if someone holds on to a
DOMImplementation JS wrapper after the document is GC'd.)
2021-12-09 21:28:52 +01:00
Andreas Kling e1287a9a45 LibWeb: Use RefCountForwarder for NavigationTiming::PerformanceTiming
This object already forwarded its ref count to DOM::Window. This patch
simply adopts the new RefCountForwarder base to achieve the same thing.
2021-12-09 21:28:52 +01:00
Andreas Kling c9a35e104b AK: Add RefCountForwarder<T>
This is a convenience template that implements reference count
forwarding. This means that an object forwards ref() and unref() to
another object.

We can use this when two ref-counted objects need to keep each other
alive. This situation poses two problems:

- Using 2x RefPtr would cause a ref cycle and leak both objects.
- Using 2x WeakPtr would allow one of them to be destroyed early.

With RefCountForwarder, only one of the objects has a ref count. The
object with the ref count points to the forwarding object by using a
non-counting smart pointer (OwnPtr or NonnullOwnPtr). Thus, both objects
are kept alive by the same ref count, and they can safely point to each
other without worrying about disjoint lifetimes.
2021-12-09 21:28:52 +01:00
Andreas Kling fed6a76990 LibJS: Add Handle::operator->() 2021-12-09 21:28:52 +01:00
Nathan Ell a1580a1d00 dos2unix: Swap to official signature validation
In the initial port of dos2unix, there was a miss in the validation
of the files. Let's switch to the original author's official
signed verification of the source :^)
2021-12-09 09:48:43 +01:00
Ben Wiederhake aa5f130c84 Inspector: Remove unused includes
Found while working on something else.
2021-12-08 17:18:37 -08:00
Lady Gegga 183b47733a Base: Add Ancient Greek Numbers to font Katica Regular 10
10140-1018E https://www.unicode.org/charts/PDF/U10140.pdf
2021-12-08 17:17:51 -08:00
Lady Gegga 9ae7efb0bd Base: Add Zanabazar Square characters to font Katica Regular 10
11A00-11A47 https://www.unicode.org/charts/PDF/U11A00.pdf
2021-12-08 17:17:51 -08:00
James Puleo dd25dfbc20 js: Improve usage of TRY when executing a file program 2021-12-08 17:17:35 -08:00
Linus Groh 859b810db1 LibJS/Tests: Enable two more skipped tests which now pass
Only two skipped tests remaining overall :^)
2021-12-08 20:08:26 +00:00
Linus Groh f1dafabbb9 LibJS: Simplify TemporalInstantString
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/271d71c
2021-12-08 19:57:19 +00:00
Luke Wilde 4f3c283f24 LibJS: Move calendar validation out of parse_temporal_calendar_string
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7207a1c
2021-12-08 19:11:50 +00:00
Luke Wilde 80dcddacea LibJS: Simplify return in parse_temporal_date_time_string
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/1f7e486
2021-12-08 19:11:50 +00:00
Luke Wilde 6244969ae2 LibJS: Remove duplicated spec step in parse_iso_date_time
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/516bf24
2021-12-08 19:11:50 +00:00
Ben Wiederhake 9f91f610e2 test-crypto: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 13cba5f8b4 Spreadsheet: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 7967a8bd8c LibTLS: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake f3e496d995 LibSQL: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake f59f7674c8 LibHTTP: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake d78365f785 LibGemini: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 18ae5ede88 LibCrypto+Tests: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 643ec03608 LibCore: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake 768b70cc4d AK+Tests: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Roberto Bampi 70660a79af Base: Add archive icons and use them for compressed files
Both 16x16 and 32x32 variants have been added.
2021-12-08 17:59:00 +01:00
Timothy Flynn 1e68e7f129 LibJS: Implement Intl.DateTimeFormat.prototype.formatToParts 2021-12-08 11:29:36 +00:00
Timothy Flynn adaf5985a4 LibJS: Implement (most of) Intl.DateTimeFormat.prototype.format
There are a few FIXMEs that will need to be addressed, but this
implements most of the prototype method. The FIXMEs are mostly related
to range formatting, which has been entirely ignored so far. But other
than that, the following will need to be addressed:

* Determining flexible day periods must be made locale-aware.
* DST will need to be determined and acted upon.
* Time zones other than UTC and calendars other than Gregorian are
  ignored.
* Some of our results differ from other engines as they have some
  format patterns we do not. For example, they seem to have a lonely
  {dayPeriod} pattern, whereas our closest pattern is
  "{hour} {dayPeriod}".
2021-12-08 11:29:36 +00:00
Timothy Flynn d010ba10c3 LibJS: Cache the data locale used by Intl.DateTimeFormat
Unlike the locale, the data locale has Unicode locale extensions removed
(e.g. the data locale for "en-US-u-ca-gregory" is just "en-US"). Cache
the data locale for LibUnicode lookups during formatting.
2021-12-08 11:29:36 +00:00
Timothy Flynn 4cc8cf9233 LibJS: Add an accessor for the %Date.now% instrinsic property 2021-12-08 11:29:36 +00:00
Timothy Flynn baf3f3bd6e LibJS: Implement Date's Week Day AO 2021-12-08 11:29:36 +00:00
Timothy Flynn e56be34148 LibJS: Implement Date's TimeClip AO 2021-12-08 11:29:36 +00:00
Timothy Flynn b76e44f66f LibUnicode: Parse and generate time zone names in long and short form 2021-12-08 11:29:36 +00:00
Timothy Flynn 2bbf8aa24c LibUnicode: Generate era, month, weekday and day period calendar symbols
The parsing in parse_calendar_symbols() might be a bit more verbose than
it really needs to be, but it is to ensure the symbols are generated in
a known order that we can control with enumerations.
2021-12-08 11:29:36 +00:00
Timothy Flynn 26f9666191 LibJS: Do not override hour, minute, and second format field lengths
This was an oversight in e42d954743.

These fields should always follow the locale preference in the CLDR.
Overriding these fields would permit formats like "h:mm:ss" to result in
strings like "1:2:3" instead of "1:02:03".
2021-12-08 11:29:36 +00:00
Timothy Flynn 9f7c727720 LibJS+LibUnicode: Generate missing patterns with fractionalSecondDigits
TR-35's Matching Skeleton algorithm dictates how user requests including
fractional second digits should be handled when the CLDR format pattern
does not include that field. When the format pattern contains {second},
but does not contain {fractionalSecondDigits}, generate a second pattern
which appends "{decimal}{fractionalSecondDigits}" to the {second} field.
2021-12-08 11:29:36 +00:00