<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[195087] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195087">195087</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-14 18:59:03 -0800 (Thu, 14 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add document.defineCustomElement
https://bugs.webkit.org/show_bug.cgi?id=153092

Reviewed by Chris Dumez.

Source/WebCore:

Added document.defineCustomElement and added a constructor to HTMLElement which can be called
as &quot;super&quot; in a subclass of HTMLElement. This is a prototype of new custom elements API and
willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/

Each author defined class can define multiple elements using distinct tag names. In such cases,
the super call must specify the tag name. e.g.

class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } }
document.defineCustomElement('some-custom-element', SomeCustomElement);
document.defineCustomElement('other-custom-element', SomeCustomElement);
new SomeCustomElement('some-custom-element');

When a class is associated with exactly one tag name, the argument can be omitted. e.g.

class AnotherCustomElement extends HTMLElement {}
document.defineCustomElement('another-custom-element', AnotherCustomElement);
new AnotherCustomElement();

We allow only subclassing of HTMLElement and only in (X)HTML namespace.

Tests: fast/custom-elements/Document-defineCustomElement.html
       fast/custom-elements/HTMLElement-constructor.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:

* bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated
with a custom element. It's a Active DOM object and lives until the associated document dies.
(WebCore::JSCustomElementInterface::JSCustomElementInterface):
(WebCore::JSCustomElementInterface::~JSCustomElementInterface):
* bindings/js/JSCustomElementInterface.h: Added.
(WebCore::JSCustomElementInterface::create):
(WebCore::JSCustomElementInterface::scriptExecutionContext):
(WebCore::JSCustomElementInterface::constructor):

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag
name with an author defined JS class after validating arguments.

* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not
specified. If a tag name is specified, check that new.target is associated with the tag name.

