| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 bool DateTimeEditBuilder::shouldYearFieldDisabled() const | 393 bool DateTimeEditBuilder::shouldYearFieldDisabled() const |
| 394 { | 394 { |
| 395 return m_parameters.minimum.getType() != DateComponents::Invalid | 395 return m_parameters.minimum.getType() != DateComponents::Invalid |
| 396 && m_parameters.maximum.getType() != 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
")); |
| 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); |
| 407 if (m_parameters.locale.isRTL() && text.length()) { | 407 if (m_parameters.locale.isRTL() && text.length()) { |
| 408 CharDirection dir = direction(text[0]); | 408 CharDirection 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(editElement().document(), String(&
rightToLeftMarkCharacter, 1))); | 410 element->appendChild(Text::create(editElement().document(), String(&
rightToLeftMarkCharacter, 1))); |
| 411 } | 411 } |
| 412 element->appendChild(Text::create(editElement().document(), text)); | 412 element->appendChild(Text::create(editElement().document(), text)); |
| 413 editElement().fieldsWrapperElement()->appendChild(element); | 413 editElement().fieldsWrapperElement()->appendChild(element); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 void DateTimeEditElement::blurByOwner() | 495 void DateTimeEditElement::blurByOwner() |
| 496 { | 496 { |
| 497 if (DateTimeFieldElement* field = focusedField()) | 497 if (DateTimeFieldElement* field = focusedField()) |
| 498 field->blur(); | 498 field->blur(); |
| 499 } | 499 } |
| 500 | 500 |
| 501 PassRefPtrWillBeRawPtr<DateTimeEditElement> DateTimeEditElement::create(Document
& document, EditControlOwner& editControlOwner) | 501 PassRefPtrWillBeRawPtr<DateTimeEditElement> DateTimeEditElement::create(Document
& document, EditControlOwner& editControlOwner) |
| 502 { | 502 { |
| 503 RefPtrWillBeRawPtr<DateTimeEditElement> container = adoptRefWillBeNoop(new D
ateTimeEditElement(document, editControlOwner)); | 503 RefPtrWillBeRawPtr<DateTimeEditElement> container = adoptRefWillBeNoop(new D
ateTimeEditElement(document, editControlOwner)); |
| 504 container->setShadowPseudoId(AtomicString("-webkit-datetime-edit", AtomicStr
ing::ConstructFromLiteral)); | 504 container->setShadowPseudoId(AtomicString("-webkit-datetime-edit")); |
| 505 container->setAttribute(idAttr, ShadowElementNames::dateTimeEdit()); | 505 container->setAttribute(idAttr, ShadowElementNames::dateTimeEdit()); |
| 506 return container.release(); | 506 return container.release(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 PassRefPtr<ComputedStyle> DateTimeEditElement::customStyleForLayoutObject() | 509 PassRefPtr<ComputedStyle> DateTimeEditElement::customStyleForLayoutObject() |
| 510 { | 510 { |
| 511 // FIXME: This is a kind of layout. We might want to introduce new layoutObj
ect. | 511 // FIXME: This is a kind of layout. We might want to introduce new layoutObj
ect. |
| 512 RefPtr<ComputedStyle> originalStyle = originalStyleForLayoutObject(); | 512 RefPtr<ComputedStyle> originalStyle = originalStyleForLayoutObject(); |
| 513 RefPtr<ComputedStyle> style = ComputedStyle::clone(*originalStyle); | 513 RefPtr<ComputedStyle> style = ComputedStyle::clone(*originalStyle); |
| 514 float width = 0; | 514 float width = 0; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 return isReadOnly(); | 661 return isReadOnly(); |
| 662 } | 662 } |
| 663 | 663 |
| 664 bool DateTimeEditElement::isReadOnly() const | 664 bool DateTimeEditElement::isReadOnly() const |
| 665 { | 665 { |
| 666 return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly(
); | 666 return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly(
); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const
DateComponents& dateValue) | 669 void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const
DateComponents& dateValue) |
| 670 { | 670 { |
| 671 DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-
edit-fields-wrapper", AtomicString::ConstructFromLiteral)); | 671 DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-
edit-fields-wrapper")); |
| 672 if (!hasChildren()) { | 672 if (!hasChildren()) { |
| 673 RefPtrWillBeRawPtr<HTMLDivElement> element = HTMLDivElement::create(docu
ment()); | 673 RefPtrWillBeRawPtr<HTMLDivElement> element = HTMLDivElement::create(docu
ment()); |
| 674 element->setShadowPseudoId(fieldsWrapperPseudoId); | 674 element->setShadowPseudoId(fieldsWrapperPseudoId); |
| 675 appendChild(element.get()); | 675 appendChild(element.get()); |
| 676 } | 676 } |
| 677 Element* fieldsWrapper = fieldsWrapperElement(); | 677 Element* fieldsWrapper = fieldsWrapperElement(); |
| 678 | 678 |
| 679 size_t focusedFieldIndex = this->focusedFieldIndex(); | 679 size_t focusedFieldIndex = this->focusedFieldIndex(); |
| 680 DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex); | 680 DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex); |
| 681 const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseud
oId() : nullAtom; | 681 const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseud
oId() : nullAtom; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |