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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return toClearButtonElement(element()->userAgentShadowRoot()->getElementById
(ShadowElementNames::clearButton())); | 143 return toClearButtonElement(element()->userAgentShadowRoot()->getElementById
(ShadowElementNames::clearButton())); |
144 } | 144 } |
145 | 145 |
146 PickerIndicatorElement* BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorE
lement() const | 146 PickerIndicatorElement* BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorE
lement() const |
147 { | 147 { |
148 return toPickerIndicatorElement(element()->userAgentShadowRoot()->getElement
ById(ShadowElementNames::pickerIndicator())); | 148 return toPickerIndicatorElement(element()->userAgentShadowRoot()->getElement
ById(ShadowElementNames::pickerIndicator())); |
149 } | 149 } |
150 | 150 |
151 inline bool BaseMultipleFieldsDateAndTimeInputType::containsFocusedShadowElement
() const | 151 inline bool BaseMultipleFieldsDateAndTimeInputType::containsFocusedShadowElement
() const |
152 { | 152 { |
153 return element()->userAgentShadowRoot()->contains(element()->document()->foc
usedElement()); | 153 return element()->userAgentShadowRoot()->contains(element()->document().focu
sedElement()); |
154 } | 154 } |
155 | 155 |
156 void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl() | 156 void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl() |
157 { | 157 { |
158 // We don't need to call blur(). This function is called when control | 158 // We don't need to call blur(). This function is called when control |
159 // lost focus. | 159 // lost focus. |
160 | 160 |
161 if (containsFocusedShadowElement()) | 161 if (containsFocusedShadowElement()) |
162 return; | 162 return; |
163 RefPtr<HTMLInputElement> protector(element()); | 163 RefPtr<HTMLInputElement> protector(element()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree() | 323 void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree() |
324 { | 324 { |
325 ASSERT(element()->shadow()); | 325 ASSERT(element()->shadow()); |
326 | 326 |
327 // Element must not have a renderer here, because if it did | 327 // Element must not have a renderer here, because if it did |
328 // DateTimeEditElement::customStyleForRenderer() is called in appendChild() | 328 // DateTimeEditElement::customStyleForRenderer() is called in appendChild() |
329 // before the field wrapper element is created. | 329 // before the field wrapper element is created. |
330 // FIXME: This code should not depend on such craziness. | 330 // FIXME: This code should not depend on such craziness. |
331 ASSERT(!element()->renderer()); | 331 ASSERT(!element()->renderer()); |
332 | 332 |
333 Document* document = element()->document(); | 333 Document& document = element()->document(); |
334 ContainerNode* container = element()->userAgentShadowRoot(); | 334 ContainerNode* container = element()->userAgentShadowRoot(); |
335 | 335 |
336 container->appendChild(DateTimeEditElement::create(document, *this)); | 336 container->appendChild(DateTimeEditElement::create(&document, *this)); |
337 updateInnerTextValue(); | 337 updateInnerTextValue(); |
338 container->appendChild(ClearButtonElement::create(document, *this)); | 338 container->appendChild(ClearButtonElement::create(&document, *this)); |
339 container->appendChild(SpinButtonElement::create(document, *this)); | 339 container->appendChild(SpinButtonElement::create(&document, *this)); |
340 | 340 |
341 bool shouldAddPickerIndicator = false; | 341 bool shouldAddPickerIndicator = false; |
342 if (InputType::themeSupportsDataListUI(this)) | 342 if (InputType::themeSupportsDataListUI(this)) |
343 shouldAddPickerIndicator = true; | 343 shouldAddPickerIndicator = true; |
344 if (RenderTheme::theme().supportsCalendarPicker(formControlType())) { | 344 if (RenderTheme::theme().supportsCalendarPicker(formControlType())) { |
345 shouldAddPickerIndicator = true; | 345 shouldAddPickerIndicator = true; |
346 m_pickerIndicatorIsAlwaysVisible = true; | 346 m_pickerIndicatorIsAlwaysVisible = true; |
347 } | 347 } |
348 if (shouldAddPickerIndicator) { | 348 if (shouldAddPickerIndicator) { |
349 container->appendChild(PickerIndicatorElement::create(document, *this)); | 349 container->appendChild(PickerIndicatorElement::create(&document, *this))
; |
350 m_pickerIndicatorIsVisible = true; | 350 m_pickerIndicatorIsVisible = true; |
351 updatePickerIndicatorVisibility(); | 351 updatePickerIndicatorVisibility(); |
352 } | 352 } |
353 m_didCreateShadowElements = true; | 353 m_didCreateShadowElements = true; |
354 } | 354 } |
355 | 355 |
356 void BaseMultipleFieldsDateAndTimeInputType::destroyShadowSubtree() | 356 void BaseMultipleFieldsDateAndTimeInputType::destroyShadowSubtree() |
357 { | 357 { |
358 ASSERT(!m_isDestroyingShadowSubtree); | 358 ASSERT(!m_isDestroyingShadowSubtree); |
359 m_isDestroyingShadowSubtree = true; | 359 m_isDestroyingShadowSubtree = true; |
(...skipping 14 matching lines...) Expand all Loading... |
374 BaseDateAndTimeInputType::destroyShadowSubtree(); | 374 BaseDateAndTimeInputType::destroyShadowSubtree(); |
375 m_isDestroyingShadowSubtree = false; | 375 m_isDestroyingShadowSubtree = false; |
376 } | 376 } |
377 | 377 |
378 void BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent(Element* oldFocuse
dElement, FocusDirection direction) | 378 void BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent(Element* oldFocuse
dElement, FocusDirection direction) |
379 { | 379 { |
380 DateTimeEditElement* edit = dateTimeEditElement(); | 380 DateTimeEditElement* edit = dateTimeEditElement(); |
381 if (!edit || m_isDestroyingShadowSubtree) | 381 if (!edit || m_isDestroyingShadowSubtree) |
382 return; | 382 return; |
383 if (direction == FocusDirectionBackward) { | 383 if (direction == FocusDirectionBackward) { |
384 if (element()->document()->page()) | 384 if (element()->document().page()) |
385 element()->document()->page()->focusController().advanceFocus(direct
ion); | 385 element()->document().page()->focusController().advanceFocus(directi
on); |
386 } else if (direction == FocusDirectionNone || direction == FocusDirectionMou
se || direction == FocusDirectionPage) { | 386 } else if (direction == FocusDirectionNone || direction == FocusDirectionMou
se || direction == FocusDirectionPage) { |
387 edit->focusByOwner(oldFocusedElement); | 387 edit->focusByOwner(oldFocusedElement); |
388 } else | 388 } else |
389 edit->focusByOwner(); | 389 edit->focusByOwner(); |
390 } | 390 } |
391 | 391 |
392 void BaseMultipleFieldsDateAndTimeInputType::forwardEvent(Event* event) | 392 void BaseMultipleFieldsDateAndTimeInputType::forwardEvent(Event* event) |
393 { | 393 { |
394 if (SpinButtonElement* element = spinButtonElement()) { | 394 if (SpinButtonElement* element = spinButtonElement()) { |
395 element->forwardEvent(event); | 395 element->forwardEvent(event); |
(...skipping 14 matching lines...) Expand all Loading... |
410 } | 410 } |
411 | 411 |
412 void BaseMultipleFieldsDateAndTimeInputType::requiredAttributeChanged() | 412 void BaseMultipleFieldsDateAndTimeInputType::requiredAttributeChanged() |
413 { | 413 { |
414 clearButtonElement()->releaseCapture(); | 414 clearButtonElement()->releaseCapture(); |
415 updateClearButtonVisibility(); | 415 updateClearButtonVisibility(); |
416 } | 416 } |
417 | 417 |
418 void BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* e
vent) | 418 void BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* e
vent) |
419 { | 419 { |
420 Document* document = element()->document(); | |
421 if (m_pickerIndicatorIsVisible | 420 if (m_pickerIndicatorIsVisible |
422 && ((event->keyIdentifier() == "Down" && event->getModifierState("Alt"))
|| (RenderTheme::theme().shouldOpenPickerWithF4Key() && event->keyIdentifier()
== "F4"))) { | 421 && ((event->keyIdentifier() == "Down" && event->getModifierState("Alt"))
|| (RenderTheme::theme().shouldOpenPickerWithF4Key() && event->keyIdentifier()
== "F4"))) { |
423 if (PickerIndicatorElement* element = pickerIndicatorElement()) | 422 if (PickerIndicatorElement* element = pickerIndicatorElement()) |
424 element->openPopup(); | 423 element->openPopup(); |
425 event->setDefaultHandled(); | 424 event->setDefaultHandled(); |
426 } else | 425 } else |
427 forwardEvent(event); | 426 forwardEvent(event); |
428 } | 427 } |
429 | 428 |
430 bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const | 429 bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 599 |
601 if (element()->isRequired() || !dateTimeEditElement()->anyEditableFieldsHave
Values()) | 600 if (element()->isRequired() || !dateTimeEditElement()->anyEditableFieldsHave
Values()) |
602 clearButton->setInlineStyleProperty(CSSPropertyVisibility, CSSValueHidde
n); | 601 clearButton->setInlineStyleProperty(CSSPropertyVisibility, CSSValueHidde
n); |
603 else | 602 else |
604 clearButton->removeInlineStyleProperty(CSSPropertyVisibility); | 603 clearButton->removeInlineStyleProperty(CSSPropertyVisibility); |
605 } | 604 } |
606 | 605 |
607 } // namespace WebCore | 606 } // namespace WebCore |
608 | 607 |
609 #endif | 608 #endif |
OLD | NEW |