Changeset 115783 in webkit


Ignore:
Timestamp:
May 1, 2012 8:01:29 PM (12 years ago)
Author:
tkent@chromium.org
Message:

Calendar Picker: Too wide in Japanese locale
https://bugs.webkit.org/show_bug.cgi?id=85331

Reviewed by Kentaro Hara.

No new tests. This is a locale-specific behavior.

  • Resources/calendarPicker.js:

(formatJapaneseImperialEra):
Do not show an imperial era later than 平成99年 to avoid very long
year string like "275760年(平成273772年)."
(YearMonthController.prototype.attachTo):

  • Respect the maximum year specfied by <input max=...> If <input max="9999-12-31"> is specified, we don't need to secure space for the year 275,760.
  • Check the width for 平成99年 as well as the maximum year because "2087年(平成99年)" is usually wider than "275760年".
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r115782 r115783  
     12012-05-01  Kent Tamura  <tkent@chromium.org>
     2
     3        Calendar Picker: Too wide in Japanese locale
     4        https://bugs.webkit.org/show_bug.cgi?id=85331
     5
     6        Reviewed by Kentaro Hara.
     7
     8        No new tests. This is a locale-specific behavior.
     9
     10        * Resources/calendarPicker.js:
     11        (formatJapaneseImperialEra):
     12        Do not show an imperial era later than 平成99年 to avoid very long
     13        year string like "275760年(平成273772年)."
     14        (YearMonthController.prototype.attachTo):
     15        - Respect the maximum year specfied by <input max=...>
     16          If <input max="9999-12-31"> is specified, we don't need to
     17          secure space for the year 275,760.
     18        - Check the width for 平成99年 as well as the maximum year because
     19          "2087年(平成99年)" is usually wider than "275760年".
     20
    1212012-05-01  Noel Gordon  <noel.gordon@gmail.com>
    222
  • trunk/Source/WebCore/Resources/calendarPicker.js

    r115276 r115783  
    123123}
    124124
     125/*
     126 * @const
     127 * @type {number}
     128 */
     129var ImperialEraLimit = 2087;
     130
    125131/**
    126132 * @param {!number} year
     
    129135 */
    130136function formatJapaneseImperialEra(year, month) {
     137    // We don't show an imperial era if it is greater than 99 becase of space
     138    // limitation.
     139    if (year > ImperialEraLimit)
     140        return "";
    131141    if (year > 1989)
    132142        return "(平成" + (year - 1988) + "年)";
     
    427437    main.appendChild(this._wall);
    428438
    429     // The maximum year which <input type=date> supports is 275,760.
    430     // See WebCore/platform/DateComponents.h
    431     var MaximumYear = 275760;
     439    var maximumYear = global.maximumDate.getUTCFullYear();
    432440    var maxWidth = 0;
    433441    for (var m = 0; m < 12; ++m) {
    434         this._month.textContent = formatYearMonth(MaximumYear, m);
     442        this._month.textContent = formatYearMonth(maximumYear, m);
    435443        maxWidth = Math.max(maxWidth, this._month.offsetWidth);
     444    }
     445    if (getLanguage() == "ja" && ImperialEraLimit < maximumYear) {
     446        for (var m = 0; m < 12; ++m) {
     447            this._month.textContent = formatYearMonth(ImperialEraLimit, m);
     448            maxWidth = Math.max(maxWidth, this._month.offsetWidth);
     449        }
    436450    }
    437451    this._month.style.minWidth = maxWidth + 'px';
Note: See TracChangeset for help on using the changeset viewer.