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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
unt) | 142 void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
unt) |
143 { | 143 { |
144 const int countForAbbreviatedMonth = 3; | 144 const int countForAbbreviatedMonth = 3; |
145 const int countForFullMonth = 4; | 145 const int countForFullMonth = 4; |
146 const int countForNarrowMonth = 5; | 146 const int countForNarrowMonth = 5; |
147 Document& document = m_editElement.document(); | 147 Document& document = m_editElement.document(); |
148 | 148 |
149 switch (fieldType) { | 149 switch (fieldType) { |
150 case DateTimeFormat::FieldTypeDayOfMonth: { | 150 case DateTimeFormat::FieldTypeDayOfMonth: { |
151 RefPtr<DateTimeFieldElement> field = DateTimeDayFieldElement::create(&do
cument, m_editElement, m_parameters.placeholderForDay, m_dayRange); | 151 RefPtr<DateTimeFieldElement> field = DateTimeDayFieldElement::create(doc
ument, m_editElement, m_parameters.placeholderForDay, m_dayRange); |
152 m_editElement.addField(field); | 152 m_editElement.addField(field); |
153 if (shouldDayOfMonthFieldDisabled()) { | 153 if (shouldDayOfMonthFieldDisabled()) { |
154 field->setValueAsDate(m_dateValue); | 154 field->setValueAsDate(m_dateValue); |
155 field->setDisabled(); | 155 field->setDisabled(); |
156 } | 156 } |
157 return; | 157 return; |
158 } | 158 } |
159 | 159 |
160 case DateTimeFormat::FieldTypeHour11: { | 160 case DateTimeFormat::FieldTypeHour11: { |
161 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour
* 12); | 161 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour
* 12); |
162 RefPtr<DateTimeFieldElement> field = DateTimeHour11FieldElement::create(
&document, m_editElement, m_hour23Range, step); | 162 RefPtr<DateTimeFieldElement> field = DateTimeHour11FieldElement::create(
document, m_editElement, m_hour23Range, step); |
163 m_editElement.addField(field); | 163 m_editElement.addField(field); |
164 if (shouldHourFieldDisabled()) { | 164 if (shouldHourFieldDisabled()) { |
165 field->setValueAsDate(m_dateValue); | 165 field->setValueAsDate(m_dateValue); |
166 field->setDisabled(); | 166 field->setDisabled(); |
167 } | 167 } |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 case DateTimeFormat::FieldTypeHour12: { | 171 case DateTimeFormat::FieldTypeHour12: { |
172 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour
* 12); | 172 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour
* 12); |
173 RefPtr<DateTimeFieldElement> field = DateTimeHour12FieldElement::create(
&document, m_editElement, m_hour23Range, step); | 173 RefPtr<DateTimeFieldElement> field = DateTimeHour12FieldElement::create(
document, m_editElement, m_hour23Range, step); |
174 m_editElement.addField(field); | 174 m_editElement.addField(field); |
175 if (shouldHourFieldDisabled()) { | 175 if (shouldHourFieldDisabled()) { |
176 field->setValueAsDate(m_dateValue); | 176 field->setValueAsDate(m_dateValue); |
177 field->setDisabled(); | 177 field->setDisabled(); |
178 } | 178 } |
179 return; | 179 return; |
180 } | 180 } |
181 | 181 |
182 case DateTimeFormat::FieldTypeHour23: { | 182 case DateTimeFormat::FieldTypeHour23: { |
183 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay)
; | 183 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay)
; |
184 RefPtr<DateTimeFieldElement> field = DateTimeHour23FieldElement::create(
&document, m_editElement, m_hour23Range, step); | 184 RefPtr<DateTimeFieldElement> field = DateTimeHour23FieldElement::create(
document, m_editElement, m_hour23Range, step); |
185 m_editElement.addField(field); | 185 m_editElement.addField(field); |
186 if (shouldHourFieldDisabled()) { | 186 if (shouldHourFieldDisabled()) { |
187 field->setValueAsDate(m_dateValue); | 187 field->setValueAsDate(m_dateValue); |
188 field->setDisabled(); | 188 field->setDisabled(); |
189 } | 189 } |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 case DateTimeFormat::FieldTypeHour24: { | 193 case DateTimeFormat::FieldTypeHour24: { |
194 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay)
; | 194 DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay)
; |
195 RefPtr<DateTimeFieldElement> field = DateTimeHour24FieldElement::create(
&document, m_editElement, m_hour23Range, step); | 195 RefPtr<DateTimeFieldElement> field = DateTimeHour24FieldElement::create(
document, m_editElement, m_hour23Range, step); |
196 m_editElement.addField(field); | 196 m_editElement.addField(field); |
197 if (shouldHourFieldDisabled()) { | 197 if (shouldHourFieldDisabled()) { |
198 field->setValueAsDate(m_dateValue); | 198 field->setValueAsDate(m_dateValue); |
199 field->setDisabled(); | 199 field->setDisabled(); |
200 } | 200 } |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 case DateTimeFormat::FieldTypeMinute: { | 204 case DateTimeFormat::FieldTypeMinute: { |
205 DateTimeNumericFieldElement::Step step = createStep(msPerMinute, msPerHo
ur); | 205 DateTimeNumericFieldElement::Step step = createStep(msPerMinute, msPerHo
ur); |
206 RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::
create(&document, m_editElement, m_minuteRange, step); | 206 RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::
create(document, m_editElement, m_minuteRange, step); |
207 m_editElement.addField(field); | 207 m_editElement.addField(field); |
208 if (shouldMinuteFieldDisabled()) { | 208 if (shouldMinuteFieldDisabled()) { |
209 field->setValueAsDate(m_dateValue); | 209 field->setValueAsDate(m_dateValue); |
210 field->setDisabled(); | 210 field->setDisabled(); |
211 } | 211 } |
212 return; | 212 return; |
213 } | 213 } |
214 | 214 |
215 case DateTimeFormat::FieldTypeMonth: // Fallthrough. | 215 case DateTimeFormat::FieldTypeMonth: // Fallthrough. |
216 case DateTimeFormat::FieldTypeMonthStandAlone: { | 216 case DateTimeFormat::FieldTypeMonthStandAlone: { |
217 int minMonth = 0, maxMonth = 11; | 217 int minMonth = 0, maxMonth = 11; |
218 if (m_parameters.minimum.type() != DateComponents::Invalid | 218 if (m_parameters.minimum.type() != DateComponents::Invalid |
219 && m_parameters.maximum.type() != DateComponents::Invalid | 219 && m_parameters.maximum.type() != DateComponents::Invalid |
220 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear(
) | 220 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear(
) |
221 && m_parameters.minimum.month() <= m_parameters.maximum.month()) { | 221 && m_parameters.minimum.month() <= m_parameters.maximum.month()) { |
222 minMonth = m_parameters.minimum.month(); | 222 minMonth = m_parameters.minimum.month(); |
223 maxMonth = m_parameters.maximum.month(); | 223 maxMonth = m_parameters.maximum.month(); |
224 } | 224 } |
225 RefPtr<DateTimeFieldElement> field; | 225 RefPtr<DateTimeFieldElement> field; |
226 switch (count) { | 226 switch (count) { |
227 case countForNarrowMonth: // Fallthrough. | 227 case countForNarrowMonth: // Fallthrough. |
228 case countForAbbreviatedMonth: | 228 case countForAbbreviatedMonth: |
229 field = DateTimeSymbolicMonthFieldElement::create(&document, m_editE
lement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortM
onthLabels() : m_parameters.locale.shortStandAloneMonthLabels(), minMonth, maxMo
nth); | 229 field = DateTimeSymbolicMonthFieldElement::create(document, m_editEl
ement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortMo
nthLabels() : m_parameters.locale.shortStandAloneMonthLabels(), minMonth, maxMon
th); |
230 break; | 230 break; |
231 case countForFullMonth: | 231 case countForFullMonth: |
232 field = DateTimeSymbolicMonthFieldElement::create(&document, m_editE
lement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthL
abels() : m_parameters.locale.standAloneMonthLabels(), minMonth, maxMonth); | 232 field = DateTimeSymbolicMonthFieldElement::create(document, m_editEl
ement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthLa
bels() : m_parameters.locale.standAloneMonthLabels(), minMonth, maxMonth); |
233 break; | 233 break; |
234 default: | 234 default: |
235 field = DateTimeMonthFieldElement::create(&document, m_editElement,
m_parameters.placeholderForMonth, DateTimeNumericFieldElement::Range(minMonth +
1, maxMonth + 1)); | 235 field = DateTimeMonthFieldElement::create(document, m_editElement, m
_parameters.placeholderForMonth, DateTimeNumericFieldElement::Range(minMonth + 1
, maxMonth + 1)); |
236 break; | 236 break; |
237 } | 237 } |
238 m_editElement.addField(field); | 238 m_editElement.addField(field); |
239 if (minMonth == maxMonth && minMonth == m_dateValue.month() && m_dateVal
ue.type() != DateComponents::Month) { | 239 if (minMonth == maxMonth && minMonth == m_dateValue.month() && m_dateVal
ue.type() != DateComponents::Month) { |
240 field->setValueAsDate(m_dateValue); | 240 field->setValueAsDate(m_dateValue); |
241 field->setDisabled(); | 241 field->setDisabled(); |
242 } | 242 } |
243 return; | 243 return; |
244 } | 244 } |
245 | 245 |
246 case DateTimeFormat::FieldTypePeriod: { | 246 case DateTimeFormat::FieldTypePeriod: { |
247 RefPtr<DateTimeFieldElement> field = DateTimeAMPMFieldElement::create(&d
ocument, m_editElement, m_parameters.locale.timeAMPMLabels()); | 247 RefPtr<DateTimeFieldElement> field = DateTimeAMPMFieldElement::create(do
cument, m_editElement, m_parameters.locale.timeAMPMLabels()); |
248 m_editElement.addField(field); | 248 m_editElement.addField(field); |
249 if (shouldAMPMFieldDisabled()) { | 249 if (shouldAMPMFieldDisabled()) { |
250 field->setValueAsDate(m_dateValue); | 250 field->setValueAsDate(m_dateValue); |
251 field->setDisabled(); | 251 field->setDisabled(); |
252 } | 252 } |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 case DateTimeFormat::FieldTypeSecond: { | 256 case DateTimeFormat::FieldTypeSecond: { |
257 DateTimeNumericFieldElement::Step step = createStep(msPerSecond, msPerMi
nute); | 257 DateTimeNumericFieldElement::Step step = createStep(msPerSecond, msPerMi
nute); |
258 RefPtr<DateTimeNumericFieldElement> field = DateTimeSecondFieldElement::
create(&document, m_editElement, m_secondRange, step); | 258 RefPtr<DateTimeNumericFieldElement> field = DateTimeSecondFieldElement::
create(document, m_editElement, m_secondRange, step); |
259 m_editElement.addField(field); | 259 m_editElement.addField(field); |
260 if (shouldSecondFieldDisabled()) { | 260 if (shouldSecondFieldDisabled()) { |
261 field->setValueAsDate(m_dateValue); | 261 field->setValueAsDate(m_dateValue); |
262 field->setDisabled(); | 262 field->setDisabled(); |
263 } | 263 } |
264 | 264 |
265 if (needMillisecondField()) { | 265 if (needMillisecondField()) { |
266 visitLiteral(m_parameters.locale.localizedDecimalSeparator()); | 266 visitLiteral(m_parameters.locale.localizedDecimalSeparator()); |
267 visitField(DateTimeFormat::FieldTypeFractionalSecond, 3); | 267 visitField(DateTimeFormat::FieldTypeFractionalSecond, 3); |
268 } | 268 } |
269 return; | 269 return; |
270 } | 270 } |
271 | 271 |
272 case DateTimeFormat::FieldTypeFractionalSecond: { | 272 case DateTimeFormat::FieldTypeFractionalSecond: { |
273 DateTimeNumericFieldElement::Step step = createStep(1, msPerSecond); | 273 DateTimeNumericFieldElement::Step step = createStep(1, msPerSecond); |
274 RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElem
ent::create(&document, m_editElement, m_millisecondRange, step); | 274 RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElem
ent::create(document, m_editElement, m_millisecondRange, step); |
275 m_editElement.addField(field); | 275 m_editElement.addField(field); |
276 if (shouldMillisecondFieldDisabled()) { | 276 if (shouldMillisecondFieldDisabled()) { |
277 field->setValueAsDate(m_dateValue); | 277 field->setValueAsDate(m_dateValue); |
278 field->setDisabled(); | 278 field->setDisabled(); |
279 } | 279 } |
280 return; | 280 return; |
281 } | 281 } |
282 | 282 |
283 case DateTimeFormat::FieldTypeWeekOfYear: { | 283 case DateTimeFormat::FieldTypeWeekOfYear: { |
284 DateTimeNumericFieldElement::Range range(DateComponents::minimumWeekNumb
er, DateComponents::maximumWeekNumber); | 284 DateTimeNumericFieldElement::Range range(DateComponents::minimumWeekNumb
er, DateComponents::maximumWeekNumber); |
285 if (m_parameters.minimum.type() != DateComponents::Invalid | 285 if (m_parameters.minimum.type() != DateComponents::Invalid |
286 && m_parameters.maximum.type() != DateComponents::Invalid | 286 && m_parameters.maximum.type() != DateComponents::Invalid |
287 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear(
) | 287 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear(
) |
288 && m_parameters.minimum.week() <= m_parameters.maximum.week()) { | 288 && m_parameters.minimum.week() <= m_parameters.maximum.week()) { |
289 range.minimum = m_parameters.minimum.week(); | 289 range.minimum = m_parameters.minimum.week(); |
290 range.maximum = m_parameters.maximum.week(); | 290 range.maximum = m_parameters.maximum.week(); |
291 } | 291 } |
292 m_editElement.addField(DateTimeWeekFieldElement::create(&document, m_edi
tElement, range)); | 292 m_editElement.addField(DateTimeWeekFieldElement::create(document, m_edit
Element, range)); |
293 return; | 293 return; |
294 } | 294 } |
295 | 295 |
296 case DateTimeFormat::FieldTypeYear: { | 296 case DateTimeFormat::FieldTypeYear: { |
297 DateTimeYearFieldElement::Parameters yearParams; | 297 DateTimeYearFieldElement::Parameters yearParams; |
298 if (m_parameters.minimum.type() == DateComponents::Invalid) { | 298 if (m_parameters.minimum.type() == DateComponents::Invalid) { |
299 yearParams.minimumYear = DateComponents::minimumYear(); | 299 yearParams.minimumYear = DateComponents::minimumYear(); |
300 yearParams.minIsSpecified = false; | 300 yearParams.minIsSpecified = false; |
301 } else { | 301 } else { |
302 yearParams.minimumYear = m_parameters.minimum.fullYear(); | 302 yearParams.minimumYear = m_parameters.minimum.fullYear(); |
303 yearParams.minIsSpecified = true; | 303 yearParams.minIsSpecified = true; |
304 } | 304 } |
305 if (m_parameters.maximum.type() == DateComponents::Invalid) { | 305 if (m_parameters.maximum.type() == DateComponents::Invalid) { |
306 yearParams.maximumYear = DateComponents::maximumYear(); | 306 yearParams.maximumYear = DateComponents::maximumYear(); |
307 yearParams.maxIsSpecified = false; | 307 yearParams.maxIsSpecified = false; |
308 } else { | 308 } else { |
309 yearParams.maximumYear = m_parameters.maximum.fullYear(); | 309 yearParams.maximumYear = m_parameters.maximum.fullYear(); |
310 yearParams.maxIsSpecified = true; | 310 yearParams.maxIsSpecified = true; |
311 } | 311 } |
312 if (yearParams.minimumYear > yearParams.maximumYear) { | 312 if (yearParams.minimumYear > yearParams.maximumYear) { |
313 std::swap(yearParams.minimumYear, yearParams.maximumYear); | 313 std::swap(yearParams.minimumYear, yearParams.maximumYear); |
314 std::swap(yearParams.minIsSpecified, yearParams.maxIsSpecified); | 314 std::swap(yearParams.minIsSpecified, yearParams.maxIsSpecified); |
315 } | 315 } |
316 yearParams.placeholder = m_parameters.placeholderForYear; | 316 yearParams.placeholder = m_parameters.placeholderForYear; |
317 RefPtr<DateTimeFieldElement> field = DateTimeYearFieldElement::create(&d
ocument, m_editElement, yearParams); | 317 RefPtr<DateTimeFieldElement> field = DateTimeYearFieldElement::create(do
cument, m_editElement, yearParams); |
318 m_editElement.addField(field); | 318 m_editElement.addField(field); |
319 if (shouldYearFieldDisabled()) { | 319 if (shouldYearFieldDisabled()) { |
320 field->setValueAsDate(m_dateValue); | 320 field->setValueAsDate(m_dateValue); |
321 field->setDisabled(); | 321 field->setDisabled(); |
322 } | 322 } |
323 return; | 323 return; |
324 } | 324 } |
325 | 325 |
326 default: | 326 default: |
327 return; | 327 return; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 return m_parameters.minimum.type() != DateComponents::Invalid | 395 return m_parameters.minimum.type() != DateComponents::Invalid |
396 && m_parameters.maximum.type() != DateComponents::Invalid | 396 && m_parameters.maximum.type() != DateComponents::Invalid |
397 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear() | 397 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear() |
398 && m_parameters.minimum.fullYear() == m_dateValue.fullYear(); | 398 && m_parameters.minimum.fullYear() == m_dateValue.fullYear(); |
399 } | 399 } |
400 | 400 |
401 void DateTimeEditBuilder::visitLiteral(const String& text) | 401 void DateTimeEditBuilder::visitLiteral(const String& text) |
402 { | 402 { |
403 DEFINE_STATIC_LOCAL(AtomicString, textPseudoId, ("-webkit-datetime-edit-text
", AtomicString::ConstructFromLiteral)); | 403 DEFINE_STATIC_LOCAL(AtomicString, textPseudoId, ("-webkit-datetime-edit-text
", AtomicString::ConstructFromLiteral)); |
404 ASSERT(text.length()); | 404 ASSERT(text.length()); |
405 RefPtr<HTMLDivElement> element = HTMLDivElement::create(&m_editElement.docum
ent()); | 405 RefPtr<HTMLDivElement> element = HTMLDivElement::create(m_editElement.docume
nt()); |
406 element->setPart(textPseudoId); | 406 element->setPart(textPseudoId); |
407 if (m_parameters.locale.isRTL() && text.length()) { | 407 if (m_parameters.locale.isRTL() && text.length()) { |
408 Direction dir = direction(text[0]); | 408 Direction dir = direction(text[0]); |
409 if (dir == SegmentSeparator || dir == WhiteSpaceNeutral || dir == OtherN
eutral) | 409 if (dir == SegmentSeparator || dir == WhiteSpaceNeutral || dir == OtherN
eutral) |
410 element->appendChild(Text::create(&m_editElement.document(), String(
&rightToLeftMark, 1))); | 410 element->appendChild(Text::create(&m_editElement.document(), String(
&rightToLeftMark, 1))); |
411 } | 411 } |
412 element->appendChild(Text::create(&m_editElement.document(), text)); | 412 element->appendChild(Text::create(&m_editElement.document(), text)); |
413 m_editElement.fieldsWrapperElement()->appendChild(element); | 413 m_editElement.fieldsWrapperElement()->appendChild(element); |
414 } | 414 } |
415 | 415 |
(...skipping 17 matching lines...) Expand all Loading... |
433 } | 433 } |
434 return step; | 434 return step; |
435 } | 435 } |
436 | 436 |
437 // ---------------------------- | 437 // ---------------------------- |
438 | 438 |
439 DateTimeEditElement::EditControlOwner::~EditControlOwner() | 439 DateTimeEditElement::EditControlOwner::~EditControlOwner() |
440 { | 440 { |
441 } | 441 } |
442 | 442 |
443 DateTimeEditElement::DateTimeEditElement(Document* document, EditControlOwner& e
ditControlOwner) | 443 DateTimeEditElement::DateTimeEditElement(Document& document, EditControlOwner& e
ditControlOwner) |
444 : HTMLDivElement(divTag, document) | 444 : HTMLDivElement(divTag, document) |
445 , m_editControlOwner(&editControlOwner) | 445 , m_editControlOwner(&editControlOwner) |
446 { | 446 { |
447 setHasCustomStyleCallbacks(); | 447 setHasCustomStyleCallbacks(); |
448 } | 448 } |
449 | 449 |
450 DateTimeEditElement::~DateTimeEditElement() | 450 DateTimeEditElement::~DateTimeEditElement() |
451 { | 451 { |
452 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 452 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
453 m_fields[fieldIndex]->removeEventHandler(); | 453 m_fields[fieldIndex]->removeEventHandler(); |
(...skipping 21 matching lines...) Expand all Loading... |
475 } | 475 } |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 void DateTimeEditElement::blurByOwner() | 479 void DateTimeEditElement::blurByOwner() |
480 { | 480 { |
481 if (DateTimeFieldElement* field = focusedField()) | 481 if (DateTimeFieldElement* field = focusedField()) |
482 field->blur(); | 482 field->blur(); |
483 } | 483 } |
484 | 484 |
485 PassRefPtr<DateTimeEditElement> DateTimeEditElement::create(Document* document,
EditControlOwner& editControlOwner) | 485 PassRefPtr<DateTimeEditElement> DateTimeEditElement::create(Document& document,
EditControlOwner& editControlOwner) |
486 { | 486 { |
487 RefPtr<DateTimeEditElement> container = adoptRef(new DateTimeEditElement(doc
ument, editControlOwner)); | 487 RefPtr<DateTimeEditElement> container = adoptRef(new DateTimeEditElement(doc
ument, editControlOwner)); |
488 container->setPart(AtomicString("-webkit-datetime-edit", AtomicString::Const
ructFromLiteral)); | 488 container->setPart(AtomicString("-webkit-datetime-edit", AtomicString::Const
ructFromLiteral)); |
489 container->setAttribute(idAttr, ShadowElementNames::dateTimeEdit()); | 489 container->setAttribute(idAttr, ShadowElementNames::dateTimeEdit()); |
490 return container.release(); | 490 return container.release(); |
491 } | 491 } |
492 | 492 |
493 PassRefPtr<RenderStyle> DateTimeEditElement::customStyleForRenderer() | 493 PassRefPtr<RenderStyle> DateTimeEditElement::customStyleForRenderer() |
494 { | 494 { |
495 // FIXME: This is a kind of layout. We might want to introduce new renderer. | 495 // FIXME: This is a kind of layout. We might want to introduce new renderer. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 644 |
645 bool DateTimeEditElement::isReadOnly() const | 645 bool DateTimeEditElement::isReadOnly() const |
646 { | 646 { |
647 return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly(
); | 647 return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly(
); |
648 } | 648 } |
649 | 649 |
650 void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const
DateComponents& dateValue) | 650 void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const
DateComponents& dateValue) |
651 { | 651 { |
652 DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-
edit-fields-wrapper", AtomicString::ConstructFromLiteral)); | 652 DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-
edit-fields-wrapper", AtomicString::ConstructFromLiteral)); |
653 if (!firstChild()) { | 653 if (!firstChild()) { |
654 RefPtr<HTMLDivElement> element = HTMLDivElement::create(&document()); | 654 RefPtr<HTMLDivElement> element = HTMLDivElement::create(document()); |
655 element->setPart(fieldsWrapperPseudoId); | 655 element->setPart(fieldsWrapperPseudoId); |
656 appendChild(element.get()); | 656 appendChild(element.get()); |
657 } | 657 } |
658 Element* fieldsWrapper = fieldsWrapperElement(); | 658 Element* fieldsWrapper = fieldsWrapperElement(); |
659 | 659 |
660 size_t focusedFieldIndex = this->focusedFieldIndex(); | 660 size_t focusedFieldIndex = this->focusedFieldIndex(); |
661 DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex); | 661 DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex); |
662 const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseud
oId() : nullAtom; | 662 const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseud
oId() : nullAtom; |
663 | 663 |
664 DateTimeEditBuilder builder(*this, layoutParameters, dateValue); | 664 DateTimeEditBuilder builder(*this, layoutParameters, dateValue); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 { | 790 { |
791 DateTimeFieldsState dateTimeFieldsState; | 791 DateTimeFieldsState dateTimeFieldsState; |
792 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 792 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
793 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); | 793 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); |
794 return dateTimeFieldsState; | 794 return dateTimeFieldsState; |
795 } | 795 } |
796 | 796 |
797 } // namespace WebCore | 797 } // namespace WebCore |
798 | 798 |
799 #endif | 799 #endif |
OLD | NEW |