Source/WebCore/ChangeLog

 12012-04-23 Kent Tamura <tkent@chromium.org>
 2
 3 Show the format indicator in a date field
 4 https://bugs.webkit.org/show_bug.cgi?id=83872
 5
 6 Reviewed by Hajime Morita.
 7
 8 Enable the fixed placeholder feature for the date type, and show
 9 the editable date format as the fixed placeholder.
 10 The format string is created by the following steps.
 11 1. Obtain a pattern string from ICU
 12 http://icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details
 13 2. Replace a sequence of 'y', 'Y', 'M', or 'd' in the pattern with
 14 a natural language string such as "year", "month", or "day".
 15
 16 Test: fast/forms/date/date-fixed-placeholder.html
 17
 18 * html/DateInputType.cpp:
 19 (WebCore::DateInputType::supportsPlaceholder): Added. Returns true.
 20 (WebCore::DateInputType::usesFixedPlaceholder): Added. Returns true.
 21 (WebCore::DateInputType::fixedPlaceholder):
 22 Added. Calls localizedDateFormatText() provided by LocalizedDate.h.
 23 * html/DateInputType.h:
 24 (DateInputType): Add declarations of new override functions.
 25 * platform/LocalizedStrings.h:
 26 (WebCore): Add dateFormat{Year,Month,DayInMonth}Text()
 27 * platform/text/ICULocale.cpp:
 28 (WebCore::isICUYearSymbol): A function to improve redability.
 29 (WebCore::isICUMonthSymbol): ditto.
 30 (WebCore::isICUDayInMonthSymbol): ditto.
 31 (WebCore::localizeFormat): Step 2 of the above description.
 32 (WebCore::ICULocale::initializeLocalizedDateFormatText):
 33 Step 1 of the above description.
 34 (WebCore::ICULocale::localizedDateFormatText):
 35 * platform/text/ICULocale.h:
 36 (ICULocale): Add new functions and a data member.
 37 * platform/text/LocalizedDate.h:
 38 (WebCore): Add localizedDateFormatText().
 39 * platform/text/LocalizedDateICU.cpp:
 40 (WebCore::localizedDateFormatText):
 41 Just call ICULocale::localizedDateFormatText().
 42
1432012-04-18 James Robinson <jamesr@chromium.org>
244
345 [chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer type

Source/WebKit/chromium/ChangeLog

 12012-04-23 Kent Tamura <tkent@chromium.org>
 2
 3 Show the format indicator in a date field
 4 https://bugs.webkit.org/show_bug.cgi?id=83872
 5
 6 Reviewed by Hajime Morita.
 7
 8 * src/LocalizedStrings.cpp:
 9 (WebCore::dateFormatYearText): Added a stub.
 10 (WebCore::dateFormatMonthText): ditto.
 11 (WebCore::dateFormatDayInMonthText): ditto.
 12
1132012-04-18 James Robinson <jamesr@chromium.org>
214
315 [chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer type

Source/WebCore/html/DateInputType.cpp

3535#include "DateComponents.h"
3636#include "HTMLInputElement.h"
3737#include "HTMLNames.h"
 38#include "LocalizedDate.h"
3839#include <wtf/PassOwnPtr.h>
3940
4041#if ENABLE(INPUT_TYPE_DATE)

@@void DateInputType::handleBlurEvent()
139140 // renderer value should be purged before style calculation.
140141 element()->updateInnerTextValue();
141142}
 143
 144bool DateInputType::supportsPlaceholder() const
 145{
 146 return true;
 147}
 148
 149bool DateInputType::usesFixedPlaceholder() const
 150{
 151 return true;
 152}
 153
 154String DateInputType::fixedPlaceholder()
 155{
 156 return localizedDateFormatText();
 157}
142158#endif // ENABLE(CALENDAR_PICKER)
143159
144160} // namespace WebCore

Source/WebCore/html/DateInputType.h

@@private:
5959 virtual void createShadowSubtree() OVERRIDE;
6060 virtual void destroyShadowSubtree() OVERRIDE;
6161 virtual void handleBlurEvent() OVERRIDE;
 62 virtual bool supportsPlaceholder() const OVERRIDE;
 63 virtual bool usesFixedPlaceholder() const OVERRIDE;
 64 virtual String fixedPlaceholder() OVERRIDE;
6265
6366 // TextFieldInputType functions
6467 virtual bool needsContainer() const OVERRIDE;

Source/WebCore/platform/LocalizedStrings.h