* dom/CustomElementDefinitions.cpp: Added.
(WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to
http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type
(WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name.
(WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name.
(WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class.
* dom/CustomElementDefinitions.h: Added.
(WebCore::CustomElementDefinitions::CustomElementInfo): Added.

* dom/Document.cpp:
(WebCore::Document::ensureCustomElementDefinitions): Added.
* dom/Document.h:
(WebCore::Document::customElementDefinitions): Added.

* dom/Document.idl:
* html/HTMLElement.idl:

LayoutTests:

Added tests for document.defineCustomElement and instantiating custom elements.

* TestExpectations: Skipped the tests on non-Mac ports.
* fast/custom-elements: Added.
* fast/custom-elements/Document-defineCustomElement-expected.txt: Added.
* fast/custom-elements/Document-defineCustomElement.html: Added.
* fast/custom-elements/HTMLElement-constructor-expected.txt: Added.
* fast/custom-elements/HTMLElement-constructor.html: Added.
* platform/mac/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDocumentCustomcpp">trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementidl">trunk/Source/WebCore/html/HTMLElement.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/fast/custom-elements/</li>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementexpectedtxt">trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementhtml">trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsHTMLElementconstructorexpectedtxt">trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsHTMLElementconstructorhtml">trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp">trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementInterfaceh">trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementDefinitionscpp">trunk/Source/WebCore/dom/CustomElementDefinitions.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementDefinitionsh">trunk/Source/WebCore/dom/CustomElementDefinitions.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/LayoutTests/ChangeLog        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-01-14  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add document.defineCustomElement
+        https://bugs.webkit.org/show_bug.cgi?id=153092
+
+        Reviewed by Chris Dumez.
+
+        Added tests for document.defineCustomElement and instantiating custom elements.
+
+        * TestExpectations: Skipped the tests on non-Mac ports.
+        * fast/custom-elements: Added.
+        * fast/custom-elements/Document-defineCustomElement-expected.txt: Added.
+        * fast/custom-elements/Document-defineCustomElement.html: Added.
+        * fast/custom-elements/HTMLElement-constructor-expected.txt: Added.
+        * fast/custom-elements/HTMLElement-constructor.html: Added.
+        * platform/mac/TestExpectations:
+
</ins><span class="cx"> 2016-01-14  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WK2: Request completion candidates when needed
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/LayoutTests/TestExpectations        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -740,6 +740,7 @@
</span><span class="cx"> webkit.org/b/148922 svg/as-object/svg-in-object-dynamic-attribute-change.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/148925 svg/dom/svg-root-lengths.html [ Pass Failure ]
</span><span class="cx"> 
</span><ins>+webkit.org/b/150225 fast/custom-elements [ Failure ]
</ins><span class="cx"> webkit.org/b/148695 fast/shadow-dom [ Failure ImageOnlyFailure ]
</span><span class="cx"> 
</span><span class="cx"> # Known failures on CSS Variables Test Suite
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+PASS Check the existence of defineCustomElement on Document interface 
+PASS document.defineCustomElement should throw with an invalid name 
+PASS document.defineCustomElement should throw with a duplicate name 
+PASS document.defineCustomElement should throw when the element interface is not a constructor 
+PASS document.defineCustomElement should define an instantiatable custom element 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsDocumentdefineCustomElementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/Document-defineCustomElement.html        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Custom Elements: Extensions to Document interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;document.defineCustomElement should define a custom element&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('defineCustomElement' in Document.prototype, '&quot;defineCustomElement&quot; exists on Document.prototype');
+    assert_true('defineCustomElement' in document, '&quot;defineCustomElement&quot; exists on document');
+}, 'Check the existence of defineCustomElement on Document interface');
+
+test(function () {
+    class MyCustomElement extends HTMLElement {};
+
+    assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement(null, MyCustomElement); },
+        'document.defineCustomElement must throw a SyntaxError if the tag name is null');
+    assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('', MyCustomElement); },
+        'document.defineCustomElement must throw a SyntaxError if the tag name is empty');
+    assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('abc', MyCustomElement); },
+        'document.defineCustomElement must throw a SyntaxError if the tag name does not contain &quot;-&quot;');
+    assert_throws({'name': 'SyntaxError'}, function () { document.defineCustomElement('a-Bc', MyCustomElement); },
+        'document.defineCustomElement 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 () { document.defineCustomElement(tagName, MyCustomElement); },
+            'document.defineCustomElement must throw a SyntaxError if the tag name is &quot;' + tagName + '&quot;');
+    }
+
+}, 'document.defineCustomElement should throw with an invalid name');
+
+test(function () {
+    class SomeCustomElement extends HTMLElement {};
+    class OtherCustomElement extends HTMLElement {};
+
+    document.defineCustomElement('some-custom-element', SomeCustomElement);
+    assert_throws({'name': 'NotSupportedError'}, function () { document.defineCustomElement('some-custom-element', OtherCustomElement); },
+        'document.defineCustomElement must throw a NotSupportedError if the specified tag name is already used');
+
+}, 'document.defineCustomElement should throw with a duplicate name');
+
+test(function () {
+    assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', 1); },
+        'document.defineCustomElement must throw a TypeError when the element interface is a number');
+    assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', '123'); },
+        'document.defineCustomElement must throw a TypeError when the element interface is a string');
+    assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', {}); },
+        'document.defineCustomElement must throw a TypeError when the element interface is an object');
+    assert_throws({'name': 'TypeError'}, function () { document.defineCustomElement('invalid-element', []); },
+        'document.defineCustomElement must throw a TypeError when the element interface is an array');
+}, 'document.defineCustomElement should throw when the element interface is not a constructor');
+
+test(function () {
+    class MyCustomElement extends HTMLElement {};
+    document.defineCustomElement('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');
+
+}, 'document.defineCustomElement should define an instantiatable custom element');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsHTMLElementconstructorexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+
+PASS HTMLElement constructor must throw a TypeError when there is no derived class 
+PASS HTMLElement constructor must throw TypeError when custom element is not well defined 
+PASS HTMLElement constructor must infer the tag name from the element interface 
+PASS HTMLElement constructor must allow associating an element interface with multiple tag names 
+PASS HTMLElement constructor must allow subclassing a custom element 
+PASS HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsHTMLElementconstructorhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Custom Elements: HTMLElement must allow subclassing&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;HTMLElement must allow subclassing&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    class SomeDefinedElement extends HTMLElement {};
+    document.defineCustomElement('defined-element', SomeDefinedElement);
+    assert_throws({'name': 'TypeError'}, function () { new HTMLElement('defined-element'); });
+}, 'HTMLElement constructor must throw a TypeError when there is no derived class');
+
+test(function () {
+    class SomeCustomElement extends HTMLElement {};
+    assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement; },
+        'Instantiating a custom element without calling defineCustomElement must throw TypeError');
+
+    class AnotherCustomElement extends HTMLElement {
+        constructor() { super('some-element'); }
+    };
+    document.defineCustomElement('another-element', AnotherCustomElement);
+    assert_throws({'name': 'TypeError'}, function () { new AnotherCustomElement; },
+        'Calling HTMLElement constructor with a mismatching tag name throw TypeError');
+
+    class YetAnotherCustomElement extends HTMLElement {
+        constructor() { super(1); }
+    };
+    document.defineCustomElement('yet-another-element', YetAnotherCustomElement);
+    assert_throws({'name': 'TypeError'}, function () { new YetAnotherCustomElement; },
+        'Calling HTMLElement constructor with a bad tag name throw TypeError');
+
+}, 'HTMLElement constructor must throw TypeError when custom element is not well defined');
+
+test(function () {
+    class CustomElementWithInferredTagName extends HTMLElement {};
+    document.defineCustomElement('inferred-name', CustomElementWithInferredTagName);
+
+    var instance = new CustomElementWithInferredTagName;
+    assert_true(instance instanceof Element, 'A custom element must inherit from Element');
+    assert_true(instance instanceof Node, 'A custom element must inherit from Node');
+    assert_equals(instance.localName, 'inferred-name');
+    assert_equals(instance.nodeName, 'INFERRED-NAME');
+    assert_equals(instance.namespaceURI, 'http://www.w3.org/1999/xhtml', 'A custom HTML element must use HTML namespace');
+
+    document.body.appendChild(instance);
+    assert_equals(document.body.lastChild, instance,
+        'document.body.appendChild must be able to insert a custom element');
+    assert_equals(document.querySelector('inferred-name'), instance,
+        'document.querySelector must be able to find a custom element by its tag name');
+
+}, 'HTMLElement constructor must infer the tag name from the element interface');
+
+test(function () {
+    class ElementWithMultipleTagNames extends HTMLElement { };
+    document.defineCustomElement('custom-element-1', ElementWithMultipleTagNames);
+    document.defineCustomElement('custom-element-2', ElementWithMultipleTagNames);
+
+    var instance1 = new ElementWithMultipleTagNames('custom-element-1');
+    assert_true(instance1 instanceof ElementWithMultipleTagNames);
+    assert_equals(instance1.localName, 'custom-element-1');
+    assert_equals(instance1.nodeName, 'CUSTOM-ELEMENT-1');
+
+    var instance2 = new ElementWithMultipleTagNames('custom-element-2');
+    assert_true(instance2 instanceof ElementWithMultipleTagNames);
+    assert_equals(instance2.localName, 'custom-element-2');
+    assert_equals(instance2.nodeName, 'CUSTOM-ELEMENT-2');
+
+    assert_throws({'name': 'TypeError'}, function () { new ElementWithMultipleTagNames; },
+        'Instantiating an element interface associated with multiple tag names without specifying the tag name must throw TypeError');
+
+}, 'HTMLElement constructor must allow associating an element interface with multiple tag names');
+
+test(function () {
+    class ConcreteCustomElement extends HTMLElement { };
+    class SubCustomElement extends ConcreteCustomElement { };
+    document.defineCustomElement('concrete-custom-element', ConcreteCustomElement);
+    document.defineCustomElement('sub-custom-element', SubCustomElement);
+
+    var instance = new SubCustomElement();
+    assert_true(instance instanceof SubCustomElement);
+    assert_equals(instance.localName, 'sub-custom-element');
+    assert_equals(instance.nodeName, 'SUB-CUSTOM-ELEMENT');
+
+}, 'HTMLElement constructor must allow subclassing a custom element');
+
+test(function () {
+    class AbstractCustomElement extends HTMLElement { };
+    class ConcreteSubCustomElement extends AbstractCustomElement { };
+    document.defineCustomElement('concrete-sub-custom-element', ConcreteSubCustomElement);
+
+    var instance = new ConcreteSubCustomElement();
+    assert_true(instance instanceof ConcreteSubCustomElement);
+    assert_equals(instance.localName, 'concrete-sub-custom-element');
+    assert_equals(instance.nodeName, 'CONCRETE-SUB-CUSTOM-ELEMENT');
+
+}, 'HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -1258,6 +1258,8 @@
</span><span class="cx"> webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slotted-rule.html [ ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slot-display-override.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><ins>+webkit.org/b/150225 fast/custom-elements [ Pass ]
+
</ins><span class="cx"> # Times out in debug.
</span><span class="cx"> [ Debug ] js/regress/getter-richards-try-catch.html [ Skip ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -1114,6 +1114,7 @@
</span><span class="cx">     bindings/js/JSCryptoKeyPairCustom.cpp
</span><span class="cx">     bindings/js/JSCryptoKeySerializationJWK.cpp
</span><span class="cx">     bindings/js/JSCryptoOperationData.cpp
</span><ins>+    bindings/js/JSCustomElementInterface.cpp
</ins><span class="cx">     bindings/js/JSCustomEventCustom.cpp
</span><span class="cx">     bindings/js/JSCustomSQLStatementErrorCallback.cpp
</span><span class="cx">     bindings/js/JSCustomXPathNSResolver.cpp
</span><span class="lines">@@ -1407,6 +1408,7 @@
</span><span class="cx">     dom/ContainerNode.cpp
</span><span class="cx">     dom/ContainerNodeAlgorithms.cpp
</span><span class="cx">     dom/ContextDestructionObserver.cpp
</span><ins>+    dom/CustomElementDefinitions.cpp
</ins><span class="cx">     dom/CustomEvent.cpp
</span><span class="cx">     dom/DOMCoreException.cpp
</span><span class="cx">     dom/DOMError.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/ChangeLog        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -1,3 +1,70 @@
</span><ins>+2016-01-14  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add document.defineCustomElement
+        https://bugs.webkit.org/show_bug.cgi?id=153092
+
+        Reviewed by Chris Dumez.
+
+        Added document.defineCustomElement and added a constructor to HTMLElement which can be called
+        as &quot;super&quot; in a subclass of HTMLElement. This is a prototype of new custom elements API and
+        willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/
+
+        Each author defined class can define multiple elements using distinct tag names. In such cases,
+        the super call must specify the tag name. e.g.
+
+        class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } }
+        document.defineCustomElement('some-custom-element', SomeCustomElement);
+        document.defineCustomElement('other-custom-element', SomeCustomElement);
+        new SomeCustomElement('some-custom-element');
+
+        When a class is associated with exactly one tag name, the argument can be omitted. e.g.
+
+        class AnotherCustomElement extends HTMLElement {}
+        document.defineCustomElement('another-custom-element', AnotherCustomElement);
+        new AnotherCustomElement();
+
+        We allow only subclassing of HTMLElement and only in (X)HTML namespace.
+
+        Tests: fast/custom-elements/Document-defineCustomElement.html
+               fast/custom-elements/HTMLElement-constructor.html
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated
+        with a custom element. It's a Active DOM object and lives until the associated document dies.
+        (WebCore::JSCustomElementInterface::JSCustomElementInterface):
+        (WebCore::JSCustomElementInterface::~JSCustomElementInterface):
+        * bindings/js/JSCustomElementInterface.h: Added.
+        (WebCore::JSCustomElementInterface::create):
+        (WebCore::JSCustomElementInterface::scriptExecutionContext):
+        (WebCore::JSCustomElementInterface::constructor):
+
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag
+        name with an author defined JS class after validating arguments.
+
+        * bindings/js/JSHTMLElementCustom.cpp:
+        (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not
+        specified. If a tag name is specified, check that new.target is associated with the tag name.
+
+        * dom/CustomElementDefinitions.cpp: Added.
+        (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to
+        http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type
+        (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name.
+        (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name.
+        (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class.
+        * dom/CustomElementDefinitions.h: Added.
+        (WebCore::CustomElementDefinitions::CustomElementInfo): Added.
+
+        * dom/Document.cpp:
+        (WebCore::Document::ensureCustomElementDefinitions): Added.
+        * dom/Document.h:
+        (WebCore::Document::customElementDefinitions): Added.
+
+        * dom/Document.idl:
+        * html/HTMLElement.idl:
+
</ins><span class="cx"> 2016-01-14  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove workaround for rdar://problem/23623670
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -3998,6 +3998,10 @@
</span><span class="cx">                 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; };
</span><span class="cx">                 9BD0BF9312A42BF50072FD43 /* ScopedEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */; };
</span><span class="cx">                 9BD0BF9412A42BF50072FD43 /* ScopedEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */; };
</span><ins>+                9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */; };
+                9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9151C462872005065BC /* JSCustomElementInterface.h */; };
+                9BD4E91A1C462CFC005065BC /* CustomElementDefinitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD4E9181C462CFC005065BC /* CustomElementDefinitions.cpp */; };
+                9BD4E91B1C462CFC005065BC /* CustomElementDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD4E9191C462CFC005065BC /* CustomElementDefinitions.h */; };
</ins><span class="cx">                 9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */; };
</span><span class="cx">                 9BDA64D71B975CE5009C4387 /* JSShadowRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B6BC9601B975966005AE1F0 /* JSShadowRoot.cpp */; };
</span><span class="cx">                 9BDA64D81B975CF2009C4387 /* JSShadowRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6BC9611B975966005AE1F0 /* JSShadowRoot.h */; };
</span><span class="lines">@@ -11572,6 +11576,10 @@
</span><span class="cx">                 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFormControlElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedEventQueue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedEventQueue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementInterface.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                9BD4E9151C462872005065BC /* JSCustomElementInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementInterface.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                9BD4E9181C462CFC005065BC /* CustomElementDefinitions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementDefinitions.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                9BD4E9191C462CFC005065BC /* CustomElementDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomElementDefinitions.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionIndexCache.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLFormControlsCollection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -21956,6 +21964,8 @@
</span><span class="cx">                                 1432E8460C51493800B1500F /* GCController.h */,
</span><span class="cx">                                 C585A66011D4FAC5004C3E4B /* IDBBindingUtilities.cpp */,
</span><span class="cx">                                 C585A66111D4FAC5004C3E4B /* IDBBindingUtilities.h */,
</span><ins>+                                9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */,
+                                9BD4E9151C462872005065BC /* JSCustomElementInterface.h */,
</ins><span class="cx">                                 E157A8EE18185425009F821D /* JSCryptoAlgorithmBuilder.cpp */,
</span><span class="cx">                                 E157A8EF18185425009F821D /* JSCryptoAlgorithmBuilder.h */,
</span><span class="cx">                                 E1C657101815F9DD00256CDD /* JSCryptoAlgorithmDictionary.cpp */,
</span><span class="lines">@@ -23830,6 +23840,8 @@
</span><span class="cx">                                 E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */,
</span><span class="cx">                                 97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */,
</span><span class="cx">                                 97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */,
</span><ins>+                                9BD4E9181C462CFC005065BC /* CustomElementDefinitions.cpp */,
+                                9BD4E9191C462CFC005065BC /* CustomElementDefinitions.h */,
</ins><span class="cx">                                 62CD32561157E57C0063B0A7 /* CustomEvent.cpp */,
</span><span class="cx">                                 62CD32571157E57C0063B0A7 /* CustomEvent.h */,
</span><span class="cx">                                 62CD32581157E57C0063B0A7 /* CustomEvent.idl */,
</span><span class="lines">@@ -25251,6 +25263,7 @@
</span><span class="cx">                                 85ECBEEB0AA7626900544F0B /* DOMHTMLAreaElement.h in Headers */,
</span><span class="cx">                                 85E7119C0AC5D5350053270F /* DOMHTMLAreaElementInternal.h in Headers */,
</span><span class="cx">                                 859A9C470AA5E3BD00B694B2 /* DOMHTMLBaseElement.h in Headers */,
</span><ins>+                                9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */,
</ins><span class="cx">                                 85E7119D0AC5D5350053270F /* DOMHTMLBaseElementInternal.h in Headers */,
</span><span class="cx">                                 85ECBEED0AA7626900544F0B /* DOMHTMLBaseFontElement.h in Headers */,
</span><span class="cx">                                 85E7119E0AC5D5350053270F /* DOMHTMLBaseFontElementInternal.h in Headers */,
</span><span class="lines">@@ -26426,6 +26439,7 @@
</span><span class="cx">                                 B2FA3D6F0AB75A6F000E5AC4 /* JSSVGFEComponentTransferElement.h in Headers */,
</span><span class="cx">                                 B2FA3D710AB75A6F000E5AC4 /* JSSVGFECompositeElement.h in Headers */,
</span><span class="cx">                                 19BFF64F11C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.h in Headers */,
</span><ins>+                                9BD4E91B1C462CFC005065BC /* CustomElementDefinitions.h in Headers */,
</ins><span class="cx">                                 B2FA3D730AB75A6F000E5AC4 /* JSSVGFEDiffuseLightingElement.h in Headers */,
</span><span class="cx">                                 B2FA3D750AB75A6F000E5AC4 /* JSSVGFEDisplacementMapElement.h in Headers */,
</span><span class="cx">                                 B2FA3D770AB75A6F000E5AC4 /* JSSVGFEDistantLightElement.h in Headers */,
</span><span class="lines">@@ -30076,6 +30090,7 @@
</span><span class="cx">                                 51DCE8020CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp in Sources */,
</span><span class="cx">                                 B59DD6A611902A62007E9684 /* JSSQLStatementCallback.cpp in Sources */,
</span><span class="cx">                                 B59DD6AA11902A71007E9684 /* JSSQLStatementErrorCallback.cpp in Sources */,
</span><ins>+                                9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */,
</ins><span class="cx">                                 514C76380CE9225E007EF3CD /* JSSQLTransaction.cpp in Sources */,
</span><span class="cx">                                 B59DD69E11902A42007E9684 /* JSSQLTransactionCallback.cpp in Sources */,
</span><span class="cx">                                 1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */,
</span><span class="lines">@@ -30807,6 +30822,7 @@
</span><span class="cx">                                 A8DF4AE80980C42C0052981B /* RenderTableCol.cpp in Sources */,
</span><span class="cx">                                 A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */,
</span><span class="cx">                                 A8DF4AED0980C42C0052981B /* RenderTableSection.cpp in Sources */,
</span><ins>+                                9BD4E91A1C462CFC005065BC /* CustomElementDefinitions.cpp in Sources */,
</ins><span class="cx">                                 BCEA488B097D93020094C9E4 /* RenderText.cpp in Sources */,
</span><span class="cx">                                 AB67D1A8097F3AE300F9392E /* RenderTextControl.cpp in Sources */,
</span><span class="cx">                                 083DAEA60F01A7FB00342754 /* RenderTextControlMultiLine.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 &quot;config.h&quot;
+#include &quot;JSCustomElementInterface.h&quot;
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+#include &quot;DOMWrapperWorld.h&quot;
+#include &quot;Element.h&quot;
+#include &quot;JSDOMGlobalObject.h&quot;
+#include &quot;JSElement.h&quot;
+#include &quot;JSMainThreadExecState.h&quot;
+#include &quot;JSMainThreadExecStateInstrumentation.h&quot;
+#include &quot;ScriptExecutionContext.h&quot;
+#include &lt;heap/WeakInlines.h&gt;
+#include &lt;runtime/JSLock.h&gt;
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSCustomElementInterface::JSCustomElementInterface(JSObject* constructor, JSDOMGlobalObject* globalObject)
+    : ActiveDOMCallback(globalObject-&gt;scriptExecutionContext())
+    , m_constructor(constructor)
+    , m_isolatedWorld(&amp;globalObject-&gt;world())
+{
+}
+
+JSCustomElementInterface::~JSCustomElementInterface()
+{
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementInterfaceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#ifndef JSCustomElementInterface_h
+#define JSCustomElementInterface_h
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+#include &quot;ActiveDOMCallback.h&quot;
+#include &lt;heap/Weak.h&gt;
+#include &lt;heap/WeakInlines.h&gt;
+#include &lt;runtime/JSObject.h&gt;
+#include &lt;wtf/Forward.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace JSC {
+
+class JSObject;
+class PrivateName;
+
+}
+
+namespace WebCore {
+
+class DOMWrapperWorld;
+class Element;
+class JSDOMGlobalObject;
+
+class JSCustomElementInterface : public RefCounted&lt;JSCustomElementInterface&gt;, public ActiveDOMCallback {
+public:
+    static Ref&lt;JSCustomElementInterface&gt; create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
+    {
+        return adoptRef(*new JSCustomElementInterface(callback, globalObject));
+    }
+
+    ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
+    JSC::JSObject* constructor() { return m_constructor.get(); }
+
+    virtual ~JSCustomElementInterface();
+
+private:
+    JSCustomElementInterface(JSC::JSObject* callback, JSDOMGlobalObject*);
+
+    mutable JSC::Weak&lt;JSC::JSObject&gt; m_constructor;
+    RefPtr&lt;DOMWrapperWorld&gt; m_isolatedWorld;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDocumentCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSDocument.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CustomElementDefinitions.h&quot;
</ins><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;FrameLoader.h&quot;
</span><span class="lines">@@ -130,4 +131,45 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+JSValue JSDocument::defineCustomElement(ExecState&amp; state)
+{
+    AtomicString tagName(state.argument(0).toString(&amp;state)-&gt;toAtomicString(&amp;state));
+    if (UNLIKELY(state.hadException()))
+        return jsUndefined();
+
+    JSObject* object = state.argument(1).getObject();
+    ConstructData callData;
+    if (!object || object-&gt;methodTable()-&gt;getConstructData(object, callData) == ConstructTypeNone)
+        return throwTypeError(&amp;state, &quot;The second argument must be a constructor&quot;);
+
+    Document&amp; document = wrapped();
+    switch (CustomElementDefinitions::checkName(tagName)) {
+    case CustomElementDefinitions::NameStatus::Valid:
+        break;
+    case CustomElementDefinitions::NameStatus::ConflictsWithBuiltinNames:
+        return throwSyntaxError(&amp;state, &quot;Custom element name cannot be same as one of the builtin elements&quot;);
+    case CustomElementDefinitions::NameStatus::NoHyphen:
+        return throwSyntaxError(&amp;state, &quot;Custom element name must contain a hyphen&quot;);
+    case CustomElementDefinitions::NameStatus::ContainsUpperCase:
+        return throwSyntaxError(&amp;state, &quot;Custom element name cannot contain an upper case letter&quot;);
+    }
+
+    QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI);
+    auto&amp; definitions = document.ensureCustomElementDefinitions();
+    if (definitions.findInterface(tagName)) {
+        ExceptionCodeWithMessage ec;
+        ec.code = NOT_SUPPORTED_ERR;
+        ec.message = &quot;Cannot define multiple custom elements with the same tag name&quot;;
+        setDOMException(&amp;state, ec);
+        return jsUndefined();
+    }
+    definitions.defineElement(name, JSCustomElementInterface::create(object, globalObject()));
+    PrivateName uniquePrivateName;
+    globalObject()-&gt;putDirect(globalObject()-&gt;vm(), uniquePrivateName, object);
+
+    return jsUndefined();
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -26,14 +26,67 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSHTMLElement.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CustomElementDefinitions.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;HTMLFormElement.h&quot;
</span><ins>+#include &lt;runtime/InternalFunction.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSWithScope.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+EncodedJSValue JSC_HOST_CALL constructJSHTMLElement(ExecState* state)
+{
+    auto* jsConstructor = jsCast&lt;DOMConstructorObject*&gt;(state-&gt;callee());
+
+    auto* context = jsConstructor-&gt;scriptExecutionContext();
+    if (!is&lt;Document&gt;(context))
+        return throwConstructorDocumentUnavailableError(*state, &quot;HTMLElement&quot;);
+    auto&amp; document = downcast&lt;Document&gt;(*context);
+
+    auto* definitions = document.customElementDefinitions();
+    if (!definitions)
+        return throwVMTypeError(state, &quot;new.target is not a valid custom element constructor&quot;);
+
+    VM&amp; vm = state-&gt;vm();
+    JSValue newTargetValue = state-&gt;thisValue();
+    JSObject* newTarget = newTargetValue.getObject();
+    QualifiedName fullName = definitions-&gt;findName(newTarget);
+    if (fullName == nullQName()) {
+        if (UNLIKELY(state-&gt;argumentCount() &lt; 1))
+            return throwVMError(state, createNotEnoughArgumentsError(state));
+    }
+
+    if (state-&gt;argumentCount()) {
+        String name;
+        if (!state-&gt;argument(0).getString(state, name))
+            return throwVMTypeError(state, &quot;The first argument is not a valid custom element name&quot;);
+        
+        auto* interface = definitions-&gt;findInterface(name);
+        if (!interface)
+            return throwVMTypeError(state, &quot;The first argument is not a valid custom element name&quot;);
+        
+        if (newTarget != interface-&gt;constructor())
+            return throwVMTypeError(state, &quot;Attempt to construct a custom element with a wrong interface&quot;);
+        
+        fullName = QualifiedName(nullAtom, name, HTMLNames::xhtmlNamespaceURI);
+    }
+
+    auto* globalObject = jsConstructor-&gt;globalObject();
+    Structure* baseStructure = getDOMStructure&lt;JSHTMLElement&gt;(vm, *globalObject);
+    auto* newElementStructure = InternalFunction::createSubclassStructure(state, newTargetValue, baseStructure);
+    if (UNLIKELY(state-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+
+    Ref&lt;HTMLElement&gt; element = HTMLElement::create(fullName, document);
+    auto* jsElement = JSHTMLElement::create(newElementStructure, globalObject, element.get());
+    cacheWrapper(globalObject-&gt;world(), element.ptr(), jsElement);
+    return JSValue::encode(jsElement);
+}
+#endif
+
</ins><span class="cx"> JSScope* JSHTMLElement::pushEventHandlerScope(ExecState* exec, JSScope* scope) const
</span><span class="cx"> {
</span><span class="cx">     HTMLElement&amp; element = wrapped();
</span></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementDefinitionscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/CustomElementDefinitions.cpp (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementDefinitions.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/CustomElementDefinitions.cpp        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 &quot;config.h&quot;
+#include &quot;CustomElementDefinitions.h&quot;
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+#include &quot;Document.h&quot;
+#include &quot;Element.h&quot;
+#include &quot;JSCustomElementInterface.h&quot;
+#include &quot;MathMLNames.h&quot;
+#include &quot;QualifiedName.h&quot;
+#include &quot;SVGNames.h&quot;
+#include &lt;runtime/JSCJSValueInlines.h&gt;
+#include &lt;wtf/text/AtomicString.h&gt;
+
+namespace WebCore {
+
+CustomElementDefinitions::NameStatus CustomElementDefinitions::checkName(const AtomicString&amp; tagName)
+{
+    bool containsHyphen = false;
+    for (unsigned i = 0; i &lt; tagName.length(); i++) {
+        if (isASCIIUpper(tagName[i]))
+            return NameStatus::ContainsUpperCase;
+        if (tagName[i] == '-')
+            containsHyphen = true;
+    }
+
+    if (!containsHyphen)
+        return NameStatus::NoHyphen;
+
+    // FIXME: We should be taking the advantage of QualifiedNames in SVG and MathML.
+    if (tagName == SVGNames::color_profileTag.localName()
+        || tagName == SVGNames::font_faceTag.localName()
+        || tagName == SVGNames::font_face_formatTag.localName()
+        || tagName == SVGNames::font_face_nameTag.localName()
+        || tagName == SVGNames::font_face_srcTag.localName()
+        || tagName == SVGNames::font_face_uriTag.localName()
+        || tagName == SVGNames::missing_glyphTag.localName()
+#if ENABLE(MATHML)
+        || tagName == MathMLNames::annotation_xmlTag.localName()
+#endif
+        )
+        return NameStatus::ConflictsWithBuiltinNames;
+
+    return NameStatus::Valid;
+}
+
+bool CustomElementDefinitions::defineElement(const QualifiedName&amp; fullName, Ref&lt;JSCustomElementInterface&gt;&amp;&amp; interface)
+{
+    ASSERT(!m_nameMap.contains(fullName.localName()));
+    auto* constructor = interface-&gt;constructor();
+    m_nameMap.add(fullName.localName(), CustomElementInfo(fullName, WTFMove(interface)));
+
+    auto addResult = m_constructorMap.add(constructor, fullName);
+    if (!addResult.isNewEntry)
+        addResult.iterator-&gt;value = nullQName(); // The interface has multiple tag names associated with it.
+
+    return true;
+}
+
+JSCustomElementInterface* CustomElementDefinitions::findInterface(const AtomicString&amp; name) const
+{
+    auto it = m_nameMap.find(name);
+    return it == m_nameMap.end() ? nullptr : it-&gt;value.interface.get();
+}
+
+const QualifiedName&amp; CustomElementDefinitions::findName(const JSC::JSObject* constructor) const
+{
+    auto it = m_constructorMap.find(constructor);
+    return it == m_constructorMap.end() ? nullQName() : it-&gt;value;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementDefinitionsh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/CustomElementDefinitions.h (0 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementDefinitions.h                                (rev 0)
+++ trunk/Source/WebCore/dom/CustomElementDefinitions.h        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+/*
+ * 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 &quot;JSCustomElementInterface.h&quot;
+#include &quot;QualifiedName.h&quot;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/text/AtomicString.h&gt;
+#include &lt;wtf/text/AtomicStringHash.h&gt;
+
+#ifndef CustomElementDefinitions_h
+#define CustomElementDefinitions_h
+
+#if ENABLE(CUSTOM_ELEMENTS)
+
+namespace JSC {
+
+class JSObject;
+    
+}
+
+namespace WebCore {
+
+class Element;
+class QualifiedName;
+
+class CustomElementDefinitions {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    bool defineElement(const QualifiedName&amp;, Ref&lt;JSCustomElementInterface&gt;&amp;&amp;);
+
+    JSCustomElementInterface* findInterface(const AtomicString&amp;) const;
+    const QualifiedName&amp; findName(const JSC::JSObject*) const;
+
+    enum class NameStatus { Valid, ConflictsWithBuiltinNames, NoHyphen, ContainsUpperCase };
+    static NameStatus checkName(const AtomicString&amp; tagName);
+
+private:
+    class CustomElementInfo {
+        WTF_MAKE_FAST_ALLOCATED;
+    public:
+        QualifiedName fullName;
+        RefPtr&lt;JSCustomElementInterface&gt; interface;
+
+        CustomElementInfo()
+            : fullName(nullQName())
+        { }
+
+        CustomElementInfo(const QualifiedName&amp; name, Ref&lt;JSCustomElementInterface&gt;&amp;&amp; interface)
+            : fullName(name)
+            , interface(WTFMove(interface))
+        { }
+    };
+
+    HashMap&lt;AtomicString, CustomElementInfo&gt; m_nameMap;
+    HashMap&lt;const JSC::JSObject*, QualifiedName&gt; m_constructorMap;
+};
+    
+}
+
+#endif
+
+#endif /* CustomElementDefinitions_h */
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include &quot;CompositionEvent.h&quot;
</span><span class="cx"> #include &quot;ContentSecurityPolicy.h&quot;
</span><span class="cx"> #include &quot;CookieJar.h&quot;
</span><ins>+#include &quot;CustomElementDefinitions.h&quot;
</ins><span class="cx"> #include &quot;CustomEvent.h&quot;
</span><span class="cx"> #include &quot;DOMImplementation.h&quot;
</span><span class="cx"> #include &quot;DOMNamedFlowCollection.h&quot;
</span><span class="lines">@@ -6352,6 +6353,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+CustomElementDefinitions&amp; Document::ensureCustomElementDefinitions()
+{
+    if (!m_customElementDefinitions)
+        m_customElementDefinitions = std::make_unique&lt;CustomElementDefinitions&gt;();
+    return *m_customElementDefinitions;
+}
+#endif
+
</ins><span class="cx"> LayoutRect Document::absoluteEventHandlerBounds(bool&amp; includesFixedPositionElements)
</span><span class="cx"> {
</span><span class="cx">     includesFixedPositionElements = false;
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/dom/Document.h        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -175,6 +175,10 @@
</span><span class="cx"> class TransformSource;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+class CustomElementDefinitions;
+#endif
+
</ins><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="cx"> struct AnnotatedRegionValue;
</span><span class="cx"> #endif
</span><span class="lines">@@ -1214,6 +1218,11 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+    CustomElementDefinitions* customElementDefinitions() { return m_customElementDefinitions.get(); }
+    CustomElementDefinitions&amp; ensureCustomElementDefinitions();
+#endif
+
</ins><span class="cx">     const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
</span><span class="cx"> 
</span><span class="cx">     typedef std::pair&lt;Region, bool&gt; RegionFixedPair;
</span><span class="lines">@@ -1747,6 +1756,10 @@
</span><span class="cx">     Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+    std::unique_ptr&lt;CustomElementDefinitions&gt; m_customElementDefinitions;
+#endif
+
</ins><span class="cx">     RefPtr&lt;CSSFontSelector&gt; m_fontSelector;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FONT_LOAD_EVENTS)
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/dom/Document.idl        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -281,6 +281,11 @@
</span><span class="cx">     [NewObject, Custom, RaisesException] TouchList createTouchList();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if defined(LANGUAGE_JAVASCRIPT) &amp;&amp; LANGUAGE_JAVASCRIPT
+    [Custom, RaisesException, Conditional=CUSTOM_ELEMENTS]
+    void defineCustomElement(DOMString tagName, CustomElementInterface elementInterface);
+#endif
+
</ins><span class="cx">     // Page visibility API.
</span><span class="cx">     readonly attribute DOMString visibilityState;
</span><span class="cx">     readonly attribute boolean hidden;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.idl (195086 => 195087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.idl        2016-01-15 01:04:25 UTC (rev 195086)
+++ trunk/Source/WebCore/html/HTMLElement.idl        2016-01-15 02:59:03 UTC (rev 195087)
</span><span class="lines">@@ -19,6 +19,9 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> [
</span><ins>+#if defined(ENABLE_CUSTOM_ELEMENTS) &amp;&amp; ENABLE_CUSTOM_ELEMENTS
+    CustomConstructor(optional DOMString localName),
+#endif
</ins><span class="cx">     JSGenerateToNativeObject,
</span><span class="cx">     JSCustomPushEventHandlerScope,
</span><span class="cx"> ] interface HTMLElement : Element {
</span></span></pre>
</div>
</div>

</body>
</html>