Title: [103205] trunk/Source/WebCore
Revision
103205
Author
[email protected]
Date
2011-12-18 18:17:39 -0800 (Sun, 18 Dec 2011)

Log Message

Add support for 8 bits strings to Document::isValidName()
https://bugs.webkit.org/show_bug.cgi?id=74784

Patch by Benjamin Poulain <[email protected]> on 2011-12-18
Reviewed by Andreas Kling.

The valid name has a fast path for ASCII, and a slow path
taking Unicode characters into account.

For 8-bit strings, we don't need to take the non-ASCII path
as it could never succeed if the ASCII path didn't.

* dom/Document.cpp:
(WebCore::isValidNameASCII):
(WebCore::Document::isValidName):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103204 => 103205)


--- trunk/Source/WebCore/ChangeLog	2011-12-19 02:13:25 UTC (rev 103204)
+++ trunk/Source/WebCore/ChangeLog	2011-12-19 02:17:39 UTC (rev 103205)
@@ -1,3 +1,20 @@
+2011-12-18  Benjamin Poulain  <[email protected]>
+
+        Add support for 8 bits strings to Document::isValidName()
+        https://bugs.webkit.org/show_bug.cgi?id=74784
+
+        Reviewed by Andreas Kling.
+
+        The valid name has a fast path for ASCII, and a slow path
+        taking Unicode characters into account.
+
+        For 8-bit strings, we don't need to take the non-ASCII path
+        as it could never succeed if the ASCII path didn't.
+
+        * dom/Document.cpp:
+        (WebCore::isValidNameASCII):
+        (WebCore::Document::isValidName):
+
 2011-12-18  Huang Dongsung  <[email protected]>
 
         [Qt] Remove redundant m_glWidget->makeCurrent() calls in GraphicsContext3DQt.

Modified: trunk/Source/WebCore/dom/Document.cpp (103204 => 103205)


--- trunk/Source/WebCore/dom/Document.cpp	2011-12-19 02:13:25 UTC (rev 103204)
+++ trunk/Source/WebCore/dom/Document.cpp	2011-12-19 02:17:39 UTC (rev 103205)
@@ -3775,9 +3775,10 @@
     return true;
 }
 
-static inline bool isValidNameASCII(const UChar* characters, unsigned length)
+template<typename CharType>
+static inline bool isValidNameASCII(const CharType* characters, unsigned length)
 {
-    UChar c = characters[0];
+    CharType c = characters[0];
     if (!(isASCIIAlpha(c) || c == ':' || c == '_'))
         return false;
 
@@ -3796,7 +3797,9 @@
     if (!length)
         return false;
 
-    const UChar* characters = name.characters();
+    if (name.is8Bit())
+        return isValidNameASCII(name.characters8(), length);
+    const UChar* characters = name.characters16();
     return isValidNameASCII(characters, length) || isValidNameNonASCII(characters, length);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to