Changeset 204367 in webkit
- Timestamp:
- Aug 10, 2016 7:08:17 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 39 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r204363 r204367 1 2016-08-10 Ryosuke Niwa <rniwa@webkit.org> 2 3 Move document.defineElement to customElements.define 4 https://bugs.webkit.org/show_bug.cgi?id=160731 5 6 Reviewed by Chris Dumez. 7 8 Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to 9 CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. 10 11 * fast/custom-elements/Document-createElement.html: 12 * fast/custom-elements/Document-defineElement-expected.txt: 13 * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements 14 in a viewless/windowless document since those documents don't have a corresponding window object. 15 * fast/custom-elements/HTMLElement-constructor.html: 16 * fast/custom-elements/attribute-changed-callback.html: 17 * fast/custom-elements/defined-pseudo-class.html: 18 * fast/custom-elements/defined-rule.html: 19 * fast/custom-elements/lifecycle-callback-timing.html: 20 * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: 21 * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: 22 * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: 23 * fast/custom-elements/parser/parser-constructs-custom-elements.html: 24 * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: 25 * fast/custom-elements/parser/parser-sets-attributes-and-children.html: 26 * fast/custom-elements/parser/parser-uses-constructed-element.html: 27 * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: 28 * fast/custom-elements/upgrading/Node-cloneNode.html: 29 * fast/custom-elements/upgrading/upgrading-parser-created-element.html: 30 * platform/mac/js/dom/global-constructors-attributes-expected.txt: 31 1 32 2016-08-10 Simon Fraser <simon.fraser@apple.com> 2 33 -
trunk/LayoutTests/fast/custom-elements/Document-createElement.html
r197602 r204367 19 19 assert_false(document.createElement('my-custom-element') instanceof MyCustomElement); 20 20 21 document.defineElement('my-custom-element', MyCustomElement);21 customElements.define('my-custom-element', MyCustomElement); 22 22 var instance = document.createElement('my-custom-element'); 23 23 assert_true(instance instanceof MyCustomElement); … … 34 34 } 35 35 }; 36 document.defineElement('object-custom-element', ObjectCustomElement);36 customElements.define('object-custom-element', ObjectCustomElement); 37 37 38 38 var instance = new ObjectCustomElement; … … 50 50 } 51 51 }; 52 document.defineElement('text-custom-element', TextCustomElement);52 customElements.define('text-custom-element', TextCustomElement); 53 53 assert_true(new TextCustomElement instanceof Text); 54 54 assert_equals(document.createElement('object-custom-element'), null); … … 65 65 } 66 66 }; 67 document.defineElement('div-custom-element', DivCustomElement);67 customElements.define('div-custom-element', DivCustomElement); 68 68 assert_true(new DivCustomElement instanceof HTMLDivElement); 69 69 … … 83 83 } 84 84 }; 85 document.defineElement('throw-custom-element', ThrowCustomElement);85 customElements.define('throw-custom-element', ThrowCustomElement); 86 86 87 87 assert_throws(null, function () { new ThrowCustomElement; }); -
trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt
r197602 r204367 1 1 2 PASS Check the existence of defineElement on Document interface 3 PASS document.defineElement should throw with an invalid name 4 PASS document.defineElement should throw when there is already a custom element of the same name 5 PASS document.defineElement should throw when there is already a custom element with the same class 6 PASS document.defineElement must throw a NotSupportedError when the context object is an associated inert template document 7 PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument 8 PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument 9 PASS document.defineElement should throw when the element interface is not a constructor 10 PASS document.defineElement should define an instantiatable custom element 2 PASS Check the existence of CustomElementsRegistry.prototype.define on CustomElementsRegistry interface 3 PASS customElements.define should throw with an invalid name 4 PASS customElements.define should throw when there is already a custom element of the same name 5 PASS customElements.define should throw when there is already a custom element with the same class 6 PASS customElements.define should throw when the element interface is not a constructor 7 PASS customElements.define should define an instantiatable custom element 11 8 -
trunk/LayoutTests/fast/custom-elements/Document-defineElement.html
r197602 r204367 4 4 <title>Custom Elements: Extensions to Document interface</title> 5 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 6 <meta name="assert" content=" document.defineElementshould define a custom element">6 <meta name="assert" content="customElements.define should define a custom element"> 7 7 <script src="../../resources/testharness.js"></script> 8 8 <script src="../../resources/testharnessreport.js"></script> … … 14 14 15 15 test(function () { 16 assert_true('define Element' in Document.prototype, '"defineElement" exists on Document.prototype');17 assert_true('define Element' in document, '"defineElement" exists on document');18 }, 'Check the existence of defineElement on Documentinterface');16 assert_true('define' in CustomElementsRegistry.prototype, '"define" exists on CustomElementsRegistry.prototype'); 17 assert_true('define' in customElements, '"define" exists on window.customElements'); 18 }, 'Check the existence of CustomElementsRegistry.prototype.define on CustomElementsRegistry interface'); 19 19 20 20 test(function () { 21 21 class MyCustomElement extends HTMLElement {}; 22 22 23 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(null, MyCustomElement); },24 ' document.defineElementmust throw a SyntaxError if the tag name is null');25 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('', MyCustomElement); },26 ' document.defineElementmust throw a SyntaxError if the tag name is empty');27 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('abc', MyCustomElement); },28 ' document.defineElementmust throw a SyntaxError if the tag name does not contain "-"');29 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('a-Bc', MyCustomElement); },30 ' document.defineElementmust throw a SyntaxError if the tag name contains an upper case letter');23 assert_throws({'name': 'SyntaxError'}, function () { customElements.define(null, MyCustomElement); }, 24 'customElements.define must throw a SyntaxError if the tag name is null'); 25 assert_throws({'name': 'SyntaxError'}, function () { customElements.define('', MyCustomElement); }, 26 'customElements.define must throw a SyntaxError if the tag name is empty'); 27 assert_throws({'name': 'SyntaxError'}, function () { customElements.define('abc', MyCustomElement); }, 28 'customElements.define must throw a SyntaxError if the tag name does not contain "-"'); 29 assert_throws({'name': 'SyntaxError'}, function () { customElements.define('a-Bc', MyCustomElement); }, 30 'customElements.define must throw a SyntaxError if the tag name contains an upper case letter'); 31 31 32 32 var builtinTagNames = [ … … 42 42 43 43 for (var tagName of builtinTagNames) { 44 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(tagName, MyCustomElement); },45 ' document.defineElementmust throw a SyntaxError if the tag name is "' + tagName + '"');44 assert_throws({'name': 'SyntaxError'}, function () { customElements.define(tagName, MyCustomElement); }, 45 'customElements.define must throw a SyntaxError if the tag name is "' + tagName + '"'); 46 46 } 47 47 48 }, ' document.defineElementshould throw with an invalid name');48 }, 'customElements.define should throw with an invalid name'); 49 49 50 50 test(function () { … … 52 52 class OtherCustomElement extends HTMLElement {}; 53 53 54 document.defineElement('some-custom-element', SomeCustomElement);55 assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-custom-element', OtherCustomElement); },56 ' document.defineElementmust throw a NotSupportedError if the specified tag name is already used');54 customElements.define('some-custom-element', SomeCustomElement); 55 assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-custom-element', OtherCustomElement); }, 56 'customElements.define must throw a NotSupportedError if the specified tag name is already used'); 57 57 58 }, ' document.defineElementshould throw when there is already a custom element of the same name');58 }, 'customElements.define should throw when there is already a custom element of the same name'); 59 59 60 60 test(function () { 61 61 class AnotherCustomElement extends HTMLElement {}; 62 62 63 document.defineElement('another-custom-element', AnotherCustomElement);64 assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-other-element', AnotherCustomElement); },65 ' document.defineElementmust throw a NotSupportedError if the specified class already defines an element');63 customElements.define('another-custom-element', AnotherCustomElement); 64 assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-other-element', AnotherCustomElement); }, 65 'customElements.define must throw a NotSupportedError if the specified class already defines an element'); 66 66 67 }, ' document.defineElementshould throw when there is already a custom element with the same class');67 }, 'customElements.define should throw when there is already a custom element with the same class'); 68 68 69 69 test(function () { 70 class SomeCustomElement extends HTMLElement {}; 71 72 var templateContentOwnerDocument = document.createElement('template').content.ownerDocument; 73 assert_throws({'name': 'NotSupportedError'}, function () { 74 templateContentOwnerDocument.defineElement('some-custom-element', SomeCustomElement); 75 }); 76 77 }, 'document.defineElement must throw a NotSupportedError when the context object is an associated inert template document'); 78 79 test(function () { 80 class SomeCustomElement extends HTMLElement {}; 81 82 var windowlessDocument = document.implementation.createHTMLDocument(); 83 assert_throws({'name': 'NotSupportedError'}, function () { 84 windowlessDocument.defineElement('some-custom-element', SomeCustomElement); 85 }); 86 87 }, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument'); 88 89 test(function () { 90 class SomeCustomElement extends HTMLElement {}; 91 92 var windowlessDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null) 93 assert_throws({'name': 'NotSupportedError'}, function () { 94 windowlessDocument.defineElement('some-custom-element', SomeCustomElement); 95 }); 96 97 }, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument'); 98 99 test(function () { 100 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', 1); }, 101 'document.defineElement must throw a TypeError when the element interface is a number'); 102 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', '123'); }, 103 'document.defineElement must throw a TypeError when the element interface is a string'); 104 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', {}); }, 105 'document.defineElement must throw a TypeError when the element interface is an object'); 106 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', []); }, 107 'document.defineElement must throw a TypeError when the element interface is an array'); 108 }, 'document.defineElement should throw when the element interface is not a constructor'); 70 assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', 1); }, 71 'customElements.define must throw a TypeError when the element interface is a number'); 72 assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', '123'); }, 73 'customElements.define must throw a TypeError when the element interface is a string'); 74 assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', {}); }, 75 'customElements.define must throw a TypeError when the element interface is an object'); 76 assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', []); }, 77 'customElements.define must throw a TypeError when the element interface is an array'); 78 }, 'customElements.define should throw when the element interface is not a constructor'); 109 79 110 80 test(function () { 111 81 class MyCustomElement extends HTMLElement {}; 112 document.defineElement('my-custom-element', MyCustomElement);82 customElements.define('my-custom-element', MyCustomElement); 113 83 114 84 var instance = new MyCustomElement; … … 125 95 'A custom element HTML must use HTML namespace'); 126 96 127 }, ' document.defineElementshould define an instantiatable custom element');97 }, 'customElements.define should define an instantiatable custom element'); 128 98 129 99 </script> -
trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html
r197602 r204367 15 15 test(function () { 16 16 class SomeDefinedElement extends HTMLElement {}; 17 document.defineElement('defined-element', SomeDefinedElement);17 customElements.define('defined-element', SomeDefinedElement); 18 18 assert_throws({'name': 'TypeError'}, function () { new HTMLElement('defined-element'); }); 19 19 }, 'HTMLElement constructor must throw a TypeError when there is no derived class'); … … 22 22 class SomeCustomElement extends HTMLElement {}; 23 23 assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement; }, 24 'Instantiating a custom element without calling defineElementmust throw TypeError');24 'Instantiating a custom element without calling customElements.define must throw TypeError'); 25 25 }, 'HTMLElement constructor must throw TypeError when custom element is not well defined'); 26 26 27 27 test(function () { 28 28 class CustomElementWithInferredTagName extends HTMLElement {}; 29 document.defineElement('inferred-name', CustomElementWithInferredTagName);29 customElements.define('inferred-name', CustomElementWithInferredTagName); 30 30 31 31 var instance = new CustomElementWithInferredTagName; … … 47 47 class ConcreteCustomElement extends HTMLElement { }; 48 48 class SubCustomElement extends ConcreteCustomElement { }; 49 document.defineElement('concrete-custom-element', ConcreteCustomElement);50 document.defineElement('sub-custom-element', SubCustomElement);49 customElements.define('concrete-custom-element', ConcreteCustomElement); 50 customElements.define('sub-custom-element', SubCustomElement); 51 51 52 52 var instance = new ConcreteCustomElement(); … … 67 67 class AbstractCustomElement extends HTMLElement { }; 68 68 class ConcreteSubCustomElement extends AbstractCustomElement { }; 69 document.defineElement('concrete-sub-custom-element', ConcreteSubCustomElement);69 customElements.define('concrete-sub-custom-element', ConcreteSubCustomElement); 70 70 71 71 var instance = new ConcreteSubCustomElement(); -
trunk/LayoutTests/fast/custom-elements/attribute-changed-callback.html
r197611 r204367 20 20 } 21 21 } 22 document.defineElement('my-custom-element', MyCustomElement);22 customElements.define('my-custom-element', MyCustomElement); 23 23 24 24 test(function () { -
trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html
r197952 r204367 26 26 } 27 27 } 28 document.defineElement('my-element', MyElement);28 customElements.define('my-element', MyElement); 29 29 30 30 test(function () { … … 60 60 } 61 61 } 62 document.defineElement('returns-another-node', ReturnsAnotherNode);62 customElements.define('returns-another-node', ReturnsAnotherNode); 63 63 64 64 document.write('<returns-another-node></returns-another-node>'); … … 73 73 var instance = document.createElement('returns-another-node-2'); 74 74 try { 75 document.defineElement('returns-another-node-2', class extends ReturnsAnotherNode {});75 customElements.define('returns-another-node-2', class extends ReturnsAnotherNode {}); 76 76 } catch (e) { } 77 77 assert_false(instance.matches(':defined')); -
trunk/LayoutTests/fast/custom-elements/defined-rule.html
r197952 r204367 32 32 <script> 33 33 34 document.defineElement('my-defined-element', class extends HTMLElement {});34 customElements.define('my-defined-element', class extends HTMLElement {}); 35 35 36 36 </script> -
trunk/LayoutTests/fast/custom-elements/lifecycle-callback-timing.html
r197634 r204367 21 21 handler() { } 22 22 } 23 document.defineElement('my-custom-element', MyCustomElement);23 customElements.define('my-custom-element', MyCustomElement); 24 24 25 25 test(function () { … … 64 64 } 65 65 } 66 document.defineElement('self-cloning-element', SelfCloningElement);66 customElements.define('self-cloning-element', SelfCloningElement); 67 67 68 68 var instance = document.createElement('self-cloning-element'); -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html
r197602 r204367 14 14 15 15 class MyCustomElement extends HTMLElement { } 16 document.defineElement('my-custom-element', MyCustomElement);16 customElements.define('my-custom-element', MyCustomElement); 17 17 18 18 document.write('<my-custom-element></my-custom-element>'); -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html
r197602 r204367 25 25 } 26 26 }; 27 document.defineElement('my-custom-element', MyCustomElement);27 customElements.define('my-custom-element', MyCustomElement); 28 28 29 29 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt
r197463 r204367 1 1 2 PASS HTML parser must NOT create a custom element before defineElementis called2 PASS HTML parser must NOT create a custom element before customElements.define is called 3 3 PASS HTML parser must create a defined custom element before executing inline scripts 4 4 -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html
r197602 r204367 24 24 assert_equals(customElement.namespaceURI, 'http://www.w3.org/1999/xhtml', 'A custom element HTML must use HTML namespace'); 25 25 26 }, 'HTML parser must NOT create a custom element before defineElementis called');26 }, 'HTML parser must NOT create a custom element before customElements.define is called'); 27 27 28 document.defineElement('my-custom-element', MyCustomElement);28 customElements.define('my-custom-element', MyCustomElement); 29 29 30 30 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html
r197602 r204367 19 19 } 20 20 }; 21 document.defineElement('returns-text', ReturnsTextNode);21 customElements.define('returns-text', ReturnsTextNode); 22 22 23 23 class ReturnsNonElementObject extends HTMLElement { … … 27 27 } 28 28 }; 29 document.defineElement('returns-non-element-object', ReturnsNonElementObject);29 customElements.define('returns-non-element-object', ReturnsNonElementObject); 30 30 31 31 class LacksSuperCall extends HTMLElement { 32 32 constructor() { } 33 33 }; 34 document.defineElement('lacks-super-call', LacksSuperCall);34 customElements.define('lacks-super-call', LacksSuperCall); 35 35 36 36 class ThrowsException extends HTMLElement { … … 39 39 } 40 40 }; 41 document.defineElement('throws-exception', ThrowsException);41 customElements.define('throws-exception', ThrowsException); 42 42 43 43 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html
r197602 r204367 23 23 } 24 24 }; 25 document.defineElement('my-custom-element', MyCustomElement);25 customElements.define('my-custom-element', MyCustomElement); 26 26 27 27 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html
r197602 r204367 26 26 } 27 27 }; 28 document.defineElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);28 customElements.define('instantiates-itself-before-super', InstantiatesItselfBeforeSuper); 29 29 30 30 let shouldCreateAnotherInstance = true; … … 43 43 } 44 44 }; 45 document.defineElement('returns-another-instance', ReturnsAnotherInstance);45 customElements.define('returns-another-instance', ReturnsAnotherInstance); 46 46 47 47 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html
r197602 r204367 14 14 15 15 class MyCustomElement extends HTMLElement { }; 16 document.defineElement('my-custom-element', MyCustomElement);16 customElements.define('my-custom-element', MyCustomElement); 17 17 18 18 document.write('<template><my-custom-element></my-custom-element></template>'); … … 44 44 45 45 class ElementInIFrame extends iframe.contentWindow.HTMLElement { }; 46 iframe.content Document.defineElement('element-in-iframe', ElementInIFrame);46 iframe.contentWindow.customElements.define('element-in-iframe', ElementInIFrame); 47 47 iframe.contentDocument.body.innerHTML = '<element-in-iframe></element-in-iframe>'; 48 48 -
trunk/LayoutTests/fast/custom-elements/upgrading/Node-cloneNode.html
r197917 r204367 26 26 test(function () { 27 27 class MyCustomElement extends HTMLElement {} 28 document.defineElement('my-custom-element', MyCustomElement);28 customElements.define('my-custom-element', MyCustomElement); 29 29 30 30 var instance = document.createElement('my-custom-element'); … … 43 43 withNewDocumentWithABrowsingContext(function (contentWindow, contentDocument) { 44 44 class MyCustomElement extends contentWindow.HTMLElement {} 45 content Document.defineElement('my-custom-element', MyCustomElement);45 contentWindow.customElements.define('my-custom-element', MyCustomElement); 46 46 47 47 var instance = contentDocument.createElement('my-custom-element'); … … 61 61 withNewDocumentWithABrowsingContext(function (contentWindow, contentDocument) { 62 62 class MyCustomElement extends contentWindow.HTMLElement { } 63 content Document.defineElement('my-custom-element', MyCustomElement);63 contentWindow.customElements.define('my-custom-element', MyCustomElement); 64 64 65 65 var instance = contentDocument.createElement('my-custom-element'); … … 92 92 } 93 93 } 94 content Document.defineElement('my-custom-element', MyCustomElement);94 contentWindow.customElements.define('my-custom-element', MyCustomElement); 95 95 96 96 var instance = contentDocument.createElement('my-custom-element'); … … 122 122 } 123 123 } 124 content Document.defineElement('my-custom-element', MyCustomElement);124 contentWindow.customElements.define('my-custom-element', MyCustomElement); 125 125 126 126 var instance = contentDocument.createElement('my-custom-element'); … … 139 139 } 140 140 } 141 content Document.defineElement('my-custom-element', MyCustomElement);141 contentWindow.customElements.define('my-custom-element', MyCustomElement); 142 142 143 143 var instance = contentDocument.createElement('my-custom-element'); … … 157 157 } 158 158 } 159 content Document.defineElement('my-custom-element', MyCustomElement);159 contentWindow.customElements.define('my-custom-element', MyCustomElement); 160 160 161 161 var instance = contentDocument.createElement('my-custom-element'); -
trunk/LayoutTests/fast/custom-elements/upgrading/upgrading-parser-created-element.html
r197917 r204367 28 28 assert_false(instance instanceof MyCustomElement); 29 29 30 document.defineElement('my-custom-element', MyCustomElement);30 customElements.define('my-custom-element', MyCustomElement); 31 31 32 32 assert_true(instance instanceof HTMLElement); 33 33 assert_true(instance instanceof MyCustomElement, 34 'Calling defineElementmust upgrade existing custom elements');34 'Calling customElements.define must upgrade existing custom elements'); 35 35 36 36 }, 'Element.prototype.createElement must add an unresolved custom element to the upgrade candidates map'); … … 47 47 48 48 assert_throws({'name': 'InvalidStateError'}, function () { 49 document.defineElement('instantiates-itself-after-super', InstantiatesItselfAfterSuper);49 customElements.define('instantiates-itself-after-super', InstantiatesItselfAfterSuper); 50 50 }); 51 51 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed' … … 62 62 63 63 assert_throws({'name': 'InvalidStateError'}, function () { 64 document.defineElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);64 customElements.define('instantiates-itself-before-super', InstantiatesItselfBeforeSuper); 65 65 }); 66 66 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed' … … 82 82 83 83 assert_throws({'name': 'InvalidStateError'}, function () { 84 document.defineElement('my-other-element', MyOtherElement);84 customElements.define('my-other-element', MyOtherElement); 85 85 }); 86 86 -
trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt
r204242 r204367 264 264 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false 265 265 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true 266 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry 267 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false 268 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false 269 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false 270 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true 266 271 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent 267 272 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
r204242 r204367 264 264 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false 265 265 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true 266 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry 267 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false 268 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false 269 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false 270 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true 266 271 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent 267 272 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
r204242 r204367 284 284 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false 285 285 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true 286 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry 287 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false 288 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false 289 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false 290 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true 286 291 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent 287 292 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
r204242 r204367 284 284 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false 285 285 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true 286 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry 287 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false 288 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false 289 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false 290 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true 286 291 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent 287 292 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt
r204242 r204367 199 199 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false 200 200 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true 201 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry 202 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false 203 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false 204 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false 205 PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true 201 206 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent 202 207 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false -
trunk/Source/WebCore/CMakeLists.txt
r204327 r204367 368 368 dom/Comment.idl 369 369 dom/CompositionEvent.idl 370 dom/CustomElementsRegistry.idl 370 371 dom/CustomEvent.idl 371 372 dom/DOMCoreException.idl … … 1121 1122 bindings/js/JSCryptoOperationData.cpp 1122 1123 bindings/js/JSCustomElementInterface.cpp 1124 bindings/js/JSCustomElementsRegistryCustom.cpp 1123 1125 bindings/js/JSCustomEventCustom.cpp 1124 1126 bindings/js/JSCustomSQLStatementErrorCallback.cpp … … 1421 1423 dom/ContainerNodeAlgorithms.cpp 1422 1424 dom/ContextDestructionObserver.cpp 1423 dom/CustomElement Definitions.cpp1425 dom/CustomElementsRegistry.cpp 1424 1426 dom/CustomEvent.cpp 1425 1427 dom/DOMCoreException.cpp -
trunk/Source/WebCore/ChangeLog
r204366 r204367 1 2016-08-10 Ryosuke Niwa <rniwa@webkit.org> 2 3 Move document.defineElement to customElements.define 4 https://bugs.webkit.org/show_bug.cgi?id=160731 5 6 Reviewed by Chris Dumez. 7 8 Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match 9 the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api 10 11 This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes 12 it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of 13 Document to match the spec's new semantics. 14 15 No new tests. The existing tests have been updated to reflect the change. 16 17 * DerivedSources.cpp: 18 * DerivedSources.make: 19 * WebCore.xcodeproj/project.pbxproj: 20 * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. 21 (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for 22 the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. 23 * bindings/js/JSDocumentCustom.cpp: 24 (WebCore::JSDocument::defineElement): Deleted. 25 * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since 26 the registry is associated with DOMWindow, not Document. 27 (WebCore::constructJSHTMLElement): 28 * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. 29 (WebCore::CustomElementsRegistry::create): Added. 30 (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. 31 (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. 32 (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. 33 (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. 34 (WebCore::CustomElementsRegistry::findInterface): Ditto. 35 (WebCore::CustomElementsRegistry::containsConstructor): Ditto. 36 * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. 37 * dom/CustomElementsRegistry.idl: Added. 38 * dom/Document.cpp: 39 (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation 40 and createFallbackHTMLElement to share code. 41 (WebCore::createHTMLElementWithNameValidation): 42 (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. 43 Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. 44 (WebCore::Document::ensureCustomElementDefinitions): Deleted. 45 * dom/Document.h: 46 (WebCore::Document::customElementDefinitions): Deleted. 47 * dom/Document.idl: 48 * dom/Element.cpp: 49 (WebCore::Element::attributeChanged): 50 * html/parser/HTMLConstructionSite.cpp: 51 (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): 52 * page/DOMWindow.cpp: 53 (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. 54 * page/DOMWindow.h: 55 * page/DOMWindow.idl: Added customElements on DOMWindow. 56 1 57 2016-08-10 Alex Christensen <achristensen@webkit.org> 2 58 -
trunk/Source/WebCore/DerivedSources.cpp
r203818 r204367 139 139 #include "JSCSSValue.cpp" 140 140 #include "JSCSSValueList.cpp" 141 #if ENABLE(CUSTOM_ELEMENTS) 142 #include "JSCustomElementsRegistry.cpp" 143 #endif 141 144 #include "JSCustomEvent.cpp" 142 145 #include "JSDatabase.cpp" -
trunk/Source/WebCore/DerivedSources.make
r204259 r204367 283 283 $(WebCore)/dom/Comment.idl \ 284 284 $(WebCore)/dom/CompositionEvent.idl \ 285 $(WebCore)/dom/CustomElementsRegistry.idl \ 285 286 $(WebCore)/dom/CustomEvent.idl \ 286 287 $(WebCore)/dom/DOMCoreException.idl \ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r204347 r204367 3929 3929 9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3930 3930 9BB737651B41C03500AE13EB /* NSAttributedStringSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BB737641B41C03500AE13EB /* NSAttributedStringSPI.h */; }; 3931 9BC5F9E01D5AAF6B002B749D /* JSCustomElementsRegistryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */; }; 3931 3932 9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3932 3933 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; }; … … 3935 3936 9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */; }; 3936 3937 9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9151C462872005065BC /* JSCustomElementInterface.h */; }; 3937 9BD4E91A1C462CFC005065BC /* CustomElement Definitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9181C462CFC005065BC /* CustomElementDefinitions.cpp */; };3938 9BD4E91B1C462CFC005065BC /* CustomElement Definitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9191C462CFC005065BC /* CustomElementDefinitions.h */; };3938 9BD4E91A1C462CFC005065BC /* CustomElementsRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */; }; 3939 9BD4E91B1C462CFC005065BC /* CustomElementsRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */; }; 3939 3940 9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */; }; 3940 3941 9BDA64D71B975CE5009C4387 /* JSShadowRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B6BC9601B975966005AE1F0 /* JSShadowRoot.cpp */; }; 3941 3942 9BDA64D81B975CF2009C4387 /* JSShadowRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6BC9611B975966005AE1F0 /* JSShadowRoot.h */; }; 3943 9BE6710B1D5AEB2100345514 /* JSCustomElementsRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */; }; 3944 9BE6710C1D5AEB2500345514 /* JSCustomElementsRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */; }; 3942 3945 9BF9A8801648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */; }; 3943 3946 9BF9A8811648DD2F001C6B23 /* JSHTMLFormControlsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */; }; … … 11495 11498 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritingDirection.h; sourceTree = "<group>"; }; 11496 11499 9BB737641B41C03500AE13EB /* NSAttributedStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSAttributedStringSPI.h; sourceTree = "<group>"; }; 11500 9BC5F9DE1D5AAD5D002B749D /* CustomElementsRegistry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomElementsRegistry.idl; sourceTree = "<group>"; }; 11501 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementsRegistryCustom.cpp; sourceTree = "<group>"; }; 11497 11502 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTextFormControlElement.h; sourceTree = "<group>"; }; 11498 11503 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFormControlElement.cpp; sourceTree = "<group>"; }; … … 11501 11506 9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementInterface.cpp; sourceTree = "<group>"; }; 11502 11507 9BD4E9151C462872005065BC /* JSCustomElementInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementInterface.h; sourceTree = "<group>"; }; 11503 9BD4E9181C462CFC005065BC /* CustomElement Definitions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementDefinitions.cpp; sourceTree = "<group>"; };11504 9BD4E9191C462CFC005065BC /* CustomElement Definitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomElementDefinitions.h; sourceTree = "<group>"; };11508 9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementsRegistry.cpp; sourceTree = "<group>"; }; 11509 9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomElementsRegistry.h; sourceTree = "<group>"; }; 11505 11510 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionIndexCache.cpp; sourceTree = "<group>"; }; 11511 9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSCustomElementsRegistry.cpp; path = "JSCustomElementsRegistry.cpp"; sourceTree = "<group>"; }; 11512 9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSCustomElementsRegistry.h; path = "JSCustomElementsRegistry.h"; sourceTree = "<group>"; }; 11506 11513 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = "<group>"; }; 11507 11514 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLFormControlsCollection.h; sourceTree = "<group>"; }; … … 20485 20492 FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */, 20486 20493 FE6FD48C0F676E9300092873 /* JSCoordinates.h */, 20494 9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */, 20495 9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */, 20487 20496 BCA83E4D0D7CE1E9003421A8 /* JSDataTransfer.cpp */, 20488 20497 BCA83E4E0D7CE1E9003421A8 /* JSDataTransfer.h */, … … 22091 22100 AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */, 22092 22101 BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */, 22102 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */, 22093 22103 DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */, 22094 22104 07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */, … … 23932 23942 97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */, 23933 23943 97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */, 23934 9BD4E9181C462CFC005065BC /* CustomElementDefinitions.cpp */, 23935 9BD4E9191C462CFC005065BC /* CustomElementDefinitions.h */, 23944 9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */, 23945 9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */, 23946 9BC5F9DE1D5AAD5D002B749D /* CustomElementsRegistry.idl */, 23936 23947 62CD32561157E57C0063B0A7 /* CustomEvent.cpp */, 23937 23948 62CD32571157E57C0063B0A7 /* CustomEvent.h */, … … 25178 25189 BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */, 25179 25190 BC2272AD0E82E8F300E7F975 /* CursorList.h in Headers */, 25180 9BD4E91B1C462CFC005065BC /* CustomElement Definitions.h in Headers */,25191 9BD4E91B1C462CFC005065BC /* CustomElementsRegistry.h in Headers */, 25181 25192 62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */, 25182 25193 A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */, … … 26804 26815 CDBEAEAD19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h in Headers */, 26805 26816 C9027F421B1D0AD200BFBFEF /* MediaSession.h in Headers */, 26817 9BE6710C1D5AEB2500345514 /* JSCustomElementsRegistry.h in Headers */, 26806 26818 C9F87CFE1B28F40E00979B83 /* MediaSessionEvents.h in Headers */, 26807 26819 C96F5EC81B5872260091EA9D /* MediaSessionInterruptionProvider.h in Headers */, … … 29016 29028 265541521489B233000DFC5D /* CursorIOS.cpp in Sources */, 29017 29029 93F19A2608245E59001E9ABC /* CursorMac.mm in Sources */, 29018 9BD4E91A1C462CFC005065BC /* CustomElement Definitions.cpp in Sources */,29030 9BD4E91A1C462CFC005065BC /* CustomElementsRegistry.cpp in Sources */, 29019 29031 62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */, 29020 29032 97BC6A201505F081001B74AC /* Database.cpp in Sources */, … … 30522 30534 BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */, 30523 30535 A8239E0009B3CF8A00B60641 /* Logging.cpp in Sources */, 30536 9BE6710B1D5AEB2100345514 /* JSCustomElementsRegistry.cpp in Sources */, 30524 30537 1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */, 30525 30538 1A0409F31A43675C009E47F3 /* MachSendRight.cpp in Sources */, … … 31043 31056 073BE34E17D180B2002BD431 /* RTCSessionDescriptionDescriptor.cpp in Sources */, 31044 31057 078E090E17D14CEE00420AA1 /* RTCStatsReport.cpp in Sources */, 31058 9BC5F9E01D5AAF6B002B749D /* JSCustomElementsRegistryCustom.cpp in Sources */, 31045 31059 078E091017D14CEE00420AA1 /* RTCStatsResponse.cpp in Sources */, 31046 31060 5E2C43671BCEE3770001E2BC /* RTCTrackEvent.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r204246 r204367 21 21 #include "JSDocument.h" 22 22 23 #include "CustomElementDefinitions.h"24 23 #include "ExceptionCode.h" 25 24 #include "Frame.h" … … 143 142 #endif 144 143 145 #if ENABLE(CUSTOM_ELEMENTS)146 JSValue JSDocument::defineElement(ExecState& state)147 {148 AtomicString tagName(state.argument(0).toString(&state)->toAtomicString(&state));149 if (UNLIKELY(state.hadException()))150 return jsUndefined();151 152 JSObject* object = state.argument(1).getObject();153 ConstructData callData;154 if (!object || object->methodTable()->getConstructData(object, callData) == ConstructType::None)155 return throwTypeError(&state, ASCIILiteral("The second argument must be a constructor"));156 157 Document& document = wrapped();158 if (!document.domWindow()) {159 throwNotSupportedError(state, "Cannot define a custom element in a docuemnt without a browsing context");160 return jsUndefined();161 }162 163 switch (Document::validateCustomElementName(tagName)) {164 case CustomElementNameValidationStatus::Valid:165 break;166 case CustomElementNameValidationStatus::ConflictsWithBuiltinNames:167 return throwSyntaxError(&state, "Custom element name cannot be same as one of the builtin elements");168 case CustomElementNameValidationStatus::NoHyphen:169 return throwSyntaxError(&state, "Custom element name must contain a hyphen");170 case CustomElementNameValidationStatus::ContainsUpperCase:171 return throwSyntaxError(&state, "Custom element name cannot contain an upper case letter");172 }173 174 auto& definitions = document.ensureCustomElementDefinitions();175 if (definitions.findInterface(tagName)) {176 throwNotSupportedError(state, "Cannot define multiple custom elements with the same tag name");177 return jsUndefined();178 }179 180 if (definitions.containsConstructor(object)) {181 throwNotSupportedError(state, "Cannot define multiple custom elements with the same class");182 return jsUndefined();183 }184 185 // FIXME: 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.186 // FIXME: 11. If Type(prototype) is not Object, throw a TypeError exception.187 // FIXME: 12. Let attachedCallback be Get(prototype, "attachedCallback"). Rethrow any exceptions.188 // FIXME: 13. Let detachedCallback be Get(prototype, "detachedCallback"). Rethrow any exceptions.189 // FIXME: 14. Let attributeChangedCallback be Get(prototype, "attributeChangedCallback"). Rethrow any exceptions.190 191 PrivateName uniquePrivateName;192 globalObject()->putDirect(globalObject()->vm(), uniquePrivateName, object);193 194 QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI);195 definitions.addElementDefinition(JSCustomElementInterface::create(name, object, globalObject()));196 197 // FIXME: 17. Let map be registry's upgrade candidates map.198 // FIXME: 18. Upgrade a newly-defined element given map and definition.199 200 return jsUndefined();201 }202 #endif203 204 144 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp
r202981 r204367 27 27 #include "JSHTMLElement.h" 28 28 29 #include "CustomElementDefinitions.h" 29 #include "CustomElementsRegistry.h" 30 #include "DOMWindow.h" 30 31 #include "Document.h" 31 32 #include "HTMLFormElement.h" 33 #include "JSCustomElementInterface.h" 32 34 #include "JSNodeCustom.h" 33 35 #include <runtime/InternalFunction.h> … … 48 50 auto& document = downcast<Document>(*context); 49 51 50 auto* definitions = document.customElementDefinitions(); 51 if (!definitions) 52 return throwVMTypeError(&exec, "new.target is not a valid custom element constructor"); 52 auto* window = document.domWindow(); 53 if (!window) 54 return throwVMTypeError(&exec, ASCIILiteral("new.target is not a valid custom element constructor")); 55 56 auto* registry = window->customElementsRegistry(); 57 if (!registry) 58 return throwVMTypeError(&exec, ASCIILiteral("new.target is not a valid custom element constructor")); 53 59 54 60 VM& vm = exec.vm(); 55 61 JSValue newTargetValue = exec.thisValue(); 56 62 JSObject* newTarget = newTargetValue.getObject(); 57 auto* elementInterface = definitions->findInterface(newTarget);63 auto* elementInterface = registry->findInterface(newTarget); 58 64 if (!elementInterface) 59 return throwVMTypeError(&exec, "new.target does not define a custom element");65 return throwVMTypeError(&exec, ASCIILiteral("new.target does not define a custom element")); 60 66 61 67 if (!elementInterface->isUpgradingElement()) { … … 75 81 Element* elementToUpgrade = elementInterface->lastElementInConstructionStack(); 76 82 if (!elementToUpgrade) { 77 throwInvalidStateError(exec, "Cannot instantiate a custom element inside its own constrcutor during upgrades");83 throwInvalidStateError(exec, ASCIILiteral("Cannot instantiate a custom element inside its own constrcutor during upgrades")); 78 84 return JSValue::encode(jsUndefined()); 79 85 } -
trunk/Source/WebCore/dom/CustomElementsRegistry.cpp
r204366 r204367 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include "CustomElement Definitions.h"27 #include "CustomElementsRegistry.h" 28 28 29 29 #if ENABLE(CUSTOM_ELEMENTS) … … 40 40 namespace WebCore { 41 41 42 void CustomElementDefinitions::addElementDefinition(Ref<JSCustomElementInterface>&& elementInterface) 42 Ref<CustomElementsRegistry> CustomElementsRegistry::create() 43 { 44 return adoptRef(*new CustomElementsRegistry()); 45 } 46 47 CustomElementsRegistry::CustomElementsRegistry() 48 { } 49 50 CustomElementsRegistry::~CustomElementsRegistry() 51 { } 52 53 void CustomElementsRegistry::addElementDefinition(Ref<JSCustomElementInterface>&& elementInterface) 43 54 { 44 55 AtomicString localName = elementInterface->name().localName(); … … 64 75 } 65 76 66 void CustomElement Definitions::addUpgradeCandidate(Element& candidate)77 void CustomElementsRegistry::addUpgradeCandidate(Element& candidate) 67 78 { 68 79 auto result = m_upgradeCandidatesMap.ensure(candidate.localName(), [] { … … 74 85 } 75 86 76 JSCustomElementInterface* CustomElement Definitions::findInterface(const QualifiedName& name) const87 JSCustomElementInterface* CustomElementsRegistry::findInterface(const QualifiedName& name) const 77 88 { 78 89 auto it = m_nameMap.find(name.localName()); 79 return it == m_nameMap.end() || it->value->name() != name ? nullptr : it->value.get();90 return it == m_nameMap.end() || it->value->name() != name ? nullptr : const_cast<JSCustomElementInterface*>(it->value.ptr()); 80 91 } 81 92 82 JSCustomElementInterface* CustomElement Definitions::findInterface(const AtomicString& name) const93 JSCustomElementInterface* CustomElementsRegistry::findInterface(const AtomicString& name) const 83 94 { 84 95 return m_nameMap.get(name); 85 96 } 86 97 87 JSCustomElementInterface* CustomElement Definitions::findInterface(const JSC::JSObject* constructor) const98 JSCustomElementInterface* CustomElementsRegistry::findInterface(const JSC::JSObject* constructor) const 88 99 { 89 100 return m_constructorMap.get(constructor); 90 101 } 91 102 92 bool CustomElement Definitions::containsConstructor(const JSC::JSObject* constructor) const103 bool CustomElementsRegistry::containsConstructor(const JSC::JSObject* constructor) const 93 104 { 94 105 return m_constructorMap.contains(constructor); -
trunk/Source/WebCore/dom/CustomElementsRegistry.h
r204366 r204367 24 24 */ 25 25 26 #include "JSCustomElementInterface.h" 26 #pragma once 27 28 #if ENABLE(CUSTOM_ELEMENTS) 29 27 30 #include "QualifiedName.h" 28 31 #include <wtf/HashMap.h> 29 32 #include <wtf/text/AtomicString.h> 30 33 #include <wtf/text/AtomicStringHash.h> 31 32 #ifndef CustomElementDefinitions_h33 #define CustomElementDefinitions_h34 35 #if ENABLE(CUSTOM_ELEMENTS)36 34 37 35 namespace JSC { … … 44 42 45 43 class Element; 44 class JSCustomElementInterface; 46 45 class QualifiedName; 47 46 48 class CustomElementDefinitions { 49 WTF_MAKE_FAST_ALLOCATED; 47 class CustomElementsRegistry : public RefCounted<CustomElementsRegistry> { 50 48 public: 49 static Ref<CustomElementsRegistry> create(); 50 ~CustomElementsRegistry(); 51 51 52 void addElementDefinition(Ref<JSCustomElementInterface>&&); 52 53 void addUpgradeCandidate(Element&); … … 58 59 59 60 private: 61 CustomElementsRegistry(); 62 60 63 HashMap<AtomicString, Vector<RefPtr<Element>>> m_upgradeCandidatesMap; 61 HashMap<AtomicString, Ref Ptr<JSCustomElementInterface>> m_nameMap;64 HashMap<AtomicString, Ref<JSCustomElementInterface>> m_nameMap; 62 65 HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap; 63 66 }; … … 66 69 67 70 #endif 68 69 #endif /* CustomElementDefinitions_h */ -
trunk/Source/WebCore/dom/Document.cpp
r204260 r204367 45 45 #include "ContentSecurityPolicy.h" 46 46 #include "CookieJar.h" 47 #include "CustomElement Definitions.h"47 #include "CustomElementsRegistry.h" 48 48 #include "CustomEvent.h" 49 49 #include "DOMImplementation.h" … … 101 101 #include "ImageLoader.h" 102 102 #include "InspectorInstrumentation.h" 103 #include "JSCustomElementInterface.h" 103 104 #include "JSLazyEventListener.h" 104 105 #include "JSModuleLoader.h" … … 880 881 } 881 882 883 #if ENABLE(CUSTOM_ELEMENTS) 884 static ALWAYS_INLINE RefPtr<HTMLElement> createUpgradeCandidateElement(Document& document, DOMWindow* window, const QualifiedName& name) 885 { 886 if (!window || !RuntimeEnabledFeatures::sharedFeatures().customElementsEnabled()) 887 return nullptr; 888 889 if (Document::validateCustomElementName(name.localName()) != CustomElementNameValidationStatus::Valid) 890 return nullptr; 891 892 auto element = HTMLElement::create(name, document); 893 element->setIsUnresolvedCustomElement(); 894 window->ensureCustomElementsRegistry().addUpgradeCandidate(element.get()); 895 return WTFMove(element); 896 } 897 #endif 898 882 899 static RefPtr<Element> createHTMLElementWithNameValidation(Document& document, const AtomicString& localName, ExceptionCode& ec) 883 900 { … … 887 904 888 905 #if ENABLE(CUSTOM_ELEMENTS) 889 auto* definitions = document.customElementDefinitions(); 890 if (UNLIKELY(definitions)) { 891 if (auto* elementInterface = definitions->findInterface(localName)) 892 return elementInterface->constructElement(localName, JSCustomElementInterface::ShouldClearException::DoNotClear); 906 auto* window = document.domWindow(); 907 if (window) { 908 auto* registry = window->customElementsRegistry(); 909 if (UNLIKELY(registry)) { 910 if (auto* elementInterface = registry->findInterface(localName)) 911 return elementInterface->constructElement(localName, JSCustomElementInterface::ShouldClearException::DoNotClear); 912 } 893 913 } 894 914 #endif … … 902 922 903 923 #if ENABLE(CUSTOM_ELEMENTS) 904 if (RuntimeEnabledFeatures::sharedFeatures().customElementsEnabled() 905 && Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) { 906 Ref<HTMLElement> element = HTMLElement::create(qualifiedName, document); 907 element->setIsUnresolvedCustomElement(); 908 document.ensureCustomElementDefinitions().addUpgradeCandidate(element.get()); 924 if (auto element = createUpgradeCandidateElement(document, window, qualifiedName)) 909 925 return WTFMove(element); 910 }911 926 #endif 912 927 … … 1072 1087 { 1073 1088 #if ENABLE(CUSTOM_ELEMENTS) 1074 auto* definitions = document.customElementDefinitions(); 1075 if (UNLIKELY(definitions)) { 1076 if (auto* elementInterface = definitions->findInterface(name)) { 1077 Ref<HTMLElement> element = HTMLElement::create(name, document); 1078 element->setIsUnresolvedCustomElement(); 1079 LifecycleCallbackQueue::enqueueElementUpgrade(element.get(), *elementInterface); 1080 return element; 1089 auto* window = document.domWindow(); 1090 if (window) { 1091 auto* registry = window->customElementsRegistry(); 1092 if (UNLIKELY(registry)) { 1093 if (auto* elementInterface = registry->findInterface(name)) { 1094 auto element = HTMLElement::create(name, document); 1095 element->setIsUnresolvedCustomElement(); 1096 LifecycleCallbackQueue::enqueueElementUpgrade(element.get(), *elementInterface); 1097 return element; 1098 } 1081 1099 } 1082 1100 } 1083 1101 // FIXME: Should we also check the equality of prefix between the custom element and name? 1084 if (Document::validateCustomElementName(name.localName()) == CustomElementNameValidationStatus::Valid) { 1085 Ref<HTMLElement> element = HTMLElement::create(name, document); 1086 element->setIsUnresolvedCustomElement(); 1087 document.ensureCustomElementDefinitions().addUpgradeCandidate(element.get()); 1088 return element; 1089 } 1102 if (auto element = createUpgradeCandidateElement(document, window, name)) 1103 return element.releaseNonNull(); 1090 1104 #endif 1091 1105 return HTMLUnknownElement::create(name, document); … … 6497 6511 } 6498 6512 6499 #if ENABLE(CUSTOM_ELEMENTS)6500 CustomElementDefinitions& Document::ensureCustomElementDefinitions()6501 {6502 if (!m_customElementDefinitions)6503 m_customElementDefinitions = std::make_unique<CustomElementDefinitions>();6504 return *m_customElementDefinitions;6505 }6506 #endif6507 6508 6513 LayoutRect Document::absoluteEventHandlerBounds(bool& includesFixedPositionElements) 6509 6514 { -
trunk/Source/WebCore/dom/Document.h
r204259 r204367 179 179 #endif 180 180 181 #if ENABLE(CUSTOM_ELEMENTS)182 class CustomElementDefinitions;183 #endif184 185 181 #if ENABLE(DASHBOARD_SUPPORT) 186 182 struct AnnotatedRegionValue; … … 1220 1216 } 1221 1217 1222 #if ENABLE(CUSTOM_ELEMENTS)1223 CustomElementDefinitions* customElementDefinitions() { return m_customElementDefinitions.get(); }1224 CustomElementDefinitions& ensureCustomElementDefinitions();1225 #endif1226 1227 1218 const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); } 1228 1219 … … 1754 1745 Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument). 1755 1746 1756 #if ENABLE(CUSTOM_ELEMENTS)1757 std::unique_ptr<CustomElementDefinitions> m_customElementDefinitions;1758 #endif1759 1760 1747 Ref<CSSFontSelector> m_fontSelector; 1761 1748 -
trunk/Source/WebCore/dom/Document.idl
r204259 r204367 244 244 #endif 245 245 246 [Custom, RaisesException, Conditional=CUSTOM_ELEMENTS, EnabledAtRuntime=CustomElements]247 void defineElement(DOMString localName, Function constructor);248 246 #endif 249 247 -
trunk/Source/WebCore/dom/Element.cpp
r204235 r204367 38 38 #include "ComposedTreeAncestorIterator.h" 39 39 #include "ContainerNodeAlgorithms.h" 40 #include "CustomElement Definitions.h"40 #include "CustomElementsRegistry.h" 41 41 #include "DOMTokenList.h" 42 42 #include "Dictionary.h" … … 1293 1293 #if ENABLE(CUSTOM_ELEMENTS) 1294 1294 if (UNLIKELY(isCustomElement())) { 1295 auto* definitions = document().customElementDefinitions(); 1296 auto* elementInterface = definitions->findInterface(tagQName()); 1297 RELEASE_ASSERT(elementInterface); 1298 LifecycleCallbackQueue::enqueueAttributeChangedCallback(*this, *elementInterface, name, oldValue, newValue); 1295 if (auto* window = document().domWindow()) { 1296 if (auto* registry = window->customElementsRegistry()) { 1297 auto* elementInterface = registry->findInterface(tagQName()); 1298 RELEASE_ASSERT(elementInterface); 1299 LifecycleCallbackQueue::enqueueAttributeChangedCallback(*this, *elementInterface, name, oldValue, newValue); 1300 } 1301 } 1299 1302 } 1300 1303 #endif -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r202559 r204367 29 29 30 30 #include "Comment.h" 31 #include "CustomElementDefinitions.h" 31 #include "CustomElementsRegistry.h" 32 #include "DOMWindow.h" 32 33 #include "DocumentFragment.h" 33 34 #include "DocumentType.h" … … 659 660 if (UNLIKELY(!element)) { 660 661 #if ENABLE(CUSTOM_ELEMENTS) 661 if (customElementInterface) { 662 auto* definitions = ownerDocument.customElementDefinitions(); 663 if (UNLIKELY(definitions)) { 664 if (auto* elementInterface = definitions->findInterface(localName)) { 662 auto* window = ownerDocument.domWindow(); 663 if (customElementInterface && window) { 664 auto* registry = window->customElementsRegistry(); 665 if (UNLIKELY(registry)) { 666 if (auto* elementInterface = registry->findInterface(localName)) { 665 667 *customElementInterface = elementInterface; 666 668 return nullptr; … … 674 676 QualifiedName qualifiedName(nullAtom, localName, xhtmlNamespaceURI); 675 677 #if ENABLE(CUSTOM_ELEMENTS) 676 if ( Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) {678 if (window && Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) { 677 679 element = HTMLElement::create(qualifiedName, ownerDocument); 678 680 element->setIsUnresolvedCustomElement(); 679 ownerDocument.ensureCustomElementDefinitions().addUpgradeCandidate(*element);681 window->ensureCustomElementsRegistry().addUpgradeCandidate(*element); 680 682 } else 681 683 #endif -
trunk/Source/WebCore/page/DOMWindow.cpp
r204259 r204367 39 39 #include "ContentExtensionRule.h" 40 40 #include "Crypto.h" 41 #include "CustomElementsRegistry.h" 41 42 #include "DOMApplicationCache.h" 42 43 #include "DOMSelection.h" … … 618 619 } 619 620 621 #if ENABLE(CUSTOM_ELEMENTS) 622 CustomElementsRegistry& DOMWindow::ensureCustomElementsRegistry() 623 { 624 if (!m_customElementsRegistry) 625 m_customElementsRegistry = CustomElementsRegistry::create(); 626 return *m_customElementsRegistry; 627 } 628 #endif 629 620 630 #if ENABLE(ORIENTATION_EVENTS) 621 631 int DOMWindow::orientation() const -
trunk/Source/WebCore/page/DOMWindow.h
r204259 r204367 50 50 class CSSStyleDeclaration; 51 51 class Crypto; 52 class CustomElementsRegistry; 52 53 class DOMApplicationCache; 53 54 class DOMSelection; … … 305 306 DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); } 306 307 308 #if ENABLE(CUSTOM_ELEMENTS) 309 CustomElementsRegistry* customElementsRegistry() { return m_customElementsRegistry.get(); } 310 CustomElementsRegistry& ensureCustomElementsRegistry(); 311 #endif 312 307 313 #if ENABLE(ORIENTATION_EVENTS) 308 314 // This is the interface orientation in degrees. Some examples are: … … 417 423 mutable RefPtr<DOMApplicationCache> m_applicationCache; 418 424 425 #if ENABLE(CUSTOM_ELEMENTS) 426 RefPtr<CustomElementsRegistry> m_customElementsRegistry; 427 #endif 428 419 429 #if ENABLE(WEB_TIMING) 420 430 mutable RefPtr<Performance> m_performance; -
trunk/Source/WebCore/page/DOMWindow.idl
r204246 r204367 202 202 #endif // defined(LANGUAGE_JAVASCRIPT) 203 203 204 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT 205 [Conditional=CUSTOM_ELEMENTS, ImplementedAs=ensureCustomElementsRegistry] readonly attribute CustomElementsRegistry customElements; 206 #endif 207 204 208 205 209 // Event Handlers
Note: See TracChangeset
for help on using the changeset viewer.