Title: [204732] trunk
Revision
204732
Author
[email protected]
Date
2016-08-22 12:45:01 -0700 (Mon, 22 Aug 2016)

Log Message

Rename CustomElementsRegistry to CustomElementRegistry
https://bugs.webkit.org/show_bug.cgi?id=161028

Reviewed by Darin Adler.

Source/_javascript_Core:

Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow
to hide window.customElements and CustomElementRegistry interface behind a runtime flag.

* runtime/CommonIdentifiers.h:

Source/WebCore:

Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548.

Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp.
(WebCore::getCustomElementCallback):
(WebCore::JSCustomElementRegistry::define):
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement):
* dom/CustomElementReactionQueue.cpp:
(WebCore::findInterfaceForCustomElement):
* dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp.
(WebCore::CustomElementRegistry::create):
(WebCore::CustomElementRegistry::CustomElementRegistry):
(WebCore::CustomElementRegistry::~CustomElementRegistry):
(WebCore::CustomElementRegistry::addElementDefinition):
(WebCore::CustomElementRegistry::addUpgradeCandidate):
(WebCore::CustomElementRegistry::findInterface):
(WebCore::CustomElementRegistry::containsConstructor):
* dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h.
* dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl.
* dom/Document.cpp:
(WebCore::createUpgradeCandidateElement):
(WebCore::createHTMLElementWithNameValidation):
(WebCore::createFallbackHTMLElement):
* dom/Element.cpp:
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::ensureCustomElementRegistry):
* page/DOMWindow.h:
* page/DOMWindow.idl:

LayoutTests:

Updated the tests and expected results after the rename.

* fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt.
* fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html.
* platform/efl/js/dom/global-constructors-attributes-expected.txt:
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/js/dom/global-constructors-attributes-expected.txt:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (204731 => 204732)


--- trunk/LayoutTests/ChangeLog	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/ChangeLog	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,3 +1,21 @@
+2016-08-22  Ryosuke Niwa  <[email protected]>
+
+        Rename CustomElementsRegistry to CustomElementRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=161028
+
+        Reviewed by Darin Adler.
+
+        Updated the tests and expected results after the rename.
+
+        * fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt.
+        * fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html.
+        * platform/efl/js/dom/global-constructors-attributes-expected.txt:
+        * platform/gtk/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac/js/dom/global-constructors-attributes-expected.txt:
+        * platform/win/js/dom/global-constructors-attributes-expected.txt:
+
 2016-08-22  Daniel Bates  <[email protected]>
 
         Attempt to fix the iOS 9 Simulator test bots after <https://trac.webkit.org/changeset/204720>

Added: trunk/LayoutTests/fast/custom-elements/CustomElementRegistry-expected.txt (0 => 204732)


--- trunk/LayoutTests/fast/custom-elements/CustomElementRegistry-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/CustomElementRegistry-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,20 @@
+
+PASS CustomElementRegistry interface must have define as a method 
+PASS customElements.define must throw with an invalid name 
+PASS customElements.define must throw when there is already a custom element of the same name 
+PASS customElements.define must throw when there is already a custom element with the same class 
+PASS customElements.define must throw when the element interface is not a constructor 
+PASS customElements.define must get "prototype" property of the constructor 
+PASS customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor 
+PASS customElements.define must throw when "prototype" property of the constructor is not an object 
+PASS customElements.define must get callbacks of the constructor prototype 
+PASS customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype 
+PASS customElements.define must rethrow an exception thrown while converting a callback value to Function callback type 
+PASS customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present 
+PASS customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype 
+PASS customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString> 
+PASS customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence<DOMString> 
+PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes 
+PASS customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined 
+PASS customElements.define must define an instantiatable custom element 
+

Added: trunk/LayoutTests/fast/custom-elements/CustomElementRegistry.html (0 => 204732)


