Commit graph

800 commits

Author SHA1 Message Date
Timothy Flynn 3ad159537e LibUnicode: Use u16 for unique string indices instead of size_t
Typically size_t is used for indices, but we can take advantage of the
knowledge that there is approximately only 46K unique strings in the
generated UnicodeLocale.cpp file. Therefore, we can get away with using
u16 to store indices. There is a VERIFY that will fail if we ever exceed
the limits of u16.

On x86_64 builds, this reduces libunicode.so from 9.2 MiB to 7.3 MiB.
On i686 builds, this reduces libunicode.so from 3.9 MiB to 3.3 MiB.

These savings are entirely in the .rodata section of the shared library.
2021-10-15 00:06:18 +01:00
Timothy Flynn ebe704a03d LibWeb: Stub out a basic IntersectionObserver interface
Note there are a couple of type differences between the spec and the IDL
file added in this commit. For example, we will need to support a type
of Variant to handle spec types such as "(double or sequence<double>)".
But for now, this allows web pages to construct an IntersectionObserver
with any valid type.
2021-10-14 10:32:51 +02:00
Timothy Flynn ff66218631 LibWeb: Allow creating "any" types in IDL with integral default values
This enables defining "any" types in IDL files such as:

    any threshold = 0;

This isn't able to parse decimal values yet.
2021-10-14 10:32:51 +02:00
Timothy Flynn f91d63af83 LibUnicode: Generate enum/alias from-string methods without a HashMap
The *_from_string() and resolve_*_alias() generated methods are the last
remaining users of HashMap in the LibUnicode generated files (read: the
last methods not using compile-time structures). This converts these
methods to use an array containing pairs of hash values to the desired
lookup value.

Because this code generation is the same between GenerateUnicodeData.cpp
and GenerateUnicodeLocale.cpp, this adds a GeneratorUtil.h header to the
LibUnicode generators to contain the method that generates the methods.
2021-10-13 16:38:51 +02:00
Linus Groh 52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh 4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh 44e70d1bc0 LibJS+LibWeb: Let WrapperGenerator deal with legacy_null_to_empty_string
This concept is not present in ECMAScript, and it bothers me every time
I see it.
It's only used by WrapperGenerator, and even there only relevant in two
places, so let's fully remove it from LibJS and use a simple ternary
expression instead:

    cpp_name = js_name.is_null() && legacy_null_to_empty_string
        ? String::empty()
        : js_name.to_string(global_object);
2021-10-11 23:36:03 +01:00
Linus Groh 661dd32432 LibWeb: Add support for the Promise<T> IDL type to WrapperGenerator
This includes parsing parameterized types (foo<T>) as well as generating
the appropriate code in generate_wrap_statement() and generate_to_cpp().
2021-10-11 13:30:17 +01:00
Linus Groh 7afd215e95 LibWeb: Initialize IDL any values without default value to undefined
Previously this would generate the following code:

    JS::Value foo_value;
    if (!foo.is_undefined())
        foo_value = foo;

Which is dangerous as we're passing an empty value around, which could
be exposed to user code again. This is fine with "= null", for which it
also generates:

    else
        foo_value = JS::js_null();

So, in summary: a value of type `any`, not `required`, with no default
value and no initializer from user code will now default to undefined
instead of an empty value.
2021-10-11 13:30:17 +01:00
Linus Groh a9a7d65099 LibWeb: Replace heycam.github.io/webidl URLs with webidl.spec.whatwg.org
Web IDL is now a WHATWG standard and the specification was moved
accordingly: https://twitter.com/annevk/status/1445311275026821120

The old URLs now redirect, but let's use canonical ones.
2021-10-11 13:15:16 +01:00
Andreas Kling fdc1c15064 LibWeb: Stub out a basic ResizeObserver interface
This patch establishes scaffolding for the ResizeObserver API.
2021-10-11 00:54:01 +02:00
Andreas Kling 5c9ca5c2dc LibWeb: Stub out a basic Selection interface
This patch establishes scaffolding for the Selection API.
2021-10-11 00:32:19 +02:00
Ben Wiederhake e900f94a03 Meta: Run check-markdown as part of 'Azure Linux NoFuzz' 2021-10-10 15:18:55 -07:00
Ben Wiederhake a296f6bb8d Meta: Invoke markdown-checker if available while linting 2021-10-10 15:18:55 -07:00
Ben Wiederhake c06a0bae04 Meta: Fix broken external links
Meta/Lagom/ReadMe.md never had any other name; not sure how that typo
happened.

