Auto merge of #20879 - tigercosmos:ccc, r=jdm

Update type of custom element constructor

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #20875 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20879)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-05-30 08:09:36 -04:00 committed by GitHub
commit 0356be3021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -5,6 +5,7 @@
use dom::bindings::callback::{CallbackContainer, ExceptionHandling};
use dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::CustomElementRegistryBinding;
use dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementConstructor;
use dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementRegistryMethods;
use dom::bindings::codegen::Bindings::CustomElementRegistryBinding::ElementDefinitionOptions;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
@ -193,7 +194,11 @@ unsafe fn get_callback(
impl CustomElementRegistryMethods for CustomElementRegistry {
#[allow(unsafe_code, unrooted_must_root)]
/// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define>
fn Define(&self, name: DOMString, constructor_: Rc<Function>, options: &ElementDefinitionOptions) -> ErrorResult {
fn Define(
&self, name: DOMString,
constructor_: Rc<CustomElementConstructor>,
options: &ElementDefinitionOptions
) -> ErrorResult {
let cx = self.window.get_cx();
rooted!(in(cx) let constructor = constructor_.callback());
let name = LocalName::from(&*name);
@ -402,7 +407,7 @@ pub struct CustomElementDefinition {
pub local_name: LocalName,
#[ignore_malloc_size_of = "Rc"]
pub constructor: Rc<Function>,
pub constructor: Rc<CustomElementConstructor>,
pub observed_attributes: Vec<DOMString>,
@ -414,7 +419,7 @@ pub struct CustomElementDefinition {
impl CustomElementDefinition {
fn new(name: LocalName,
local_name: LocalName,
constructor: Rc<Function>,
constructor: Rc<CustomElementConstructor>,
observed_attributes: Vec<DOMString>,
callbacks: LifecycleCallbacks)
-> CustomElementDefinition {
@ -543,7 +548,7 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
/// <https://html.spec.whatwg.org/multipage/#concept-upgrade-an-element>
/// Steps 7.1-7.2
#[allow(unsafe_code)]
fn run_upgrade_constructor(constructor: &Rc<Function>, element: &Element) -> ErrorResult {
fn run_upgrade_constructor(constructor: &Rc<CustomElementConstructor>, element: &Element) -> ErrorResult {
let window = window_from_node(element);
let cx = window.get_cx();
rooted!(in(cx) let constructor_val = ObjectValue(constructor.callback()));

View file

@ -6,13 +6,15 @@
[Pref="dom.customelements.enabled"]
interface CustomElementRegistry {
[Throws, CEReactions]
void define(DOMString name, Function constructor_, optional ElementDefinitionOptions options);
void define(DOMString name, CustomElementConstructor constructor_, optional ElementDefinitionOptions options);
any get(DOMString name);
Promise<void> whenDefined(DOMString name);
};
callback CustomElementConstructor = any();
dictionary ElementDefinitionOptions {
DOMString extends;
};