Commit graph

1465 commits

Author SHA1 Message Date
Timothy Flynn
b24b9c0a65 LibUnicode: Fallback to per-locale default calendars
When patterns, symbols, etc. for a requested calendar are not found, use
the locale's default calendar.
2022-07-15 12:31:43 +02:00
Timothy Flynn
c849cb9d76 LibUnicode: Fallback to per-locale default numbering systems
When patterns, grouping digits, symbols, etc. for a requested numbering
system are not found, use the locale's default numbering system. This
will allow using the correct digits e.g. for the locale "en-u-nu-arab"
even though the "en" locale only contains patterns for the "latn"
numbering system.
2022-07-15 12:31:43 +02:00
Timothy Flynn
f8f7015419 LibUnicode: Generate a method to lookup locale-preferred keyword values 2022-07-15 12:31:43 +02:00
Timothy Flynn
80568d5776 LibUnicode: Generate a method to lookup available keyword values 2022-07-15 12:31:43 +02:00
Timothy Flynn
c2e5b20eb6 LibUnicode: Generate available values for the keywords co, kf, kn, hc
This also ensures we only include values we actually support in the
generated list of available values.
2022-07-15 12:31:43 +02:00
Linus Groh
9244f1697d LibWeb: Add definitions from '2.2.1. Methods' in the Fetch spec 2022-07-14 00:42:26 +01:00
Linus Groh
22a627fc1a LibWeb: Move Origin into the HTML namespace
Origin is defined in the HTML Standard, and therefore belongs into the
HTML directory and namespace in LibWeb.
https://html.spec.whatwg.org/multipage/origin.html#origin
2022-07-14 00:42:26 +01:00
Tim Schumacher
3d51642037 LibCore: Replace the ArgsParser option argument setting with an enum
Replacement conditions for `requires_argument` have been chosen based
on what would be most convenient for implementing an eventual optional
argument mode.
2022-07-14 00:24:24 +01:00
Tim Schumacher
fb877effb8 Meta+Ports: Automatically generate a meson cross file that we can use 2022-07-13 21:22:52 +01:00
sin-ack
fbc771efe9 Everywhere: Use default StringView constructor over nullptr
While null StringViews are just as bad, these prevent the removal of
StringView(char const*) as that constructor accepts a nullptr.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
sin-ack
7456904a39 Meta+Userland: Simplify some formatters
These are mostly minor mistakes I've encountered while working on the
removal of StringView(char const*). The usage of builder.put_string over
Format<FormatString>::format is preferrable as it will avoid the
indirection altogether when there's no formatting to be done. Similarly,
there is no need to do format(builder, "{}", number) when
builder.put_u64(number) works equally well.

Additionally a few Strings where only constant strings were used are
replaced with StringViews.
2022-07-12 23:11:35 +02:00
Timothy Flynn
a337b059dd LibUnicode: Parse and generate per-locale plural ranges 2022-07-12 00:43:34 +01:00
Luke Wilde
3845982d38 LibWeb/IDL: Add support for optional sequences 2022-07-11 22:35:08 +02:00
kleines Filmröllchen
fb7cd7b340 Documentation: Merge UsingFontEditor into existing FontEditor manpage
The generate-manpages script needs to be updated again to handle the new
PNGs in section 1. (I'm intentionally not making this a multi-directory
glob.)
2022-07-11 11:35:56 +02:00
kleines Filmröllchen
8558a6b83b Meta: Also check CONTRIBUTING with check-markdown.sh 2022-07-11 11:35:56 +02:00
Luke Wilde
36c3a0fac2 Meta: Make utmp start out as an empty object instead of empty string
The reason empty string was treated as JSON null was to paper over an
issue where UTMP would start out as the empty string and presumably
cause errors when trying to parse it as JSON. This was added in
commit a409b832.

This changes that by making UTMP start out as an empty JSON object
instead of the empty string.
2022-07-10 23:31:48 +02:00
Daniel Bertalan
5c3b182b7e Meta: Teach pick_host_compiler about Homebrew Clang
Homebrew does not add upstream LLVM's install location to $PATH so as
not to conflict with XCode tools, so we should look for it by its
absolute path. LLVM is installed to /opt/homebrew/opt/llvm on ARM Macs,
and is a symlink that points to the latest stable LLVM version.
2022-07-10 12:38:05 +02:00
Timothy Flynn
232df4196b LibUnicode: Replace NumberFormat::Plurality with Unicode::PluralCategory
To prepare for using plural rules within number & duration format, this
removes the NumberFormat::Plurality enumeration.

