servo: Merge #17224 - WebIDL HTMLConstructor support (from cbrewster:html_constructor); r=jdm
authorConnor Brewster <connor.brewster@eagles.oc.edu>
Thu, 15 Jun 2017 21:47:16 -0700
changeset 1160621 10f024665eb783cbf0ed7337cb69dfb5bda4761d
parent 1160620 28bddcbef8e16ff816993386f4ba5c432b17919b
child 1160622 73a6cce42ce9e405c35c59804978c8337c12728a
push id198555
push userhikezoe@mozilla.com
push dateFri, 16 Jun 2017 11:05:47 +0000
treeherdertry@dbd69dca4a04 [default view] [failures only]
reviewersjdm
milestone56.0a1
servo: Merge #17224 - WebIDL HTMLConstructor support (from cbrewster:html_constructor); r=jdm <!-- Please describe your changes on the following line: --> spec: https://html.spec.whatwg.org/multipage/#htmlconstructor --- <!-- 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 #17194 (github issue number if applicable). <!-- Either: --> - [X] 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: c58bcc23ea5c4b5f83944e111ce9a2d0ec2b5400
servo/Cargo.lock
servo/components/script/dom/bindings/codegen/CodegenRust.py
servo/components/script/dom/bindings/codegen/Configuration.py
servo/components/script/dom/bindings/interface.rs
servo/components/script/dom/create.rs
servo/components/script/dom/customelementregistry.rs
servo/components/script/dom/webidls/HTMLAnchorElement.webidl
servo/components/script/dom/webidls/HTMLAppletElement.webidl
servo/components/script/dom/webidls/HTMLAreaElement.webidl
servo/components/script/dom/webidls/HTMLAudioElement.webidl
servo/components/script/dom/webidls/HTMLBRElement.webidl
servo/components/script/dom/webidls/HTMLBaseElement.webidl
servo/components/script/dom/webidls/HTMLBodyElement.webidl
servo/components/script/dom/webidls/HTMLButtonElement.webidl
servo/components/script/dom/webidls/HTMLCanvasElement.webidl
servo/components/script/dom/webidls/HTMLDListElement.webidl
servo/components/script/dom/webidls/HTMLDataElement.webidl
servo/components/script/dom/webidls/HTMLDataListElement.webidl
servo/components/script/dom/webidls/HTMLDetailsElement.webidl
servo/components/script/dom/webidls/HTMLDialogElement.webidl
servo/components/script/dom/webidls/HTMLDirectoryElement.webidl
servo/components/script/dom/webidls/HTMLDivElement.webidl
servo/components/script/dom/webidls/HTMLElement.webidl
servo/components/script/dom/webidls/HTMLEmbedElement.webidl
servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
servo/components/script/dom/webidls/HTMLFontElement.webidl
servo/components/script/dom/webidls/HTMLFormElement.webidl
servo/components/script/dom/webidls/HTMLFrameElement.webidl
servo/components/script/dom/webidls/HTMLFrameSetElement.webidl
servo/components/script/dom/webidls/HTMLHRElement.webidl
servo/components/script/dom/webidls/HTMLHeadElement.webidl
servo/components/script/dom/webidls/HTMLHeadingElement.webidl
servo/components/script/dom/webidls/HTMLHtmlElement.webidl
servo/components/script/dom/webidls/HTMLIFrameElement.webidl
servo/components/script/dom/webidls/HTMLImageElement.webidl
servo/components/script/dom/webidls/HTMLInputElement.webidl
servo/components/script/dom/webidls/HTMLLIElement.webidl
servo/components/script/dom/webidls/HTMLLabelElement.webidl
servo/components/script/dom/webidls/HTMLLegendElement.webidl
servo/components/script/dom/webidls/HTMLLinkElement.webidl
servo/components/script/dom/webidls/HTMLMapElement.webidl
servo/components/script/dom/webidls/HTMLMetaElement.webidl
servo/components/script/dom/webidls/HTMLMeterElement.webidl
servo/components/script/dom/webidls/HTMLModElement.webidl
servo/components/script/dom/webidls/HTMLOListElement.webidl
servo/components/script/dom/webidls/HTMLObjectElement.webidl
servo/components/script/dom/webidls/HTMLOptGroupElement.webidl
servo/components/script/dom/webidls/HTMLOptionElement.webidl
servo/components/script/dom/webidls/HTMLOutputElement.webidl
servo/components/script/dom/webidls/HTMLParagraphElement.webidl
servo/components/script/dom/webidls/HTMLParamElement.webidl
servo/components/script/dom/webidls/HTMLPreElement.webidl
servo/components/script/dom/webidls/HTMLProgressElement.webidl
servo/components/script/dom/webidls/HTMLQuoteElement.webidl
servo/components/script/dom/webidls/HTMLScriptElement.webidl
servo/components/script/dom/webidls/HTMLSelectElement.webidl
servo/components/script/dom/webidls/HTMLSourceElement.webidl
servo/components/script/dom/webidls/HTMLSpanElement.webidl
servo/components/script/dom/webidls/HTMLStyleElement.webidl
servo/components/script/dom/webidls/HTMLTableCaptionElement.webidl
servo/components/script/dom/webidls/HTMLTableCellElement.webidl
servo/components/script/dom/webidls/HTMLTableColElement.webidl
servo/components/script/dom/webidls/HTMLTableDataCellElement.webidl
servo/components/script/dom/webidls/HTMLTableElement.webidl
servo/components/script/dom/webidls/HTMLTableHeaderCellElement.webidl
servo/components/script/dom/webidls/HTMLTableRowElement.webidl
servo/components/script/dom/webidls/HTMLTableSectionElement.webidl
servo/components/script/dom/webidls/HTMLTemplateElement.webidl
servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
servo/components/script/dom/webidls/HTMLTimeElement.webidl
servo/components/script/dom/webidls/HTMLTitleElement.webidl
servo/components/script/dom/webidls/HTMLTrackElement.webidl
servo/components/script/dom/webidls/HTMLUListElement.webidl
servo/components/script/dom/webidls/HTMLVideoElement.webidl
--- a/servo/Cargo.lock
+++ b/servo/Cargo.lock
@@ -1367,17 +1367,17 @@ source = "registry+https://github.com/ru
 dependencies = [
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "js"
 version = "0.1.6"
-source = "git+https://github.com/servo/rust-mozjs#bc7af508c194d56eef3a2c52772ae261b9a1facb"
+source = "git+https://github.com/servo/rust-mozjs#3de4ff3d52361a47a17e3b4fcb02c779b99d93d4"
 dependencies = [
  "cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
  "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/servo/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2858,17 +2858,17 @@ create_noncallback_interface_object(cx,
                                     %(static_methods)s,
                                     %(static_attrs)s,
                                     %(consts)s,
                                     prototype.handle(),
                                     %(name)s,
                                     %(length)s,
                                     interface.handle_mut());
 assert!(!interface.is_null());""" % properties))
-            if self.descriptor.hasDescendants():
+            if self.descriptor.shouldCacheConstructor():
                 code.append(CGGeneric("""\
 assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
 (*cache)[PrototypeList::Constructor::%(id)s as usize] = interface.get();
 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize),
                               ptr::null_mut(),
                               interface.get());
 """ % properties))
 
@@ -5296,21 +5296,89 @@ class CGClassConstructHook(CGAbstractExt
         self.exposureSet = descriptor.interface.exposureSet
 
     def definition_body(self):
         preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"""
         if len(self.exposureSet) == 1:
             preamble += "let global = Root::downcast::<dom::types::%s>(global).unwrap();\n" % list(self.exposureSet)[0]
         preamble += """let args = CallArgs::from_vp(vp, argc);\n"""
         preamble = CGGeneric(preamble)