--- trunk/LayoutTests/fast/custom-elements/CustomElementRegistry.html	                        (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/CustomElementRegistry.html	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,272 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Custom Elements: CustomElementRegistry interface</title>
+<meta name="author" title="Ryosuke Niwa" href=""
+<meta name="assert" content="CustomElementRegistry interface must exist">
+<script src=""
+<script src=""
+<link rel='stylesheet' href=''>
+</head>
+<body>
+<div id="log"></div>
+<script>
+
+test(function () {
+    assert_true('define' in CustomElementRegistry.prototype, '"define" exists on CustomElementRegistry.prototype');
+    assert_true('define' in customElements, '"define" exists on window.customElements');
+}, 'CustomElementRegistry interface must have define as a method');
+
+test(function () {
+    class MyCustomElement extends HTMLElement {};
+
+    assert_throws({'name': 'SyntaxError'}, function () { customElements.define(null, MyCustomElement); },
+        'customElements.define must throw a SyntaxError if the tag name is null');
+    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('', MyCustomElement); },
+        'customElements.define must throw a SyntaxError if the tag name is empty');
+    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('abc', MyCustomElement); },
+        'customElements.define must throw a SyntaxError if the tag name does not contain "-"');
+    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('a-Bc', MyCustomElement); },
+        'customElements.define must throw a SyntaxError if the tag name contains an upper case letter');
+
+    var builtinTagNames = [
+        'annotation-xml',
+        'color-profile',
+        'font-face',
+        'font-face-src',
+        'font-face-uri',
+        'font-face-format',
+        'font-face-name',
+        'missing-glyph'
+    ];
+
+    for (var tagName of builtinTagNames) {
+        assert_throws({'name': 'SyntaxError'}, function () { customElements.define(tagName, MyCustomElement); },
+            'customElements.define must throw a SyntaxError if the tag name is "' + tagName + '"');
+    }
+
+}, 'customElements.define must throw with an invalid name');
+
+test(function () {
+    class SomeCustomElement extends HTMLElement {};
+    class OtherCustomElement extends HTMLElement {};
+
+    customElements.define('some-custom-element', SomeCustomElement);
+    assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-custom-element', OtherCustomElement); },
+        'customElements.define must throw a NotSupportedError if the specified tag name is already used');
+
+}, 'customElements.define must throw when there is already a custom element of the same name');
+
+test(function () {
+    class AnotherCustomElement extends HTMLElement {};
+
+    customElements.define('another-custom-element', AnotherCustomElement);
+    assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-other-element', AnotherCustomElement); },
+        'customElements.define must throw a NotSupportedError if the specified class already defines an element');
+
+}, 'customElements.define must throw when there is already a custom element with the same class');
+
+test(function () {
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', 1); },
+        'customElements.define must throw a TypeError when the element interface is a number');
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', '123'); },
+        'customElements.define must throw a TypeError when the element interface is a string');
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', {}); },
+        'customElements.define must throw a TypeError when the element interface is an object');
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', []); },
+        'customElements.define must throw a TypeError when the element interface is an array');
+}, 'customElements.define must throw when the element interface is not a constructor');
+
+test(function () {
+    var calls = [];
+    var proxy = new Proxy(class extends HTMLElement { }, {
+        get: function (target, name) {
+            calls.push(name);
+            return target[name];
+        }
+    });
+    customElements.define('proxy-element', proxy);
+    assert_array_equals(calls, ['prototype']);
+}, 'customElements.define must get "prototype" property of the constructor');
+
+test(function () {
+    var proxy = new Proxy(class extends HTMLElement { }, {
+        get: function (target, name) {
+            throw {name: 'expectedError'};
+        }
+    });
+    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-string-prototype', proxy); });
+}, 'customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor');
+
+test(function () {
+    var returnedValue;
+    var proxy = new Proxy(class extends HTMLElement { }, {
+        get: function (target, name) { return returnedValue; }
+    });
+
+    returnedValue = null;
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
+        'customElements.define must throw when "prototype" property of the constructor is null');
+    returnedValue = undefined;
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
+        'customElements.define must throw when "prototype" property of the constructor is undefined');
+    returnedValue = 'hello';
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
+        'customElements.define must throw when "prototype" property of the constructor is a string');
+    returnedValue = 1;
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
+        'customElements.define must throw when "prototype" property of the constructor is a number');
+
+}, 'customElements.define must throw when "prototype" property of the constructor is not an object');
+
+test(function () {
+    var constructor = function () {}
+    var calls = [];
+    constructor.prototype = new Proxy(constructor.prototype, {
+        get: function (target, name) {
+            calls.push(name);
+            return target[name];
+        }
+    });
+    customElements.define('element-with-proxy-prototype', constructor);
+    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']);
+}, 'customElements.define must get callbacks of the constructor prototype');
+
+test(function () {
+    var constructor = function () {}
+    var calls = [];
+    constructor.prototype = new Proxy(constructor.prototype, {
+        get: function (target, name) {
+            calls.push(name);
+            if (name == 'disconnectedCallback')
+                throw {name: 'expectedError'};
+            return target[name];
+        }
+    });
+    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-throwing-callback', constructor); });
+    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback'],
+        'customElements.define must not get callbacks after one of the get throws');
+}, 'customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype');
+
+test(function () {
+    var constructor = function () {}
+    var calls = [];
+    constructor.prototype = new Proxy(constructor.prototype, {
+        get: function (target, name) {
+            calls.push(name);
+            if (name == 'adoptedCallback')
+                return 1;
+            return target[name];
+        }
+    });
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-throwing-callback', constructor); });
+    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback', 'adoptedCallback'],
+        'customElements.define must not get callbacks after one of the conversion throws');
+}, 'customElements.define must rethrow an exception thrown while converting a callback value to Function callback type');
+
+test(function () {
+    var constructor = function () {}
+    constructor.prototype.attributeChangedCallback = function () { };
+    var prototypeCalls = [];
+    var callOrder = 0;
+    constructor.prototype = new Proxy(constructor.prototype, {
+        get: function (target, name) {
+            if (name == 'prototype' || name == 'observedAttributes')
+                throw 'Unexpected access to observedAttributes';
+            prototypeCalls.push(callOrder++);    
+            prototypeCalls.push(name);
+            return target[name];
+        }
+    });
+    var constructorCalls = [];
+    var proxy = new Proxy(constructor, {
+        get: function (target, name) {
+            constructorCalls.push(callOrder++);    
+            constructorCalls.push(name);
+            return target[name];
+        }
+    });
+    customElements.define('element-with-attribute-changed-callback', proxy);
+    assert_array_equals(prototypeCalls, [1, 'connectedCallback', 2, 'disconnectedCallback', 3, 'adoptedCallback', 4, 'attributeChangedCallback']);
+    assert_array_equals(constructorCalls, [0, 'prototype', 5, 'observedAttributes']);
+}, 'customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present');
+
+test(function () {
+    var constructor = function () {}
+    constructor.prototype.attributeChangedCallback = function () { };
+    var calls = [];
+    var proxy = new Proxy(constructor, {
+        get: function (target, name) {
+            calls.push(name);
+            if (name == 'observedAttributes')
+                throw {name: 'expectedError'};
+            return target[name];
+        }
+    });
+    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-throwing-observed-attributes', proxy); });
+    assert_array_equals(calls, ['prototype', 'observedAttributes'],
+        'customElements.define must get "prototype" and "observedAttributes" on the constructor');
+}, 'customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype');
+
+test(function () {
+    var constructor = function () {}
+    constructor.prototype.attributeChangedCallback = function () { };
+    var calls = [];
+    var proxy = new Proxy(constructor, {
+        get: function (target, name) {
+            calls.push(name);
+            if (name == 'observedAttributes')
+                return 1;
+            return target[name];
+        }
+    });
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-invalid-observed-attributes', proxy); });
+    assert_array_equals(calls, ['prototype', 'observedAttributes'],
+        'customElements.define must get "prototype" and "observedAttributes" on the constructor');
+}, 'customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString>');
+
+test(function () {
+    var constructor = function () {}
+    constructor.prototype.attributeChangedCallback = function () { };
+    constructor.observedAttributes = {[Symbol.iterator]: function *() {
+        yield 'foo';
+        throw {name: 'SomeError'};
+    }};
+    assert_throws({'name': 'SomeError'}, function () { customElements.define('element-with-generator-observed-attributes', constructor); });
+}, 'customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence<DOMString>');
+
+test(function () {
+    var constructor = function () {}
+    constructor.prototype.attributeChangedCallback = function () { };
+    constructor.observedAttributes = {[Symbol.iterator]: 1};
+    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-observed-attributes-with-uncallable-iterator', constructor); });
+}, 'customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes');
+
+test(function () {
+    var constructor = function () {}
+    constructor.observedAttributes = 1;
+    customElements.define('element-without-callback-with-invalid-observed-attributes', constructor);
+}, 'customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined');
+
+test(function () {
+    class MyCustomElement extends HTMLElement {};
+    customElements.define('my-custom-element', MyCustomElement);
+
+    var instance = new MyCustomElement;
+    assert_true(instance instanceof MyCustomElement,
+        'An instance of a custom HTML element be an instance of the associated interface');
+
+    assert_true(instance instanceof HTMLElement,
+        'An instance of a custom HTML element must inherit from HTMLElement');
+
+    assert_equals(instance.localName, 'my-custom-element',
+        'An instance of a custom element must use the associated tag name');
+
+    assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml',
+        'A custom element HTML must use HTML namespace');
+
+}, 'customElements.define must define an instantiatable custom element');
+
+</script>
+</body>
+</html>

Deleted: trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt (204731 => 204732)


--- trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,20 +0,0 @@
-
-PASS CustomElementsRegistry interface must have define as a method 
-PASS customElements.define must throw with an invalid name 
-PASS customElements.define must throw when there is already a custom element of the same name 
-PASS customElements.define must throw when there is already a custom element with the same class 
-PASS customElements.define must throw when the element interface is not a constructor 
-PASS customElements.define must get "prototype" property of the constructor 
-PASS customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor 
-PASS customElements.define must throw when "prototype" property of the constructor is not an object 
-PASS customElements.define must get callbacks of the constructor prototype 
-PASS customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype 
-PASS customElements.define must rethrow an exception thrown while converting a callback value to Function callback type 
-PASS customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present 
-PASS customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype 
-PASS customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString> 
-PASS customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence<DOMString> 
-PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes 
-PASS customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined 
-PASS customElements.define must define an instantiatable custom element 
-

Deleted: trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry.html (204731 => 204732)


--- trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry.html	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/fast/custom-elements/CustomElementsRegistry.html	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,272 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Custom Elements: CustomElementsRegistry interface</title>
-<meta name="author" title="Ryosuke Niwa" href=""
-<meta name="assert" content="CustomElementsRegistry interface must exist">
-<script src=""
-<script src=""
-<link rel='stylesheet' href=''>
-</head>
-<body>
-<div id="log"></div>
-<script>
-
-test(function () {
-    assert_true('define' in CustomElementsRegistry.prototype, '"define" exists on CustomElementsRegistry.prototype');
-    assert_true('define' in customElements, '"define" exists on window.customElements');
-}, 'CustomElementsRegistry interface must have define as a method');
-
-test(function () {
-    class MyCustomElement extends HTMLElement {};
-
-    assert_throws({'name': 'SyntaxError'}, function () { customElements.define(null, MyCustomElement); },
-        'customElements.define must throw a SyntaxError if the tag name is null');
-    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('', MyCustomElement); },
-        'customElements.define must throw a SyntaxError if the tag name is empty');
-    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('abc', MyCustomElement); },
-        'customElements.define must throw a SyntaxError if the tag name does not contain "-"');
-    assert_throws({'name': 'SyntaxError'}, function () { customElements.define('a-Bc', MyCustomElement); },
-        'customElements.define must throw a SyntaxError if the tag name contains an upper case letter');
-
-    var builtinTagNames = [
-        'annotation-xml',
-        'color-profile',
-        'font-face',
-        'font-face-src',
-        'font-face-uri',
-        'font-face-format',
-        'font-face-name',
-        'missing-glyph'
-    ];
-
-    for (var tagName of builtinTagNames) {
-        assert_throws({'name': 'SyntaxError'}, function () { customElements.define(tagName, MyCustomElement); },
-            'customElements.define must throw a SyntaxError if the tag name is "' + tagName + '"');
-    }
-
-}, 'customElements.define must throw with an invalid name');
-
-test(function () {
-    class SomeCustomElement extends HTMLElement {};
-    class OtherCustomElement extends HTMLElement {};
-
-    customElements.define('some-custom-element', SomeCustomElement);
-    assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-custom-element', OtherCustomElement); },
-        'customElements.define must throw a NotSupportedError if the specified tag name is already used');
-
-}, 'customElements.define must throw when there is already a custom element of the same name');
-
-test(function () {
-    class AnotherCustomElement extends HTMLElement {};
-
-    customElements.define('another-custom-element', AnotherCustomElement);
-    assert_throws({'name': 'NotSupportedError'}, function () { customElements.define('some-other-element', AnotherCustomElement); },
-        'customElements.define must throw a NotSupportedError if the specified class already defines an element');
-
-}, 'customElements.define must throw when there is already a custom element with the same class');
-
-test(function () {
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', 1); },
-        'customElements.define must throw a TypeError when the element interface is a number');
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', '123'); },
-        'customElements.define must throw a TypeError when the element interface is a string');
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', {}); },
-        'customElements.define must throw a TypeError when the element interface is an object');
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('invalid-element', []); },
-        'customElements.define must throw a TypeError when the element interface is an array');
-}, 'customElements.define must throw when the element interface is not a constructor');
-
-test(function () {
-    var calls = [];
-    var proxy = new Proxy(class extends HTMLElement { }, {
-        get: function (target, name) {
-            calls.push(name);
-            return target[name];
-        }
-    });
-    customElements.define('proxy-element', proxy);
-    assert_array_equals(calls, ['prototype']);
-}, 'customElements.define must get "prototype" property of the constructor');
-
-test(function () {
-    var proxy = new Proxy(class extends HTMLElement { }, {
-        get: function (target, name) {
-            throw {name: 'expectedError'};
-        }
-    });
-    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-string-prototype', proxy); });
-}, 'customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor');
-
-test(function () {
-    var returnedValue;
-    var proxy = new Proxy(class extends HTMLElement { }, {
-        get: function (target, name) { return returnedValue; }
-    });
-
-    returnedValue = null;
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
-        'customElements.define must throw when "prototype" property of the constructor is null');
-    returnedValue = undefined;
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
-        'customElements.define must throw when "prototype" property of the constructor is undefined');
-    returnedValue = 'hello';
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
-        'customElements.define must throw when "prototype" property of the constructor is a string');
-    returnedValue = 1;
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-string-prototype', proxy); },
-        'customElements.define must throw when "prototype" property of the constructor is a number');
-
-}, 'customElements.define must throw when "prototype" property of the constructor is not an object');
-
-test(function () {
-    var constructor = function () {}
-    var calls = [];
-    constructor.prototype = new Proxy(constructor.prototype, {
-        get: function (target, name) {
-            calls.push(name);
-            return target[name];
-        }
-    });
-    customElements.define('element-with-proxy-prototype', constructor);
-    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']);
-}, 'customElements.define must get callbacks of the constructor prototype');
-
-test(function () {
-    var constructor = function () {}
-    var calls = [];
-    constructor.prototype = new Proxy(constructor.prototype, {
-        get: function (target, name) {
-            calls.push(name);
-            if (name == 'disconnectedCallback')
-                throw {name: 'expectedError'};
-            return target[name];
-        }
-    });
-    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-throwing-callback', constructor); });
-    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback'],
-        'customElements.define must not get callbacks after one of the get throws');
-}, 'customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype');
-
-test(function () {
-    var constructor = function () {}
-    var calls = [];
-    constructor.prototype = new Proxy(constructor.prototype, {
-        get: function (target, name) {
-            calls.push(name);
-            if (name == 'adoptedCallback')
-                return 1;
-            return target[name];
-        }
-    });
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-throwing-callback', constructor); });
-    assert_array_equals(calls, ['connectedCallback', 'disconnectedCallback', 'adoptedCallback'],
-        'customElements.define must not get callbacks after one of the conversion throws');
-}, 'customElements.define must rethrow an exception thrown while converting a callback value to Function callback type');
-
-test(function () {
-    var constructor = function () {}
-    constructor.prototype.attributeChangedCallback = function () { };
-    var prototypeCalls = [];
-    var callOrder = 0;
-    constructor.prototype = new Proxy(constructor.prototype, {
-        get: function (target, name) {
-            if (name == 'prototype' || name == 'observedAttributes')
-                throw 'Unexpected access to observedAttributes';
-            prototypeCalls.push(callOrder++);    
-            prototypeCalls.push(name);
-            return target[name];
-        }
-    });
-    var constructorCalls = [];
-    var proxy = new Proxy(constructor, {
-        get: function (target, name) {
-            constructorCalls.push(callOrder++);    
-            constructorCalls.push(name);
-            return target[name];
-        }
-    });
-    customElements.define('element-with-attribute-changed-callback', proxy);
-    assert_array_equals(prototypeCalls, [1, 'connectedCallback', 2, 'disconnectedCallback', 3, 'adoptedCallback', 4, 'attributeChangedCallback']);
-    assert_array_equals(constructorCalls, [0, 'prototype', 5, 'observedAttributes']);
-}, 'customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present');
-
-test(function () {
-    var constructor = function () {}
-    constructor.prototype.attributeChangedCallback = function () { };
-    var calls = [];
-    var proxy = new Proxy(constructor, {
-        get: function (target, name) {
-            calls.push(name);
-            if (name == 'observedAttributes')
-                throw {name: 'expectedError'};
-            return target[name];
-        }
-    });
-    assert_throws({'name': 'expectedError'}, function () { customElements.define('element-with-throwing-observed-attributes', proxy); });
-    assert_array_equals(calls, ['prototype', 'observedAttributes'],
-        'customElements.define must get "prototype" and "observedAttributes" on the constructor');
-}, 'customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype');
-
-test(function () {
-    var constructor = function () {}
-    constructor.prototype.attributeChangedCallback = function () { };
-    var calls = [];
-    var proxy = new Proxy(constructor, {
-        get: function (target, name) {
-            calls.push(name);
-            if (name == 'observedAttributes')
-                return 1;
-            return target[name];
-        }
-    });
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-invalid-observed-attributes', proxy); });
-    assert_array_equals(calls, ['prototype', 'observedAttributes'],
-        'customElements.define must get "prototype" and "observedAttributes" on the constructor');
-}, 'customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString>');
-
-test(function () {
-    var constructor = function () {}
-    constructor.prototype.attributeChangedCallback = function () { };
-    constructor.observedAttributes = {[Symbol.iterator]: function *() {
-        yield 'foo';
-        throw {name: 'SomeError'};
-    }};
-    assert_throws({'name': 'SomeError'}, function () { customElements.define('element-with-generator-observed-attributes', constructor); });
-}, 'customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence<DOMString>');
-
-test(function () {
-    var constructor = function () {}
-    constructor.prototype.attributeChangedCallback = function () { };
-    constructor.observedAttributes = {[Symbol.iterator]: 1};
-    assert_throws({'name': 'TypeError'}, function () { customElements.define('element-with-observed-attributes-with-uncallable-iterator', constructor); });
-}, 'customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes');
-
-test(function () {
-    var constructor = function () {}
-    constructor.observedAttributes = 1;
-    customElements.define('element-without-callback-with-invalid-observed-attributes', constructor);
-}, 'customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined');
-
-test(function () {
-    class MyCustomElement extends HTMLElement {};
-    customElements.define('my-custom-element', MyCustomElement);
-
-    var instance = new MyCustomElement;
-    assert_true(instance instanceof MyCustomElement,
-        'An instance of a custom HTML element be an instance of the associated interface');
-
-    assert_true(instance instanceof HTMLElement,
-        'An instance of a custom HTML element must inherit from HTMLElement');
-
-    assert_equals(instance.localName, 'my-custom-element',
-        'An instance of a custom element must use the associated tag name');
-
-    assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml',
-        'A custom element HTML must use HTML namespace');
-
-}, 'customElements.define must define an instantiatable custom element');
-
-</script>
-</body>
-</html>

Modified: trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -263,11 +263,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -298,11 +298,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -298,11 +298,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -298,11 +298,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -298,11 +298,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt (204731 => 204732)


--- trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -198,11 +198,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').value is CustomElementsRegistry
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'CustomElementsRegistry').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').value is CustomElementRegistry
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'CustomElementRegistry').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').value is CustomEvent
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'CustomEvent').hasOwnProperty('set') is false

Modified: trunk/Source/_javascript_Core/ChangeLog (204731 => 204732)


--- trunk/Source/_javascript_Core/ChangeLog	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,3 +1,15 @@
+2016-08-22  Ryosuke Niwa  <[email protected]>
+
+        Rename CustomElementsRegistry to CustomElementRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=161028
+
+        Reviewed by Darin Adler.
+
+        Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow
+        to hide window.customElements and CustomElementRegistry interface behind a runtime flag.
+
+        * runtime/CommonIdentifiers.h:
+
 2016-08-22  Mark Lam  <[email protected]>
 
         Remove dead code.

