Title: [132292] trunk/Source/WebCore
Revision
132292
Author
tk...@chromium.org
Date
2012-10-23 19:16:57 -0700 (Tue, 23 Oct 2012)

Log Message

Move appendAsLDMLLiteral in LocaleWin.cpp to a common place
https://bugs.webkit.org/show_bug.cgi?id=100129

Reviewed by Kentaro Hara.

We're going to use appendAsLDMLLiteral in other code, and it is
related to DateTimeFormat class.  So we move it to DateTimeFormat
class as quoteAndAppendLiteral.

No new tests because of no behavior change.

* platform/text/DateTimeFormat.cpp:
(WebCore::DateTimeFormat::quoteAndAppendLiteral):
Moved from LocaleWin.cpp
* platform/text/DateTimeFormat.h:
Declare StringBuilder by wtf/Forward.h. It also declares String.
(DateTimeFormat): Declare quoteAndAppendLiteral.
* platform/text/LocaleWin.cpp:
(WebCore): Move appendLDMLLiteral to DateTimeFormat.
(WebCore::convertWindowsDateFormatToLDML):
Follow the moving.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132291 => 132292)


--- trunk/Source/WebCore/ChangeLog	2012-10-24 02:12:21 UTC (rev 132291)
+++ trunk/Source/WebCore/ChangeLog	2012-10-24 02:16:57 UTC (rev 132292)
@@ -1,5 +1,29 @@
 2012-10-23  Kent Tamura  <tk...@chromium.org>
 
+        Move appendAsLDMLLiteral in LocaleWin.cpp to a common place
+        https://bugs.webkit.org/show_bug.cgi?id=100129
+
+        Reviewed by Kentaro Hara.
+
+        We're going to use appendAsLDMLLiteral in other code, and it is
+        related to DateTimeFormat class.  So we move it to DateTimeFormat
+        class as quoteAndAppendLiteral.
+
+        No new tests because of no behavior change.
+
+        * platform/text/DateTimeFormat.cpp:
+        (WebCore::DateTimeFormat::quoteAndAppendLiteral):
+        Moved from LocaleWin.cpp
+        * platform/text/DateTimeFormat.h:
+        Declare StringBuilder by wtf/Forward.h. It also declares String.
+        (DateTimeFormat): Declare quoteAndAppendLiteral.
+        * platform/text/LocaleWin.cpp:
+        (WebCore): Move appendLDMLLiteral to DateTimeFormat.
+        (WebCore::convertWindowsDateFormatToLDML):
+        Follow the moving.
+
+2012-10-23  Kent Tamura  <tk...@chromium.org>
+
         REGRESSION(r131421): Text baseline is not aligned in some locales
         https://bugs.webkit.org/show_bug.cgi?id=100088
 

Modified: trunk/Source/WebCore/platform/text/DateTimeFormat.cpp (132291 => 132292)


--- trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2012-10-24 02:12:21 UTC (rev 132291)
+++ trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2012-10-24 02:16:57 UTC (rev 132292)
@@ -241,6 +241,32 @@
     return false;
 }
 
+void DateTimeFormat::quoteAndAppendLiteral(const String& literal, StringBuilder& buffer)
+{
+    if (literal.length() <= 0)
+        return;
+    
+    if (literal.find('\'') == notFound) {
+        buffer.append("'");
+        buffer.append(literal);
+        buffer.append("'");
+        return;
+    }
+
+    for (unsigned i = 0; i < literal.length(); ++i) {
+        if (literal[i] == '\'')
+            buffer.append("''");
+        else {
+            String escaped = literal.substring(i);
+            escaped.replace(ASCIILiteral("'"), ASCIILiteral("''"));
+            buffer.append("'");
+            buffer.append(escaped);
+            buffer.append("'");
+            return;
+        }
+    }
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/platform/text/DateTimeFormat.h (132291 => 132292)


--- trunk/Source/WebCore/platform/text/DateTimeFormat.h	2012-10-24 02:12:21 UTC (rev 132291)
+++ trunk/Source/WebCore/platform/text/DateTimeFormat.h	2012-10-24 02:16:57 UTC (rev 132292)
@@ -27,7 +27,7 @@
 #define DateTimeFormat_h
 
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-#include <wtf/text/WTFString.h>
+#include <wtf/Forward.h>
 
 namespace WebCore {
 
@@ -103,6 +103,7 @@
 
     // Returns true if succeeded, false if failed.
     static bool parse(const String&, TokenHandler&);
+    static void quoteAndAppendLiteral(const String&, StringBuilder&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/text/LocaleWin.cpp (132291 => 132292)


--- trunk/Source/WebCore/platform/text/LocaleWin.cpp	2012-10-24 02:12:21 UTC (rev 132291)
+++ trunk/Source/WebCore/platform/text/LocaleWin.cpp	2012-10-24 02:16:57 UTC (rev 132292)
@@ -579,39 +579,13 @@
 #endif
 
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-static void appendAsLDMLLiteral(const String& literal, StringBuilder& buffer)
-{
-    if (literal.length() <= 0)
-        return;
-    
-    if (literal.find('\'') == notFound) {
-        buffer.append("'");
-        buffer.append(literal);
-        buffer.append("'");
-        return;
-    }
-
-    for (unsigned i = 0; i < literal.length(); ++i) {
-        if (literal[i] == '\'')
-            buffer.append("''");
-        else {
-            String escaped = literal.substring(i);
-            escaped.replace(ASCIILiteral("'"), ASCIILiteral("''"));
-            buffer.append("'");
-            buffer.append(escaped);
-            buffer.append("'");
-            return;
-        }
-    }
-}
-
 static String convertWindowsDateFormatToLDML(const Vector<DateFormatToken>& tokens)
 {
     StringBuilder buffer;
     for (unsigned i = 0; i < tokens.size(); ++i) {
         switch (tokens[i].type) {
         case DateFormatToken::Literal:
-            appendAsLDMLLiteral(tokens[i].data, buffer);
+            DateTimeFormat::quoteAndAppendLiteral(tokens[i].data, buffer);
             break;
 
         case DateFormatToken::Day2:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to