-        name = self.constructor.identifier.name
-        nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
-        callGenerator = CGMethodCall(["&global"], nativeName, True,
-                                     self.descriptor, self.constructor)
-        return CGList([preamble, callGenerator])
+        if self.constructor.isHTMLConstructor():
+            signatures = self.constructor.signatures()
+            assert len(signatures) == 1
+            constructorCall = CGGeneric("""\
+// Step 2 https://html.spec.whatwg.org/multipage/#htmlconstructor
+// The custom element definition cannot use an element interface as its constructor
+
+// The new_target might be a cross-compartment wrapper. Get the underlying object
+// so we can do the spec's object-identity checks.
+rooted!(in(cx) let new_target = UnwrapObject(args.new_target().to_object(), 1));
+if new_target.is_null() {
+    throw_dom_exception(cx, global.upcast::<GlobalScope>(), Error::Type("new.target is null".to_owned()));
+    return false;
+}
+
+if args.callee() == new_target.get() {
+    throw_dom_exception(cx, global.upcast::<GlobalScope>(),
+        Error::Type("new.target must not be the active function object".to_owned()));
+    return false;
+}
+
+// Step 6
+rooted!(in(cx) let mut prototype = ptr::null_mut());
+{
+    rooted!(in(cx) let mut proto_val = UndefinedValue());
+    let _ac = JSAutoCompartment::new(cx, new_target.get());
+    if !JS_GetProperty(cx, new_target.handle(), b"prototype\\0".as_ptr() as *const _, proto_val.handle_mut()) {
+        return false;
+    }
+
+    if !proto_val.is_object() {
+        // Step 7 of https://html.spec.whatwg.org/multipage/#htmlconstructor.
+        // This fallback behavior is designed to match analogous behavior for the
+        // JavaScript built-ins. So we enter the compartment of our underlying
+        // newTarget object and fall back to the prototype object from that global.
+        // XXX The spec says to use GetFunctionRealm(), which is not actually
+        // the same thing as what we have here (e.g. in the case of scripted callable proxies
+        // whose target is not same-compartment with the proxy, or bound functions, etc).
+        // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
+
+        rooted!(in(cx) let global_object = CurrentGlobalOrNull(cx));
+        GetProtoObject(cx, global_object.handle(), prototype.handle_mut());
+    } else {
+        // Step 6
+        prototype.set(proto_val.to_object());
+    };
+}
+
+// Wrap prototype in this context since it is from the newTarget compartment
+if !JS_WrapObject(cx, prototype.handle_mut()) {
+    return false;
+}
+
+let result: Result<Root<%s>, Error> = html_constructor(&global, &args);
+let result = match result {
+    Ok(result) => result,
+    Err(e) => {
+        throw_dom_exception(cx, global.upcast::<GlobalScope>(), e);
+        return false;
+    },
+};
+
+JS_SetPrototype(cx, result.reflector().get_jsobject(), prototype.handle());
+
+(result).to_jsval(cx, args.rval());
+return true;
+""" % self.descriptor.name)
+        else:
+            name = self.constructor.identifier.name
+            nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
+            constructorCall = CGMethodCall(["&global"], nativeName, True,
+                                           self.descriptor, self.constructor)
+        return CGList([preamble, constructorCall])
 
 
 class CGClassFinalizeHook(CGAbstractClassHook):
     """
     A hook for finalize, used to release our native object.
     """
     def __init__(self, descriptor):
         args = [Argument('*mut JSFreeOp', '_fop'), Argument('*mut JSObject', 'obj')]
