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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 if (!m_popup) | 78 if (!m_popup) |
79 return; | 79 return; |
80 m_chromeClient->closePagePopup(m_popup); | 80 m_chromeClient->closePagePopup(m_popup); |
81 } | 81 } |
82 | 82 |
83 WebCore::IntSize DateTimeChooserImpl::contentSize() | 83 WebCore::IntSize DateTimeChooserImpl::contentSize() |
84 { | 84 { |
85 return WebCore::IntSize(0, 0); | 85 return WebCore::IntSize(0, 0); |
86 } | 86 } |
87 | 87 |
88 static String valueToDateTimeString(double value, AtomicString type) | |
89 { | |
90 WebCore::DateComponents components; | |
91 if (type == WebCore::InputTypeNames::date()) | |
92 components.setMillisecondsSinceEpochForDate(value); | |
93 else if (type == WebCore::InputTypeNames::datetimelocal()) | |
94 components.setMillisecondsSinceEpochForDateTimeLocal(value); | |
95 else if (type == WebCore::InputTypeNames::month()) | |
96 components.setMonthsSinceEpoch(value); | |
97 else if (type == WebCore::InputTypeNames::time()) | |
98 components.setMillisecondsSinceMidnight(value); | |
99 else if (type == WebCore::InputTypeNames::week()) | |
100 components.setMillisecondsSinceEpochForWeek(value); | |
101 else | |
102 ASSERT_NOT_REACHED(); | |
103 return components.type() == WebCore::DateComponents::Invalid ? String() : co mponents.toString(); | |
104 } | |
105 | |
88 void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer) | 106 void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer) |
89 { | 107 { |
90 WebCore::DateComponents minDate; | |
91 WebCore::DateComponents maxDate; | |
92 if (m_parameters.type == WebCore::InputTypeNames::month()) { | |
93 minDate.setMonthsSinceEpoch(m_parameters.minimum); | |
94 maxDate.setMonthsSinceEpoch(m_parameters.maximum); | |
95 } else if (m_parameters.type == WebCore::InputTypeNames::week()) { | |
96 minDate.setMillisecondsSinceEpochForWeek(m_parameters.minimum); | |
97 maxDate.setMillisecondsSinceEpochForWeek(m_parameters.maximum); | |
98 } else { | |
99 minDate.setMillisecondsSinceEpochForDate(m_parameters.minimum); | |
100 maxDate.setMillisecondsSinceEpochForDate(m_parameters.maximum); | |
101 } | |
102 String stepString = String::number(m_parameters.step); | 108 String stepString = String::number(m_parameters.step); |
103 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc ateTrailingZeros); | 109 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc ateTrailingZeros); |
104 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a nchorRectInRootView); | 110 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a nchorRectInRootView); |
105 String todayLabelString; | 111 String todayLabelString; |
106 String otherDateLabelString; | 112 String otherDateLabelString; |
107 if (m_parameters.type == WebCore::InputTypeNames::month()) { | 113 if (m_parameters.type == WebCore::InputTypeNames::month()) { |
108 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut tonLabel); | 114 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut tonLabel); |
109 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon thLabel); | 115 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon thLabel); |
110 } else if (m_parameters.type == WebCore::InputTypeNames::week()) { | 116 } else if (m_parameters.type == WebCore::InputTypeNames::week()) { |
111 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt onLabel); | 117 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt onLabel); |
112 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee kLabel); | 118 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee kLabel); |
113 } else { | 119 } else { |
114 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda y); | 120 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda y); |
115 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat eLabel); | 121 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat eLabel); |
116 } | 122 } |
117 | 123 |
118 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer); | 124 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer); |
119 writer.addData(pickerCommonCss, sizeof(pickerCommonCss)); | 125 writer.addData(pickerCommonCss, sizeof(pickerCommonCss)); |
120 writer.addData(pickerButtonCss, sizeof(pickerButtonCss)); | 126 writer.addData(pickerButtonCss, sizeof(pickerButtonCss)); |
121 writer.addData(suggestionPickerCss, sizeof(suggestionPickerCss)); | 127 writer.addData(suggestionPickerCss, sizeof(suggestionPickerCss)); |
122 writer.addData(calendarPickerCss, sizeof(calendarPickerCss)); | 128 writer.addData(calendarPickerCss, sizeof(calendarPickerCss)); |
123 addString("</style></head><body><div id=main>Loading...</div><script>\n" | 129 addString("</style></head><body><div id=main>Loading...</div><script>\n" |
124 "window.dialogArguments = {\n", writer); | 130 "window.dialogArguments = {\n", writer); |
125 addProperty("anchorRectInScreen", anchorRectInScreen, writer); | 131 addProperty("anchorRectInScreen", anchorRectInScreen, writer); |
126 addProperty("min", minDate.toString(), writer); | 132 addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters. type), writer); |
127 addProperty("max", maxDate.toString(), writer); | 133 addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters. type), writer); |
128 addProperty("step", stepString, writer); | 134 addProperty("step", stepString, writer); |
129 addProperty("stepBase", stepBaseString, writer); | 135 addProperty("stepBase", stepBaseString, writer); |
130 addProperty("required", m_parameters.required, writer); | 136 addProperty("required", m_parameters.required, writer); |
131 addProperty("currentValue", m_parameters.currentValue, writer); | 137 addProperty("currentValue", valueToDateTimeString(m_parameters.currentValue, m_parameters.type), writer); |
132 addProperty("locale", m_parameters.locale.string(), writer); | 138 addProperty("locale", m_parameters.locale.string(), writer); |
133 addProperty("todayLabel", todayLabelString, writer); | 139 addProperty("todayLabel", todayLabelString, writer); |
134 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC lear), writer); | 140 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC lear), writer); |
135 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber Label), writer); | 141 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber Label), writer); |
136 addProperty("weekStartDay", m_locale->firstDayOfWeek(), writer); | 142 addProperty("weekStartDay", m_locale->firstDayOfWeek(), writer); |
137 addProperty("shortMonthLabels", m_locale->shortMonthLabels(), writer); | 143 addProperty("shortMonthLabels", m_locale->shortMonthLabels(), writer); |
138 addProperty("dayLabels", m_locale->weekDayShortLabels(), writer); | 144 addProperty("dayLabels", m_locale->weekDayShortLabels(), writer); |
139 addProperty("isLocaleRTL", m_locale->isRTL(), writer); | 145 addProperty("isLocaleRTL", m_locale->isRTL(), writer); |
140 addProperty("isRTL", m_parameters.isAnchorElementRTL, writer); | 146 addProperty("isRTL", m_parameters.isAnchorElementRTL, writer); |
141 addProperty("mode", m_parameters.type.string(), writer); | 147 addProperty("mode", m_parameters.type.string(), writer); |
142 if (m_parameters.suggestionValues.size()) { | 148 if (m_parameters.suggestions.size()) { |
149 Vector<String> suggestionValues; | |
150 Vector<String> localizedSuggestionValues; | |
151 Vector<String> suggestionLabels; | |
152 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { | |
tkent
2013/11/07 01:43:10
|i| should be size_t because Vector::size is size_
| |
153 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio ns[i].value, m_parameters.type)); | |
154 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz edValue); | |
155 suggestionLabels.append(m_parameters.suggestions[i].label); | |
156 } | |
157 addProperty("suggestionValues", suggestionValues, writer); | |
158 addProperty("localizedSuggestionValues", localizedSuggestionValues, writ er); | |
159 addProperty("suggestionLabels", suggestionLabels, writer); | |
143 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI nRootView.width()), writer); | 160 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI nRootView.width()), writer); |
144 addProperty("suggestionValues", m_parameters.suggestionValues, writer); | |
145 addProperty("localizedSuggestionValues", m_parameters.localizedSuggestio nValues, writer); | |
146 addProperty("suggestionLabels", m_parameters.suggestionLabels, writer); | |
147 addProperty("showOtherDateEntry", WebCore::RenderTheme::theme().supports CalendarPicker(m_parameters.type), writer); | 161 addProperty("showOtherDateEntry", WebCore::RenderTheme::theme().supports CalendarPicker(m_parameters.type), writer); |
148 addProperty("otherDateLabel", otherDateLabelString, writer); | 162 addProperty("otherDateLabel", otherDateLabelString, writer); |
149 addProperty("suggestionHighlightColor", WebCore::RenderTheme::theme().ac tiveListBoxSelectionBackgroundColor().serialized(), writer); | 163 addProperty("suggestionHighlightColor", WebCore::RenderTheme::theme().ac tiveListBoxSelectionBackgroundColor().serialized(), writer); |
150 addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::theme( ).activeListBoxSelectionForegroundColor().serialized(), writer); | 164 addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::theme( ).activeListBoxSelectionForegroundColor().serialized(), writer); |
151 } | 165 } |
152 addString("}\n", writer); | 166 addString("}\n", writer); |
153 | 167 |
154 writer.addData(pickerCommonJs, sizeof(pickerCommonJs)); | 168 writer.addData(pickerCommonJs, sizeof(pickerCommonJs)); |
155 writer.addData(suggestionPickerJs, sizeof(suggestionPickerJs)); | 169 writer.addData(suggestionPickerJs, sizeof(suggestionPickerJs)); |
156 writer.addData(calendarPickerJs, sizeof(calendarPickerJs)); | 170 writer.addData(calendarPickerJs, sizeof(calendarPickerJs)); |
(...skipping 26 matching lines...) Expand all Loading... | |
183 void DateTimeChooserImpl::didClosePopup() | 197 void DateTimeChooserImpl::didClosePopup() |
184 { | 198 { |
185 ASSERT(m_client); | 199 ASSERT(m_client); |
186 m_popup = 0; | 200 m_popup = 0; |
187 m_client->didEndChooser(); | 201 m_client->didEndChooser(); |
188 } | 202 } |
189 | 203 |
190 } // namespace WebKit | 204 } // namespace WebKit |
191 | 205 |
192 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 206 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
OLD | NEW |