Modified: trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h (204731 => 204732)


--- trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2016-08-22 19:45:01 UTC (rev 204732)
@@ -37,6 +37,7 @@
     macro(BYTES_PER_ELEMENT) \
     macro(Boolean) \
     macro(Collator) \
+    macro(CustomElementRegistry) \
     macro(Date) \
     macro(DateTimeFormat) \
     macro(DocumentTimeline) \
@@ -135,6 +136,7 @@
     macro(constructor) \
     macro(count) \
     macro(counters) \
+    macro(customElements) \
     macro(day) \
     macro(defineProperty) \
     macro(description) \

Modified: trunk/Source/WebCore/CMakeLists.txt (204731 => 204732)


--- trunk/Source/WebCore/CMakeLists.txt	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-08-22 19:45:01 UTC (rev 204732)
@@ -375,7 +375,7 @@
     dom/ClientRectList.idl
     dom/Comment.idl
     dom/CompositionEvent.idl
-    dom/CustomElementsRegistry.idl
+    dom/CustomElementRegistry.idl
     dom/CustomEvent.idl
     dom/DOMCoreException.idl
     dom/DOMError.idl
@@ -1136,7 +1136,7 @@
     bindings/js/JSCryptoKeySerializationJWK.cpp
     bindings/js/JSCryptoOperationData.cpp
     bindings/js/JSCustomElementInterface.cpp
-    bindings/js/JSCustomElementsRegistryCustom.cpp
+    bindings/js/JSCustomElementRegistryCustom.cpp
     bindings/js/JSCustomEventCustom.cpp
     bindings/js/JSCustomSQLStatementErrorCallback.cpp
     bindings/js/JSCustomXPathNSResolver.cpp
@@ -1438,7 +1438,7 @@
     dom/ContainerNodeAlgorithms.cpp
     dom/ContextDestructionObserver.cpp
     dom/CustomElementReactionQueue.cpp
-    dom/CustomElementsRegistry.cpp
+    dom/CustomElementRegistry.cpp
     dom/CustomEvent.cpp
     dom/DOMCoreException.cpp
     dom/DOMError.cpp

Modified: trunk/Source/WebCore/ChangeLog (204731 => 204732)


--- trunk/Source/WebCore/ChangeLog	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/ChangeLog	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,3 +1,47 @@
+2016-08-22  Ryosuke Niwa  <[email protected]>
+
+        Rename CustomElementsRegistry to CustomElementRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=161028
+
+        Reviewed by Darin Adler.
+
+        Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548.
+
+        Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled.
+
+        * CMakeLists.txt:
+        * DerivedSources.cpp:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp.
+        (WebCore::getCustomElementCallback):
+        (WebCore::JSCustomElementRegistry::define):
+        * bindings/js/JSHTMLElementCustom.cpp:
+        (WebCore::constructJSHTMLElement):
+        * dom/CustomElementReactionQueue.cpp:
+        (WebCore::findInterfaceForCustomElement):
+        * dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp.
+        (WebCore::CustomElementRegistry::create):
+        (WebCore::CustomElementRegistry::CustomElementRegistry):
+        (WebCore::CustomElementRegistry::~CustomElementRegistry):
+        (WebCore::CustomElementRegistry::addElementDefinition):
+        (WebCore::CustomElementRegistry::addUpgradeCandidate):
+        (WebCore::CustomElementRegistry::findInterface):
+        (WebCore::CustomElementRegistry::containsConstructor):
+        * dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h.
+        * dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl.
+        * dom/Document.cpp:
+        (WebCore::createUpgradeCandidateElement):
+        (WebCore::createHTMLElementWithNameValidation):
+        (WebCore::createFallbackHTMLElement):
+        * dom/Element.cpp:
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::ensureCustomElementRegistry):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
 2016-08-22  Chris Dumez  <[email protected]>
 
         Add support for GlobalEventHandlers.oncuechange attribute

Modified: trunk/Source/WebCore/DerivedSources.cpp (204731 => 204732)


--- trunk/Source/WebCore/DerivedSources.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/DerivedSources.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -138,7 +138,7 @@
 #include "JSCSSValue.cpp"
 #include "JSCSSValueList.cpp"
 #if ENABLE(CUSTOM_ELEMENTS)
-#include "JSCustomElementsRegistry.cpp"
+#include "JSCustomElementRegistry.cpp"
 #endif
 #include "JSCustomEvent.cpp"
 #include "JSDatabase.cpp"

Modified: trunk/Source/WebCore/DerivedSources.make (204731 => 204732)


--- trunk/Source/WebCore/DerivedSources.make	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/DerivedSources.make	2016-08-22 19:45:01 UTC (rev 204732)
@@ -286,7 +286,7 @@
     $(WebCore)/dom/ClientRectList.idl \
     $(WebCore)/dom/Comment.idl \
     $(WebCore)/dom/CompositionEvent.idl \
-    $(WebCore)/dom/CustomElementsRegistry.idl \
+    $(WebCore)/dom/CustomElementRegistry.idl \
     $(WebCore)/dom/CustomEvent.idl \
     $(WebCore)/dom/DOMCoreException.idl \
     $(WebCore)/dom/DOMError.idl \

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204731 => 204732)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-22 19:45:01 UTC (rev 204732)
@@ -3587,7 +3587,7 @@
 		9BAB6C6D12550631001626D4 /* EditingStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */; };
 		9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9BB737651B41C03500AE13EB /* NSAttributedStringSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BB737641B41C03500AE13EB /* NSAttributedStringSPI.h */; };
-		9BC5F9E01D5AAF6B002B749D /* JSCustomElementsRegistryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */; };
+		9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */; };
 		9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; };
 		9BD0BF9312A42BF50072FD43 /* ScopedEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */; };
@@ -3594,13 +3594,13 @@
 		9BD0BF9412A42BF50072FD43 /* ScopedEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */; };
 		9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */; };
 		9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9151C462872005065BC /* JSCustomElementInterface.h */; };
-		9BD4E91A1C462CFC005065BC /* CustomElementsRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */; };
-		9BD4E91B1C462CFC005065BC /* CustomElementsRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */; };
+		9BD4E91A1C462CFC005065BC /* CustomElementRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9181C462CFC005065BC /* CustomElementRegistry.cpp */; };
+		9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9191C462CFC005065BC /* CustomElementRegistry.h */; };
 		9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */; };
 		9BDA64D71B975CE5009C4387 /* JSShadowRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B6BC9601B975966005AE1F0 /* JSShadowRoot.cpp */; };
 		9BDA64D81B975CF2009C4387 /* JSShadowRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6BC9611B975966005AE1F0 /* JSShadowRoot.h */; };