@@ -5512,19 +5580,21 @@ def generate_imports(config, cgthings, d
         'js::jsapi::JS_HasPropertyById',
         'js::jsapi::JS_InitializePropertiesFromCompatibleNativeObject',
         'js::jsapi::JS_NewObject',
         'js::jsapi::JS_NewObjectWithGivenProto',
         'js::jsapi::JS_NewObjectWithoutMetadata',
         'js::jsapi::JS_ObjectIsDate',
         'js::jsapi::JS_SetImmutablePrototype',
         'js::jsapi::JS_SetProperty',
+        'js::jsapi::JS_SetPrototype',
         'js::jsapi::JS_SetReservedSlot',
         'js::jsapi::JS_SplicePrototype',
         'js::jsapi::JS_WrapValue',
+        'js::jsapi::JS_WrapObject',
         'js::jsapi::MutableHandle',
         'js::jsapi::MutableHandleObject',
         'js::jsapi::MutableHandleValue',
         'js::jsapi::ObjectOpResult',
         'js::jsapi::PropertyDescriptor',
         'js::jsapi::RootedId',
         'js::jsapi::RootedObject',
         'js::jsapi::RootedString',
@@ -5542,38 +5612,40 @@ def generate_imports(config, cgthings, d
         'js::glue::CallJitSetterOp',
         'js::glue::CreateProxyHandler',
         'js::glue::GetProxyPrivate',
         'js::glue::NewProxyObject',
         'js::glue::ProxyTraps',
         'js::glue::RUST_JSID_IS_STRING',
         'js::glue::RUST_SYMBOL_TO_JSID',
         'js::glue::int_to_jsid',
+        'js::glue::UnwrapObject',
         'js::panic::maybe_resume_unwind',
         'js::panic::wrap_panic',
         'js::rust::GCMethods',
         'js::rust::define_methods',
         'js::rust::define_properties',
         'js::rust::get_object_class',
         'dom',
         'dom::bindings',
         'dom::bindings::codegen::InterfaceObjectMap',
         'dom::bindings::constant::ConstantSpec',
         'dom::bindings::constant::ConstantVal',
         'dom::bindings::interface::ConstructorClassHook',
         'dom::bindings::interface::InterfaceConstructorBehavior',
         'dom::bindings::interface::NonCallbackInterfaceObjectClass',
+        'dom::bindings::interface::create_global_object',
         'dom::bindings::interface::create_callback_interface_object',
-        'dom::bindings::interface::create_global_object',
         'dom::bindings::interface::create_interface_prototype_object',
         'dom::bindings::interface::create_named_constructors',
         'dom::bindings::interface::create_noncallback_interface_object',
         'dom::bindings::interface::define_guarded_constants',
         'dom::bindings::interface::define_guarded_methods',
         'dom::bindings::interface::define_guarded_properties',
+        'dom::bindings::interface::html_constructor',
         'dom::bindings::interface::is_exposed_in',
         'dom::bindings::iterable::Iterable',
         'dom::bindings::iterable::IteratorType',
         'dom::bindings::js::JS',
         'dom::bindings::js::Root',
         'dom::bindings::js::RootedReference',
         'dom::bindings::namespace::NamespaceObjectClass',
         'dom::bindings::namespace::create_namespace_object',
--- a/servo/components/script/dom/bindings/codegen/Configuration.py
+++ b/servo/components/script/dom/bindings/codegen/Configuration.py
@@ -393,17 +393,21 @@ class Descriptor(DescriptorProvider):
     def hasDescendants(self):
         return (self.interface.getUserData("hasConcreteDescendant", False) or
                 self.interface.getUserData("hasProxyDescendant", False))
 
     def shouldHaveGetConstructorObjectMethod(self):
         assert self.interface.hasInterfaceObject()
         if self.interface.getExtendedAttribute("Inline"):
             return False
-        return self.interface.isCallback() or self.interface.isNamespace() or self.hasDescendants()
+        return (self.interface.isCallback() or self.interface.isNamespace() or
+                self.hasDescendants() or self.interface.getExtendedAttribute("HTMLConstructor"))
+
+    def shouldCacheConstructor(self):
+        return self.hasDescendants() or self.interface.getExtendedAttribute("HTMLConstructor")
 
     def isExposedConditionally(self):
         return self.interface.isExposedConditionally()
 
     def isGlobal(self):
         """
         Returns true if this is the primary interface for a global object
         of some sort.
--- a/servo/components/script/dom/bindings/interface.rs
+++ b/servo/components/script/dom/bindings/interface.rs
@@ -1,25 +1,100 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! Machinery to initialise interface prototype objects and interface objects.
 
+use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding;
+use dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
+use dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
+use dom::bindings::codegen::Bindings::HTMLBRElementBinding;
+use dom::bindings::codegen::Bindings::HTMLBaseElementBinding;
+use dom::bindings::codegen::Bindings::HTMLBodyElementBinding;
+use dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
+use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDListElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDataElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDataListElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDialogElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDirectoryElementBinding;
+use dom::bindings::codegen::Bindings::HTMLDivElementBinding;
+use dom::bindings::codegen::Bindings::HTMLElementBinding;
+use dom::bindings::codegen::Bindings::HTMLEmbedElementBinding;
+use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
+use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
+use dom::bindings::codegen::Bindings::HTMLFormElementBinding;
+use dom::bindings::codegen::Bindings::HTMLFrameElementBinding;
+use dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding;
+use dom::bindings::codegen::Bindings::HTMLHRElementBinding;
+use dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
+use dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
+use dom::bindings::codegen::Bindings::HTMLHtmlElementBinding;
+use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
+use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
+use dom::bindings::codegen::Bindings::HTMLInputElementBinding;
+use dom::bindings::codegen::Bindings::HTMLLIElementBinding;
+use dom::bindings::codegen::Bindings::HTMLLabelElementBinding;
+use dom::bindings::codegen::Bindings::HTMLLegendElementBinding;
+use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
+use dom::bindings::codegen::Bindings::HTMLMapElementBinding;
+use dom::bindings::codegen::Bindings::HTMLMetaElementBinding;
+use dom::bindings::codegen::Bindings::HTMLMeterElementBinding;
+use dom::bindings::codegen::Bindings::HTMLModElementBinding;
+use dom::bindings::codegen::Bindings::HTMLOListElementBinding;
+use dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
+use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
+use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
+use dom::bindings::codegen::Bindings::HTMLOutputElementBinding;
+use dom::bindings::codegen::Bindings::HTMLParagraphElementBinding;
+use dom::bindings::codegen::Bindings::HTMLParamElementBinding;
+use dom::bindings::codegen::Bindings::HTMLPreElementBinding;
+use dom::bindings::codegen::Bindings::HTMLProgressElementBinding;
+use dom::bindings::codegen::Bindings::HTMLQuoteElementBinding;
+use dom::bindings::codegen::Bindings::HTMLScriptElementBinding;
+use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
+use dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
+use dom::bindings::codegen::Bindings::HTMLSpanElementBinding;
+use dom::bindings::codegen::Bindings::HTMLStyleElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableColElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableHeaderCellElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTimeElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTrackElementBinding;
+use dom::bindings::codegen::Bindings::HTMLUListElementBinding;
+use dom::bindings::codegen::Bindings::HTMLVideoElementBinding;
+use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
 use dom::bindings::codegen::InterfaceObjectMap::Globals;
 use dom::bindings::codegen::PrototypeList;
 use dom::bindings::constant::{ConstantSpec, define_constants};
-use dom::bindings::conversions::{DOM_OBJECT_SLOT, get_dom_class};
+use dom::bindings::conversions::{DOM_OBJECT_SLOT, DerivedFrom, get_dom_class};
+use dom::bindings::error::{Error, Fallible};
 use dom::bindings::guard::Guard;
+use dom::bindings::js::Root;
 use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
+use dom::create::create_native_html_element;
+use dom::element::{Element, ElementCreator};
+use dom::htmlelement::HTMLElement;
+use dom::window::Window;
+use html5ever::LocalName;
+use html5ever::interface::QualName;
 use js::error::throw_type_error;
-use js::glue::{RUST_SYMBOL_TO_JSID, UncheckedUnwrapObject};
-use js::jsapi::{Class, ClassOps, CompartmentOptions, GetGlobalForObjectCrossCompartment};
-use js::jsapi::{GetWellKnownSymbol, HandleObject, HandleValue, JSAutoCompartment};
-use js::jsapi::{JSClass, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject};
+use js::glue::{RUST_SYMBOL_TO_JSID, UncheckedUnwrapObject, UnwrapObject};
+use js::jsapi::{CallArgs, Class, ClassOps, CompartmentOptions, CurrentGlobalOrNull};
+use js::jsapi::{GetGlobalForObjectCrossCompartment, GetWellKnownSymbol, HandleObject, HandleValue};
+use js::jsapi::{JSAutoCompartment, JSClass, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject};
 use js::jsapi::{JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING};
 use js::jsapi::{JSPropertySpec, JSString, JSTracer, JSVersion, JS_AtomizeAndPinString};
 use js::jsapi::{JS_DefineProperty, JS_DefineProperty1, JS_DefineProperty2};
 use js::jsapi::{JS_DefineProperty4, JS_DefinePropertyById3, JS_FireOnNewGlobalObject};
 use js::jsapi::{JS_GetFunctionObject, JS_GetPrototype};
 use js::jsapi::{JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewGlobalObject};
 use js::jsapi::{JS_NewObject, JS_NewObjectWithUniqueType, JS_NewPlainObject};
 use js::jsapi::{JS_NewStringCopyN, JS_SetReservedSlot, MutableHandleObject};
@@ -153,16 +228,83 @@ pub unsafe fn create_global_object(
     JS_SetReservedSlot(rval.get(),
                        DOM_PROTOTYPE_SLOT,
                        PrivateValue(Box::into_raw(proto_array) as *const libc::c_void));
 
     let _ac = JSAutoCompartment::new(cx, rval.get());
     JS_FireOnNewGlobalObject(cx, rval.handle());
 }
 
+// https://html.spec.whatwg.org/multipage/#htmlconstructor
+pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fallible<Root<T>>
+                                  where T: DerivedFrom<Element> {
+    let document = window.Document();
+
+    // Step 1
+    let registry = window.CustomElements();
+
+    // Step 2 is checked in the generated caller code
+
+    // Step 3
+    rooted!(in(window.get_cx()) let new_target = call_args.new_target().to_object());
+    let definition = match registry.lookup_definition_by_constructor(new_target.handle()) {
+        Some(definition) => definition,
+        None => return Err(Error::Type("No custom element definition found for new.target".to_owned())),
+    };
+
+    rooted!(in(window.get_cx()) let callee = UnwrapObject(call_args.callee(), 1));
+    if callee.is_null() {
+        return Err(Error::Security);
+    }
+
+    {
+        let _ac = JSAutoCompartment::new(window.get_cx(), callee.get());
+        rooted!(in(window.get_cx()) let mut constructor = ptr::null_mut());
+        rooted!(in(window.get_cx()) let global_object = CurrentGlobalOrNull(window.get_cx()));
+
+        if definition.is_autonomous() {
+            // Step 4
+            // Since this element is autonomous, its active function object must be the HTMLElement
+
+            // Retrieve the constructor object for HTMLElement
+            HTMLElementBinding::GetConstructorObject(window.get_cx(), global_object.handle(), constructor.handle_mut());
+
+        } else {
+            // Step 5
+            get_constructor_object_from_local_name(definition.local_name.clone(),
+                                                   window.get_cx(),
+                                                   global_object.handle(),
+                                                   constructor.handle_mut());
+        }
+        // Callee must be the same as the element interface's constructor object.
+        if constructor.get() != callee.get() {
+            return Err(Error::Type("Custom element does not extend the proper interface".to_owned()));
+        }
+    }
+
+    // Step 8.1
+    let name = QualName::new(None, ns!(html), definition.local_name.clone());
+    let element = if definition.is_autonomous() {
+        Root::upcast(HTMLElement::new(name.local, None, &*document))
+    } else {
+        create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated)
+    };
+
+    // Step 8.2 is performed in the generated caller code.
+
+    // TODO: Step 8.3 - 8.4
+    // Set the element's custom element state and definition.
+
+    // Step 8.5
+    Root::downcast(element).ok_or(Error::InvalidState)
+
+    // TODO: Steps 9-13
+    // Custom element upgrades are not implemented yet, so these steps are unnecessary.
+}
+
 /// Create and define the interface object of a callback interface.
 pub unsafe fn create_callback_interface_object(
         cx: *mut JSContext,
         global: HandleObject,
         constants: &[Guard<&[ConstantSpec]>],
         name: &[u8],
         rval: MutableHandleObject) {
     assert!(!constants.is_empty());
@@ -469,8 +611,151 @@ unsafe extern "C" fn invalid_constructor
 unsafe extern "C" fn non_new_constructor(
         cx: *mut JSContext,
         _argc: libc::c_uint,
         _vp: *mut JSVal)
         -> bool {
     throw_type_error(cx, "This constructor needs to be called with `new`.");
     false
 }
+
+/// Returns the constructor object for the element associated with the given local name.
+/// This list should only include elements marked with the [HTMLConstructor] extended attribute.
+pub fn get_constructor_object_from_local_name(name: LocalName,
+                                              cx: *mut JSContext,
+                                              global: HandleObject,
+                                              rval: MutableHandleObject)
+                                              -> bool {
+    macro_rules! get_constructor(
+        ($binding:ident) => ({
+            unsafe { $binding::GetConstructorObject(cx, global, rval); }
+            true
+        })
+    );
+
+    match name {
+        local_name!("a")          => get_constructor!(HTMLAnchorElementBinding),
+        local_name!("abbr")       => get_constructor!(HTMLElementBinding),
+        local_name!("acronym")    => get_constructor!(HTMLElementBinding),
+        local_name!("address")    => get_constructor!(HTMLElementBinding),
+        local_name!("area")       => get_constructor!(HTMLAreaElementBinding),
+        local_name!("article")    => get_constructor!(HTMLElementBinding),
+        local_name!("aside")      => get_constructor!(HTMLElementBinding),
+        local_name!("audio")      => get_constructor!(HTMLAudioElementBinding),
+        local_name!("b")          => get_constructor!(HTMLElementBinding),
+        local_name!("base")       => get_constructor!(HTMLBaseElementBinding),
+        local_name!("bdi")        => get_constructor!(HTMLElementBinding),
+        local_name!("bdo")        => get_constructor!(HTMLElementBinding),
+        local_name!("big")        => get_constructor!(HTMLElementBinding),
+        local_name!("blockquote") => get_constructor!(HTMLQuoteElementBinding),
+        local_name!("body")       => get_constructor!(HTMLBodyElementBinding),
+        local_name!("br")         => get_constructor!(HTMLBRElementBinding),
+        local_name!("button")     => get_constructor!(HTMLButtonElementBinding),
+        local_name!("canvas")     => get_constructor!(HTMLCanvasElementBinding),
+        local_name!("caption")    => get_constructor!(HTMLTableCaptionElementBinding),
+        local_name!("center")     => get_constructor!(HTMLElementBinding),
+        local_name!("cite")       => get_constructor!(HTMLElementBinding),
+        local_name!("code")       => get_constructor!(HTMLElementBinding),
+        local_name!("col")        => get_constructor!(HTMLTableColElementBinding),
+        local_name!("colgroup")   => get_constructor!(HTMLTableColElementBinding),
+        local_name!("data")       => get_constructor!(HTMLDataElementBinding),
+        local_name!("datalist")   => get_constructor!(HTMLDataListElementBinding),
+        local_name!("dd")         => get_constructor!(HTMLElementBinding),
+        local_name!("del")        => get_constructor!(HTMLModElementBinding),
+        local_name!("details")    => get_constructor!(HTMLDetailsElementBinding),
+        local_name!("dfn")        => get_constructor!(HTMLElementBinding),
+        local_name!("dialog")     => get_constructor!(HTMLDialogElementBinding),
+        local_name!("dir")        => get_constructor!(HTMLDirectoryElementBinding),
+        local_name!("div")        => get_constructor!(HTMLDivElementBinding),
+        local_name!("dl")         => get_constructor!(HTMLDListElementBinding),
+        local_name!("dt")         => get_constructor!(HTMLElementBinding),
+        local_name!("em")         => get_constructor!(HTMLElementBinding),
+        local_name!("embed")      => get_constructor!(HTMLEmbedElementBinding),
+        local_name!("fieldset")   => get_constructor!(HTMLFieldSetElementBinding),
+        local_name!("figcaption") => get_constructor!(HTMLElementBinding),
+        local_name!("figure")     => get_constructor!(HTMLElementBinding),
+        local_name!("font")       => get_constructor!(HTMLFontElementBinding),
+        local_name!("footer")     => get_constructor!(HTMLElementBinding),
+        local_name!("form")       => get_constructor!(HTMLFormElementBinding),
+        local_name!("frame")      => get_constructor!(HTMLFrameElementBinding),
+        local_name!("frameset")   => get_constructor!(HTMLFrameSetElementBinding),
+        local_name!("h1")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("h2")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("h3")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("h4")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("h5")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("h6")         => get_constructor!(HTMLHeadingElementBinding),
+        local_name!("head")       => get_constructor!(HTMLHeadElementBinding),
+        local_name!("header")     => get_constructor!(HTMLElementBinding),
+        local_name!("hgroup")     => get_constructor!(HTMLElementBinding),
+        local_name!("hr")         => get_constructor!(HTMLHRElementBinding),
+        local_name!("html")       => get_constructor!(HTMLHtmlElementBinding),
+        local_name!("i")          => get_constructor!(HTMLElementBinding),
+        local_name!("iframe")     => get_constructor!(HTMLIFrameElementBinding),
+        local_name!("img")        => get_constructor!(HTMLImageElementBinding),
+        local_name!("input")      => get_constructor!(HTMLInputElementBinding),
+        local_name!("ins")        => get_constructor!(HTMLModElementBinding),
+        local_name!("kbd")        => get_constructor!(HTMLElementBinding),
+        local_name!("label")      => get_constructor!(HTMLLabelElementBinding),
+        local_name!("legend")     => get_constructor!(HTMLLegendElementBinding),
+        local_name!("li")         => get_constructor!(HTMLLIElementBinding),
+        local_name!("link")       => get_constructor!(HTMLLinkElementBinding),
+        local_name!("listing")    => get_constructor!(HTMLPreElementBinding),
+        local_name!("main")       => get_constructor!(HTMLElementBinding),
+        local_name!("map")        => get_constructor!(HTMLMapElementBinding),
+        local_name!("mark")       => get_constructor!(HTMLElementBinding),
+        local_name!("marquee")    => get_constructor!(HTMLElementBinding),
+        local_name!("meta")       => get_constructor!(HTMLMetaElementBinding),
+        local_name!("meter")      => get_constructor!(HTMLMeterElementBinding),
+        local_name!("nav")        => get_constructor!(HTMLElementBinding),
+        local_name!("nobr")       => get_constructor!(HTMLElementBinding),
+        local_name!("noframes")   => get_constructor!(HTMLElementBinding),
+        local_name!("noscript")   => get_constructor!(HTMLElementBinding),
+        local_name!("object")     => get_constructor!(HTMLObjectElementBinding),
+        local_name!("ol")         => get_constructor!(HTMLOListElementBinding),
+        local_name!("optgroup")   => get_constructor!(HTMLOptGroupElementBinding),
+        local_name!("option")     => get_constructor!(HTMLOptionElementBinding),
+        local_name!("output")     => get_constructor!(HTMLOutputElementBinding),
+        local_name!("p")          => get_constructor!(HTMLParagraphElementBinding),
+        local_name!("param")      => get_constructor!(HTMLParamElementBinding),
+        local_name!("plaintext")  => get_constructor!(HTMLPreElementBinding),
+        local_name!("pre")        => get_constructor!(HTMLPreElementBinding),
+        local_name!("progress")   => get_constructor!(HTMLProgressElementBinding),
+        local_name!("q")          => get_constructor!(HTMLQuoteElementBinding),
+        local_name!("rp")         => get_constructor!(HTMLElementBinding),
+        local_name!("rt")         => get_constructor!(HTMLElementBinding),
+        local_name!("ruby")       => get_constructor!(HTMLElementBinding),
+        local_name!("s")          => get_constructor!(HTMLElementBinding),
+        local_name!("samp")       => get_constructor!(HTMLElementBinding),
+        local_name!("script")     => get_constructor!(HTMLScriptElementBinding),
+        local_name!("section")    => get_constructor!(HTMLElementBinding),
+        local_name!("select")     => get_constructor!(HTMLSelectElementBinding),
+        local_name!("small")      => get_constructor!(HTMLElementBinding),
+        local_name!("source")     => get_constructor!(HTMLSourceElementBinding),
+        local_name!("span")       => get_constructor!(HTMLSpanElementBinding),
+        local_name!("strike")     => get_constructor!(HTMLElementBinding),
+        local_name!("strong")     => get_constructor!(HTMLElementBinding),
+        local_name!("style")      => get_constructor!(HTMLStyleElementBinding),
+        local_name!("sub")        => get_constructor!(HTMLElementBinding),
+        local_name!("summary")    => get_constructor!(HTMLElementBinding),
+        local_name!("sup")        => get_constructor!(HTMLElementBinding),
+        local_name!("table")      => get_constructor!(HTMLTableElementBinding),
+        local_name!("tbody")      => get_constructor!(HTMLTableSectionElementBinding),
+        local_name!("td")         => get_constructor!(HTMLTableDataCellElementBinding),
+        local_name!("template")   => get_constructor!(HTMLTemplateElementBinding),
+        local_name!("textarea")   => get_constructor!(HTMLTextAreaElementBinding),
+        local_name!("tfoot")      => get_constructor!(HTMLTableSectionElementBinding),
+        local_name!("th")         => get_constructor!(HTMLTableHeaderCellElementBinding),
+        local_name!("thead")      => get_constructor!(HTMLTableSectionElementBinding),
+        local_name!("time")       => get_constructor!(HTMLTimeElementBinding),
+        local_name!("title")      => get_constructor!(HTMLTitleElementBinding),
+        local_name!("tr")         => get_constructor!(HTMLTableRowElementBinding),
+        local_name!("tt")         => get_constructor!(HTMLElementBinding),
+        local_name!("track")      => get_constructor!(HTMLTrackElementBinding),
+        local_name!("u")          => get_constructor!(HTMLElementBinding),
+        local_name!("ul")         => get_constructor!(HTMLUListElementBinding),
+        local_name!("var")        => get_constructor!(HTMLElementBinding),
+        local_name!("video")      => get_constructor!(HTMLVideoElementBinding),
+        local_name!("wbr")        => get_constructor!(HTMLElementBinding),
+        local_name!("xmp")        => get_constructor!(HTMLPreElementBinding),
+        _                         => false,
+    }
+}
--- a/servo/components/script/dom/create.rs
+++ b/servo/components/script/dom/create.rs
@@ -102,20 +102,28 @@ fn create_svg_element(name: QualName,
 
     match name.local {
         local_name!("svg")        => make!(SVGSVGElement),
         _                   => Element::new(name.local, name.ns, prefix, document),
     }
 }
 
 fn create_html_element(name: QualName,
-                      prefix: Option<Prefix>,
-                      document: &Document,
-                      creator: ElementCreator)
-                      -> Root<Element> {
+                       prefix: Option<Prefix>,
+                       document: &Document,
+                       creator: ElementCreator)
+                       -> Root<Element> {
+    create_native_html_element(name, prefix, document, creator)
+}
+
+pub fn create_native_html_element(name: QualName,
+                                  prefix: Option<Prefix>,
+                                  document: &Document,
+                                  creator: ElementCreator)
+                                  -> Root<Element> {
     assert!(name.ns == ns!(html));
 
     macro_rules! make(
         ($ctor:ident) => ({
             let obj = $ctor::new(name.local, prefix, document);
             Root::upcast(obj)
         });
         ($ctor:ident, $($arg:expr),+) => ({
--- a/servo/components/script/dom/customelementregistry.rs
+++ b/servo/components/script/dom/customelementregistry.rs
@@ -13,36 +13,38 @@ use dom::bindings::inheritance::Castable
 use dom::bindings::js::{JS, Root};
 use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
 use dom::bindings::str::DOMString;
 use dom::domexception::{DOMErrorName, DOMException};
 use dom::globalscope::GlobalScope;
 use dom::promise::Promise;
 use dom::window::Window;
 use dom_struct::dom_struct;
+use html5ever::LocalName;
 use js::conversions::ToJSValConvertible;
 use js::jsapi::{IsConstructor, HandleObject, JS_GetProperty, JSAutoCompartment, JSContext};
 use js::jsval::{JSVal, UndefinedValue};
 use std::cell::Cell;
 use std::collections::HashMap;
 use std::rc::Rc;
 
-// https://html.spec.whatwg.org/multipage/#customelementregistry
+/// https://html.spec.whatwg.org/multipage/#customelementregistry
 #[dom_struct]
 pub struct CustomElementRegistry {
     reflector_: Reflector,
 
     window: JS<Window>,
 
     #[ignore_heap_size_of = "Rc"]
     when_defined: DOMRefCell<HashMap<DOMString, Rc<Promise>>>,
 
     element_definition_is_running: Cell<bool>,
 
-    definitions: DOMRefCell<HashMap<DOMString, CustomElementDefinition>>,
+    #[ignore_heap_size_of = "Rc"]
+    definitions: DOMRefCell<HashMap<DOMString, Rc<CustomElementDefinition>>>,
 }
 
 impl CustomElementRegistry {
     fn new_inherited(window: &Window) -> CustomElementRegistry {
         CustomElementRegistry {
             reflector_: Reflector::new(),
             window: JS::from_ref(window),
             when_defined: DOMRefCell::new(HashMap::new()),
@@ -52,24 +54,30 @@ impl CustomElementRegistry {
     }
 
     pub fn new(window: &Window) -> Root<CustomElementRegistry> {
         reflect_dom_object(box CustomElementRegistry::new_inherited(window),
                            window,
                            CustomElementRegistryBinding::Wrap)
     }
 
-    // Cleans up any active promises
-    // https://github.com/servo/servo/issues/15318
+    /// Cleans up any active promises
+    /// https://github.com/servo/servo/issues/15318
     pub fn teardown(&self) {
         self.when_defined.borrow_mut().clear()
     }
 
-    // https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define
-    // Steps 10.1, 10.2
+    pub fn lookup_definition_by_constructor(&self, constructor: HandleObject) -> Option<Rc<CustomElementDefinition>> {
+        self.definitions.borrow().values().find(|definition| {
+            definition.constructor.callback() == constructor.get()
+        }).cloned()
+    }
+
+    /// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define
+    /// Steps 10.1, 10.2
     #[allow(unsafe_code)]
     fn check_prototype(&self, constructor: HandleObject) -> ErrorResult {
         let global_scope = self.window.upcast::<GlobalScope>();
         rooted!(in(global_scope.get_cx()) let mut prototype = UndefinedValue());
         unsafe {
             // Step 10.1
             if !JS_GetProperty(global_scope.get_cx(),
                                constructor,
@@ -84,17 +92,17 @@ impl CustomElementRegistry {
             }
         }
         Ok(())
     }
 }
 
 impl CustomElementRegistryMethods for CustomElementRegistry {
     #[allow(unsafe_code, unrooted_must_root)]
-    // https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define
+    /// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define
     fn Define(&self, name: DOMString, constructor_: Rc<Function>, options: &ElementDefinitionOptions) -> ErrorResult {
         let global_scope = self.window.upcast::<GlobalScope>();
         rooted!(in(global_scope.get_cx()) let constructor = constructor_.callback());
 
         // Step 1
         if unsafe { !IsConstructor(constructor.get()) } {
             return Err(Error::Type("Second argument of CustomElementRegistry.define is not a constructor".to_owned()));
         }
@@ -120,24 +128,24 @@ impl CustomElementRegistryMethods for Cu
         // Steps 5, 7
         let local_name = if let Some(ref extended_name) = *extends {
             // Step 7.1
             if is_valid_custom_element_name(extended_name) {
                 return Err(Error::NotSupported)
             }
 
             // Step 7.2
-            if !is_known_element_interface(extended_name) {
+            if !is_extendable_element_interface(extended_name) {
                 return Err(Error::NotSupported)
             }
 
-            extended_name.clone()
+            extended_name
         } else {
             // Step 7.3
-            name.clone()
+            &name
         };
 
         // Step 8
         if self.element_definition_is_running.get() {
             return Err(Error::NotSupported);
         }
 
         // Step 9
@@ -152,48 +160,50 @@ impl CustomElementRegistryMethods for Cu
         // TODO: Steps 10.3 - 10.6
         // 10.3 - 10.4 Handle lifecycle callbacks
         // 10.5 - 10.6 Get observed attributes from the constructor
 
         self.element_definition_is_running.set(false);
         result?;
 
         // Step 11
-        let definition = CustomElementDefinition::new(name.clone(), local_name, constructor_);
+        let definition = CustomElementDefinition::new(LocalName::from(&*name),
+                                                      LocalName::from(&**local_name),
+                                                      constructor_);
 
         // Step 12
-        self.definitions.borrow_mut().insert(name.clone(), definition);
+        self.definitions.borrow_mut().insert(name.clone(), Rc::new(definition));
 
         // TODO: Step 13, 14, 15
         // Handle custom element upgrades
 
         // Step 16, 16.3
         if let Some(promise) = self.when_defined.borrow_mut().remove(&name) {
             // 16.1
             let cx = promise.global().get_cx();
             // 16.2
             promise.resolve_native(cx, &UndefinedValue());
         }
         Ok(())
     }
 
-    // https://html.spec.whatwg.org/multipage/#dom-customelementregistry-get
+    /// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-get
     #[allow(unsafe_code)]
     unsafe fn Get(&self, cx: *mut JSContext, name: DOMString) -> JSVal {
         match self.definitions.borrow().get(&name) {
             Some(definition) => {
                 rooted!(in(cx) let mut constructor = UndefinedValue());
                 definition.constructor.to_jsval(cx, constructor.handle_mut());
                 constructor.get()
             },
             None => UndefinedValue(),
         }
     }
 
-    // https://html.spec.whatwg.org/multipage/#dom-customelementregistry-whendefined
+    /// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-whendefined
     #[allow(unrooted_must_root)]
     fn WhenDefined(&self, name: DOMString) -> Rc<Promise> {
         let global_scope = self.window.upcast::<GlobalScope>();
 
         // Step 1
         if !is_valid_custom_element_name(&name) {
             let promise = Promise::new(global_scope);
             promise.reject_native(global_scope.get_cx(), &DOMException::new(global_scope, DOMErrorName::SyntaxError));
@@ -217,37 +227,43 @@ impl CustomElementRegistryMethods for Cu
             promise
         });
 
         // Step 6
         promise
     }
 }
 
-#[derive(HeapSizeOf, JSTraceable)]
-struct CustomElementDefinition {
-    name: DOMString,
+/// https://html.spec.whatwg.org/multipage/#custom-element-definition
+#[derive(HeapSizeOf, JSTraceable, Clone)]
+pub struct CustomElementDefinition {
+    pub name: LocalName,
 
-    local_name: DOMString,
+    pub local_name: LocalName,
 
     #[ignore_heap_size_of = "Rc"]
-    constructor: Rc<Function>,
+    pub constructor: Rc<Function>,
 }
 
 impl CustomElementDefinition {
-    fn new(name: DOMString, local_name: DOMString, constructor: Rc<Function>) -> CustomElementDefinition {
+    fn new(name: LocalName, local_name: LocalName, constructor: Rc<Function>) -> CustomElementDefinition {
         CustomElementDefinition {
             name: name,
             local_name: local_name,
             constructor: constructor,
         }
     }
+
+    /// https://html.spec.whatwg.org/multipage/#autonomous-custom-element
+    pub fn is_autonomous(&self) -> bool {
+        self.name == self.local_name
+    }
 }
 
-// https://html.spec.whatwg.org/multipage/#valid-custom-element-name
+/// https://html.spec.whatwg.org/multipage/#valid-custom-element-name
 fn is_valid_custom_element_name(name: &str) -> bool {
     // Custom elment names must match:
     // PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
 
     let mut chars = name.chars();
     if !chars.next().map_or(false, |c| c >= 'a' && c <= 'z') {
         return false;
     }
@@ -279,18 +295,18 @@ fn is_valid_custom_element_name(name: &s
         name == "missing-glyph"
     {
         return false;
     }
 
     true
 }
 
-// Check if this character is a PCENChar
-// https://html.spec.whatwg.org/multipage/#prod-pcenchar
+/// Check if this character is a PCENChar
+/// https://html.spec.whatwg.org/multipage/#prod-pcenchar
 fn is_potential_custom_element_char(c: char) -> bool {
     c == '-' || c == '.' || c == '_' || c == '\u{B7}' ||
     (c >= '0' && c <= '9') ||
     (c >= 'a' && c <= 'z') ||
     (c >= '\u{C0}' && c <= '\u{D6}') ||
     (c >= '\u{D8}' && c <= '\u{F6}') ||
     (c >= '\u{F8}' && c <= '\u{37D}') ||
     (c >= '\u{37F}' && c <= '\u{1FFF}') ||
@@ -298,22 +314,21 @@ fn is_potential_custom_element_char(c: c
     (c >= '\u{203F}' && c <= '\u{2040}') ||
     (c >= '\u{2070}' && c <= '\u{2FEF}') ||
     (c >= '\u{3001}' && c <= '\u{D7FF}') ||
     (c >= '\u{F900}' && c <= '\u{FDCF}') ||
     (c >= '\u{FDF0}' && c <= '\u{FFFD}') ||
     (c >= '\u{10000}' && c <= '\u{EFFFF}')
 }
 
-fn is_known_element_interface(element: &str) -> bool {
+fn is_extendable_element_interface(element: &str) -> bool {
     element == "a" ||
     element == "abbr" ||
     element == "acronym" ||
     element == "address" ||
-    element == "applet" ||
     element == "area" ||
     element == "article" ||
     element == "aside" ||
     element == "audio" ||
     element == "b" ||
     element == "base" ||
     element == "bdi" ||
     element == "bdo" ||
--- a/servo/components/script/dom/webidls/HTMLAnchorElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLAnchorElement.webidl
@@ -6,16 +6,17 @@
  * https://html.spec.whatwg.org/multipage/#the-a-element
  * https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
 // https://html.spec.whatwg.org/multipage/#htmlanchorelement
+[HTMLConstructor]
 interface HTMLAnchorElement : HTMLElement {
   attribute DOMString target;
   //       attribute DOMString download;
   //       attribute USVString ping;
            attribute DOMString rel;
   readonly attribute DOMTokenList relList;
   //       attribute DOMString hreflang;
   //       attribute DOMString type;
--- a/servo/components/script/dom/webidls/HTMLAppletElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLAppletElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlappletelement
+// Note: intentionally not [HTMLConstructor]
 interface HTMLAppletElement : HTMLElement {
   //         attribute DOMString align;
   //         attribute DOMString alt;
   //         attribute DOMString archive;
   //         attribute DOMString code;
   //         attribute DOMString codeBase;
   //         attribute DOMString height;
   //         attribute unsigned long hspace;
--- a/servo/components/script/dom/webidls/HTMLAreaElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLAreaElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlareaelement
+[HTMLConstructor]
 interface HTMLAreaElement : HTMLElement {
   //         attribute DOMString alt;
   //         attribute DOMString coords;
   //         attribute DOMString shape;
   //         attribute DOMString target;
   //         attribute DOMString download;
   //         attribute USVString ping;
   //         attribute DOMString rel;
--- a/servo/components/script/dom/webidls/HTMLAudioElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLAudioElement.webidl
@@ -1,7 +1,7 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlaudioelement
-//[NamedConstructor=Audio(optional DOMString src)]
+[HTMLConstructor/*, NamedConstructor=Audio(optional DOMString src)*/]
 interface HTMLAudioElement : HTMLMediaElement {};
--- a/servo/components/script/dom/webidls/HTMLBRElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLBRElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlbrelement
+[HTMLConstructor]
 interface HTMLBRElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLBRElement-partial
 partial interface HTMLBRElement {
   //         attribute DOMString clear;
 };
--- a/servo/components/script/dom/webidls/HTMLBaseElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLBaseElement.webidl
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlbaseelement
+[HTMLConstructor]
 interface HTMLBaseElement : HTMLElement {
            attribute DOMString href;
 //           attribute DOMString target;
 };
--- a/servo/components/script/dom/webidls/HTMLBodyElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLBodyElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#the-body-element
+[HTMLConstructor]
 interface HTMLBodyElement : HTMLElement {
   // also has obsolete members
 };
 HTMLBodyElement implements WindowEventHandlers;
 
 // https://html.spec.whatwg.org/multipage/#HTMLBodyElement-partial
 partial interface HTMLBodyElement {
     [TreatNullAs=EmptyString] attribute DOMString text;
--- a/servo/components/script/dom/webidls/HTMLButtonElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLButtonElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlbuttonelement
+[HTMLConstructor]
 interface HTMLButtonElement : HTMLElement {
   //         attribute boolean autofocus;
              attribute boolean disabled;
   readonly attribute HTMLFormElement? form;
              attribute DOMString formAction;
              attribute DOMString formEnctype;
              attribute DOMString formMethod;
              attribute boolean formNoValidate;
--- a/servo/components/script/dom/webidls/HTMLCanvasElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLCanvasElement.webidl
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlcanvaselement
 typedef (CanvasRenderingContext2D or WebGLRenderingContext) RenderingContext;
 
+[HTMLConstructor]
 interface HTMLCanvasElement : HTMLElement {
   [Pure]
            attribute unsigned long width;
   [Pure]
            attribute unsigned long height;
 
   RenderingContext? getContext(DOMString contextId, any... arguments);
   //boolean probablySupportsContext(DOMString contextId, any... arguments);
--- a/servo/components/script/dom/webidls/HTMLDListElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDListElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldlistelement
+[HTMLConstructor]
 interface HTMLDListElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLDListElement-partial
 partial interface HTMLDListElement {
   //         attribute boolean compact;
 };
--- a/servo/components/script/dom/webidls/HTMLDataElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDataElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldataelement
+[HTMLConstructor]
 interface HTMLDataElement : HTMLElement {
            attribute DOMString value;
 };
--- a/servo/components/script/dom/webidls/HTMLDataListElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDataListElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldatalistelement
+[HTMLConstructor]
 interface HTMLDataListElement : HTMLElement {
   readonly attribute HTMLCollection options;
 };
--- a/servo/components/script/dom/webidls/HTMLDetailsElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDetailsElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldetailselement
+[HTMLConstructor]
 interface HTMLDetailsElement : HTMLElement {
     attribute boolean open;
 };
--- a/servo/components/script/dom/webidls/HTMLDialogElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDialogElement.webidl
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldialogelement
+[HTMLConstructor]
 interface HTMLDialogElement : HTMLElement {
   attribute boolean open;
   attribute DOMString returnValue;
   //void show(optional (MouseEvent or Element) anchor);
   //void showModal(optional (MouseEvent or Element) anchor);
   void close(optional DOMString returnValue);
 };
--- a/servo/components/script/dom/webidls/HTMLDirectoryElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDirectoryElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldirectoryelement
+[HTMLConstructor]
 interface HTMLDirectoryElement : HTMLElement {
   //         attribute boolean compact;
 };
--- a/servo/components/script/dom/webidls/HTMLDivElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLDivElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmldivelement
+[HTMLConstructor]
 interface HTMLDivElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLDivElement-partial
 partial interface HTMLDivElement {
   attribute DOMString align;
 };
--- a/servo/components/script/dom/webidls/HTMLElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlelement
+[HTMLConstructor]
 interface HTMLElement : Element {
   // metadata attributes
            attribute DOMString title;
            attribute DOMString lang;
   //         attribute boolean translate;
   //         attribute DOMString dir;
   readonly attribute DOMStringMap dataset;
 
--- a/servo/components/script/dom/webidls/HTMLEmbedElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLEmbedElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlembedelement
+[HTMLConstructor]
 interface HTMLEmbedElement : HTMLElement {
   //         attribute DOMString src;
   //         attribute DOMString type;
   //         attribute DOMString width;
   //         attribute DOMString height;
   //legacycaller any (any... arguments);
 
   // also has obsolete members
--- a/servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlfieldsetelement
+[HTMLConstructor]
 interface HTMLFieldSetElement : HTMLElement {
            attribute boolean disabled;
   readonly attribute HTMLFormElement? form;
   //         attribute DOMString name;
 
   //readonly attribute DOMString type;
 
   [SameObject] readonly attribute HTMLCollection elements;
--- a/servo/components/script/dom/webidls/HTMLFontElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFontElement.webidl
@@ -1,10 +1,11 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlfontelement
+[HTMLConstructor]
 interface HTMLFontElement : HTMLElement {
   [TreatNullAs=EmptyString] attribute DOMString color;
   attribute DOMString face;
   attribute DOMString size;
 };
--- a/servo/components/script/dom/webidls/HTMLFormElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFormElement.webidl
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlformelement
-//[OverrideBuiltins]
+[/*OverrideBuiltins, */HTMLConstructor]
 interface HTMLFormElement : HTMLElement {
            attribute DOMString acceptCharset;
            attribute DOMString action;
            attribute DOMString autocomplete;
            attribute DOMString enctype;
            attribute DOMString encoding;
            attribute DOMString method;
            attribute DOMString name;
--- a/servo/components/script/dom/webidls/HTMLFrameElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFrameElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlframeelement
+[HTMLConstructor]
 interface HTMLFrameElement : HTMLElement {
   //         attribute DOMString name;
   //         attribute DOMString scrolling;
   //         attribute DOMString src;
   //         attribute DOMString frameBorder;
   //         attribute DOMString longDesc;
   //         attribute boolean noResize;
   //readonly attribute Document? contentDocument;
--- a/servo/components/script/dom/webidls/HTMLFrameSetElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFrameSetElement.webidl
@@ -1,11 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlframesetelement
+[HTMLConstructor]
 interface HTMLFrameSetElement : HTMLElement {
   //         attribute DOMString cols;
   //         attribute DOMString rows;
 };
 
 HTMLFrameSetElement implements WindowEventHandlers;
--- a/servo/components/script/dom/webidls/HTMLHRElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLHRElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlhrelement
+[HTMLConstructor]
 interface HTMLHRElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLHRElement-partial
 partial interface HTMLHRElement {
   attribute DOMString align;
   attribute DOMString color;
--- a/servo/components/script/dom/webidls/HTMLHeadElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLHeadElement.webidl
@@ -1,6 +1,7 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlheadelement
+[HTMLConstructor]
 interface HTMLHeadElement : HTMLElement {};
--- a/servo/components/script/dom/webidls/HTMLHeadingElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLHeadingElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlheadingelement
+[HTMLConstructor]
 interface HTMLHeadingElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLHeadingElement-partial
 partial interface HTMLHeadingElement {
   //         attribute DOMString align;
 };
--- a/servo/components/script/dom/webidls/HTMLHtmlElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLHtmlElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlhtmlelement
+[HTMLConstructor]
 interface HTMLHtmlElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLHtmlElement-partial
 partial interface HTMLHtmlElement {
   //         attribute DOMString version;
 };
--- a/servo/components/script/dom/webidls/HTMLIFrameElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLIFrameElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmliframeelement
+[HTMLConstructor]
 interface HTMLIFrameElement : HTMLElement {
            attribute DOMString src;
   //         attribute DOMString srcdoc;
 
   // https://github.com/servo/servo/issues/14453
   // attribute DOMString name;
 
            [SameObject, PutForwards=value]
--- a/servo/components/script/dom/webidls/HTMLImageElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLImageElement.webidl
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlimageelement
-[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
+[HTMLConstructor, NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
 interface HTMLImageElement : HTMLElement {
            attribute DOMString alt;
            attribute DOMString src;
   //         attribute DOMString srcset;
            attribute DOMString? crossOrigin;
            attribute DOMString useMap;
            attribute boolean isMap;
            attribute unsigned long width;
--- a/servo/components/script/dom/webidls/HTMLInputElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLInputElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlinputelement
+[HTMLConstructor]
 interface HTMLInputElement : HTMLElement {
            attribute DOMString accept;
            attribute DOMString alt;
   //         attribute DOMString autocomplete;
   //         attribute boolean autofocus;
            attribute boolean defaultChecked;
            attribute boolean checked;
            attribute DOMString dirName;
--- a/servo/components/script/dom/webidls/HTMLLIElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLLIElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmllielement
+[HTMLConstructor]
 interface HTMLLIElement : HTMLElement {
   attribute long value;
 
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLLIElement-partial
 partial interface HTMLLIElement {
--- a/servo/components/script/dom/webidls/HTMLLabelElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLLabelElement.webidl
@@ -1,10 +1,11 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmllabelelement
+[HTMLConstructor]
 interface HTMLLabelElement : HTMLElement {
   readonly attribute HTMLFormElement? form;
   attribute DOMString htmlFor;
   readonly attribute HTMLElement? control;
 };
--- a/servo/components/script/dom/webidls/HTMLLegendElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLLegendElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmllegendelement
+[HTMLConstructor]
 interface HTMLLegendElement : HTMLElement {
   readonly attribute HTMLFormElement? form;
 
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLLegendElement-partial
 partial interface HTMLLegendElement {
--- a/servo/components/script/dom/webidls/HTMLLinkElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLLinkElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmllinkelement
+[HTMLConstructor]
 interface HTMLLinkElement : HTMLElement {
            attribute DOMString href;
            attribute DOMString? crossOrigin;
            attribute DOMString rel;
   readonly attribute DOMTokenList relList;
            attribute DOMString media;
            attribute DOMString hreflang;
            attribute DOMString type;
--- a/servo/components/script/dom/webidls/HTMLMapElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLMapElement.webidl
@@ -1,10 +1,11 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlmapelement
+[HTMLConstructor]
 interface HTMLMapElement : HTMLElement {
   //         attribute DOMString name;
   //readonly attribute HTMLCollection areas;
   //readonly attribute HTMLCollection images;
 };
--- a/servo/components/script/dom/webidls/HTMLMetaElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLMetaElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlmetaelement
+[HTMLConstructor]
 interface HTMLMetaElement : HTMLElement {
              attribute DOMString name;
   //         attribute DOMString httpEquiv;
              attribute DOMString content;
 
   // also has obsolete members
 };
 
--- a/servo/components/script/dom/webidls/HTMLMeterElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLMeterElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlmeterelement
+[HTMLConstructor]
 interface HTMLMeterElement : HTMLElement {
   //         attribute double value;
   //         attribute double min;
   //         attribute double max;
   //         attribute double low;
   //         attribute double high;
   //         attribute double optimum;
   readonly attribute NodeList labels;
--- a/servo/components/script/dom/webidls/HTMLModElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLModElement.webidl
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlmodelement
+[HTMLConstructor]
 interface HTMLModElement : HTMLElement {
   //         attribute DOMString cite;
   //         attribute DOMString dateTime;
 };
--- a/servo/components/script/dom/webidls/HTMLOListElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLOListElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlolistelement
+[HTMLConstructor]
 interface HTMLOListElement : HTMLElement {
   //         attribute boolean reversed;
   //         attribute long start;
   //         attribute DOMString type;
 
   // also has obsolete members
 };
 
--- a/servo/components/script/dom/webidls/HTMLObjectElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLObjectElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlobjectelement
+[HTMLConstructor]
 interface HTMLObjectElement : HTMLElement {
   //         attribute DOMString data;
            attribute DOMString type;
   //         attribute boolean typeMustMatch;
   //         attribute DOMString name;
   //         attribute DOMString useMap;
   readonly attribute HTMLFormElement? form;
   //         attribute DOMString width;
--- a/servo/components/script/dom/webidls/HTMLOptGroupElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLOptGroupElement.webidl
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmloptgroupelement
+[HTMLConstructor]
 interface HTMLOptGroupElement : HTMLElement {
            attribute boolean disabled;
   //         attribute DOMString label;
 };
--- a/servo/components/script/dom/webidls/HTMLOptionElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLOptionElement.webidl
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmloptionelement
-//[NamedConstructor=Option(optional DOMString text = "", optional DOMString value,
-//                         optional boolean defaultSelected = false,
-//                         optional boolean selected = false)]
+[HTMLConstructor/*, NamedConstructor=Option(optional DOMString text = "", optional DOMString value,
+                         optional boolean defaultSelected = false,
+                         optional boolean selected = false)*/]
 interface HTMLOptionElement : HTMLElement {
              attribute boolean disabled;
              readonly attribute HTMLFormElement? form;
              attribute DOMString label;
              attribute boolean defaultSelected;
              attribute boolean selected;
              attribute DOMString value;
 
--- a/servo/components/script/dom/webidls/HTMLOutputElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLOutputElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmloutputelement
+[HTMLConstructor]
 interface HTMLOutputElement : HTMLElement {
   // [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor;
   readonly attribute HTMLFormElement? form;
   //         attribute DOMString name;
 
   //readonly attribute DOMString type;
   //         attribute DOMString defaultValue;
   //         attribute DOMString value;
--- a/servo/components/script/dom/webidls/HTMLParagraphElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLParagraphElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlparagraphelement
+[HTMLConstructor]
 interface HTMLParagraphElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLParagraphElement-partial
 partial interface HTMLParagraphElement {
   //         attribute DOMString align;
 };
--- a/servo/components/script/dom/webidls/HTMLParamElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLParamElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlparamelement
+[HTMLConstructor]
 interface HTMLParamElement : HTMLElement {
   //         attribute DOMString name;
   //         attribute DOMString value;
 
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLParamElement-partial
--- a/servo/components/script/dom/webidls/HTMLPreElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLPreElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlpreelement
+[HTMLConstructor]
 interface HTMLPreElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLPreElement-partial
 partial interface HTMLPreElement {
   //         attribute long width;
 };
--- a/servo/components/script/dom/webidls/HTMLProgressElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLProgressElement.webidl
@@ -1,11 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlprogresselement
+[HTMLConstructor]
 interface HTMLProgressElement : HTMLElement {
   //         attribute double value;
   //         attribute double max;
   //readonly attribute double position;
   readonly attribute NodeList labels;
 };
--- a/servo/components/script/dom/webidls/HTMLQuoteElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLQuoteElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlquoteelement
+[HTMLConstructor]
 interface HTMLQuoteElement : HTMLElement {
   //         attribute DOMString cite;
 };
--- a/servo/components/script/dom/webidls/HTMLScriptElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLScriptElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlscriptelement
+[HTMLConstructor]
 interface HTMLScriptElement : HTMLElement {
            attribute DOMString src;
            attribute DOMString type;
            attribute DOMString charset;
            attribute boolean async;
            attribute boolean defer;
            attribute DOMString? crossOrigin;
            [Pure]
--- a/servo/components/script/dom/webidls/HTMLSelectElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLSelectElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlselectelement
+[HTMLConstructor]
 interface HTMLSelectElement : HTMLElement {
   //         attribute boolean autofocus;
            attribute boolean disabled;
   readonly attribute HTMLFormElement? form;
            attribute boolean multiple;
            attribute DOMString name;
   //         attribute boolean required;
            attribute unsigned long size;
--- a/servo/components/script/dom/webidls/HTMLSourceElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLSourceElement.webidl
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlsourceelement
+[HTMLConstructor]
 interface HTMLSourceElement : HTMLElement {
   //         attribute DOMString src;
   //         attribute DOMString type;
 };
--- a/servo/components/script/dom/webidls/HTMLSpanElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLSpanElement.webidl
@@ -1,6 +1,7 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlspanelement
+[HTMLConstructor]
 interface HTMLSpanElement : HTMLElement {};
--- a/servo/components/script/dom/webidls/HTMLStyleElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLStyleElement.webidl
@@ -1,11 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlstyleelement
+[HTMLConstructor]
 interface HTMLStyleElement : HTMLElement {
   //         attribute DOMString media;
   //         attribute DOMString type;
   //         attribute boolean scoped;
 };
 HTMLStyleElement implements LinkStyle;
--- a/servo/components/script/dom/webidls/HTMLTableCaptionElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableCaptionElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltablecaptionelement
+[HTMLConstructor]
 interface HTMLTableCaptionElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLTableCaptionElement-partial
 partial interface HTMLTableCaptionElement {
   //         attribute DOMString align;
 };
--- a/servo/components/script/dom/webidls/HTMLTableCellElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableCellElement.webidl
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltablecellelement
-[Abstract]
+[HTMLConstructor, Abstract]
 interface HTMLTableCellElement : HTMLElement {
   attribute unsigned long colSpan;
   attribute unsigned long rowSpan;
   //         attribute DOMString headers;
   readonly attribute long cellIndex;
 
   // also has obsolete members
 };
--- a/servo/components/script/dom/webidls/HTMLTableColElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableColElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltablecolelement
+[HTMLConstructor]
 interface HTMLTableColElement : HTMLElement {
   //         attribute unsigned long span;
 
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLTableColElement-partial
 partial interface HTMLTableColElement {
--- a/servo/components/script/dom/webidls/HTMLTableDataCellElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableDataCellElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltabledatacellelement
+[HTMLConstructor]
 interface HTMLTableDataCellElement : HTMLTableCellElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLTableDataCellElement-partial
 partial interface HTMLTableDataCellElement {
   //         attribute DOMString abbr;
 };
--- a/servo/components/script/dom/webidls/HTMLTableElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltableelement
+[HTMLConstructor]
 interface HTMLTableElement : HTMLElement {
            attribute HTMLTableCaptionElement? caption;
   HTMLTableCaptionElement createCaption();
   void deleteCaption();
   [SetterThrows]
            attribute HTMLTableSectionElement? tHead;
   HTMLTableSectionElement createTHead();
   void deleteTHead();
--- a/servo/components/script/dom/webidls/HTMLTableHeaderCellElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableHeaderCellElement.webidl
@@ -1,11 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltableheadercellelement
+[HTMLConstructor]
 interface HTMLTableHeaderCellElement : HTMLTableCellElement {
   //         attribute DOMString scope;
   //         attribute DOMString abbr;
   //         attribute DOMString sorted;
   //void sort();
 };
--- a/servo/components/script/dom/webidls/HTMLTableRowElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableRowElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltablerowelement
+[HTMLConstructor]
 interface HTMLTableRowElement : HTMLElement {
   readonly attribute long rowIndex;
   readonly attribute long sectionRowIndex;
   readonly attribute HTMLCollection cells;
   [Throws]
   HTMLElement insertCell(optional long index = -1);
   [Throws]
   void deleteCell(long index);
--- a/servo/components/script/dom/webidls/HTMLTableSectionElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTableSectionElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltablesectionelement
+[HTMLConstructor]
 interface HTMLTableSectionElement : HTMLElement {
   readonly attribute HTMLCollection rows;
   [Throws]
   HTMLElement insertRow(optional long index = -1);
   [Throws]
   void deleteRow(long index);
 
   // also has obsolete members
--- a/servo/components/script/dom/webidls/HTMLTemplateElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTemplateElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltemplateelement
+[HTMLConstructor]
 interface HTMLTemplateElement : HTMLElement {
   readonly attribute DocumentFragment content;
 };
--- a/servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltextareaelement
+[HTMLConstructor]
 interface HTMLTextAreaElement : HTMLElement {
   //         attribute DOMString autocomplete;
   //         attribute boolean autofocus;
              [SetterThrows]
              attribute unsigned long cols;
   //         attribute DOMString dirName;
            attribute boolean disabled;
   readonly attribute HTMLFormElement? form;
--- a/servo/components/script/dom/webidls/HTMLTimeElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTimeElement.webidl
@@ -1,8 +1,9 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltimeelement
+[HTMLConstructor]
 interface HTMLTimeElement : HTMLElement {
   attribute DOMString dateTime;
 };
--- a/servo/components/script/dom/webidls/HTMLTitleElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTitleElement.webidl
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltitleelement
+[HTMLConstructor]
 interface HTMLTitleElement : HTMLElement {
     [Pure]
            attribute DOMString text;
 };
--- a/servo/components/script/dom/webidls/HTMLTrackElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTrackElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmltrackelement
+[HTMLConstructor]
 interface HTMLTrackElement : HTMLElement {
   //         attribute DOMString kind;
   //         attribute DOMString src;
   //         attribute DOMString srclang;
   //         attribute DOMString label;
   //         attribute boolean default;
 
   //const unsigned short NONE = 0;
--- a/servo/components/script/dom/webidls/HTMLUListElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLUListElement.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlulistelement
+[HTMLConstructor]
 interface HTMLUListElement : HTMLElement {
   // also has obsolete members
 };
 
 // https://html.spec.whatwg.org/multipage/#HTMLUListElement-partial
 partial interface HTMLUListElement {
   //         attribute boolean compact;
   //         attribute DOMString type;
--- a/servo/components/script/dom/webidls/HTMLVideoElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLVideoElement.webidl
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#htmlvideoelement
+[HTMLConstructor]
 interface HTMLVideoElement : HTMLMediaElement {
   //         attribute unsigned long width;
   //         attribute unsigned long height;
   //readonly attribute unsigned long videoWidth;
   //readonly attribute unsigned long videoHeight;
   //         attribute DOMString poster;
 };