OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 m_dateTimeEditElement->blurByOwner(); | 188 m_dateTimeEditElement->blurByOwner(); |
189 } | 189 } |
190 | 190 |
191 RenderObject* BaseMultipleFieldsDateAndTimeInputType::createRenderer(RenderArena
* arena, RenderStyle* style) const | 191 RenderObject* BaseMultipleFieldsDateAndTimeInputType::createRenderer(RenderArena
* arena, RenderStyle* style) const |
192 { | 192 { |
193 return InputType::createRenderer(arena, style); | 193 return InputType::createRenderer(arena, style); |
194 } | 194 } |
195 | 195 |
196 void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree() | 196 void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree() |
197 { | 197 { |
198 DEFINE_STATIC_LOCAL(AtomicString, dateAndTimeInputContainerPseudoId, ("-webk
it-date-and-time-container", AtomicString::ConstructFromLiteral)); | |
199 | |
200 ASSERT(element()->shadow()); | 198 ASSERT(element()->shadow()); |
201 | 199 |
202 Document* document = element()->document(); | 200 Document* document = element()->document(); |
203 RefPtr<HTMLDivElement> container = HTMLDivElement::create(document); | 201 ContainerNode* container = element()->userAgentShadowRoot(); |
204 element()->userAgentShadowRoot()->appendChild(container); | |
205 container->setPseudo(dateAndTimeInputContainerPseudoId); | |
206 | 202 |
207 RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(
document, *this)); | 203 RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(
document, *this)); |
208 m_dateTimeEditElement = dateTimeEditElement.get(); | 204 m_dateTimeEditElement = dateTimeEditElement.get(); |
209 container->appendChild(m_dateTimeEditElement); | 205 container->appendChild(m_dateTimeEditElement); |
210 updateInnerTextValue(); | 206 updateInnerTextValue(); |
211 | 207 |
212 RefPtr<SpinButtonElement> spinButton = SpinButtonElement::create(document, *
this); | 208 RefPtr<SpinButtonElement> spinButton = SpinButtonElement::create(document, *
this); |
213 m_spinButtonElement = spinButton.get(); | 209 m_spinButtonElement = spinButton.get(); |
214 container->appendChild(spinButton); | 210 container->appendChild(spinButton); |
215 | 211 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 339 |
344 void BaseMultipleFieldsDateAndTimeInputType::setValue(const String& sanitizedVal
ue, bool valueChanged, TextFieldEventBehavior eventBehavior) | 340 void BaseMultipleFieldsDateAndTimeInputType::setValue(const String& sanitizedVal
ue, bool valueChanged, TextFieldEventBehavior eventBehavior) |
345 { | 341 { |
346 InputType::setValue(sanitizedValue, valueChanged, eventBehavior); | 342 InputType::setValue(sanitizedValue, valueChanged, eventBehavior); |
347 if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_
dateTimeEditElement->anyEditableFieldsHaveValues())) { | 343 if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_
dateTimeEditElement->anyEditableFieldsHaveValues())) { |
348 updateInnerTextValue(); | 344 updateInnerTextValue(); |
349 element()->setNeedsValidityCheck(); | 345 element()->setNeedsValidityCheck(); |
350 } | 346 } |
351 } | 347 } |
352 | 348 |
| 349 bool BaseMultipleFieldsDateAndTimeInputType::shouldApplyLocaleDirection() const |
| 350 { |
| 351 return true; |
| 352 } |
| 353 |
353 bool BaseMultipleFieldsDateAndTimeInputType::shouldUseInputMethod() const | 354 bool BaseMultipleFieldsDateAndTimeInputType::shouldUseInputMethod() const |
354 { | 355 { |
355 return false; | 356 return false; |
356 } | 357 } |
357 | 358 |
358 void BaseMultipleFieldsDateAndTimeInputType::stepAttributeChanged() | 359 void BaseMultipleFieldsDateAndTimeInputType::stepAttributeChanged() |
359 { | 360 { |
360 updateInnerTextValue(); | 361 updateInnerTextValue(); |
361 } | 362 } |
362 | 363 |
363 void BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue() | 364 void BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue() |
364 { | 365 { |
365 if (!m_dateTimeEditElement) | 366 if (!m_dateTimeEditElement) |
366 return; | 367 return; |
367 | 368 |
368 AtomicString direction = element()->locale().isRTL() ? AtomicString("rtl", A
tomicString::ConstructFromLiteral) : AtomicString("ltr", AtomicString::Construct
FromLiteral); | |
369 if (Element* container = ElementTraversal::firstWithin(element()->userAgentS
hadowRoot())) | |
370 container->setAttribute(HTMLNames::dirAttr, direction); | |
371 | |
372 DateTimeEditElement::LayoutParameters layoutParameters(element()->locale(),
createStepRange(AnyIsDefaultStep)); | 369 DateTimeEditElement::LayoutParameters layoutParameters(element()->locale(),
createStepRange(AnyIsDefaultStep)); |
373 | 370 |
374 DateComponents date; | 371 DateComponents date; |
375 const bool hasValue = parseToDateComponents(element()->value(), &date); | 372 const bool hasValue = parseToDateComponents(element()->value(), &date); |
376 if (!hasValue) | 373 if (!hasValue) |
377 setMillisecondToDateComponents(layoutParameters.stepRange.minimum().toDo
uble(), &date); | 374 setMillisecondToDateComponents(layoutParameters.stepRange.minimum().toDo
uble(), &date); |
378 | 375 |
379 setupLayoutParameters(layoutParameters, date); | 376 setupLayoutParameters(layoutParameters, date); |
380 | 377 |
381 if (hasValue) | 378 if (hasValue) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 { | 438 { |
442 StepRange stepRange = createStepRange(AnyIsDefaultStep); | 439 StepRange stepRange = createStepRange(AnyIsDefaultStep); |
443 return date.second() || date.millisecond() | 440 return date.second() || date.millisecond() |
444 || !stepRange.minimum().remainder(static_cast<int>(msPerMinute)).isZero(
) | 441 || !stepRange.minimum().remainder(static_cast<int>(msPerMinute)).isZero(
) |
445 || !stepRange.step().remainder(static_cast<int>(msPerMinute)).isZero(); | 442 || !stepRange.step().remainder(static_cast<int>(msPerMinute)).isZero(); |
446 } | 443 } |
447 | 444 |
448 } // namespace WebCore | 445 } // namespace WebCore |
449 | 446 |
450 #endif | 447 #endif |
OLD | NEW |