-		9BE6710B1D5AEB2100345514 /* JSCustomElementsRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */; };
-		9BE6710C1D5AEB2500345514 /* JSCustomElementsRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */; };
+		9BE6710B1D5AEB2100345514 /* JSCustomElementRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BE671091D5AEB0400345514 /* JSCustomElementRegistry.cpp */; };
+		9BE6710C1D5AEB2500345514 /* JSCustomElementRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BE6710A1D5AEB0400345514 /* JSCustomElementRegistry.h */; };
 		9BF9A8801648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */; };
 		9BF9A8811648DD2F001C6B23 /* JSHTMLFormControlsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */; };
 		9D6380101AF173220031A15C /* StyleSelfAlignmentData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D63800F1AF16E160031A15C /* StyleSelfAlignmentData.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10762,8 +10762,8 @@
 		9BAB6C6B12550631001626D4 /* EditingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditingStyle.cpp; sourceTree = "<group>"; };
 		9BAF3B2312C1A39800014BF1 /* WritingDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritingDirection.h; sourceTree = "<group>"; };
 		9BB737641B41C03500AE13EB /* NSAttributedStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSAttributedStringSPI.h; sourceTree = "<group>"; };
-		9BC5F9DE1D5AAD5D002B749D /* CustomElementsRegistry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomElementsRegistry.idl; sourceTree = "<group>"; };
-		9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementsRegistryCustom.cpp; sourceTree = "<group>"; };
+		9BC5F9DE1D5AAD5D002B749D /* CustomElementRegistry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomElementRegistry.idl; sourceTree = "<group>"; };
+		9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementRegistryCustom.cpp; sourceTree = "<group>"; };
 		9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTextFormControlElement.h; sourceTree = "<group>"; };
 		9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFormControlElement.cpp; sourceTree = "<group>"; };
 		9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedEventQueue.h; sourceTree = "<group>"; };
@@ -10770,11 +10770,11 @@
 		9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedEventQueue.cpp; sourceTree = "<group>"; };
 		9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementInterface.cpp; sourceTree = "<group>"; };
 		9BD4E9151C462872005065BC /* JSCustomElementInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementInterface.h; sourceTree = "<group>"; };
-		9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementsRegistry.cpp; sourceTree = "<group>"; };
-		9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomElementsRegistry.h; sourceTree = "<group>"; };
+		9BD4E9181C462CFC005065BC /* CustomElementRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementRegistry.cpp; sourceTree = "<group>"; };
+		9BD4E9191C462CFC005065BC /* CustomElementRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomElementRegistry.h; sourceTree = "<group>"; };
 		9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionIndexCache.cpp; sourceTree = "<group>"; };
-		9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementsRegistry.cpp; sourceTree = "<group>"; };
-		9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementsRegistry.h; sourceTree = "<group>"; };
+		9BE671091D5AEB0400345514 /* JSCustomElementRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementRegistry.cpp; sourceTree = "<group>"; };
+		9BE6710A1D5AEB0400345514 /* JSCustomElementRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementRegistry.h; sourceTree = "<group>"; };
 		9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = "<group>"; };
 		9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLFormControlsCollection.h; sourceTree = "<group>"; };
 		9D63800F1AF16E160031A15C /* StyleSelfAlignmentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSelfAlignmentData.h; sourceTree = "<group>"; };
@@ -19375,8 +19375,8 @@
 				93F9B6DF0BA0FB7200854064 /* JSComment.h */,
 				FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */,
 				FE6FD48C0F676E9300092873 /* JSCoordinates.h */,
-				9BE671091D5AEB0400345514 /* JSCustomElementsRegistry.cpp */,
-				9BE6710A1D5AEB0400345514 /* JSCustomElementsRegistry.h */,
+				9BE671091D5AEB0400345514 /* JSCustomElementRegistry.cpp */,
+				9BE6710A1D5AEB0400345514 /* JSCustomElementRegistry.h */,
 				BCA83E4D0D7CE1E9003421A8 /* JSDataTransfer.cpp */,
 				BCA83E4E0D7CE1E9003421A8 /* JSDataTransfer.h */,
 				31FB1A63120A5D3F00DC02A0 /* JSDeviceMotionEvent.cpp */,
@@ -20924,7 +20924,7 @@
 				BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
 				AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
 				BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
-				9BC5F9DF1D5AAF6A002B749D /* JSCustomElementsRegistryCustom.cpp */,
+				9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */,
 				DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
 				07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */,
 				BCA83E510D7CE205003421A8 /* JSDataTransferCustom.cpp */,
@@ -22761,9 +22761,9 @@
 				97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */,
 				9B56C9A91C89329A00C456DF /* CustomElementReactionQueue.cpp */,
 				9B56C9A81C89312800C456DF /* CustomElementReactionQueue.h */,
-				9BD4E9181C462CFC005065BC /* CustomElementsRegistry.cpp */,
-				9BD4E9191C462CFC005065BC /* CustomElementsRegistry.h */,
-				9BC5F9DE1D5AAD5D002B749D /* CustomElementsRegistry.idl */,
+				9BD4E9181C462CFC005065BC /* CustomElementRegistry.cpp */,
+				9BD4E9191C462CFC005065BC /* CustomElementRegistry.h */,
+				9BC5F9DE1D5AAD5D002B749D /* CustomElementRegistry.idl */,
 				62CD32561157E57C0063B0A7 /* CustomEvent.cpp */,
 				62CD32571157E57C0063B0A7 /* CustomEvent.h */,
 				62CD32581157E57C0063B0A7 /* CustomEvent.idl */,
@@ -24010,7 +24010,7 @@
 				BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */,
 				BC2272AD0E82E8F300E7F975 /* CursorList.h in Headers */,
 				93D437A01D57B19A00AB85EA /* CustomElementReactionQueue.h in Headers */,
-				9BD4E91B1C462CFC005065BC /* CustomElementsRegistry.h in Headers */,
+				9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */,
 				62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
 				A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */,
 				A80E6D0B0A1989CA007FB8C5 /* DashboardRegion.h in Headers */,
@@ -24756,7 +24756,7 @@
 				14CF78A609F58CD800EB3665 /* JSCSSValue.h in Headers */,
 				A8D05FAC0A23B30F005E7203 /* JSCSSValueList.h in Headers */,
 				9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */,
-				9BE6710C1D5AEB2500345514 /* JSCustomElementsRegistry.h in Headers */,
+				9BE6710C1D5AEB2500345514 /* JSCustomElementRegistry.h in Headers */,
 				E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
 				E10B937C0B73C00A003ED890 /* JSCustomXPathNSResolver.h in Headers */,
 				1AE82F900CAAFA9D002237AE /* JSDatabase.h in Headers */,
@@ -27653,7 +27653,7 @@
 				265541521489B233000DFC5D /* CursorIOS.cpp in Sources */,
 				93F19A2608245E59001E9ABC /* CursorMac.mm in Sources */,
 				9B56C9AA1C89329A00C456DF /* CustomElementReactionQueue.cpp in Sources */,
-				9BD4E91A1C462CFC005065BC /* CustomElementsRegistry.cpp in Sources */,
+				9BD4E91A1C462CFC005065BC /* CustomElementRegistry.cpp in Sources */,
 				62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */,
 				97BC6A201505F081001B74AC /* Database.cpp in Sources */,
 				97BC6A231505F081001B74AC /* DatabaseAuthorizer.cpp in Sources */,
@@ -28342,8 +28342,8 @@
 				BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
 				A8D05FAB0A23B30F005E7203 /* JSCSSValueList.cpp in Sources */,
 				9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */,
-				9BE6710B1D5AEB2100345514 /* JSCustomElementsRegistry.cpp in Sources */,
-				9BC5F9E01D5AAF6B002B749D /* JSCustomElementsRegistryCustom.cpp in Sources */,
+				9BE6710B1D5AEB2100345514 /* JSCustomElementRegistry.cpp in Sources */,
+				9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */,
 				E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
 				DEC297611B4F2F8D005F5945 /* JSCustomEventCustom.cpp in Sources */,
 				51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */,

Added: trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp (0 => 204732)


--- trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSCustomElementRegistry.h"
+
+#include "CustomElementRegistry.h"
+#include "Document.h"
+#include "HTMLNames.h"
+#include "JSCustomElementInterface.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+static JSObject* getCustomElementCallback(ExecState& state, JSObject& prototype, const Identifier& id)
+{
+    JSValue callback = prototype.get(&state, id);
+    if (state.hadException())
+        return nullptr;
+    if (callback.isUndefined())
+        return nullptr;
+    if (!callback.isFunction()) {
+        throwTypeError(&state, ASCIILiteral("A custom element callback must be a function"));
+        return nullptr;
+    }
+    return callback.getObject();
+}
+
+// https://html.spec.whatwg.org/#dom-customelementregistry-define
+JSValue JSCustomElementRegistry::define(ExecState& state)
+{
+    if (UNLIKELY(state.argumentCount() < 2))
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    AtomicString localName(state.uncheckedArgument(0).toString(&state)->toAtomicString(&state));
+    if (UNLIKELY(state.hadException()))
+        return jsUndefined();
+
+    JSValue constructorValue = state.uncheckedArgument(1);
+    if (!constructorValue.isConstructor())
+        return throwTypeError(&state, ASCIILiteral("The second argument must be a constructor"));
+    JSObject* constructor = constructorValue.getObject();
+
+    // FIXME: Throw a TypeError if constructor doesn't inherit from HTMLElement.
+    // https://github.com/w3c/webcomponents/issues/541
+
+    switch (Document::validateCustomElementName(localName)) {
+    case CustomElementNameValidationStatus::Valid:
+        break;
+    case CustomElementNameValidationStatus::ConflictsWithBuiltinNames:
+        return throwSyntaxError(&state, ASCIILiteral("Custom element name cannot be same as one of the builtin elements"));
+    case CustomElementNameValidationStatus::NoHyphen:
+        return throwSyntaxError(&state, ASCIILiteral("Custom element name must contain a hyphen"));
+    case CustomElementNameValidationStatus::ContainsUpperCase:
+        return throwSyntaxError(&state, ASCIILiteral("Custom element name cannot contain an upper case letter"));
+    }
+
+    // FIXME: Check re-entrancy here.
+    // https://github.com/w3c/webcomponents/issues/545
+
+    CustomElementRegistry& registry = wrapped();
+    if (registry.findInterface(localName)) {
+        throwNotSupportedError(state, ASCIILiteral("Cannot define multiple custom elements with the same tag name"));
+        return jsUndefined();
+    }
+
+    if (registry.containsConstructor(constructor)) {
+        throwNotSupportedError(state, ASCIILiteral("Cannot define multiple custom elements with the same class"));
+        return jsUndefined();
+    }
+
+    auto& vm = globalObject()->vm();
+    JSValue prototypeValue = constructor->get(&state, vm.propertyNames->prototype);
+    if (state.hadException())
+        return jsUndefined();
+    if (!prototypeValue.isObject())
+        return throwTypeError(&state, ASCIILiteral("Custom element constructor's prototype must be an object"));
+    JSObject& prototypeObject = *asObject(prototypeValue);
+
+    QualifiedName name(nullAtom, localName, HTMLNames::xhtmlNamespaceURI);
+    auto elementInterface = JSCustomElementInterface::create(name, constructor, globalObject());
+
+    auto* connectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback"));
+    if (state.hadException())
+        return jsUndefined();
+    if (connectedCallback)
+        elementInterface->setConnectedCallback(connectedCallback);
+
+    auto* disconnectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback"));
+    if (state.hadException())
+        return jsUndefined();
+    if (disconnectedCallback)
+        elementInterface->setDisconnectedCallback(disconnectedCallback);
+
+    // FIXME: Add the support for adoptedCallback.
+    getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback"));
+    if (state.hadException())
+        return jsUndefined();
+
+    auto* attributeChangedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "attributeChangedCallback"));
+    if (state.hadException())
+        return jsUndefined();
+    if (attributeChangedCallback) {
+        auto value = convertOptional<Vector<String>>(state, constructor->get(&state, Identifier::fromString(&state, "observedAttributes")));
+        if (state.hadException())
+            return jsUndefined();
+        if (value)
+            elementInterface->setAttributeChangedCallback(attributeChangedCallback, *value);
+    }
+
+    PrivateName uniquePrivateName;
+    globalObject()->putDirect(vm, uniquePrivateName, constructor);
+
+    registry.addElementDefinition(WTFMove(elementInterface));
+
+    // FIXME: 17. Let map be registry's upgrade candidates map.
+    // FIXME: 18. Upgrade a newly-defined element given map and definition.
+    // FIXME: 19. Resolve whenDefined promise.
+
+    return jsUndefined();
+}
+#endif
+
+}

Deleted: trunk/Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp (204731 => 204732)


--- trunk/Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSCustomElementsRegistry.h"
-
-#include "CustomElementsRegistry.h"
-#include "Document.h"
-#include "HTMLNames.h"
-#include "JSCustomElementInterface.h"
-#include "JSDOMBinding.h"
-#include "JSDOMConvert.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-#if ENABLE(CUSTOM_ELEMENTS)
-
-static JSObject* getCustomElementCallback(ExecState& state, JSObject& prototype, const Identifier& id)
-{
-    JSValue callback = prototype.get(&state, id);
-    if (state.hadException())
-        return nullptr;
-    if (callback.isUndefined())
-        return nullptr;
-    if (!callback.isFunction()) {
-        throwTypeError(&state, ASCIILiteral("A custom element callback must be a function"));
-        return nullptr;
-    }
-    return callback.getObject();
-}
-
-// https://html.spec.whatwg.org/#dom-customelementsregistry-define
-JSValue JSCustomElementsRegistry::define(ExecState& state)
-{
-    if (UNLIKELY(state.argumentCount() < 2))
-        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
-
-    AtomicString localName(state.uncheckedArgument(0).toString(&state)->toAtomicString(&state));
-    if (UNLIKELY(state.hadException()))
-        return jsUndefined();
-
-    JSValue constructorValue = state.uncheckedArgument(1);
-    if (!constructorValue.isConstructor())
-        return throwTypeError(&state, ASCIILiteral("The second argument must be a constructor"));
-    JSObject* constructor = constructorValue.getObject();
-
-    // FIXME: Throw a TypeError if constructor doesn't inherit from HTMLElement.
-    // https://github.com/w3c/webcomponents/issues/541
-
-    switch (Document::validateCustomElementName(localName)) {
-    case CustomElementNameValidationStatus::Valid:
-        break;
-    case CustomElementNameValidationStatus::ConflictsWithBuiltinNames:
-        return throwSyntaxError(&state, ASCIILiteral("Custom element name cannot be same as one of the builtin elements"));
-    case CustomElementNameValidationStatus::NoHyphen:
-        return throwSyntaxError(&state, ASCIILiteral("Custom element name must contain a hyphen"));
-    case CustomElementNameValidationStatus::ContainsUpperCase:
-        return throwSyntaxError(&state, ASCIILiteral("Custom element name cannot contain an upper case letter"));
-    }
-
-    // FIXME: Check re-entrancy here.
-    // https://github.com/w3c/webcomponents/issues/545
-
-    CustomElementsRegistry& registry = wrapped();
-    if (registry.findInterface(localName)) {
-        throwNotSupportedError(state, ASCIILiteral("Cannot define multiple custom elements with the same tag name"));
-        return jsUndefined();
-    }
-
-    if (registry.containsConstructor(constructor)) {
-        throwNotSupportedError(state, ASCIILiteral("Cannot define multiple custom elements with the same class"));
-        return jsUndefined();
-    }
-
-    auto& vm = globalObject()->vm();
-    JSValue prototypeValue = constructor->get(&state, vm.propertyNames->prototype);
-    if (state.hadException())
-        return jsUndefined();
-    if (!prototypeValue.isObject())
-        return throwTypeError(&state, ASCIILiteral("Custom element constructor's prototype must be an object"));
-    JSObject& prototypeObject = *asObject(prototypeValue);
-
-    QualifiedName name(nullAtom, localName, HTMLNames::xhtmlNamespaceURI);
-    auto elementInterface = JSCustomElementInterface::create(name, constructor, globalObject());
-
-    auto* connectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback"));
-    if (state.hadException())
-        return jsUndefined();
-    if (connectedCallback)
-        elementInterface->setConnectedCallback(connectedCallback);
-
-    auto* disconnectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback"));
-    if (state.hadException())
-        return jsUndefined();
-    if (disconnectedCallback)
-        elementInterface->setDisconnectedCallback(disconnectedCallback);
-
-    // FIXME: Add the support for adoptedCallback.
-    getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback"));
-    if (state.hadException())
-        return jsUndefined();
-
-    auto* attributeChangedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "attributeChangedCallback"));
-    if (state.hadException())
-        return jsUndefined();
-    if (attributeChangedCallback) {
-        auto value = convertOptional<Vector<String>>(state, constructor->get(&state, Identifier::fromString(&state, "observedAttributes")));
-        if (state.hadException())
-            return jsUndefined();
-        if (value)
-            elementInterface->setAttributeChangedCallback(attributeChangedCallback, *value);
-    }
-
-    PrivateName uniquePrivateName;
-    globalObject()->putDirect(vm, uniquePrivateName, constructor);
-
-    registry.addElementDefinition(WTFMove(elementInterface));
-
-    // FIXME: 17. Let map be registry's upgrade candidates map.
-    // FIXME: 18. Upgrade a newly-defined element given map and definition.
-    // FIXME: 19. Resolve whenDefined promise.
-
-    return jsUndefined();
-}
-#endif
-
-}

Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (204731 => 204732)


--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "JSHTMLElement.h"
 
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "DOMWindow.h"
 #include "Document.h"
 #include "HTMLFormElement.h"
@@ -53,7 +53,7 @@
     if (!window)
         return throwVMTypeError(&exec, ASCIILiteral("new.target is not a valid custom element constructor"));
 
-    auto* registry = window->customElementsRegistry();
+    auto* registry = window->customElementRegistry();
     if (!registry)
         return throwVMTypeError(&exec, ASCIILiteral("new.target is not a valid custom element constructor"));
 

Modified: trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp (204731 => 204732)


--- trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -28,7 +28,7 @@
 
 #if ENABLE(CUSTOM_ELEMENTS)
 
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "DOMWindow.h"
 #include "Document.h"
 #include "Element.h"
