Commit graph

31034 commits

Author SHA1 Message Date
Linus Groh
038d354b5d LibJS: Remove Object::value_of()
Being really close to Object.prototype.valueOf() name wise makes this
unnecessarily confusing - while it sometimes serves as the
implementation of a valueOf() function, it's an abstraction which the
spec doesn't have.
Use the appropriate getters to retrieve specific internal slots instead,
most commonly [[FooData]] from the primitive wrapper objects.
For the Object class specifically, use the Value(Object*) ctor instead.
2021-12-10 22:52:36 +00:00
Timothy Flynn
07c5419a82 LibJS: Add test case for locales which do not define day periods
Some locales do not define morning, night, etc. day period ranges.
TR-35 states they should fall back to the fixed day periods AM and PM.
Add a test case for the "as" locale, which is one such locale, to ensure
its AM/PM symbols are used.
2021-12-10 21:27:24 +00:00
Timothy Flynn
5bdee9e38a LibJS: Use locale-aware day period time ranges to format period symbols
For the test cases changed here, we now recognize "morning2" and
"afternoon2" from the CLDR, so the expected results now match the specs
and other engines.
2021-12-10 21:27:24 +00:00
Timothy Flynn
a417c23de0 LibUnicode: Parse and generate per-locale day period ranges 2021-12-10 21:27:24 +00:00
Timothy Flynn
fa8e881cfa LibUnicode: Parse and generate secondary day period symbols
Generate morning2, afternoon2, evening2, and night2 symbols.
2021-12-10 21:27:24 +00:00
Timothy Flynn
76aab821f4 LibJS+LibUnicode: Rename some Unicode::DayPeriod values
In the CLDR, there aren't "night" values, there are "night1" & "night2"
values. This is for locales which use a different name for nighttime
depending on the hour. For example, the ja locale uses "夜" between the
hours of 19:00 and 23:00, and "夜中" between the hours of 23:00 and
04:00. Our CLDR parser is currently ignoring "night2", so this rename
is to prepare for that.

We could probably come up with better names, but in the end, the API in
LibUnicode will be such that outside callers won't even see Night1, etc.
2021-12-10 21:27:24 +00:00
Luke Wilde
1a5bf15b4d LibWeb: Implement AbortSignal.throwIfAborted
See: https://github.com/whatwg/dom/commit/cfe2f1e
2021-12-10 23:05:36 +02:00
Luke Wilde
64040c136e LibWeb: Add support for AbortSignal.reason 2021-12-10 23:05:36 +02:00
Idan Horowitz
4dbda2d5b4 Meta: Enable the "bugprone-dangling-handle" clang-tidy check
This should catch (the trivial cases of) construction of StringViews
from temporary Strings and the construction of Spans from temporary
Vectors.
2021-12-10 23:00:24 +02:00
Sam Atkins
197759e30f LibWeb: Fix off-by-one error when highlighting unquoted HTML attributes
This fixes #11166
2021-12-10 21:27:13 +01:00
Timothy Flynn
2e4e0195de LibJS: Implement ECMA-402 Date.prototype.toLocaleTimeString 2021-12-10 13:58:33 +00:00
Timothy Flynn
4d310fd7aa LibJS: Implement ECMA-402 Date.prototype.toLocaleDateString 2021-12-10 13:58:33 +00:00
Timothy Flynn
9a62c01ebc LibJS: Implement ECMA-402 Date.prototype.toLocaleString 2021-12-10 13:58:33 +00:00
Hendiadyoin1
9be409585c Kernel: Some clang-tidy fixes in Bus/VirtIO 2021-12-09 22:53:42 -08:00
Hendiadyoin1
471b38db68 Kernel: Some clang-tidy fixes in Bus/USB 2021-12-09 22:53:42 -08:00
Hendiadyoin1
b03b7f806a Kernel: Mark USBTransfer's constructor as private
We have a try_create method for that.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
21c5c4026b Kernel: Mark ACPI::Parser's empty destructor as default 2021-12-09 22:53:42 -08:00
Hendiadyoin1
73aa5c75d5 Kernel: Fix some clang-tidy warnings in PCI::Access 2021-12-09 22:53:42 -08:00
Hendiadyoin1
19ba32651d Kernel: Use AK:any_of in PCI::Device capability checks
This is equivalent to std::any_of as clang-tidy suggests.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
5adf5f4dee Kernel: Construct PCIDeviceAttributeSysFSComponent with StringViews
There is no use to create a temporary String of a char const* to just
cast it to a StringView on SysFSComponent construction again.
Also this could have lead to a UAF bug.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
de26dd253b Kernel: Pass capabilities as const reference in PCI::Address 2021-12-09 22:53:42 -08:00
Hendiadyoin1
3070252090 Kernel: Mark PCI::Address as trivially copyable 2021-12-09 22:53:42 -08:00
Hendiadyoin1
f9e8fe557c Kernel: Add missing include to SlabAllocator 2021-12-09 22:53:42 -08:00
Lady Gegga
991384856a Base: Add some Vai characters to font Katica Regular 10
A5A8-A5D1 https://www.unicode.org/charts/PDF/UA500.pdf
2021-12-10 06:52:40 +01:00
Sam Atkins
54bbb97ac6 Browser+LibWeb+WebContent: Add variables display to Inspector
This allows us to see which custom properties apply to a given element,
which previously wasn't shown.
2021-12-10 06:52:17 +01:00
Timothy Flynn
53df13fed7 LibJS: Implement Intl.DateTimeFormat.prototype.formatRangeToParts 2021-12-09 23:43:04 +00:00
Timothy Flynn
04f8fb07e1 LibJS: Implement Intl.DateTimeFormat.prototype.formatRange 2021-12-09 23:43:04 +00:00
Timothy Flynn
1f35eda37b LibJS: Store range format patterns in the Intl.DateTimeFormat object
Now that LibUnicode generates these patterns, the AO steps to retrieve
them may be implemented.
2021-12-09 23:43:04 +00:00
Timothy Flynn
7a0d5e3f7a LibJS: Do not return views into potentially freed memory
In a future commit, the "part" view returned from FormatDateTimePattern
may be a view into a string that goes out of scope. Ensure the AO only
returns valid views. A similar approach is used in Intl.NumberFormat.
2021-12-09 23:43:04 +00:00
Timothy Flynn
2024d9e9ea LibUnicode: Add method to combine two format pattern skeletons
The fields of the generated elements must be in the same order as the
table here:
https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table

Further, only one field from each group of fields is allowed.
2021-12-09 23:43:04 +00:00
Timothy Flynn
9d4c4303fd LibUnicode: Parse and generate date time range format patterns 2021-12-09 23:43:04 +00:00
Timothy Flynn
fe84a365c2 LibUnicode: Parse and generate format pattern skeletons
Pattern skeletons are more or less the "key" of format patterns. Every
format pattern is assigned a skeleton. Interval patterns (which are not
yet parsed) are also assigned a skeleton - this is used to match them to
an "owning" format pattern. So we will use the skeleton generated here
to match format patterns at runtime with their available interval
patterns.

An alternative approach would be to append interval patterns directly to
their owning format pattern, but this has some draw backs:

    1. Skeletons aren't totally unique. A skeleton may appear in both
       the "dateFormats" and "availableFormats" objects, in which case
       the same interval formats would be generated more than once.

    2. Otherwise unique format patterns may only differ by the interval
       patterns assigned to them. This would cause the UniqueStorage for
       the format patterns to increase in size, impacting both compile
       times and libunicode.so size.
2021-12-09 23:43:04 +00:00
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