This also adds PluralCategory::ExactlyZero & PluralCategory::ExactlyOne.
These are used in locales like French, where PluralCategory::One really
means any value from 0.00 to 1.99. PluralCategory::ExactlyOne means only
the value 1, as the name implies. These exact rules are not known by the
general plural rules, they are explicitly for number / currency format.
2022-07-08 20:33:52 +02:00
Timothy Flynn
cc5c707649 LibJS+LibUnicode: Do not generate the PluralCategory enum
The PluralCategory enum is currently generated for plural rules. Instead
of generating it, this moves the enum to the public LibUnicode header.
While it was nice to auto-discover these values, they are well defined
by TR-35, and we will need their values from within the number format
code generator (which can't rely on the plural rules generator having
run yet). Further, number format will require additional values in the
enum that plural rules doesn't know about.
2022-07-08 20:33:52 +02:00
Kenneth Myhra
247951e09c LibWeb: Add URLSearchParams as part of union type for XHR::send()
This patch adds support for URLSearchParams to XHR::send() and
introduces the union type XMLHttpRequestBodyInit.

XHR::send() now has support for String and URLSearchParams.
2022-07-08 12:37:01 +02:00
Tim Schumacher
6978b53ea0 Meta: Don't disable custom Toolchain on SerenityOS
Parts of our build system and scripts rely on the fact that we are
cross-compiling. For now, remove the "try to build natively" part to get
the build running and leave a TODO for later.
2022-07-08 12:04:01 +02:00
Tim Schumacher
92bf442d83 Meta: Provide the correct path for e2fsck on SerenityOS 2022-07-08 12:04:01 +02:00
Tim Schumacher
139f871781 Meta: Use pls instead of sudo on SerenityOS 2022-07-08 12:04:01 +02:00
Timothy Flynn
bf85bf2a9e LibJS: Use Intl.PluralRules within Intl.RelativeFormat
The Polish test cases added here cover previous failures from test262,
due to the way that 0 is specified to be "many" in Polish.
2022-07-08 11:51:54 +02:00
Timothy Flynn
8aeacccd82 LibUnicode: Generate a list of available plural categories per locale
Separate lists are generated for cardinal and ordinal form.
2022-07-08 11:51:54 +02:00
Timothy Flynn
ea78bac36d LibUnicode: Parse and generate per-locale plural rules from the CLDR
Plural rules in the CLDR are of the form:

"cs": {
    "pluralRule-count-one": "i = 1 and v = 0 @integer 1",
    "pluralRule-count-few": "i = 2..4 and v = 0 @integer 2~4",
    "pluralRule-count-many": "v != 0 @decimal 0.0~1.5, 10.0, 100.0 ...",
    "pluralRule-count-other": "@integer 0, 5~19, 100, 1000, 10000 ..."
}

The syntax is described here:
https://unicode.org/reports/tr35/tr35-numbers.html#Plural_rules_syntax

There are up to 2 sets of rules for each locale, a cardinal set and an
ordinal set. The approach here is to generate a C++ function for each
set of rules. Each condition in the rules (e.g. "i = 1 and v = 0") is
transpiled to a C++ if-statement within its function. Then lookup tables
are generated to match locales to their generated functions.

NOTE: -Wno-parentheses-equality is added to the LibUnicodeData compile
flags because the generated plural rules have lots of extra parentheses
(because e.g. we need to selectively negate and combine rules). The code
to generate only exactly the right number of parentheses is quite hairy,
so this just tells the compiler to ignore the extras.
2022-07-08 11:51:54 +02:00
Tim Schumacher
6677cd6d70 Meta: Don't overwrite newer files when building the root filesystem 2022-07-07 21:49:48 +01:00
Timothy Flynn
12e7c0808a LibUnicode: Generate per-region week data
This includes:
* The minimum number of days in a week for that week to count as the
  first week of a new year.
* The day to be shown as the first day of the week in a calendar.
* The start/end days of the weekend.

Like the existing hour cycle data, week data is presented per-region in
the CLDR, rather than per-locale. The method to add likely subtags to a
locale to perform region lookups is the same.

The list of regions in the CLDR for hour cycle, minimum days, first day,
and weekend days are quite different. So rather than changing the
existing HourCycleRegion enum to a generic Region enum, we generate
separate enums for each of the week data fields. This allows each lookup
into these fields to remain simple array-based index access, without any
"jumps" for regions that don't have CLDR data for a field.
2022-07-06 16:56:42 +02:00
Timothy Flynn
4868b888be LibUnicode: Generate per-locale text layout information
Currently contains just each locale's character order, but is set up to
easily add other text layout fields from the CLDR if ECMA-402 eventually
requires them.
2022-07-06 16:56:42 +02:00
Timothy Flynn
fa005bd276 LibTimeZone: Parse and generate a list of time zones used by region
The zone1970.tab file in the TZDB contains regional time zone data, some
of which we already parse for the system time zone settings map.