@@ -113,7 +113,7 @@
     if (!window)
         return nullptr;
 
-    auto* registry = window->customElementsRegistry();
+    auto* registry = window->customElementRegistry();
     if (!registry)
         return nullptr;
 

Added: trunk/Source/WebCore/dom/CustomElementRegistry.cpp (0 => 204732)


--- trunk/Source/WebCore/dom/CustomElementRegistry.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/CustomElementRegistry.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CustomElementRegistry.h"
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+#include "Document.h"
+#include "Element.h"
+#include "JSCustomElementInterface.h"
+#include "MathMLNames.h"
+#include "QualifiedName.h"
+#include "SVGNames.h"
+#include <runtime/JSCJSValueInlines.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+Ref<CustomElementRegistry> CustomElementRegistry::create()
+{
+    return adoptRef(*new CustomElementRegistry());
+}
+
+CustomElementRegistry::CustomElementRegistry()
+{ }
+
+CustomElementRegistry::~CustomElementRegistry()
+{ }
+
+void CustomElementRegistry::addElementDefinition(Ref<JSCustomElementInterface>&& elementInterface)
+{
+    AtomicString localName = elementInterface->name().localName();
+    ASSERT(!m_nameMap.contains(localName));
+    m_constructorMap.add(elementInterface->constructor(), elementInterface.ptr());
+    m_nameMap.add(localName, elementInterface.copyRef());
+
+    auto candidateList = m_upgradeCandidatesMap.find(localName);
+    if (candidateList == m_upgradeCandidatesMap.end())
+        return;
+
+    Vector<RefPtr<Element>> list(WTFMove(candidateList->value));
+
+    m_upgradeCandidatesMap.remove(localName);
+
+    for (auto& candidate : list) {
+        ASSERT(candidate);
+        elementInterface->upgradeElement(*candidate);
+    }
+
+    // We should not be adding more upgrade candidate for this local name.
+    ASSERT(!m_upgradeCandidatesMap.contains(localName));
+}
+
+void CustomElementRegistry::addUpgradeCandidate(Element& candidate)
+{
+    auto result = m_upgradeCandidatesMap.ensure(candidate.localName(), [] {
+        return Vector<RefPtr<Element>>();
+    });
+    auto& nodeVector = result.iterator->value;
+    ASSERT(!nodeVector.contains(&candidate));
+    nodeVector.append(&candidate);
+}
+
+JSCustomElementInterface* CustomElementRegistry::findInterface(const QualifiedName& name) const
+{
+    auto it = m_nameMap.find(name.localName());
+    return it == m_nameMap.end() || it->value->name() != name ? nullptr : const_cast<JSCustomElementInterface*>(it->value.ptr());
+}
+
+JSCustomElementInterface* CustomElementRegistry::findInterface(const AtomicString& name) const
+{
+    return m_nameMap.get(name);
+}
+
+JSCustomElementInterface* CustomElementRegistry::findInterface(const JSC::JSObject* constructor) const
+{
+    return m_constructorMap.get(constructor);
+}
+
+bool CustomElementRegistry::containsConstructor(const JSC::JSObject* constructor) const
+{
+    return m_constructorMap.contains(constructor);
+}
+
+}
+
+#endif

Added: trunk/Source/WebCore/dom/CustomElementRegistry.h (0 => 204732)


--- trunk/Source/WebCore/dom/CustomElementRegistry.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/CustomElementRegistry.h	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+#include "QualifiedName.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/AtomicStringHash.h>
+
+namespace JSC {
+
+class JSObject;
+    
+}
+
+namespace WebCore {
+
+class Element;
+class JSCustomElementInterface;
+class QualifiedName;
+
+class CustomElementRegistry : public RefCounted<CustomElementRegistry> {
+public:
+    static Ref<CustomElementRegistry> create();
+    ~CustomElementRegistry();
+
+    void addElementDefinition(Ref<JSCustomElementInterface>&&);
+    void addUpgradeCandidate(Element&);
+
+    JSCustomElementInterface* findInterface(const QualifiedName&) const;
+    JSCustomElementInterface* findInterface(const AtomicString&) const;
+    JSCustomElementInterface* findInterface(const JSC::JSObject*) const;
+    bool containsConstructor(const JSC::JSObject*) const;
+
+private:
+    CustomElementRegistry();
+
+    HashMap<AtomicString, Vector<RefPtr<Element>>> m_upgradeCandidatesMap;
+    HashMap<AtomicString, Ref<JSCustomElementInterface>> m_nameMap;
+    HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap;
+};
+    
+}
+
+#endif

Added: trunk/Source/WebCore/dom/CustomElementRegistry.idl (0 => 204732)


