Permalink
Browse files

Node.cpp shouldn't duplicate QualifiedName parsing logic

https://bugs.webkit.org/show_bug.cgi?id=76672

Reviewed by Eric Seidel.

I added this code out of ignorance that this logic already existed in
Document.cpp.  In a future patch, we should consider moving it to
QualifiedName.cpp.

* dom/Node.cpp:
(WebCore):
(WebCore::Node::checkSetPrefix):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
1 parent 590e749 commit fba9e4fe03cc4873f348bcc313e6a9130c0ce1e6 Adam Barth committed Jan 25, 2012
Showing with 16 additions and 57 deletions.
  1. +15 −0 Source/WebCore/ChangeLog
  2. +1 −57 Source/WebCore/dom/Node.cpp
View
@@ -1,3 +1,18 @@
+2012-01-25 Adam Barth <abarth@webkit.org>
+
+ Node.cpp shouldn't duplicate QualifiedName parsing logic
+ https://bugs.webkit.org/show_bug.cgi?id=76672
+
+ Reviewed by Eric Seidel.
+
+ I added this code out of ignorance that this logic already existed in
+ Document.cpp. In a future patch, we should consider moving it to
+ QualifiedName.cpp.
+
+ * dom/Node.cpp:
+ (WebCore):
+ (WebCore::Node::checkSetPrefix):
+
2012-01-25 Eric Seidel <eric@webkit.org>
Share more code between updateWidget implementations in HTMLEmbedElement and HTMLObjectElement
@@ -128,62 +128,6 @@ namespace WebCore {
using namespace HTMLNames;
-// http://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameStartChar
-static bool isValidNameStartCharacter(UChar c)
-{
- return isASCIIAlpha(c)
- || c == ':'
- || c == '_'
- || (c >= 0xC0 && c <= 0xD6)
- || (c >= 0xD8 && c <= 0xF6)
- || (c >= 0xF8 && c <= 0x2FF)
- || (c >= 0x370 && c <= 0x37D)
- || (c >= 0x37F && c <= 0x1FFF)
- || (c >= 0x200C && c <= 0x200D)
- || (c >= 0x2070 && c <= 0x218F)
- || (c >= 0x2C00 && c <= 0x2FEF)
- || (c >= 0x3001 && c <= 0xD7FF)
- || (c >= 0xF900 && c <= 0xFDCF)
- || (c >= 0xFDF0 && c <= 0xFFFD)
- // We're supposed to allow characters in the range U+10000-U+EFFFF,
- // but doing so precisely requires decoding UTF-16 surrogates.
- // Instead, we just allow all non-BMP characters. This is consistent
- // with the philosphy (if not the letter) of the XML specification:
- // "The intention is to be inclusive rather than exclusive, so that
- // writing systems not yet encoded in Unicode can be used in XML names."
- //
- // FIXME: Validate non-BMP characters correctly.
- || (c >= 0xD800 && c <= 0xDFFF);
-}
-
-// http://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar
-static bool isValidNameCharacter(UChar c)
-{
- return isValidNameStartCharacter(c)
- || isASCIIDigit(c)
- || c == '-'
- || c == '.'
- || c == 0xB7
- || (c >= 0x0300 && c <= 0x036F)
- || (c >= 0x203F && c <= 0x2040);
-}
-
-// http://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name
-static bool hasInvalidValidNameCharacters(const AtomicString& prefix)
-{
- const UChar* characters = prefix.characters();
- size_t length = prefix.length();
- if (!length)
- return false;
- if (!isValidNameStartCharacter(characters[0]))
- return true;
- for (size_t i = 1; i < length; ++i) {
- if (!isValidNameCharacter(characters[i]))
- return true;
- }
- return false;
-}
-
bool Node::isSupported(const String& feature, const String& version)
{
return DOMImplementation::hasFeature(feature, version);
@@ -1244,7 +1188,7 @@ void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec)
// Perform error checking as required by spec for setting Node.prefix. Used by
// Element::setPrefix() and Attr::setPrefix()
- if (hasInvalidValidNameCharacters(prefix)) {
+ if (!prefix.isEmpty() && !Document::isValidName(prefix)) {
ec = INVALID_CHARACTER_ERR;
return;
}

0 comments on commit fba9e4f

Please sign in to comment.