The link to the non-existent directory is especially vexing because the
text goes on to explain that we don't want such a directory to exist.

Found by running markdown-checker, and 'wget'ing all external links.
2021-10-10 15:18:55 -07:00
Ben Wiederhake 3f88d65b78 markdown-checker: New tool that checks document links 2021-10-10 15:18:55 -07:00
Timothy Flynn 597379e864 LibUnicode: Generate and use unique locale-related alias strings
Almost all of these are already in the unique string list.
2021-10-10 22:21:48 +02:00
Timothy Flynn acb7bd917f LibUnicode: Generate and use unique subtag and complex alias strings 2021-10-10 22:21:48 +02:00
Timothy Flynn 3d67f6bd29 LibUnicode: Generate and use unique list-format strings
The list-format strings used for Intl.ListFormat are small, but quite
heavily duplicated. For example, the string "{0}, {1}" appears 6,519
times. Generate unique strings for this data to avoid duplication.
2021-10-10 22:21:48 +02:00
Timothy Flynn f9e605397c LibUnicode: Generate and use a set of unique locale-related strings
In the generated UnicodeLocale.cpp file, there are 296,408 strings for
localizations of languages, territories, scripts, currencies & keywords.
Of these, only 43,848 (14.8%) are actually unique, so there are quite a
large number of duplicated strings.

This generates a single compile-time array to store these strings. The
arrays for the localizations now store an index into this single array
rather than duplicating any strings.
2021-10-10 22:21:48 +02:00
Timothy Flynn 3f0095b57a LibUnicode: Skip unknown languages and territories
Some CLDR languages.json / territories.json files contain localizations
for some lanuages/territories that are otherwise not present in the CLDR
database. We already don't generate anything in UnicodeLocale.cpp for
these anomalies, but this will stop us from even storing that data in
the generator's memory.

This doesn't affect the output of the generator, but will have an effect
after an upcoming commit to unique-ify all of the strings in the CLDR.
2021-10-10 22:21:48 +02:00
Ben Wiederhake 6d99b7b72e Meta: Re-enable warnings for deprecated copies also for Lagom 2021-10-10 21:21:35 +01:00
Timothy Flynn 79707d83d3 LibUnicode: Stop generating large UnicodeData hash map
The data in this hash map is now available by way of much smaller arrays
and is now unused.
2021-10-10 13:49:37 +02:00
Timothy Flynn d83b262e64 LibUnicode: Generate standalone compile-time array for combining class 2021-10-10 13:49:37 +02:00
Timothy Flynn 9f83774913 LibUnicode: Generate standalone compile-time array for special casing
There are only 112 code points with special casing rules, so this array
is quite small (compared to the size 34,626 UnicodeData hash map that is
also storing this data). Removing all casing rules from UnicodeData will
happen in a subsequent commit.
2021-10-10 13:49:37 +02:00
Timothy Flynn da4b8897a7 LibUnicode: Generate standalone compile-time arrays for simple casing
Currently, all casing information (simple and special) are stored in a
compile-time array of size 34,626, then statically copied to a hash map
at runtime. In an effort to reduce the resulting memory usage, store the
simple casing rules in standalone compile-time arrays. The uppercase map
is size 1,450 and the lowercase map is size 1,433. Any code point not in
a map will implicitly have an identity mapping.
2021-10-10 13:49:37 +02:00
Idan Horowitz 9958277317 Meta: Disable -Wmaybe-uninitialized for Lagom 2021-10-07 21:56:03 +03:00
Nico Weber a7b558bf7d Meta: Warn on rebuild-toolchain i686 clang
It's "Clang" (capitalized). Silently building gcc if the toolchain
isn't know seems a bit unfriendly. So print a warning for this
(and for other unknown toolchains).
2021-10-07 18:34:13 +03:00
Ben Wiederhake 52e9f25403 Everywhere: Change from http to https where feasible
I used "git grep -FIn http://" to find all occurrences, and looked at
each one. If an occurrence was really just a link, and if a https
version exists, and if our Browser can access it at least as well as the
http version, then I changed the occurrence to https.

