Title: [127400] trunk/Source/WebCore
Revision
127400
Author
[email protected]
Date
2012-09-02 23:03:32 -0700 (Sun, 02 Sep 2012)

Log Message

[Forms] Empty visible value of AM/PM field of multiple fields time input UI should display variable number of "-" based on maximum number of labels
https://bugs.webkit.org/show_bug.cgi?id=95660

Reviewed by Kent Tamura.

This patch changes visible empty value of AM/PM field in multiple
fields time input UI to "-", "--", "---", and so on based on maximum
length of AM/PM labels. In current implementation, it is always "--"
regardless locale, although on Arabic, AM/PM are represented in one
character.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

No new tests. Once multiple field time input UI uses "lang" HTML
attribute to take time format, we can write a test for this patch.

* html/shadow/DateTimeSymbolicFieldElement.cpp:
(makeVisibleEmptyValue): Build visible empty value from maximum length
of labels.
(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue): Changed to
use m_visibleEmptyValue.
* html/shadow/DateTimeSymbolicFieldElement.h:
(WebCore::DateTimeSymbolicFieldElement): Added new member variable
m_visibleEmptyValue to hold visible empty value.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127399 => 127400)


--- trunk/Source/WebCore/ChangeLog	2012-09-03 05:51:42 UTC (rev 127399)
+++ trunk/Source/WebCore/ChangeLog	2012-09-03 06:03:32 UTC (rev 127400)
@@ -1,5 +1,33 @@
 2012-09-02  Yoshifumi Inoue  <[email protected]>
 
+        [Forms] Empty visible value of AM/PM field of multiple fields time input UI should display variable number of "-" based on maximum number of labels
+        https://bugs.webkit.org/show_bug.cgi?id=95660
+
+        Reviewed by Kent Tamura.
+
+        This patch changes visible empty value of AM/PM field in multiple
+        fields time input UI to "-", "--", "---", and so on based on maximum
+        length of AM/PM labels. In current implementation, it is always "--"
+        regardless locale, although on Arabic, AM/PM are represented in one
+        character.
+
+        This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
+        ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
+
+        No new tests. Once multiple field time input UI uses "lang" HTML
+        attribute to take time format, we can write a test for this patch.
+
+        * html/shadow/DateTimeSymbolicFieldElement.cpp:
+        (makeVisibleEmptyValue): Build visible empty value from maximum length
+        of labels.
+        (WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue): Changed to
+        use m_visibleEmptyValue.
+        * html/shadow/DateTimeSymbolicFieldElement.h:
+        (WebCore::DateTimeSymbolicFieldElement): Added new member variable
+        m_visibleEmptyValue to hold visible empty value.
+
+2012-09-02  Yoshifumi Inoue  <[email protected]>
+
         [Forms] AM/PM field of multiple fields time input UI should be fixed width
         https://bugs.webkit.org/show_bug.cgi?id=95542
 

Modified: trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp (127399 => 127400)


--- trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp	2012-09-03 05:51:42 UTC (rev 127399)
+++ trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp	2012-09-03 06:03:32 UTC (rev 127400)
@@ -32,13 +32,27 @@
 #include "RenderStyle.h"
 #include "StyleResolver.h"
 #include "TextRun.h"
+#include <wtf/text/StringBuilder.h>
 #include <wtf/unicode/Unicode.h>
 
 namespace WebCore {
 
+static AtomicString makeVisibleEmptyValue(const Vector<String>& symbols)
+{
+    unsigned maximumLength = 0;
+    for (unsigned index = 0; index < symbols.size(); ++index)
+        maximumLength = std::max(maximumLength, numGraphemeClusters(symbols[index]));
+    StringBuilder builder;
+    builder.reserveCapacity(maximumLength);
+    for (unsigned length = 0; length < maximumLength; ++length)
+        builder.append('-');
+    return builder.toAtomicString();
+}
+
 DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& symbols)
     : DateTimeFieldElement(document, fieldOwner)
     , m_symbols(symbols)
+    , m_visibleEmptyValue(makeVisibleEmptyValue(symbols))
     , m_selectedIndex(-1)
 {
     ASSERT(!symbols.isEmpty());
@@ -117,8 +131,7 @@
 
 String DateTimeSymbolicFieldElement::visibleEmptyValue() const
 {
-    // FIXME: Number of dashs should be maximum length of labels.
-    return "--";
+    return m_visibleEmptyValue;
 }
 
 String DateTimeSymbolicFieldElement::visibleValue() const

Modified: trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h (127399 => 127400)


--- trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h	2012-09-03 05:51:42 UTC (rev 127399)
+++ trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h	2012-09-03 06:03:32 UTC (rev 127400)
@@ -57,6 +57,10 @@
     virtual String visibleValue() const OVERRIDE FINAL;
 
     const Vector<String> m_symbols;
+
+    // We use AtomicString to share visible empty value among multiple
+    // DateTimeEditElements in the page.
+    const AtomicString m_visibleEmptyValue;
     int m_selectedIndex;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to