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

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

Issue 2259173002: Fix style errors in core/html/shadow/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 341
342 bool DateTimeEditBuilder::shouldHourFieldDisabled() const 342 bool DateTimeEditBuilder::shouldHourFieldDisabled() const
343 { 343 {
344 if (m_hour23Range.isSingleton() && m_hour23Range.minimum == m_dateValue.hour () 344 if (m_hour23Range.isSingleton() && m_hour23Range.minimum == m_dateValue.hour ()
345 && !(shouldMinuteFieldDisabled() && shouldSecondFieldDisabled() && shoul dMillisecondFieldDisabled())) 345 && !(shouldMinuteFieldDisabled() && shouldSecondFieldDisabled() && shoul dMillisecondFieldDisabled()))
346 return true; 346 return true;
347 347
348 if (m_dateValue.getType() == DateComponents::Time) 348 if (m_dateValue.getType() == DateComponents::Time)
349 return false; 349 return false;
350 ASSERT(m_dateValue.getType() == DateComponents::DateTimeLocal); 350 DCHECK_EQ(m_dateValue.getType(), DateComponents::DateTimeLocal);
351 351
352 if (shouldDayOfMonthFieldDisabled()) { 352 if (shouldDayOfMonthFieldDisabled()) {
353 ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear( )); 353 DCHECK_EQ(m_parameters.minimum.fullYear(), m_parameters.maximum.fullYear ());
354 ASSERT(m_parameters.minimum.month() == m_parameters.maximum.month()); 354 DCHECK_EQ(m_parameters.minimum.month(), m_parameters.maximum.month());
355 return false; 355 return false;
356 } 356 }
357 357
358 const Decimal decimalMsPerDay(static_cast<int>(msPerDay)); 358 const Decimal decimalMsPerDay(static_cast<int>(msPerDay));
359 Decimal hourPartOfMinimum = (stepRange().stepBase().abs().remainder(decimalM sPerDay) / static_cast<int>(msPerHour)).floor(); 359 Decimal hourPartOfMinimum = (stepRange().stepBase().abs().remainder(decimalM sPerDay) / static_cast<int>(msPerHour)).floor();
360 return hourPartOfMinimum == m_dateValue.hour() && stepRange().step().remaind er(decimalMsPerDay).isZero(); 360 return hourPartOfMinimum == m_dateValue.hour() && stepRange().step().remaind er(decimalMsPerDay).isZero();
361 } 361 }
362 362
363 bool DateTimeEditBuilder::shouldMillisecondFieldDisabled() const 363 bool DateTimeEditBuilder::shouldMillisecondFieldDisabled() const
364 { 364 {
(...skipping 28 matching lines...) Expand all
393 { 393 {
394 return m_parameters.minimum.getType() != DateComponents::Invalid 394 return m_parameters.minimum.getType() != DateComponents::Invalid
395 && m_parameters.maximum.getType() != DateComponents::Invalid 395 && m_parameters.maximum.getType() != DateComponents::Invalid
396 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear() 396 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear()
397 && m_parameters.minimum.fullYear() == m_dateValue.fullYear(); 397 && m_parameters.minimum.fullYear() == m_dateValue.fullYear();
398 } 398 }
399 399
400 void DateTimeEditBuilder::visitLiteral(const String& text) 400 void DateTimeEditBuilder::visitLiteral(const String& text)
401 { 401 {
402 DEFINE_STATIC_LOCAL(AtomicString, textPseudoId, ("-webkit-datetime-edit-text ")); 402 DEFINE_STATIC_LOCAL(AtomicString, textPseudoId, ("-webkit-datetime-edit-text "));
403 ASSERT(text.length()); 403 DCHECK_GT(text.length(), 0u);
404 HTMLDivElement* element = HTMLDivElement::create(editElement().document()); 404 HTMLDivElement* element = HTMLDivElement::create(editElement().document());
405 element->setShadowPseudoId(textPseudoId); 405 element->setShadowPseudoId(textPseudoId);
406 if (m_parameters.locale.isRTL() && text.length()) { 406 if (m_parameters.locale.isRTL() && text.length()) {
407 CharDirection dir = direction(text[0]); 407 CharDirection dir = direction(text[0]);
408 if (dir == SegmentSeparator || dir == WhiteSpaceNeutral || dir == OtherN eutral) 408 if (dir == SegmentSeparator || dir == WhiteSpaceNeutral || dir == OtherN eutral)
409 element->appendChild(Text::create(editElement().document(), String(& rightToLeftMarkCharacter, 1))); 409 element->appendChild(Text::create(editElement().document(), String(& rightToLeftMarkCharacter, 1)));
410 } 410 }
411 element->appendChild(Text::create(editElement().document(), text)); 411 element->appendChild(Text::create(editElement().document(), text));
412 editElement().fieldsWrapperElement()->appendChild(element); 412 editElement().fieldsWrapperElement()->appendChild(element);
413 } 413 }
414 414
415 DateTimeEditElement& DateTimeEditBuilder::editElement() const 415 DateTimeEditElement& DateTimeEditBuilder::editElement() const
416 { 416 {
417 return *m_editElement; 417 return *m_editElement;
418 } 418 }
419 419
420 DateTimeNumericFieldElement::Step DateTimeEditBuilder::createStep(double msPerFi eldUnit, double msPerFieldSize) const 420 DateTimeNumericFieldElement::Step DateTimeEditBuilder::createStep(double msPerFi eldUnit, double msPerFieldSize) const
421 { 421 {
422 const Decimal msPerFieldUnitDecimal(static_cast<int>(msPerFieldUnit)); 422 const Decimal msPerFieldUnitDecimal(static_cast<int>(msPerFieldUnit));
423 const Decimal msPerFieldSizeDecimal(static_cast<int>(msPerFieldSize)); 423 const Decimal msPerFieldSizeDecimal(static_cast<int>(msPerFieldSize));
424 Decimal stepMilliseconds = stepRange().step(); 424 Decimal stepMilliseconds = stepRange().step();
425 ASSERT(!msPerFieldUnitDecimal.isZero()); 425 DCHECK(!msPerFieldUnitDecimal.isZero());
yosin_UTC9 2016/08/19 08:01:35 OPTIONAL: It seems we want to have |operator<<| fo
426 ASSERT(!msPerFieldSizeDecimal.isZero()); 426 DCHECK(!msPerFieldSizeDecimal.isZero());
427 ASSERT(!stepMilliseconds.isZero()); 427 DCHECK(!stepMilliseconds.isZero());
428 428
429 DateTimeNumericFieldElement::Step step(1, 0); 429 DateTimeNumericFieldElement::Step step(1, 0);
430 430
431 if (stepMilliseconds.remainder(msPerFieldSizeDecimal).isZero()) 431 if (stepMilliseconds.remainder(msPerFieldSizeDecimal).isZero())
432 stepMilliseconds = msPerFieldSizeDecimal; 432 stepMilliseconds = msPerFieldSizeDecimal;
433 433
434 if (msPerFieldSizeDecimal.remainder(stepMilliseconds).isZero() && stepMillis econds.remainder(msPerFieldUnitDecimal).isZero()) { 434 if (msPerFieldSizeDecimal.remainder(stepMilliseconds).isZero() && stepMillis econds.remainder(msPerFieldUnitDecimal).isZero()) {
435 step.step = static_cast<int>((stepMilliseconds / msPerFieldUnitDecimal). toDouble()); 435 step.step = static_cast<int>((stepMilliseconds / msPerFieldUnitDecimal). toDouble());
436 step.stepBase = static_cast<int>((stepRange().stepBase() / msPerFieldUni tDecimal).floor().remainder(msPerFieldSizeDecimal / msPerFieldUnitDecimal).toDou ble()); 436 step.stepBase = static_cast<int>((stepRange().stepBase() / msPerFieldUni tDecimal).floor().remainder(msPerFieldSizeDecimal / msPerFieldUnitDecimal).toDou ble());
437 } 437 }
(...skipping 19 matching lines...) Expand all
457 457
458 DEFINE_TRACE(DateTimeEditElement) 458 DEFINE_TRACE(DateTimeEditElement)
459 { 459 {
460 visitor->trace(m_fields); 460 visitor->trace(m_fields);
461 visitor->trace(m_editControlOwner); 461 visitor->trace(m_editControlOwner);
462 HTMLDivElement::trace(visitor); 462 HTMLDivElement::trace(visitor);
463 } 463 }
464 464
465 inline Element* DateTimeEditElement::fieldsWrapperElement() const 465 inline Element* DateTimeEditElement::fieldsWrapperElement() const
466 { 466 {
467 ASSERT(firstChild()); 467 DCHECK(firstChild());
468 return toElement(firstChild()); 468 return toElement(firstChild());
469 } 469 }
470 470
471 void DateTimeEditElement::addField(DateTimeFieldElement* field) 471 void DateTimeEditElement::addField(DateTimeFieldElement* field)
472 { 472 {
473 if (m_fields.size() >= maximumNumberOfFields) 473 if (m_fields.size() >= maximumNumberOfFields)
474 return; 474 return;
475 m_fields.append(field); 475 m_fields.append(field);
476 fieldsWrapperElement()->appendChild(field); 476 fieldsWrapperElement()->appendChild(field);
477 } 477 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 m_fields[fieldIndex]->setEmptyValue(DateTimeFieldElement::DispatchNoEven t); 757 m_fields[fieldIndex]->setEmptyValue(DateTimeFieldElement::DispatchNoEven t);
758 } 758 }
759 759
760 bool DateTimeEditElement::hasFocusedField() 760 bool DateTimeEditElement::hasFocusedField()
761 { 761 {
762 return focusedFieldIndex() != invalidFieldIndex; 762 return focusedFieldIndex() != invalidFieldIndex;
763 } 763 }
764 764
765 void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date) 765 void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date)
766 { 766 {
767 ASSERT(date.getType() == DateComponents::Date); 767 DCHECK_EQ(date.getType(), DateComponents::Date);
768 768
769 if (!m_editControlOwner) 769 if (!m_editControlOwner)
770 return; 770 return;
771 771
772 DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState(); 772 DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState();
773 dateTimeFieldsState.setYear(date.fullYear()); 773 dateTimeFieldsState.setYear(date.fullYear());
774 dateTimeFieldsState.setMonth(date.month() + 1); 774 dateTimeFieldsState.setMonth(date.month() + 1);
775 dateTimeFieldsState.setDayOfMonth(date.monthDay()); 775 dateTimeFieldsState.setDayOfMonth(date.monthDay());
776 setValueAsDateTimeFieldsState(dateTimeFieldsState); 776 setValueAsDateTimeFieldsState(dateTimeFieldsState);
777 m_editControlOwner->editControlValueChanged(); 777 m_editControlOwner->editControlValueChanged();
(...skipping 28 matching lines...) Expand all
806 806
807 DateTimeFieldsState DateTimeEditElement::valueAsDateTimeFieldsState() const 807 DateTimeFieldsState DateTimeEditElement::valueAsDateTimeFieldsState() const
808 { 808 {
809 DateTimeFieldsState dateTimeFieldsState; 809 DateTimeFieldsState dateTimeFieldsState;
810 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) 810 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex)
811 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); 811 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState);
812 return dateTimeFieldsState; 812 return dateTimeFieldsState;
813 } 813 }
814 814
815 } // namespace blink 815 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698