Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/DateTimeEditElement.cpp

Issue 1746283002: Rename enums/functions that collide in chromium style in platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-13-platform: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& element, const Dat eTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date Value) 85 DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& element, const Dat eTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date Value)
86 : m_editElement(&element) 86 : m_editElement(&element)
87 , m_dateValue(dateValue) 87 , m_dateValue(dateValue)
88 , m_parameters(layoutParameters) 88 , m_parameters(layoutParameters)
89 , m_dayRange(1, 31) 89 , m_dayRange(1, 31)
90 , m_hour23Range(0, 23) 90 , m_hour23Range(0, 23)
91 , m_minuteRange(0, 59) 91 , m_minuteRange(0, 59)
92 , m_secondRange(0, 59) 92 , m_secondRange(0, 59)
93 , m_millisecondRange(0, 999) 93 , m_millisecondRange(0, 999)
94 { 94 {
95 if (m_dateValue.type() == DateComponents::Date || m_dateValue.type() == Date Components::DateTimeLocal) { 95 if (m_dateValue.getType() == DateComponents::Date || m_dateValue.getType() = = DateComponents::DateTimeLocal) {
96 if (m_parameters.minimum.type() != DateComponents::Invalid 96 if (m_parameters.minimum.getType() != DateComponents::Invalid
97 && m_parameters.maximum.type() != DateComponents::Invalid 97 && m_parameters.maximum.getType() != DateComponents::Invalid
98 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear( ) 98 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear( )
99 && m_parameters.minimum.month() == m_parameters.maximum.month() 99 && m_parameters.minimum.month() == m_parameters.maximum.month()
100 && m_parameters.minimum.monthDay() <= m_parameters.maximum.monthDay( )) { 100 && m_parameters.minimum.monthDay() <= m_parameters.maximum.monthDay( )) {
101 m_dayRange.minimum = m_parameters.minimum.monthDay(); 101 m_dayRange.minimum = m_parameters.minimum.monthDay();
102 m_dayRange.maximum = m_parameters.maximum.monthDay(); 102 m_dayRange.maximum = m_parameters.maximum.monthDay();
103 } 103 }
104 } 104 }
105 105
106 if (m_dateValue.type() == DateComponents::Time || m_dayRange.isSingleton()) { 106 if (m_dateValue.getType() == DateComponents::Time || m_dayRange.isSingleton( )) {
107 if (m_parameters.minimum.type() != DateComponents::Invalid 107 if (m_parameters.minimum.getType() != DateComponents::Invalid
108 && m_parameters.maximum.type() != DateComponents::Invalid 108 && m_parameters.maximum.getType() != DateComponents::Invalid
109 && m_parameters.minimum.hour() <= m_parameters.maximum.hour()) { 109 && m_parameters.minimum.hour() <= m_parameters.maximum.hour()) {
110 m_hour23Range.minimum = m_parameters.minimum.hour(); 110 m_hour23Range.minimum = m_parameters.minimum.hour();
111 m_hour23Range.maximum = m_parameters.maximum.hour(); 111 m_hour23Range.maximum = m_parameters.maximum.hour();
112 } 112 }
113 } 113 }
114 114
115 if (m_hour23Range.isSingleton() && m_parameters.minimum.minute() <= m_parame ters.maximum.minute()) { 115 if (m_hour23Range.isSingleton() && m_parameters.minimum.minute() <= m_parame ters.maximum.minute()) {
116 m_minuteRange.minimum = m_parameters.minimum.minute(); 116 m_minuteRange.minimum = m_parameters.minimum.minute();
117 m_minuteRange.maximum = m_parameters.maximum.minute(); 117 m_minuteRange.maximum = m_parameters.maximum.minute();
118 } 118 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.getType() != DateComponents::Invalid
219 && m_parameters.maximum.type() != DateComponents::Invalid 219 && m_parameters.maximum.getType() != 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 RefPtrWillBeRawPtr<DateTimeFieldElement> field; 225 RefPtrWillBeRawPtr<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, editElem ent(), fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortMo nthLabels() : m_parameters.locale.shortStandAloneMonthLabels(), minMonth, maxMon th); 229 field = DateTimeSymbolicMonthFieldElement::create(document, editElem ent(), 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, editElem ent(), fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthLa bels() : m_parameters.locale.standAloneMonthLabels(), minMonth, maxMonth); 232 field = DateTimeSymbolicMonthFieldElement::create(document, editElem ent(), 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, editElement(), m _parameters.placeholderForMonth, DateTimeNumericFieldElement::Range(minMonth + 1 , maxMonth + 1)); 235 field = DateTimeMonthFieldElement::create(document, editElement(), m _parameters.placeholderForMonth, DateTimeNumericFieldElement::Range(minMonth + 1 , maxMonth + 1));
236 break; 236 break;
237 } 237 }
238 editElement().addField(field); 238 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.getType() != 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 RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeAMPMFieldElemen t::create(document, editElement(), m_parameters.locale.timeAMPMLabels()); 247 RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeAMPMFieldElemen t::create(document, editElement(), m_parameters.locale.timeAMPMLabels());
248 editElement().addField(field); 248 editElement().addField(field);
249 if (shouldAMPMFieldDisabled()) { 249 if (shouldAMPMFieldDisabled()) {
(...skipping 25 matching lines...) Expand all
275 editElement().addField(field); 275 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.getType() != DateComponents::Invalid
286 && m_parameters.maximum.type() != DateComponents::Invalid 286 && m_parameters.maximum.getType() != 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 editElement().addField(DateTimeWeekFieldElement::create(document, editEl ement(), range)); 292 editElement().addField(DateTimeWeekFieldElement::create(document, editEl ement(), 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.getType() == 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.getType() == 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 }
(...skipping 14 matching lines...) Expand all
330 330
331 bool DateTimeEditBuilder::shouldAMPMFieldDisabled() const 331 bool DateTimeEditBuilder::shouldAMPMFieldDisabled() const
332 { 332 {
333 return shouldHourFieldDisabled() 333 return shouldHourFieldDisabled()
334 || (m_hour23Range.minimum < 12 && m_hour23Range.maximum < 12 && m_dateVa lue.hour() < 12) 334 || (m_hour23Range.minimum < 12 && m_hour23Range.maximum < 12 && m_dateVa lue.hour() < 12)
335 || (m_hour23Range.minimum >= 12 && m_hour23Range.maximum >= 12 && m_date Value.hour() >= 12); 335 || (m_hour23Range.minimum >= 12 && m_hour23Range.maximum >= 12 && m_date Value.hour() >= 12);
336 } 336 }
337 337
338 bool DateTimeEditBuilder::shouldDayOfMonthFieldDisabled() const 338 bool DateTimeEditBuilder::shouldDayOfMonthFieldDisabled() const
339 { 339 {
340 return m_dayRange.isSingleton() && m_dayRange.minimum == m_dateValue.monthDa y() && m_dateValue.type() != DateComponents::Date; 340 return m_dayRange.isSingleton() && m_dayRange.minimum == m_dateValue.monthDa y() && m_dateValue.getType() != DateComponents::Date;
341 } 341 }
342 342
343 bool DateTimeEditBuilder::shouldHourFieldDisabled() const 343 bool DateTimeEditBuilder::shouldHourFieldDisabled() const
344 { 344 {
345 if (m_hour23Range.isSingleton() && m_hour23Range.minimum == m_dateValue.hour () 345 if (m_hour23Range.isSingleton() && m_hour23Range.minimum == m_dateValue.hour ()
346 && !(shouldMinuteFieldDisabled() && shouldSecondFieldDisabled() && shoul dMillisecondFieldDisabled())) 346 && !(shouldMinuteFieldDisabled() && shouldSecondFieldDisabled() && shoul dMillisecondFieldDisabled()))
347 return true; 347 return true;
348 348
349 if (m_dateValue.type() == DateComponents::Time) 349 if (m_dateValue.getType() == DateComponents::Time)
350 return false; 350 return false;
351 ASSERT(m_dateValue.type() == DateComponents::DateTimeLocal); 351 ASSERT(m_dateValue.getType() == DateComponents::DateTimeLocal);
352 352
353 if (shouldDayOfMonthFieldDisabled()) { 353 if (shouldDayOfMonthFieldDisabled()) {
354 ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear( )); 354 ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear( ));
355 ASSERT(m_parameters.minimum.month() == m_parameters.maximum.month()); 355 ASSERT(m_parameters.minimum.month() == m_parameters.maximum.month());
356 return false; 356 return false;
357 } 357 }
358 358
359 const Decimal decimalMsPerDay(static_cast<int>(msPerDay)); 359 const Decimal decimalMsPerDay(static_cast<int>(msPerDay));
360 Decimal hourPartOfMinimum = (stepRange().stepBase().abs().remainder(decimalM sPerDay) / static_cast<int>(msPerHour)).floor(); 360 Decimal hourPartOfMinimum = (stepRange().stepBase().abs().remainder(decimalM sPerDay) / static_cast<int>(msPerHour)).floor();
361 return hourPartOfMinimum == m_dateValue.hour() && stepRange().step().remaind er(decimalMsPerDay).isZero(); 361 return hourPartOfMinimum == m_dateValue.hour() && stepRange().step().remaind er(decimalMsPerDay).isZero();
(...skipping 23 matching lines...) Expand all
385 if (m_secondRange.isSingleton() && m_secondRange.minimum == m_dateValue.seco nd()) 385 if (m_secondRange.isSingleton() && m_secondRange.minimum == m_dateValue.seco nd())
386 return true; 386 return true;
387 387
388 const Decimal decimalMsPerMinute(static_cast<int>(msPerMinute)); 388 const Decimal decimalMsPerMinute(static_cast<int>(msPerMinute));
389 Decimal secondPartOfMinimum = (stepRange().stepBase().abs().remainder(decima lMsPerMinute) / static_cast<int>(msPerSecond)).floor(); 389 Decimal secondPartOfMinimum = (stepRange().stepBase().abs().remainder(decima lMsPerMinute) / static_cast<int>(msPerSecond)).floor();
390 return secondPartOfMinimum == m_dateValue.second() && stepRange().step().rem ainder(decimalMsPerMinute).isZero(); 390 return secondPartOfMinimum == m_dateValue.second() && stepRange().step().rem ainder(decimalMsPerMinute).isZero();
391 } 391 }
392 392
393 bool DateTimeEditBuilder::shouldYearFieldDisabled() const 393 bool DateTimeEditBuilder::shouldYearFieldDisabled() const
394 { 394 {
395 return m_parameters.minimum.type() != DateComponents::Invalid 395 return m_parameters.minimum.getType() != DateComponents::Invalid
396 && m_parameters.maximum.type() != DateComponents::Invalid 396 && m_parameters.maximum.getType() != 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 RefPtrWillBeRawPtr<HTMLDivElement> element = HTMLDivElement::create(editElem ent().document()); 405 RefPtrWillBeRawPtr<HTMLDivElement> element = HTMLDivElement::create(editElem ent().document());
406 element->setShadowPseudoId(textPseudoId); 406 element->setShadowPseudoId(textPseudoId);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 m_fields[fieldIndex]->setEmptyValue(DateTimeFieldElement::DispatchNoEven t); 764 m_fields[fieldIndex]->setEmptyValue(DateTimeFieldElement::DispatchNoEven t);
765 } 765 }
766 766
767 bool DateTimeEditElement::hasFocusedField() 767 bool DateTimeEditElement::hasFocusedField()
768 { 768 {
769 return focusedFieldIndex() != invalidFieldIndex; 769 return focusedFieldIndex() != invalidFieldIndex;
770 } 770 }
771 771
772 void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date) 772 void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date)
773 { 773 {
774 ASSERT(date.type() == DateComponents::Date); 774 ASSERT(date.getType() == DateComponents::Date);
775 775
776 if (!m_editControlOwner) 776 if (!m_editControlOwner)
777 return; 777 return;
778 778
779 DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState(); 779 DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState();
780 dateTimeFieldsState.setYear(date.fullYear()); 780 dateTimeFieldsState.setYear(date.fullYear());
781 dateTimeFieldsState.setMonth(date.month() + 1); 781 dateTimeFieldsState.setMonth(date.month() + 1);
782 dateTimeFieldsState.setDayOfMonth(date.monthDay()); 782 dateTimeFieldsState.setDayOfMonth(date.monthDay());
783 setValueAsDateTimeFieldsState(dateTimeFieldsState); 783 setValueAsDateTimeFieldsState(dateTimeFieldsState);
784 m_editControlOwner->editControlValueChanged(); 784 m_editControlOwner->editControlValueChanged();
(...skipping 30 matching lines...) Expand all
815 { 815 {
816 DateTimeFieldsState dateTimeFieldsState; 816 DateTimeFieldsState dateTimeFieldsState;
817 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) 817 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex)
818 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); 818 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState);
819 return dateTimeFieldsState; 819 return dateTimeFieldsState;
820 } 820 }
821 821
822 } // namespace blink 822 } // namespace blink
823 823
824 #endif 824 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.cpp ('k') | third_party/WebKit/Source/core/input/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698