[Custom Elements] Any HTMLElement subclass should become a superclass of custom element
https://bugs.webkit.org/show_bug.cgi?id=110436

Reviewed by Dimitri Glazkov.

Source/WebCore:

This change introduces "type extension" concept of custom elements.
With the type extension, each custom elements are able to inherit
from not only HTMLElement, but also any HTML element. To make it work,
this change extends the plumbing.

This change does following changes:

= Data structure:

- Let CustomElementConstructor objects being keyed by pair of (element
  name, local name) as the standard requries, instead of just using
  single name. See CustomElementRegistry::ConstructorMap and CustomElementRegistry::find().

- Creates mapping from WrapperTypeInfo to element name.  This map
  can be looked-up by generated functions like
  findHTMLTagNameOfV8Type().  With this table, WebKit can determine
  the custom element local name of given prototype object. See  make_names.pl.
  Note that V8 prototype object knows associated WrapperTypeInfo. See r144865.

= Hooking up element lifecyle:

- Create appropriate C++ instance for each custom element.  Before
  this change, the C++ backend of custom elements were always
  HTMLUnknownElements or HTMLElement.  See
  CustomElementConstructor::createElement() and ElementFactories in
  make_names.pl.

- Hooks up element construction and element wrapper creation for
  custom element "before" non-custom case instead of "after"
  that. We do this because custom element needs to
  override non-custom case when @is attribute is given for
  otherwise-non-custom elements like <div is=x-bar>.
  See make_names.pl.

- Gives @is attributes to elements if needed. See setTypeExtension() call sites
  like Document::createElement(), Document::createElementtNS() and CustomElementConstructor::createElementt()

Test: fast/dom/custom/document-register-type-extensions.html

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
* bindings/scripts/test/V8/V8Float64Array.h:
* bindings/scripts/test/V8/V8TestActiveDOMObject.h:
* bindings/scripts/test/V8/V8TestCustomNamedGetter.h:
* bindings/scripts/test/V8/V8TestEventConstructor.h:
* bindings/scripts/test/V8/V8TestEventTarget.h:
* bindings/scripts/test/V8/V8TestException.h:
* bindings/scripts/test/V8/V8TestInterface.h:
* bindings/scripts/test/V8/V8TestMediaQueryListListener.h:
* bindings/scripts/test/V8/V8TestNamedConstructor.h:
* bindings/scripts/test/V8/V8TestNode.h:
* bindings/scripts/test/V8/V8TestObj.h:
* bindings/scripts/test/V8/V8TestOverloadedConstructors.h:
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h:
* bindings/scripts/test/V8/V8TestTypedefs.h:
* bindings/v8/CustomElementHelpers.cpp:
(WebCore::hasValidPrototypeChain):
(WebCore::CustomElementHelpers::isValidPrototypeParameter):
(WebCore::CustomElementHelpers::findLocalName):
(WebCore):
(WebCore::CustomElementHelpers::findWrapperType):
* bindings/v8/CustomElementHelpers.h:
(CustomElementHelpers):
* bindings/v8/V8CustomElement.cpp:
(WebCore::V8CustomElement::createWrapper):
* bindings/v8/V8CustomElement.h:
(V8CustomElement):
(WebCore::V8CustomElement::wrap):
(WebCore::V8CustomElement::constructorOf):
* bindings/v8/WrapperTypeInfo.h:
(WrapperTypeTraits): Added.
* bindings/v8/custom/V8CustomElementConstructorCustom.cpp:
(WebCore::V8CustomElementConstructor::callAsFunctionCallback):
* dom/CustomElementConstructor.cpp:
(WebCore::CustomElementConstructor::create):
(WebCore::CustomElementConstructor::CustomElementConstructor):
(WebCore::CustomElementConstructor::createElement):
(WebCore::setTypeExtension):
* dom/CustomElementConstructor.h:
(CustomElementConstructor):
(WebCore::CustomElementConstructor::document):
(WebCore::CustomElementConstructor::typeName):
(WebCore::CustomElementConstructor::localName):
* dom/CustomElementRegistry.cpp:
(WebCore::nameIncludesHyphen):
(WebCore::CustomElementRegistry::isValidName):
(WebCore::CustomElementRegistry::registerElement):
(WebCore::CustomElementRegistry::findFor):
(WebCore::CustomElementRegistry::find):
(WebCore::CustomElementRegistry::createElement):
* dom/CustomElementRegistry.h:
(CustomElementRegistry):
* dom/Document.cpp:
(WebCore::Document::createElement):
(WebCore::Document::createElementNS):
(WebCore::Document::registerElement):
* dom/Document.h:
(Document):
(WebCore::Document::registry): Moved from Document.cpp to be inlined.
* dom/Document.idl:
* dom/make_names.pl:
(printFactoryCppFile):
(printWrapperFactoryCppFile):
(printWrapperFactoryHeaderFile):
* html/HTMLAttributeNames.in: Added @is attribute

LayoutTests:

* fast/dom/custom/document-register-basic-expected.txt:
* fast/dom/custom/document-register-basic.html:
* fast/dom/custom/document-register-type-extensions-expected.txt: Added.
* fast/dom/custom/document-register-type-extensions.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145932 268f45cc-cd09-0410-ab3c-d52691b4dbfc