| Index: third_party/WebKit/Source/core/dom/custom/CustomElement.h
|
| diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.h b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
|
| index ec8f3c1546b5e74181b1b0e7f308088f848439f2..3a2f5540546d138e582c4f152db7edc11ad3867b 100644
|
| --- a/third_party/WebKit/Source/core/dom/custom/CustomElement.h
|
| +++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
|
| @@ -8,6 +8,7 @@
|
| #include "core/CoreExport.h"
|
| #include "core/HTMLNames.h"
|
| #include "core/dom/Element.h"
|
| +#include "platform/text/Character.h"
|
| #include "wtf/Allocator.h"
|
| #include "wtf/text/AtomicString.h"
|
|
|
| @@ -32,7 +33,32 @@ public:
|
|
|
| static CustomElementDefinition* definitionForElement(const Element*);
|
|
|
| - static bool isValidName(const AtomicString& name);
|
| + static bool isValidName(const AtomicString& name)
|
| + {
|
| + // This quickly rejects all common built-in element names.
|
| + if (name.find('-', 1) == kNotFound)
|
| + return false;
|
| +
|
| + // Note: All valid names start with an ASCII character.
|
| + if (!Character::isPotentialCustomElementNameStartChar(name[0]))
|
| + return false;
|
| +
|
| + if (name.is8Bit()) {
|
| + for (size_t i = 1; i < name.length(); ++i) {
|
| + if (!Character::isPotentialCustomElementName8BitChar(name[i]))
|
| + return false;
|
| + }
|
| + } else {
|
| + for (size_t i = 1; i < name.length(); ) {
|
| + UChar32 ch;
|
| + U16_NEXT(name.characters16(), i, name.length(), ch);
|
| + if (!Character::isPotentialCustomElementNameChar(ch))
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + return !isHyphenatedSpecElementName(name);
|
| + }
|
|
|
| static bool shouldCreateCustomElement(const AtomicString& localName);
|
| static bool shouldCreateCustomElement(const QualifiedName&);
|
| @@ -54,6 +80,11 @@ public:
|
| static void tryToUpgrade(Element*);
|
|
|
| private:
|
| + // Some existing specs have element names with hyphens in them,
|
| + // like font-face in SVG. The custom elements spec explicitly
|
| + // disallows these as custom element names.
|
| + // https://html.spec.whatwg.org/#valid-custom-element-name
|
| + static bool isHyphenatedSpecElementName(const AtomicString&);
|
| static HTMLElement* createUndefinedElement(Document&, const QualifiedName&);
|
| };
|
|
|
|
|