| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 DateTimeChooserImpl::DateTimeChooserImpl(ChromeClientImpl* chromeClient, DateTim
eChooserClient* client, const DateTimeChooserParameters& parameters) | 49 DateTimeChooserImpl::DateTimeChooserImpl(ChromeClientImpl* chromeClient, DateTim
eChooserClient* client, const DateTimeChooserParameters& parameters) |
| 50 : m_chromeClient(chromeClient) | 50 : m_chromeClient(chromeClient) |
| 51 , m_client(client) | 51 , m_client(client) |
| 52 , m_popup(0) | 52 , m_popup(0) |
| 53 , m_parameters(parameters) | 53 , m_parameters(parameters) |
| 54 , m_locale(Locale::create(parameters.locale)) | 54 , m_locale(Locale::create(parameters.locale)) |
| 55 { | 55 { |
| 56 ASSERT(m_chromeClient); | 56 ASSERT(m_chromeClient); |
| 57 ASSERT(m_client); | 57 ASSERT(m_client); |
| 58 m_popup = m_chromeClient->openPagePopup(this, m_parameters.anchorRectInRootV
iew); | 58 m_popup = m_chromeClient->openPagePopup(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 PassRefPtr<DateTimeChooserImpl> DateTimeChooserImpl::create(ChromeClientImpl* ch
romeClient, DateTimeChooserClient* client, const DateTimeChooserParameters& para
meters) | 61 PassRefPtr<DateTimeChooserImpl> DateTimeChooserImpl::create(ChromeClientImpl* ch
romeClient, DateTimeChooserClient* client, const DateTimeChooserParameters& para
meters) |
| 62 { | 62 { |
| 63 return adoptRef(new DateTimeChooserImpl(chromeClient, client, parameters)); | 63 return adoptRef(new DateTimeChooserImpl(chromeClient, client, parameters)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 DateTimeChooserImpl::~DateTimeChooserImpl() | 66 DateTimeChooserImpl::~DateTimeChooserImpl() |
| 67 { | 67 { |
| 68 } | 68 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 99 components.setMillisecondsSinceEpochForWeek(value); | 99 components.setMillisecondsSinceEpochForWeek(value); |
| 100 else | 100 else |
| 101 ASSERT_NOT_REACHED(); | 101 ASSERT_NOT_REACHED(); |
| 102 return components.type() == DateComponents::Invalid ? String() : components.
toString(); | 102 return components.type() == DateComponents::Invalid ? String() : components.
toString(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void DateTimeChooserImpl::writeDocument(SharedBuffer* data) | 105 void DateTimeChooserImpl::writeDocument(SharedBuffer* data) |
| 106 { | 106 { |
| 107 String stepString = String::number(m_parameters.step); | 107 String stepString = String::number(m_parameters.step); |
| 108 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc
ateTrailingZeros); | 108 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc
ateTrailingZeros); |
| 109 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a
nchorRectInRootView); | |
| 110 String todayLabelString; | 109 String todayLabelString; |
| 111 String otherDateLabelString; | 110 String otherDateLabelString; |
| 112 if (m_parameters.type == InputTypeNames::month) { | 111 if (m_parameters.type == InputTypeNames::month) { |
| 113 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut
tonLabel); | 112 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut
tonLabel); |
| 114 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon
thLabel); | 113 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon
thLabel); |
| 115 } else if (m_parameters.type == InputTypeNames::week) { | 114 } else if (m_parameters.type == InputTypeNames::week) { |
| 116 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt
onLabel); | 115 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt
onLabel); |
| 117 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee
kLabel); | 116 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee
kLabel); |
| 118 } else { | 117 } else { |
| 119 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda
y); | 118 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda
y); |
| 120 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat
eLabel); | 119 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat
eLabel); |
| 121 } | 120 } |
| 122 | 121 |
| 123 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); | 122 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); |
| 124 data->append(Platform::current()->loadResource("pickerCommon.css")); | 123 data->append(Platform::current()->loadResource("pickerCommon.css")); |
| 125 data->append(Platform::current()->loadResource("pickerButton.css")); | 124 data->append(Platform::current()->loadResource("pickerButton.css")); |
| 126 data->append(Platform::current()->loadResource("suggestionPicker.css")); | 125 data->append(Platform::current()->loadResource("suggestionPicker.css")); |
| 127 data->append(Platform::current()->loadResource("calendarPicker.css")); | 126 data->append(Platform::current()->loadResource("calendarPicker.css")); |
| 128 addString("</style></head><body><div id=main>Loading...</div><script>\n" | 127 addString("</style></head><body><div id=main>Loading...</div><script>\n" |
| 129 "window.dialogArguments = {\n", data); | 128 "window.dialogArguments = {\n", data); |
| 130 addProperty("anchorRectInScreen", anchorRectInScreen, data); | 129 addProperty("anchorRectInScreen", m_parameters.anchorRectInScreen, data); |
| 131 addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters.
type), data); | 130 addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters.
type), data); |
| 132 addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters.
type), data); | 131 addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters.
type), data); |
| 133 addProperty("step", stepString, data); | 132 addProperty("step", stepString, data); |
| 134 addProperty("stepBase", stepBaseString, data); | 133 addProperty("stepBase", stepBaseString, data); |
| 135 addProperty("required", m_parameters.required, data); | 134 addProperty("required", m_parameters.required, data); |
| 136 addProperty("currentValue", valueToDateTimeString(m_parameters.doubleValue,
m_parameters.type), data); | 135 addProperty("currentValue", valueToDateTimeString(m_parameters.doubleValue,
m_parameters.type), data); |
| 137 addProperty("locale", m_parameters.locale.string(), data); | 136 addProperty("locale", m_parameters.locale.string(), data); |
| 138 addProperty("todayLabel", todayLabelString, data); | 137 addProperty("todayLabel", todayLabelString, data); |
| 139 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC
lear), data); | 138 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC
lear), data); |
| 140 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber
Label), data); | 139 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber
Label), data); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 152 Vector<String> localizedSuggestionValues; | 151 Vector<String> localizedSuggestionValues; |
| 153 Vector<String> suggestionLabels; | 152 Vector<String> suggestionLabels; |
| 154 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { | 153 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { |
| 155 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio
ns[i].value, m_parameters.type)); | 154 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio
ns[i].value, m_parameters.type)); |
| 156 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz
edValue); | 155 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz
edValue); |
| 157 suggestionLabels.append(m_parameters.suggestions[i].label); | 156 suggestionLabels.append(m_parameters.suggestions[i].label); |
| 158 } | 157 } |
| 159 addProperty("suggestionValues", suggestionValues, data); | 158 addProperty("suggestionValues", suggestionValues, data); |
| 160 addProperty("localizedSuggestionValues", localizedSuggestionValues, data
); | 159 addProperty("localizedSuggestionValues", localizedSuggestionValues, data
); |
| 161 addProperty("suggestionLabels", suggestionLabels, data); | 160 addProperty("suggestionLabels", suggestionLabels, data); |
| 162 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI
nRootView.width()), data); | 161 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI
nRootFrame.width()), data); |
| 163 addProperty("showOtherDateEntry", LayoutTheme::theme().supportsCalendarP
icker(m_parameters.type), data); | 162 addProperty("showOtherDateEntry", LayoutTheme::theme().supportsCalendarP
icker(m_parameters.type), data); |
| 164 addProperty("otherDateLabel", otherDateLabelString, data); | 163 addProperty("otherDateLabel", otherDateLabelString, data); |
| 165 addProperty("suggestionHighlightColor", LayoutTheme::theme().activeListB
oxSelectionBackgroundColor().serialized(), data); | 164 addProperty("suggestionHighlightColor", LayoutTheme::theme().activeListB
oxSelectionBackgroundColor().serialized(), data); |
| 166 addProperty("suggestionHighlightTextColor", LayoutTheme::theme().activeL
istBoxSelectionForegroundColor().serialized(), data); | 165 addProperty("suggestionHighlightTextColor", LayoutTheme::theme().activeL
istBoxSelectionForegroundColor().serialized(), data); |
| 167 } | 166 } |
| 168 addString("}\n", data); | 167 addString("}\n", data); |
| 169 | 168 |
| 170 data->append(Platform::current()->loadResource("pickerCommon.js")); | 169 data->append(Platform::current()->loadResource("pickerCommon.js")); |
| 171 data->append(Platform::current()->loadResource("suggestionPicker.js")); | 170 data->append(Platform::current()->loadResource("suggestionPicker.js")); |
| 172 data->append(Platform::current()->loadResource("calendarPicker.js")); | 171 data->append(Platform::current()->loadResource("calendarPicker.js")); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 void DateTimeChooserImpl::didClosePopup() | 203 void DateTimeChooserImpl::didClosePopup() |
| 205 { | 204 { |
| 206 ASSERT(m_client); | 205 ASSERT(m_client); |
| 207 m_popup = 0; | 206 m_popup = 0; |
| 208 m_client->didEndChooser(); | 207 m_client->didEndChooser(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 } // namespace blink | 210 } // namespace blink |
| 212 | 211 |
| 213 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 212 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| OLD | NEW |