Commit Graph

738 Commits

Author SHA1 Message Date
Linus Groh
8c81c84c18 LibJS: Convert internal_set_prototype_of() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
5148150e1c LibJS: Convert internal_get_prototype_of() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Andreas Kling
6cda24097b LibWeb: Add the CSSStyleRule interface with some limited functionality 2021-09-30 00:00:55 +02:00
Andreas Kling
dadb92a155 LibWeb: Generate CSS::property_id_from_camel_case_string()
This allows us to resolve a "camelCase" CSS property name to our own
CSS::PropertyID enum. This will be used by CSSOM bindings.
2021-09-29 21:21:57 +02:00
Andreas Kling
3a4565beec LibWeb: Make CSSRule and CSSRuleList available to JavaScript :^)
This patch makes both of these classes inherit from RefCounted and
Bindings::Wrappable, plus some minimal rejigging to allow us to keep
using them internally while also exposing them to web content.
2021-09-29 21:21:57 +02:00
Idan Horowitz
e04f3c713c LibWeb: Add support for custom #import IDL statements
This will currently be used to support dictionary inheritance between
dictionaries defined across different IDL definition files.
2021-09-29 19:38:41 +02:00
Luke Wilde
2202428ca4 LibWeb: Add initial support for the IDL [Unscopable] extended attribute
This adds support for the [Unscopable] extended attribute to attributes
and functions.

I believe it should be applicable to all interface members, but I
haven't done that here.
2021-09-29 17:56:13 +02:00
Luke Wilde
881e9d1341 LibWeb: Make StyleSheetList.item an IDL getter 2021-09-29 14:57:59 +01:00
Ali Mohammad Pur
398435277b RequestServer: Use an OwnPtr for cached connections
Otherwise we'd end up trying to delete the wrong connection if a
connection made before us is deleted.
Fixes _some_ RequestServer spins (though not all...).
This commit also adds a small debug mechanism to RequestServer (which
can be enabled by turning REQUEST_SERVER_DEBUG on), that can dump all
the current active connections in the cache, what they're doing, and how
long they've been doing that by sending it a SIGINFO.
2021-09-29 11:47:18 +02:00
Idan Horowitz
071a358ffb LibWeb: Add support for converting IDL dictionaries to native structs 2021-09-29 10:09:33 +03:00
Idan Horowitz
c3810b827a LibWeb: Add support for parsing IDL dictionaries 2021-09-29 10:09:33 +03:00
Idan Horowitz
87f655f2af LibWeb: Change IDL::parse_interface's return type to NonnullOwnPtr
We always returned an interface, so there's no need for the null state.
2021-09-29 10:09:33 +03:00
Idan Horowitz
cdde3ba5c5 LibWeb: Add partial support for IDL Iterable declarations
This currently only supports pair iterables (i.e. iterable<key, value>)
support for value iterables (i.e. iterable<value>) is left as TODO().

Since currently our cmake setup calls the WrapperGenerator separately
and unconditionally for each (hard-coded) output file iterable wrappers
have to be explicitly marked so in the CMakeLists.txt declaration, we
could likely improve this in the future by querying WrapperGenerator
for the outputs based on the IDL.
2021-09-28 16:51:27 +02:00
Idan Horowitz
2fab43ba5d LibWeb: Add support for wrapping arbitrary values to WrapperGenerator
This patch essentially just splits the non return-specific logic from
generate_return_statement (i.e. the wrapping of the cpp value into
a javascript one) into a separate function generate_wrap_statement that
can be used to wrap any cpp value during wrapper generation.
2021-09-28 16:51:27 +02:00
Idan Horowitz
a11f7868a4 LibWeb: Only consume [a-zA-Z0-9_] characters for IDL types 2021-09-28 16:51:27 +02:00
Luke Wilde
067d839615 LibWeb: Add support for the any type in returning and parameters
Required for CustomEvent.
2021-09-27 18:45:45 +02:00
Luke Wilde
d30ec4d790 LibWeb: Add [CustomVisit] IDL interface extended attribute
This custom attribute will be used for objects that hold onto arbitrary
JS::Value's. This is needed as JS::Handle can only be constructed for
objects that implement JS::Cell, which JS::Value doesn't.