@@namespace WebCore {
214214#if ENABLE(CALENDAR_PICKER)
215215 String calendarTodayText();
216216 String calendarClearText();
 217 String dateFormatYearText();
 218 String dateFormatMonthText();
 219 String dateFormatDayInMonthText();
217220#endif
218221
219222#if !PLATFORM(CHROMIUM)

Source/WebCore/platform/text/ICULocale.cpp

3131#include "config.h"
3232#include "ICULocale.h"
3333
 34#include "LocalizedStrings.h"
3435#include <limits>
3536#include <wtf/PassOwnPtr.h>
3637#include <wtf/text/StringBuilder.h>

@@String ICULocale::formatLocalizedDate(const DateComponents& dateComponents)
311312}
312313
313314#if ENABLE(CALENDAR_PICKER)
 315static inline bool isICUYearSymbol(UChar letter)
 316{
 317 return letter == 'y' || letter == 'Y';
 318}
 319
 320static inline bool isICUMonthSymbol(UChar letter)
 321{
 322 return letter == 'M';
 323}
 324
 325static inline bool isICUDayInMonthSymbol(UChar letter)
 326{
 327 return letter == 'd';
 328}
 329
 330// Specification of the input:
 331// http://icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details
 332static String localizeFormat(const Vector<UChar>& buffer)
 333{
 334 StringBuilder builder;
 335 UChar lastChar = 0;
 336 bool inQuote = false;
 337 for (unsigned i = 0; i < buffer.size(); ++i) {
 338 if (inQuote) {
 339 if (buffer[i] == '\'') {
 340 inQuote = false;
 341 lastChar = 0;
 342 ASSERT(i);
 343 if (buffer[i - 1] == '\'')
 344 builder.append('\'');
 345 } else
 346 builder.append(buffer[i]);
 347 } else {
 348 if (isASCIIAlpha(lastChar) && lastChar == buffer[i])
 349 continue;
 350 lastChar = buffer[i];
 351 if (isICUYearSymbol(lastChar)) {
 352 String text = dateFormatYearText();
 353 builder.append(text.isEmpty() ? "Year" : text);
 354 } else if (isICUMonthSymbol(lastChar)) {
 355 String text = dateFormatMonthText();
 356 builder.append(text.isEmpty() ? "Month" : text);
 357 } else if (isICUDayInMonthSymbol(lastChar)) {
 358 String text = dateFormatDayInMonthText();
 359 builder.append(text.isEmpty() ? "Day" : text);
 360 } else if (lastChar == '\'')
 361 inQuote = true;
 362 else
 363 builder.append(lastChar);
 364 }
 365 }
 366 return builder.toString();
 367}
 368
 369void ICULocale::initializeLocalizedDateFormatText()
 370{
 371 if (!m_localizedDateFormatText.isNull())
 372 return;
 373 m_localizedDateFormatText = String("");
 374 if (!initializeShortDateFormat())
 375 return;
 376 UErrorCode status = U_ZERO_ERROR;
 377 int32_t length = udat_toPattern(m_shortDateFormat, TRUE, 0, 0, &status);
 378 if (status != U_BUFFER_OVERFLOW_ERROR)
 379 return;
 380 Vector<UChar> buffer(length);
 381 status = U_ZERO_ERROR;
 382 udat_toPattern(m_shortDateFormat, TRUE, buffer.data(), length, &status);
 383 if (U_FAILURE(status))
 384 return;
 385 m_localizedDateFormatText = localizeFormat(buffer);
 386}
 387
 388String ICULocale::localizedDateFormatText()
 389{
 390 initializeLocalizedDateFormatText();
 391 return m_localizedDateFormatText;
 392}
 393
314394PassOwnPtr<Vector<String> > ICULocale::createLabelVector(UDateFormatSymbolType type, int32_t startIndex, int32_t size)
315395{
316396 if (!m_shortDateFormat)

Source/WebCore/platform/text/ICULocale.h

@@public:
5656 // For LocalizedDate
5757 double parseLocalizedDate(const String&);
5858 String formatLocalizedDate(const DateComponents&);
59 
6059#if ENABLE(CALENDAR_PICKER)
 60 String localizedDateFormatText();
 61
6162 // For LocalizedCalendar
6263 const Vector<String>& monthLabels();
6364 const Vector<String>& weekDayShortLabels();

@@private:
7778 bool initializeShortDateFormat();
7879
7980#if ENABLE(CALENDAR_PICKER)
 81 void initializeLocalizedDateFormatText();
8082 PassOwnPtr<Vector<String> > createLabelVector(UDateFormatSymbolType, int32_t startIndex, int32_t size);
8183 void initializeCalendar();
8284#endif

@@private:
99101 bool m_didCreateShortDateFormat;
100102
101103#if ENABLE(CALENDAR_PICKER)
 104 String m_localizedDateFormatText;
102105 OwnPtr<Vector<String> > m_monthLabels;
103106 OwnPtr<Vector<String> > m_weekDayShortLabels;
104107 unsigned m_firstDayOfWeek;

Source/WebCore/platform/text/LocalizedDate.h

@@double parseLocalizedDate(const String&, DateComponents::Type);
4444// localized dates the function should return an empty string.
4545String formatLocalizedDate(const DateComponents& dateComponents);
4646
 47#if ENABLE(CALENDAR_PICKER)
 48String localizedDateFormatText();
 49#endif
4750} // namespace WebCore
4851
4952#endif // LocalizedDate_h

