Auto merge of #29805 - jdm:dom-protos, r=mrobinson

Support extending DOM classes in JS

Adds support for determining the correct prototype as part of a `new` call for non-HTML constructors. Support for HTML constructors [was added](https://github.com/servo/servo/blob/master/components/script/dom/bindings/htmlconstructor.rs#L116) as part of the custom element work, but that wasn't enough for extending other DOM objects like `EventTarget`.

This work is based on Gecko's code in https://searchfox.org/mozilla-central/rev/2d678a843ceab81e43f7ffb83212197dc10e944a/dom/bindings/BindingUtils.cpp#3667, and is split into two parts:
1) the actualy new implementation (demonstrating that extending `EventTarget` works as expected)
2) plumbing the new prototype through all of the rest of the DOM object construction code.

This ends up being more complex than the way it's done in Gecko because they have lazy DOM reflectors, so their native DOM objects can be constructed without any knowledge of a JS prototype. Servo's reflectors are eager, however, so we need to propagate prototype information into individual constructors. As a result, this was a tedious set of changes to make.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #29770
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2023-06-01 05:06:09 +02:00 committed by GitHub
commit fd7698c3ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
208 changed files with 2657 additions and 696 deletions

4
Cargo.lock generated
View file

@ -3752,7 +3752,7 @@ dependencies = [
[[package]]
name = "mozjs"
version = "0.14.1"
source = "git+https://github.com/servo/mozjs#d2a3526611cc123139d01f9ac4ff915f805f9e74"
source = "git+https://github.com/servo/mozjs#b9edc816b6662a5986e190cdf53ae295049acb92"
dependencies = [
"cc",
"lazy_static",
@ -3765,7 +3765,7 @@ dependencies = [
[[package]]
name = "mozjs_sys"
version = "0.68.2"
source = "git+https://github.com/servo/mozjs#d2a3526611cc123139d01f9ac4ff915f805f9e74"
source = "git+https://github.com/servo/mozjs#b9edc816b6662a5986e190cdf53ae295049acb92"
dependencies = [
"bindgen",
"cc",