This works by overriding the `visit_edges` function in the wrapper.
This overridden function calls the base `visit_edges` and then forwards
it to the underlying implementation.

This will be used for CustomEvent, which must hold onto an arbitrary
JS::Value for it's entire lifespan.
2021-09-27 18:45:45 +02:00
Nico Weber
5565db5aa1 Meta: Pass -serial stdio to qemu on aarch64
With this, `Meta/serenity.sh run aarch64` produces some output on
the terminal :^)
2021-09-26 23:14:01 +00:00
Andreas Kling
43d378940f LibWeb: Add DOMRect and Element.getBoundingClientRect()
This marks our entry into the Web::Geometry namespace, based on the
"Geometry" spec at https://drafts.fxtf.org/geometry/
2021-09-27 01:01:29 +02:00
Luke Wilde
41ae0c0216 LibWeb: Add support for IDL legacy platform objects
A legacy platform object is a non-global platform object that
implements a special operation. A special operation is a getter, setter
and/or deleter. This is particularly used for old collection types,
such as HTMLCollection, NodeList, etc.

This will be used to make these spec-compliant and remove their custom
wrappers. Additionally, it will be used to implement collections that
we don't have yet, such as DOMStringMap.
2021-09-26 18:59:56 +02:00
Idan Horowitz
8dcf4e0346 LibWeb: Return undefined from generated EventHandler setters
Returning an empty value without throwing an exception is no longer
valid.
2021-09-25 23:35:54 +02:00
Sam Atkins
4b554ba92a LibWeb: Clarify StyleValue API with new naming scheme
This does a few things, that are hard to separate. For a while now, it's
been confuzing what `StyleValue::is_foo()` actually means. It sometimes
was used to check the type, and sometimes to see if it could return a
certain value type. The new naming scheme is:

- `is_length()` - is it a LengthStyleValue?
- `as_length()` - casts it to LengthStyleValue
- `has_length()` - can it return a Length?
- `to_length()` - gets the internal value out (eg, Length)

This also means, no more `static_cast<LengthStyleValue const&>(*this)`
stuff when dealing with StyleValues. :^)

Hopefully this will be a bit clearer going forward. There are lots of
places using the original methods, so I'll be going through them to
hopefully catch any issues.
2021-09-24 15:01:43 +02:00
Linus Groh
a1a164e6b8 LibWeb: Return undefined from generated setters, not an empty value
These now crash as VM::call() uses ThrowExceptionOr<T>, which refuses to
hold an empty JS::Value as its non-exception result.
We only need to return an empty value when should_return_empty() says
so for the return value of throw_dom_exception_if_needed().

Co-authored-by: Luke Wilde <lukew@serenityos.org>
2021-09-24 12:57:04 +02:00
Sam Atkins
b927972da7 LibWeb: Add range-checking to property_accepts_value()
For `number` and `integer` types, you can add a range afterwards to add
a range check, using similar syntax to that used in the CSS specs. For
example:

```json
"font-weight": {
  ...
  "valid-types": [
    "number [1,1000]"
  ],
  ...
}
```

This limits any numbers to the range `1 <= n <= 1000`.
2021-09-23 17:47:40 +02:00
Sam Atkins
11d3098f40 LibWeb: Generate property_accepts_value() function :^)
Previously, we have not been validating the values for CSS declarations
inside the Parser. This causes issues, since we should be discarding
invalid style declarations, so that previous ones are used instead. For
example, in this code:

```css
.foo {
  width: 2em;
  width: orange;
}
```

... the `width: orange` declaration overwrites the `width: 2em` one,
even though it is invalid. According to the spec, `width: orange` should
be rejected at parse time, and discarded, leaving `width: 2em` as the
resulting value.