Source/WebCore/platform/text/LocalizedDateICU.cpp

@@String formatLocalizedDate(const DateComponents& dateComponents)
7070 return String();
7171}
7272
 73#if ENABLE(CALENDAR_PICKER)
 74String localizedDateFormatText()
 75{
 76 return ICULocale::currentLocale()->localizedDateFormatText();
 77}
 78#endif
 79
7380}

Source/WebKit/chromium/src/LocalizedStrings.cpp

@@String calendarClearText()
406406{
407407 return query(WebLocalizedString::CalendarClear);
408408}
 409
 410String dateFormatYearText()
 411{
 412 // FXIME: Implement.
 413 return String();
 414}
 415
 416String dateFormatMonthText()
 417{
 418 // FXIME: Implement.
 419 return String();
 420}
 421
 422String dateFormatDayInMonthText()
 423{
 424 // FXIME: Implement.
 425 return String();
 426}
409427#endif
410428
411429} // namespace WebCore

LayoutTests/ChangeLog

 12012-04-23 Kent Tamura <tkent@chromium.org>
 2
 3 Show the format indicator in a date field
 4 https://bugs.webkit.org/show_bug.cgi?id=83872
 5
 6 Reviewed by Hajime Morita.
 7
 8 * fast/forms/date/date-fixed-placeholder-expected.txt: Added.
 9 * fast/forms/date/date-fixed-placeholder.html: Added.
 10 * platform/chromium/test_expectations.txt:
 11 Mark date-appearance.html FAIL because of render dump change.
 12
1132012-04-23 Sheriff Bot <webkit.review.bot@gmail.com>
214
315 Unreviewed, rolling out r114965.

LayoutTests/fast/forms/date/date-fixed-placeholder-expected.txt

 1Check placeholder behavior of type=date with ENABLE_CALENDAR_PICKER
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS visiblePlaceholder.indexOf("year") >= 0 is true
 7PASS visiblePlaceholder.indexOf("month") >= 0 is true
 8PASS visiblePlaceholder.indexOf("day") >= 0 is true
 9PASS visiblePlaceholder is internals.visiblePlaceholder(document.getElementById("date-with-placeholder-attribute")).toLowerCase()
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13

LayoutTests/fast/forms/date/date-fixed-placeholder.html

 1<!DOCTYPE html>
 2<body>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4
 5<input type="date" id="date-without-placeholder-attribute">
 6<input type="date" id="date-with-placeholder-attribute" placeholder="Your birth day">
 7
 8<script>
 9description('Check placeholder behavior of type=date with ENABLE_CALENDAR_PICKER');
 10if (window.internals) {
 11 var visiblePlaceholder = internals.visiblePlaceholder(document.getElementById('date-without-placeholder-attribute')).toLowerCase();
 12 // Assume English locale.
 13 shouldBeTrue('visiblePlaceholder.indexOf("year") >= 0');
 14 shouldBeTrue('visiblePlaceholder.indexOf("month") >= 0');
 15 shouldBeTrue('visiblePlaceholder.indexOf("day") >= 0');
 16 shouldBe('visiblePlaceholder', 'internals.visiblePlaceholder(document.getElementById("date-with-placeholder-attribute")).toLowerCase()');
 17} else
 18 debug('Both of the date fields should have default placeholders which contain "year", "month", and "day."');
 19
 20
 21</script>
 22<script src="../../js/resources/js-test-post.js"></script>
 23</body>

LayoutTests/platform/chromium/test_expectations.txt

@@BUGWK29359 : fast/forms/datetimelocal = PASS FAIL
10971097BUGWK29359 : fast/forms/month = PASS FAIL
10981098BUGWK29359 : fast/forms/time = PASS FAIL
10991099BUGWK29359 : fast/forms/week = PASS FAIL
 1100// Need rebaseline
 1101BUGWK83872 : fast/forms/date/date-appearance.html = FAIL
11001102
11011103BUGCR78376 : http/tests/media/video-play-stall-seek.html = TIMEOUT
11021104