--- trunk/Source/WebCore/dom/CustomElementRegistry.idl	                        (rev 0)
+++ trunk/Source/WebCore/dom/CustomElementRegistry.idl	2016-08-22 19:45:01 UTC (rev 204732)
@@ -0,0 +1,35 @@
+/*
+* Copyright (C) 2016 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+[
+    Conditional=CUSTOM_ELEMENTS,
+    EnabledAtRuntime=CustomElements,
+    JSGenerateToNativeObject,
+    ImplementationLacksVTable
+] interface CustomElementRegistry {
+
+    [CEReactions, Custom] void define(DOMString name, Function constructor);
+
+};

Deleted: trunk/Source/WebCore/dom/CustomElementsRegistry.cpp (204731 => 204732)


--- trunk/Source/WebCore/dom/CustomElementsRegistry.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/CustomElementsRegistry.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CustomElementsRegistry.h"
-
-#if ENABLE(CUSTOM_ELEMENTS)
-
-#include "Document.h"
-#include "Element.h"
-#include "JSCustomElementInterface.h"
-#include "MathMLNames.h"
-#include "QualifiedName.h"
-#include "SVGNames.h"
-#include <runtime/JSCJSValueInlines.h>
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-Ref<CustomElementsRegistry> CustomElementsRegistry::create()
-{
-    return adoptRef(*new CustomElementsRegistry());
-}
-
-CustomElementsRegistry::CustomElementsRegistry()
-{ }
-
-CustomElementsRegistry::~CustomElementsRegistry()
-{ }
-
-void CustomElementsRegistry::addElementDefinition(Ref<JSCustomElementInterface>&& elementInterface)
-{
-    AtomicString localName = elementInterface->name().localName();
-    ASSERT(!m_nameMap.contains(localName));
-    m_constructorMap.add(elementInterface->constructor(), elementInterface.ptr());
-    m_nameMap.add(localName, elementInterface.copyRef());
-
-    auto candidateList = m_upgradeCandidatesMap.find(localName);
-    if (candidateList == m_upgradeCandidatesMap.end())
-        return;
-
-    Vector<RefPtr<Element>> list(WTFMove(candidateList->value));
-
-    m_upgradeCandidatesMap.remove(localName);
-
-    for (auto& candidate : list) {
-        ASSERT(candidate);
-        elementInterface->upgradeElement(*candidate);
-    }
-
-    // We should not be adding more upgrade candidate for this local name.
-    ASSERT(!m_upgradeCandidatesMap.contains(localName));
-}
-
-void CustomElementsRegistry::addUpgradeCandidate(Element& candidate)
-{
-    auto result = m_upgradeCandidatesMap.ensure(candidate.localName(), [] {
-        return Vector<RefPtr<Element>>();
-    });
-    auto& nodeVector = result.iterator->value;
-    ASSERT(!nodeVector.contains(&candidate));
-    nodeVector.append(&candidate);
-}
-
-JSCustomElementInterface* CustomElementsRegistry::findInterface(const QualifiedName& name) const
-{
-    auto it = m_nameMap.find(name.localName());
-    return it == m_nameMap.end() || it->value->name() != name ? nullptr : const_cast<JSCustomElementInterface*>(it->value.ptr());
-}
-
-JSCustomElementInterface* CustomElementsRegistry::findInterface(const AtomicString& name) const
-{
-    return m_nameMap.get(name);
-}
-
-JSCustomElementInterface* CustomElementsRegistry::findInterface(const JSC::JSObject* constructor) const
-{
-    return m_constructorMap.get(constructor);
-}
-
-bool CustomElementsRegistry::containsConstructor(const JSC::JSObject* constructor) const
-{
-    return m_constructorMap.contains(constructor);
-}
-
-}
-
-#endif

Deleted: trunk/Source/WebCore/dom/CustomElementsRegistry.h (204731 => 204732)


--- trunk/Source/WebCore/dom/CustomElementsRegistry.h	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/CustomElementsRegistry.h	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(CUSTOM_ELEMENTS)
-
-#include "QualifiedName.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/AtomicStringHash.h>
-
-namespace JSC {
-
-class JSObject;
-    
-}
-
-namespace WebCore {
-
-class Element;
-class JSCustomElementInterface;
-class QualifiedName;
-
-class CustomElementsRegistry : public RefCounted<CustomElementsRegistry> {
-public:
-    static Ref<CustomElementsRegistry> create();
-    ~CustomElementsRegistry();
-
-    void addElementDefinition(Ref<JSCustomElementInterface>&&);
-    void addUpgradeCandidate(Element&);
-
-    JSCustomElementInterface* findInterface(const QualifiedName&) const;
-    JSCustomElementInterface* findInterface(const AtomicString&) const;
-    JSCustomElementInterface* findInterface(const JSC::JSObject*) const;
-    bool containsConstructor(const JSC::JSObject*) const;
-
-private:
-    CustomElementsRegistry();
-
-    HashMap<AtomicString, Vector<RefPtr<Element>>> m_upgradeCandidatesMap;
-    HashMap<AtomicString, Ref<JSCustomElementInterface>> m_nameMap;
-    HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap;
-};
-    
-}
-
-#endif

Deleted: trunk/Source/WebCore/dom/CustomElementsRegistry.idl (204731 => 204732)


--- trunk/Source/WebCore/dom/CustomElementsRegistry.idl	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/CustomElementsRegistry.idl	2016-08-22 19:45:01 UTC (rev 204732)
@@ -1,34 +0,0 @@
-/*
-* Copyright (C) 2016 Apple Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
-* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-[
-    Conditional=CUSTOM_ELEMENTS,
-    JSGenerateToNativeObject,
-    ImplementationLacksVTable
-] interface CustomElementsRegistry {
-
-    [CEReactions, Custom] void define(DOMString name, Function constructor);
-
-};

Modified: trunk/Source/WebCore/dom/Document.cpp (204731 => 204732)


--- trunk/Source/WebCore/dom/Document.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -45,7 +45,7 @@
 #include "ContentSecurityPolicy.h"
 #include "CookieJar.h"
 #include "CustomElementReactionQueue.h"
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "CustomEvent.h"
 #include "DOMImplementation.h"
 #include "DOMNamedFlowCollection.h"
@@ -891,7 +891,7 @@
 
     auto element = HTMLElement::create(name, document);
     element->setIsUnresolvedCustomElement();
-    window->ensureCustomElementsRegistry().addUpgradeCandidate(element.get());
+    window->ensureCustomElementRegistry().addUpgradeCandidate(element.get());
     return WTFMove(element);
 }
 #endif
@@ -905,7 +905,7 @@
 #if ENABLE(CUSTOM_ELEMENTS)
     auto* window = document.domWindow();
     if (window) {
-        auto* registry = window->customElementsRegistry();
+        auto* registry = window->customElementRegistry();
         if (UNLIKELY(registry)) {
             if (auto* elementInterface = registry->findInterface(localName))
                 return elementInterface->constructElement(localName, JSCustomElementInterface::ShouldClearException::DoNotClear);
@@ -1088,7 +1088,7 @@
 #if ENABLE(CUSTOM_ELEMENTS)
     auto* window = document.domWindow();
     if (window) {
-        auto* registry = window->customElementsRegistry();
+        auto* registry = window->customElementRegistry();
         if (UNLIKELY(registry)) {
             if (auto* elementInterface = registry->findInterface(name)) {
                 auto element = HTMLElement::create(name, document);

Modified: trunk/Source/WebCore/dom/Element.cpp (204731 => 204732)


--- trunk/Source/WebCore/dom/Element.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -38,7 +38,7 @@
 #include "ComposedTreeAncestorIterator.h"
 #include "ContainerNodeAlgorithms.h"
 #include "CustomElementReactionQueue.h"
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "DOMTokenList.h"
 #include "Dictionary.h"
 #include "DocumentAnimation.h"

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (204731 => 204732)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -28,7 +28,7 @@
 #include "HTMLTreeBuilder.h"
 
 #include "Comment.h"
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "DOMWindow.h"
 #include "DocumentFragment.h"
 #include "DocumentType.h"
@@ -661,7 +661,7 @@
 #if ENABLE(CUSTOM_ELEMENTS)
         auto* window = ownerDocument.domWindow();
         if (customElementInterface && window) {
-            auto* registry = window->customElementsRegistry();
+            auto* registry = window->customElementRegistry();
             if (UNLIKELY(registry)) {
                 if (auto* elementInterface = registry->findInterface(localName)) {
                     *customElementInterface = elementInterface;
@@ -678,7 +678,7 @@
         if (window && Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) {
             element = HTMLElement::create(qualifiedName, ownerDocument);
             element->setIsUnresolvedCustomElement();
-            window->ensureCustomElementsRegistry().addUpgradeCandidate(*element);
+            window->ensureCustomElementRegistry().addUpgradeCandidate(*element);
         } else
 #endif
             element = HTMLUnknownElement::create(qualifiedName, ownerDocument);

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (204731 => 204732)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2016-08-22 19:45:01 UTC (rev 204732)
@@ -38,7 +38,7 @@
 #include "ContentExtensionActions.h"
 #include "ContentExtensionRule.h"
 #include "Crypto.h"
-#include "CustomElementsRegistry.h"
+#include "CustomElementRegistry.h"
 #include "DOMApplicationCache.h"
 #include "DOMSelection.h"
 #include "DOMStringList.h"
@@ -621,11 +621,11 @@
 }
 
 #if ENABLE(CUSTOM_ELEMENTS)
-CustomElementsRegistry& DOMWindow::ensureCustomElementsRegistry()
+CustomElementRegistry& DOMWindow::ensureCustomElementRegistry()
 {
-    if (!m_customElementsRegistry)
-        m_customElementsRegistry = CustomElementsRegistry::create();
-    return *m_customElementsRegistry;
+    if (!m_customElementRegistry)
+        m_customElementRegistry = CustomElementRegistry::create();
+    return *m_customElementRegistry;
 }
 #endif
 

Modified: trunk/Source/WebCore/page/DOMWindow.h (204731 => 204732)


--- trunk/Source/WebCore/page/DOMWindow.h	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/page/DOMWindow.h	2016-08-22 19:45:01 UTC (rev 204732)
@@ -48,7 +48,7 @@
     class CSSRuleList;
     class CSSStyleDeclaration;
     class Crypto;
-    class CustomElementsRegistry;
+    class CustomElementRegistry;
     class DOMApplicationCache;
     class DOMSelection;
     class DOMURL;
@@ -305,8 +305,8 @@
         DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
 
 #if ENABLE(CUSTOM_ELEMENTS)
-        CustomElementsRegistry* customElementsRegistry() { return m_customElementsRegistry.get(); }
-        CustomElementsRegistry& ensureCustomElementsRegistry();
+        CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
+        CustomElementRegistry& ensureCustomElementRegistry();
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)
@@ -422,7 +422,7 @@
         mutable RefPtr<DOMApplicationCache> m_applicationCache;
 
 #if ENABLE(CUSTOM_ELEMENTS)
-        RefPtr<CustomElementsRegistry> m_customElementsRegistry;
+        RefPtr<CustomElementRegistry> m_customElementRegistry;
 #endif
 
 #if ENABLE(WEB_TIMING)

Modified: trunk/Source/WebCore/page/DOMWindow.idl (204731 => 204732)


--- trunk/Source/WebCore/page/DOMWindow.idl	2016-08-22 19:12:09 UTC (rev 204731)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2016-08-22 19:45:01 UTC (rev 204732)
@@ -195,7 +195,7 @@
     attribute DOMURLConstructor webkitURL; // FIXME: deprecate this.
     attribute MutationObserverConstructor WebKitMutationObserver; // FIXME: Add metrics to determine when we can remove this.
 
-    [Conditional=CUSTOM_ELEMENTS, ImplementedAs=ensureCustomElementsRegistry] readonly attribute CustomElementsRegistry customElements;
+    [Conditional=CUSTOM_ELEMENTS, EnabledAtRuntime=CustomElements, ImplementedAs=ensureCustomElementRegistry] readonly attribute CustomElementRegistry customElements;
 #endif
 
     // Event Handlers
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to