Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElement.h

Issue 2292433002: CL for perf tryjob on linux (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7974b2508b5d8191e1633172847b5c8e8dbdf0ab 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.h
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
@@ -8,6 +8,8 @@
#include "core/CoreExport.h"
#include "core/HTMLNames.h"
#include "core/dom/Element.h"
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/text/Character.h"
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h"
@@ -32,14 +34,43 @@ public:
static CustomElementDefinition* definitionForElement(const Element*);
- static bool isValidName(const AtomicString& name);
+ static bool isValidName(const AtomicString& name)
+ {
+ if (!name.length() || name[0] < 'a' || name[0] > 'z')
+ return false;
+
+ bool hasHyphens = false;
+ if (name.is8Bit()) {
+ for (size_t i = 1; i < name.length(); ) {
+ UChar ch = name[i++];
+ if (ch == '-')
+ hasHyphens = true;
+ else if (!Character::isPotentialCustomElementNameChar(ch))
+ return false;
+ }
+ } else {
+ for (size_t i = 1; i < name.length(); ) {
+ UChar32 ch;
+ U16_NEXT(name.characters16(), i, name.length(), ch);
+ if (ch == '-')
+ hasHyphens = true;
+ else if (!Character::isPotentialCustomElementNameChar(ch))
+ return false;
+ }
+ }
+ return hasHyphens && !isHyphenContainingElementName(name);
+ }
+
+ static bool shouldCreateCustomElement(const AtomicString& localName)
+ {
+ return RuntimeEnabledFeatures::customElementsV1Enabled()
+ && isValidName(localName);
+ }
- static bool shouldCreateCustomElement(const AtomicString& localName);
static bool shouldCreateCustomElement(const QualifiedName&);
- static HTMLElement* createCustomElementSync(Document&, const AtomicString& localName, ExceptionState&);
- static HTMLElement* createCustomElementSync(Document&, const QualifiedName&, ExceptionState&);
- static HTMLElement* createCustomElementSync(Document&, const QualifiedName&);
+ static HTMLElement* createCustomElementSync(Document&, const AtomicString& localName, ExceptionState*);
+ static HTMLElement* createCustomElementSync(Document&, const QualifiedName&, ExceptionState*);
static HTMLElement* createCustomElementAsync(Document&, const QualifiedName&);
static HTMLElement* createFailedElement(Document&, const QualifiedName&);
@@ -55,6 +86,11 @@ public:
private:
static HTMLElement* createUndefinedElement(Document&, const QualifiedName&);
+
+ // A hyphen-containing element name is an element name from a
+ // specification which contains a hyphen, for example, font-face
+ // from SVG. These are not allowed as custom element names.
+ static bool isHyphenContainingElementName(const AtomicString&);
};
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/custom/CustomElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698