Many properties (mostly shorthands) are parsed specially, and so they
are already rejected if they are invalid. But for simple properties, we
currently accept any value. With `property_accepts_value()`, we can
check if the value is valid in `parse_css_value()`, and reject it if it
is not.
2021-09-23 17:47:40 +02:00
Sam Atkins
a1bc89b814 LibWeb: Generate property_maximum_value_count()
This will allow the CSS Parser to check if a property has been give too
many arguments, and if so, reject it as invalid.
2021-09-23 17:47:40 +02:00
Andreas Kling
ca45d34055 LibWeb: Don't add shorthand CSS properties to cascaded values
We already expand shorthands in the cascade, so there's no need to
preserve them in the output.

This patch reorganizes the CSS::PropertyID enum values so that we can
easily iterate over all shorthand or longhand properties.
2021-09-21 16:54:28 +02:00
Timothy Flynn
8084957e88 CI: Create a secondary ccache for the Clang toolchain build
We bust the prebuilt cache when any header in e.g. LibC changes. Doing a
full toolchain rebuild probably isn't necessary, so this adds a separate
ccache to speed up toolchain builds.
2021-09-21 15:39:17 +03:00
Timothy Flynn
4a4e614387 CI: Set ccache path based on template parameter
Currently, the templated steps in Caches.yml rely on the environment
variable CCACHE_DIR being set to configure the ccache location. To
prepare for multiple ccache paths, do not rely on this environment
variable because only one ccache can use it at a time. Instead, pass
the path into the template as a parameter.
2021-09-21 15:39:17 +03:00
Andreas Kling
7ed49e954f LibWeb: Don't print debug spam when looking up missing initial values
I'm about to look up a lot of missing values, and the spam was getting
out of hand.
2021-09-21 12:33:15 +02:00
Andreas Kling
95559c4277 LibWeb: Implement basic support for MessageChannel and MessagePort
This patch adds a basic initial implementation of these API's.

Since LibWeb currently doesn't support workers, this implementation of
messaging doesn't bother with serializing and deserializing messages.
2021-09-19 22:34:44 +02:00
Andreas Kling
dd29abe4d6 Meta: Bump default VM memory size to 1 GiB 2021-09-19 22:34:43 +02:00
Brian Gianforcaro
aa118642aa Lagom/Fuzzers: Add fuzzer for the LibCrypto PEM parser 2021-09-18 17:15:08 +00:00
Brian Gianforcaro
4f5d71b4e8 Lagom/Fuzzers: Add fuzzer for the LibTLS ASN1 parser 2021-09-18 17:15:08 +00:00
Andrew Kaster
aed56b46d4 Documentation: Update Lagom ReadMe with new fuzzer build instructions 2021-09-18 16:38:59 +03:00
Sam Atkins
6ea9edf84b LibWeb: Generate shorthand initial values after their longhands
When parsing shorthand values, we'd like to use
`property_initial_value()` to get their longhand property values,
instead of hard-coding them as we currently do. That involves
recursively calling that function while the `initial_values` map is
being initialized, which causes problems because the shorthands appear
alphabetically before their longhand components, so the longhands aren't
initialized yet!

The solution here is to perform 2 passes when generating the code,
outputting properties without "longhands" first, and the rest after.
This could potentially cause issues when shorthands have multiple
levels, in particular `border` -> `border-color` -> `border-left-color`.
But, we do not currently define a default value for `border`, and
`border-color` takes only a single value, so it's fine for now. :^)
2021-09-17 23:06:45 +02:00
Andreas Kling
11bb6e045f LibWeb: Add the IdleDeadline interface from the RequestIdleCallback spec 2021-09-17 13:20:18 +02:00
Brian Gianforcaro
5c244a7893 Meta: Set SERENITY_ARCH if it is not set in debug-kernel.sh
This appears to have regressed recently in commit 783a58dbc.
2021-09-17 09:16:40 +00:00
Andrew Kaster
d0506730b8 Meta: Ensure BUILD_LAGOM is set when running serenity.sh test lagom
If the superbuild created the lagom binary directory, it won't set
BUILD_LAGOM=ON in the CMake cache for that binary directory. Insert a
check into build_target() to make sure that if the user explicitly asks
for the lagom target, we have all our ducks in a row.
2021-09-16 15:47:13 +00:00
Andrew Kaster
454a839f49 CI+Meta: Update Sonar Cloud CI job for new SuperBuild configuration
This requires exposing the `configure` step on the `serenity`
ExternalProject in the SuperBuild CMakeLists so that we can continue to
only build the generated sources and not the entire OS.
2021-09-16 15:47:13 +00:00
Andrew Kaster
04d91e90c2 Meta: Fix Lagom RPATH for non-Ubuntu Linux and macOS hosts
Multi-lib distros like Gentoo and Fedora install lagom-core.so into
lagom-install/lib64 rather than lib. Set the install RPATH based on
CMAKE_INSTALL_LIBDIR to avoid the wrong path being set in the binaries.

