From cedff6e214eb07afff9756608475db289d9aaff2 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:07:09 -0400 Subject: [PATCH] Bug 1416999 - Remove document.registerElement Tag #1375 --- dom/base/CustomElementRegistry.cpp | 19 +- dom/base/CustomElementRegistry.h | 10 +- dom/base/Element.cpp | 41 +-- dom/base/nsContentUtils.cpp | 29 -- dom/base/nsContentUtils.h | 7 +- dom/base/nsDocument.cpp | 247 ------------------ dom/base/nsDocument.h | 11 - dom/base/nsIDocument.h | 9 - dom/base/test/chrome/chrome.ini | 8 +- dom/base/test/chrome/registerElement_ep.js | 8 - .../chrome/test_registerElement_content.xul | 52 ---- .../test/chrome/test_registerElement_ep.xul | 44 ---- dom/base/test/mochitest.ini | 2 +- dom/base/test/test_document_register.html | 6 +- dom/html/test/mochitest.ini | 1 - dom/html/test/test_bug1081037.html | 133 ---------- .../mochitest/webcomponents/mochitest.ini | 5 +- ...est_custom_element_callback_innerhtml.html | 26 +- ...om_element_register_invalid_callbacks.html | 69 ----- .../test_document_register_parser.html | 47 ---- .../test_document_shared_registry.html | 46 ---- .../test_template_custom_elements.html | 32 --- .../test_unresolved_pseudo_class.html | 26 +- dom/webidl/Document.webidl | 7 - dom/webidl/WebComponents.webidl | 5 - .../tests/mochitest/test_bug1094930.html | 10 +- layout/base/crashtests/1261351-iframe.html | 33 +-- layout/style/crashtests/1017798-1.html | 28 +- 28 files changed, 82 insertions(+), 879 deletions(-) delete mode 100644 dom/base/test/chrome/registerElement_ep.js delete mode 100644 dom/base/test/chrome/test_registerElement_content.xul delete mode 100644 dom/base/test/chrome/test_registerElement_ep.xul delete mode 100644 dom/html/test/test_bug1081037.html delete mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_register_invalid_callbacks.html delete mode 100644 dom/tests/mochitest/webcomponents/test_document_register_parser.html delete mode 100644 dom/tests/mochitest/webcomponents/test_document_shared_registry.html delete mode 100644 dom/tests/mochitest/webcomponents/test_template_custom_elements.html diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index e4d4c0670f..67bd8e185d 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -414,19 +414,6 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType reactionsStack->EnqueueCallbackReaction(aCustomElement, Move(callback)); } -void -CustomElementRegistry::GetCustomPrototype(nsIAtom* aAtom, - JS::MutableHandle aPrototype) -{ - mozilla::dom::CustomElementDefinition* definition = - mCustomDefinitions.GetWeak(aAtom); - if (definition) { - aPrototype.set(definition->mPrototype); - } else { - aPrototype.set(nullptr); - } -} - void CustomElementRegistry::UpgradeCandidates(nsIAtom* aKey, CustomElementDefinition* aDefinition, @@ -624,9 +611,9 @@ CustomElementRegistry::Define(const nsAString& aName, */ JSAutoCompartment ac(cx, constructor); JS::Rooted prototypev(cx); - // The .prototype on the constructor passed from document.registerElement - // is the "expando" of a wrapper. So we should get it from wrapper instead - // instead of underlying object. + // The .prototype on the constructor passed could be an "expando" of a + // wrapper. So we should get it from wrapper instead of the underlying + // object. if (!JS_GetProperty(cx, constructor, "prototype", &prototypev)) { aRv.StealExceptionFromJSContext(cx); return; diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index c416e50439..a736e3019d 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -423,9 +423,6 @@ public: LifecycleAdoptedCallbackArgs* aAdoptedCallbackArgs, CustomElementDefinition* aDefinition); - void GetCustomPrototype(nsIAtom* aAtom, - JS::MutableHandle aPrototype); - /** * Upgrade an element. * https://html.spec.whatwg.org/multipage/scripting.html#upgrades @@ -434,8 +431,7 @@ public: /** * Registers an unresolved custom element that is a candidate for - * upgrade when the definition is registered via registerElement. - * |aTypeName| is the name of the custom element type, if it is not + * upgrade. |aTypeName| is the name of the custom element type, if it is not * provided, then element name is used. |aTypeName| should be provided * when registering a custom element that extends an existing * element. e.g. - - -
- - - - diff --git a/dom/tests/mochitest/webcomponents/test_document_shared_registry.html b/dom/tests/mochitest/webcomponents/test_document_shared_registry.html deleted file mode 100644 index db72e1e6ca..0000000000 --- a/dom/tests/mochitest/webcomponents/test_document_shared_registry.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Test shared registry for associated HTML documents. - - - - -
-Bug 783129 - - - diff --git a/dom/tests/mochitest/webcomponents/test_template_custom_elements.html b/dom/tests/mochitest/webcomponents/test_template_custom_elements.html deleted file mode 100644 index f7f4340cf4..0000000000 --- a/dom/tests/mochitest/webcomponents/test_template_custom_elements.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - Test for custom elements in template - - - - - -Bug 1091425 - - - - diff --git a/dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html b/dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html index 3e1fae8ee8..a1ff3b3c6b 100644 --- a/dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html +++ b/dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html @@ -42,7 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1111633 diff --git a/layout/base/crashtests/1261351-iframe.html b/layout/base/crashtests/1261351-iframe.html index 82c1e25fae..a0484f3325 100644 --- a/layout/base/crashtests/1261351-iframe.html +++ b/layout/base/crashtests/1261351-iframe.html @@ -3,23 +3,26 @@ 'use strict'; // -sp-context: content (function () { - let proto = Object.create(HTMLDivElement.prototype); - proto.template = ``; - proto.createdCallback = function() { - let shadow = this.createShadowRoot(); - if (this.template) { - let te = document.createElement('template'); - te.innerHTML = this.template; - shadow.appendChild(document.importNode(te.content, true)); - } - }; + class UiComponentTest extends HTMLDivElement { + constructor() { + super(); + this.template = ``; + } - let UiComponentTest = document.registerElement('ui-component-test', { - prototype: proto, - }); + connectedCallback() { + let shadow = this.createShadowRoot(); + if (this.template) { + let te = document.createElement('template'); + te.innerHTML = this.template; + shadow.appendChild(document.importNode(te.content, true)); + } + } + }; - let uic = new UiComponentTest(); - document.body.appendChild(uic); + customElements.define('ui-component-test', UiComponentTest, { extend: 'div'} ); + + let uic = new UiComponentTest(); + document.body.appendChild(uic); })(); diff --git a/layout/style/crashtests/1017798-1.html b/layout/style/crashtests/1017798-1.html index 097217d188..0460c8756f 100644 --- a/layout/style/crashtests/1017798-1.html +++ b/layout/style/crashtests/1017798-1.html @@ -50,27 +50,27 @@ gaia_switch/examples/index.html from the Gaia repository. window.GaiaSwitch = (function(win) { // Extend from the HTMLElement prototype - var proto = Object.create(HTMLElement.prototype); + class GaiaSwitch extends HTMLElement { + connectedCallback() { + var shadow = this.createShadowRoot(); + this._template = template.content.cloneNode(true); + this._input = this._template.querySelector('input[type="checkbox"]'); - proto.createdCallback = function() { - var shadow = this.createShadowRoot(); - this._template = template.content.cloneNode(true); - this._input = this._template.querySelector('input[type="checkbox"]'); + var checked = this.getAttribute('checked'); + if (checked !== null) { + this._input.checked = true; + } - var checked = this.getAttribute('checked'); - if (checked !== null) { - this._input.checked = true; + shadow.appendChild(this._template); + + ComponentUtils.style.call(this, ''); } - - shadow.appendChild(this._template); - - ComponentUtils.style.call(this, ''); }; /** * Proxy the checked property to the input element. */ - Object.defineProperty( proto, 'checked', { + Object.defineProperty( GaiaSwitch.prototype, 'checked', { get: function() { return this._input.checked; }, @@ -82,7 +82,7 @@ window.GaiaSwitch = (function(win) { /** * Proxy the name property to the input element. */ - Object.defineProperty( proto, 'name', { + Object.defineProperty( GaiaSwitch.prototype, 'name', { get: function() { return this.getAttribute('name'); },