This parses the region names from that file and generates a list of time
zones which are used in each of those regions.
2022-07-06 16:56:42 +02:00
Andrew Kaster
0a62fcfbdf Meta: Build select Services in Lagom
Add overrides for serenity_bin and serenity_lib to allow the actual
CMakeLists.txt from Userland to be used to build as many services as
possible without adding more clutter to Meta/Lagom/CMakeLists.txt
2022-07-06 14:24:23 +02:00
Andrew Kaster
2b29e611fe Meta: Rename Lagom library target names from LagomFoo to LibFoo
This matches the target names for the main serenity build, and will make
simplifying the Lagom build much easier going forward.

The LagomFoo name came from a time when we had both library builds in
the same CMake generated project and needed to deconflict the names.
2022-07-06 14:24:23 +02:00
Andrew Kaster
02e8f29560 Meta: Use CMAKE_INSTALL_FOODIR variables instead of hardcoding usr/foo
In preparation for future refactoring of Lagom, let's use the variables
from GNUInstallDirs as much as possible for the helper macros and other
scripts used by the main build already.
2022-07-06 14:24:23 +02:00
DexesTTP
6c7ee391cb LibWeb: Replace all uses of -'s and ::'s when running the IDL generator
These were obvious wrong uses of the old default "only first occurence"
parameter that was used in String::replace.
2022-07-06 11:12:45 +02:00
DexesTTP
7ceeb74535 AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes.

In particular, this does not fix any of the wrong uses of the previous
default parameter (which used to be 'false', meaning "only replace the
first occurence in the string"). It simply replaces the default uses by
String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
2022-07-06 11:12:45 +02:00
Luke Wilde
de88e119a0 LibWeb: Implement XMLSerializer
The main thing that is missing is validating certain pieces of data
against XML productions in well-formed mode, but nothing uses
well-formed mode right now.

Required by Closure Library for sanitising HTML.
e687b3d8ab/closure/goog/html/sanitizer/safedomtreeprocessor.js (L117)
2022-07-05 21:25:05 +02:00
Daniel Bertalan
fc3532e9b7 Lagom: Do not set -fno-semantic-interposition on macOS
The Mach-O file format does not have ELF's interposition rules, so this
flag does not make sense for macOS builds. While GCC silently accepts
the unsupported option, Clang issues a warning for it.

This commit makes it possible to build Lagom with LLVM from Homebrew.
2022-07-04 21:46:02 +02:00
Idan Horowitz
f4785e2468 LibUnicode: Generate data about DurationFormat-required units as well 2022-07-01 01:00:05 +03:00
Idan Horowitz
573061e76c LibUnicode: Extract the timeSeparator numeric symbol from CLDR
This will be used by Intl.DurationFormat
2022-07-01 01:00:05 +03:00
Luke Wilde
885c6b6678 LibWeb: Return instead of throwing on unknown enums in attribute setters
I saw one site relying on this, where they are trying to set
XHR.responseType to "text/plain", which is not a valid responseType.
However, they also don't expect it to throw. The IDL spec special cases
enumerations to make it return instead of throwing in this case.
2022-06-29 21:21:50 +01:00
Andrew Kaster
fef83ed47d Meta: Install runtime/utility from jakt to make hello-jakt build again
Also add a compile flag that fixes a warning from including <serenity.h>
2022-06-19 09:00:02 +02:00
kleines Filmröllchen
2c6e3ea2e9 Meta: Add a PNG size check to CI and pre-commit checks
This uses optipng to check how much size can be reduced on PNG files. If
that's more than 2 KiB for at least one file, the check fails. As with
other checks, it doesn't run if optipng is not installed.
2022-06-18 21:58:43 +04:30
Luke Wilde
076c9772a4 LibWeb: Add ability to present LibGL framebuffer and add clearing 2022-06-13 21:45:27 +01:00
Luke Wilde
58f882200c LibWeb: Add the ability to retrieve a WebGL context from getContext 2022-06-13 21:45:27 +01:00
Luke Wilde
b0c2aee2e4 LibWeb: Introduce the WebGL namespace and add WebGLContextEvent 2022-06-13 21:45:27 +01:00
Luke Wilde
df2c0588ea LibWeb/IDL: Add support for returning JS::Object from IDL functions 2022-06-13 21:45:27 +01:00