I'm happy to report that I didn't run into a single site where Browser
can't deal with the https version.
2021-10-05 02:08:08 +02:00
Andreas Kling bf43b0f884 LibWeb: Make IDL-constructed objects aware of their JS wrapper
Having IDL constructors call FooWrapper::create(impl) directly was
creating a wrapper directly without telling the impl object about the
wrapper. This meant that we had wrapped C++ objects with a null
wrapper() pointer.
2021-10-04 12:13:25 +02:00
Linus Groh 2f42675ebd LibJS: Convert ordinary_set_with_own_descriptor() to ThrowCompletionOr 2021-10-04 09:52:15 +01:00
Linus Groh 3be26f56db LibJS: Convert has_own_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
Linus Groh fb443b3fb4 LibJS: Convert create_data_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
Linus Groh b7e5f08e56 LibJS: Convert Object::get() to ThrowCompletionOr
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
davidot ac2c3a73b1 LibJS: Add a specific test for invalid unicode characters in the lexer
Also fixes that it tried to make substrings past the end of the source
if we overran the source length.
2021-10-03 17:42:05 +02:00
Luke Wilde 8d6db36cbb LibWeb: Add support for NodeList
This introduces 3 classes: NodeList, StaticNodeList and LiveNodeList.
NodeList is the base of the static and live versions. Static is a
snapshot whereas live acts on the underlying data and thus inhibits
the same issues we have currently with HTMLCollection.

They were split into separate classes to not have them weirdly
mis-mashed together.

The create functions for static and live both return a NNRP to the base
class. This is to prevent having to do awkward casting at creation
and/or return, as the bindings expect to see the base NodeList only.
2021-10-03 00:18:52 +02:00
Luke Wilde bfd089fbd1 LibWeb: Add support for IDL value iterators
This also renames Interface::iterator_types to pair_iterator_types to
reduce confusion between value and pair iterators.
2021-10-03 00:18:52 +02:00
Linus Groh ba6e4c7ae1 LibJS+LibWeb: Use Object::set_prototype() in more places 2021-10-02 14:53:06 +01:00
Idan Horowitz a4bc3fa255 LibWeb: Initialize IDL-generated prototypes' prototype directly
Instead of setting it to the default object prototype and then
immediately setting it again via internal_set_prototype_of, we can just
set it directly in the parent constructor call.
2021-10-02 13:23:59 +01:00
Andreas Kling 77f0e57b27 RequestServer: Don't hide the SIGINFO state dump behind a debug macro
Until we're confident that RequestServer doesn't need this runtime debug
dump helper, it's much nicer if everyone has it built in, so they can
simply send a SIGINFO if they see it acting up.
2021-10-01 20:17:15 +02:00
Idan Horowitz 43482dfde3 LibWeb: Support dictionary-only IDL files 2021-10-01 20:14:45 +02:00
Idan Horowitz ac25c28c43 LibWeb: Add the missing UIEvent IDL constructor 2021-10-01 20:14:45 +02:00
Idan Horowitz 7b2c63fd87 LibWeb: Add support for unwrapping the WindowObject to WrapperGenerator 2021-10-01 20:14:45 +02:00
Idan Horowitz 4d71f22673 LibWeb: Add the missing ProgressEvent IDL constructor 2021-10-01 20:14:45 +02:00
Idan Horowitz 7f551d7f6a LibWeb: Use the LibWeb source directory as the IDL #import base path
This allows us to include IDL files from other base LibWeb directories
wihout using relative `../foo.idl` references.
2021-10-01 20:14:45 +02:00
Nico Weber 9ec9886b04 Meta: Fix typos 2021-10-01 01:06:40 +01:00
Idan Horowitz 2c6c9b73c8 LibWeb: Add the Web::Crypto namespace, built-in, and getRandomValues
Since we don't support IDL typedefs or unions yet, the responsibility
of verifying the type of the argument is temporarily moved from the
generated Wrapper to the implementation.
2021-09-30 20:02:09 +02:00
Timothy Flynn becbb0ea97 LibUnicode: Upgrade to Unicode version 14.0.0 2021-09-30 17:37:57 +01:00
Timothy Flynn c8dbcdb0bc LibUnicode: Do not compare generated file contents before writing
This is now covered by unicode_data.cmake after the superbuild changes.
2021-09-30 17:37:57 +01:00
Timothy Flynn a466b78bf3 LibUnicode: Remove cached UCD and CLDR files when their version changes 2021-09-30 17:37:57 +01:00