Also apply macOS specific RPATH rules to fix the build on that platform.
2021-09-16 15:47:13 +00:00
Ben Wiederhake
51b42e0463 Meta: Make QtCreator aware of all CMake files 2021-09-15 20:21:19 +00:00
Andrew Kaster
368d2ace55 Meta: Add FIXME for not setting BUILD_SHARED_LIBS in Lagom build
This is really the business of the consuming project. We will need to
make changes to libjs-test262 and to oss-fuzz to address this properly.
2021-09-15 19:04:52 +04:30
Andrew Kaster
bd7b158c71 Meta: Update serenity.sh for the SuperBuild
Direct build commands to the SuperBuild's binary directory, and
image/run commands to the Serenity binary directory.

As a side benefit, make the lagom target only build Lagom instead of the
entire OS alongside Lagom.
2021-09-15 19:04:52 +04:30
Andrew Kaster
b5c98ede08 Meta: Switch to a SuperBuild that splits host and target builds
Replace the old logic where we would start with a host build, and swap
all the CMake compiler and target variables underneath it to trick
CMake into building for Serenity after we configured and built the Lagom
code generators.

The SuperBuild creates two ExternalProjects, one for Lagom and one for
Serenity. The Serenity project depends on the install stage for the
Lagom build. The SuperBuild also generates a CMakeToolchain file for the
Serenity build to use that replaces the old toolchain file that was only
used for Ports.

To ensure that code generators are rebuilt when core libraries such as
AK and LibCore are modified, developers will need to direct their manual
`ninja` invocations to the SuperBuild's binary directory instead of the
Serenity binary directory.

This commit includes warning coalescing and option style cleanup for the
affected CMakeLists in the Kernel, top level, and runtime support
libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN
with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be
confused by a host clang compiler.
2021-09-15 19:04:52 +04:30
Andrew Kaster
904a268872 Meta: Move all options to targetname_options.cmake files
This common strategy of having a serenity_option() macro defined in
either the Lagom or top level CMakeLists.txt allows us to do two things:

First, we can more clearly see which options are Serenity-specific,
Lagom-specific, or common between the target and host builds.

Second, it enables the upcoming SuperBuild changes to set() the options
in the SuperBuild's CMake cache and forward each target's options to the
corresponding ExternalProject.
2021-09-15 19:04:52 +04:30
Andrew Kaster
6e7cc40b18 Meta: Add Meta/CMake to the CMAKE_MODULE_PATH for Serenity and Lagom
This makes it so we don't need to specify the full path to all the
helper scripts we include() from different places in the codebase and
feels a lot cleaner.
2021-09-15 19:04:52 +04:30
Andrew Kaster
a269a32a17 Meta: Use Lagom:: namespaced names for code generators
This will be required when we switch to a SuperBuild that has Lagom as
a configure time dependency, but is a distinct enough change to be
separate.
2021-09-15 19:04:52 +04:30
Andrew Kaster
fc8d1bf3ce Meta: Allow specifying alternative paths for downloaded Unicode data
This lets us possibly share downloaded artifacts between different
builds without re-downloading them every time you change toolchains.
2021-09-15 19:04:52 +04:30
Andrew Kaster
a6d83e02d2 Meta: Define and use lagom_tool() CMake helper function for all Tools
We'll use this to prevent repeating common tool dependencies. They all
depend on LibCore and AK only. We also want to encapsulate common
install rules for them.
2021-09-15 19:04:52 +04:30