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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 m_dateTimeChooser = element().document().frameHost()->chrome().openDateTimeC
hooser(this, parameters); | 57 m_dateTimeChooser = element().document().frameHost()->chrome().openDateTimeC
hooser(this, parameters); |
58 } | 58 } |
59 | 59 |
60 void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree() | 60 void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree() |
61 { | 61 { |
62 DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-t
ime-value", AtomicString::ConstructFromLiteral)); | 62 DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-t
ime-value", AtomicString::ConstructFromLiteral)); |
63 | 63 |
64 RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element().doc
ument()); | 64 RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element().doc
ument()); |
65 valueContainer->setShadowPseudoId(valueContainerPseudo); | 65 valueContainer->setShadowPseudoId(valueContainerPseudo); |
66 element().userAgentShadowRoot()->appendChild(valueContainer.get()); | 66 element().userAgentShadowRoot()->appendChild(valueContainer.get()); |
67 updateAppearance(); | 67 updateView(); |
68 } | 68 } |
69 | 69 |
70 void BaseChooserOnlyDateAndTimeInputType::updateAppearance() | 70 void BaseChooserOnlyDateAndTimeInputType::updateView() |
71 { | 71 { |
72 Node* node = element().userAgentShadowRoot()->firstChild(); | 72 Node* node = element().userAgentShadowRoot()->firstChild(); |
73 if (!node || !node->isHTMLElement()) | 73 if (!node || !node->isHTMLElement()) |
74 return; | 74 return; |
75 String displayValue = visibleValue(); | 75 String displayValue; |
| 76 if (!element().suggestedValue().isNull()) |
| 77 displayValue = element().suggestedValue(); |
| 78 else |
| 79 displayValue = visibleValue(); |
76 if (displayValue.isEmpty()) { | 80 if (displayValue.isEmpty()) { |
77 // Need to put something to keep text baseline. | 81 // Need to put something to keep text baseline. |
78 displayValue = " "; | 82 displayValue = " "; |
79 } | 83 } |
80 toHTMLElement(node)->setInnerText(displayValue, ASSERT_NO_EXCEPTION); | 84 toHTMLElement(node)->setInnerText(displayValue, ASSERT_NO_EXCEPTION); |
81 } | 85 } |
82 | 86 |
83 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool val
ueChanged, TextFieldEventBehavior eventBehavior) | 87 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool val
ueChanged, TextFieldEventBehavior eventBehavior) |
84 { | 88 { |
85 BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior); | 89 BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior); |
86 if (valueChanged) | 90 if (valueChanged) |
87 updateAppearance(); | 91 updateView(); |
88 } | 92 } |
89 | 93 |
90 void BaseChooserOnlyDateAndTimeInputType::closePopupView() | 94 void BaseChooserOnlyDateAndTimeInputType::closePopupView() |
91 { | 95 { |
92 closeDateTimeChooser(); | 96 closeDateTimeChooser(); |
93 } | 97 } |
94 | 98 |
95 void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value) | 99 void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value) |
96 { | 100 { |
97 element().setValue(value, DispatchInputAndChangeEvent); | 101 element().setValue(value, DispatchInputAndChangeEvent); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 137 } |
134 | 138 |
135 void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents) | 139 void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents) |
136 { | 140 { |
137 BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents); | 141 BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents); |
138 BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents); | 142 BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents); |
139 } | 143 } |
140 | 144 |
141 } | 145 } |
142 #endif | 146 #endif |
OLD | NEW |