Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/Document.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp |
| index 814f71fd5e4707711f266950c0261cc6fbad7b14..0c81e6496e9de52277785a0d93fb24db860c7857 100644 |
| --- a/third_party/WebKit/Source/core/dom/Document.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp |
| @@ -44,6 +44,7 @@ |
| #include "bindings/core/v8/V8PerIsolateData.h" |
| #include "bindings/core/v8/WindowProxy.h" |
| #include "core/HTMLElementFactory.h" |
| +#include "core/HTMLElementTypeHelpers.h" |
| #include "core/HTMLNames.h" |
| #include "core/SVGElementFactory.h" |
| #include "core/SVGNames.h" |
| @@ -713,6 +714,9 @@ String getTypeExtension(Document* document, |
| Element* Document::createElement(const AtomicString& localName, |
| const StringOrDictionary& stringOrOptions, |
| ExceptionState& exceptionState) { |
| + const AtomicString& is = |
| + AtomicString(getTypeExtension(this, stringOrOptions, exceptionState)); |
| + |
| if (!isValidName(localName)) { |
| exceptionState.throwDOMException( |
| InvalidCharacterError, |
| @@ -722,9 +726,14 @@ Element* Document::createElement(const AtomicString& localName, |
| Element* element; |
| - if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) { |
| + bool shouldCreateBuiltin = |
| + stringOrOptions.isDictionary() && |
| + RuntimeEnabledFeatures::customElementsBuiltinEnabled(); |
| + |
| + if (CustomElement::shouldCreateCustomElement(convertLocalName(localName)) || |
| + shouldCreateBuiltin) { |
| element = CustomElement::createCustomElementSync( |
| - *this, convertLocalName(localName)); |
| + *this, convertLocalName(localName), is); |
| } else if (V0CustomElement::isValidName(localName) && registrationContext()) { |
| element = registrationContext()->createCustomTagElement( |
| *this, QualifiedName(nullAtom, convertLocalName(localName), |
| @@ -735,11 +744,13 @@ Element* Document::createElement(const AtomicString& localName, |
| return nullptr; |
| } |
| - String typeExtention = |
| - getTypeExtension(this, stringOrOptions, exceptionState); |
| - if (!typeExtention.isEmpty()) { |
| - V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| - element, AtomicString(typeExtention)); |
| + if (!is.isEmpty()) { |
| + if (element->getCustomElementState() != CustomElementState::Custom) { |
| + V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| + element, is); |
| + } else if (stringOrOptions.isDictionary()) { |
| + element->setAttribute(HTMLNames::isAttr, is); |
| + } |
| } |
| return element; |
| @@ -784,25 +795,43 @@ Element* Document::createElementNS(const AtomicString& namespaceURI, |
| const AtomicString& qualifiedName, |
| const StringOrDictionary& stringOrOptions, |
| ExceptionState& exceptionState) { |
| + const AtomicString& is = |
| + AtomicString(getTypeExtension(this, stringOrOptions, exceptionState)); |
| + |
| + if (!isValidName(qualifiedName)) { |
| + exceptionState.throwDOMException( |
| + InvalidCharacterError, |
| + "The tag name provided ('" + qualifiedName + "') is not a valid name."); |
| + return nullptr; |
| + } |
| + |
| QualifiedName qName( |
| createQualifiedName(namespaceURI, qualifiedName, exceptionState)); |
| if (qName == QualifiedName::null()) |
| return nullptr; |
| Element* element; |
| - if (CustomElement::shouldCreateCustomElement(qName)) |
| - element = CustomElement::createCustomElementSync(*this, qName); |
| - else if (V0CustomElement::isValidName(qName.localName()) && |
| - registrationContext()) |
| + |
| + bool shouldCreateBuiltin = |
|
dominicc (has gone to gerrit)
2016/11/10 03:43:09
Maybe *may* create builtin is better? If the optio
|
| + stringOrOptions.isDictionary() && |
| + RuntimeEnabledFeatures::customElementsBuiltinEnabled(); |
| + |
| + if (CustomElement::shouldCreateCustomElement(qName) || shouldCreateBuiltin) { |
| + element = CustomElement::createCustomElementSync(*this, qName, is); |
| + } else if (V0CustomElement::isValidName(qName.localName()) && |
| + registrationContext()) { |
| element = registrationContext()->createCustomTagElement(*this, qName); |
| - else |
| + } else { |
| element = createElement(qName, CreatedByCreateElement); |
| + } |
| - String typeExtention = |
| - getTypeExtension(this, stringOrOptions, exceptionState); |
| - if (!typeExtention.isEmpty()) { |
| - V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| - element, AtomicString(typeExtention)); |
| + if (!is.isEmpty()) { |
| + if (element->getCustomElementState() != CustomElementState::Custom) { |
|
dominicc (has gone to gerrit)
2016/11/10 03:43:09
I'm not sure about this part. Doesn't v0-ish stuff
|
| + V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| + element, is); |
| + } else if (stringOrOptions.isDictionary()) { |
| + element->setAttribute(HTMLNames::isAttr, is); |
| + } |
| } |
| return element; |