OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 bool willRespondToMouseClickEvents() override | 94 bool willRespondToMouseClickEvents() override |
95 { | 95 { |
96 return hostInput() && !hostInput()->isDisabledOrReadOnly() && document()
.isActive(); | 96 return hostInput() && !hostInput()->isDisabledOrReadOnly() && document()
.isActive(); |
97 } | 97 } |
98 | 98 |
99 public: | 99 public: |
100 static PassRefPtrWillBeRawPtr<DataListIndicatorElement> create(Document& doc
ument) | 100 static PassRefPtrWillBeRawPtr<DataListIndicatorElement> create(Document& doc
ument) |
101 { | 101 { |
102 RefPtrWillBeRawPtr<DataListIndicatorElement> element = adoptRefWillBeNoo
p(new DataListIndicatorElement(document)); | 102 RefPtrWillBeRawPtr<DataListIndicatorElement> element = adoptRefWillBeNoo
p(new DataListIndicatorElement(document)); |
103 element->setShadowPseudoId(AtomicString("-webkit-calendar-picker-indicat
or", AtomicString::ConstructFromLiteral)); | 103 element->setShadowPseudoId(AtomicString("-webkit-calendar-picker-indicat
or")); |
104 element->setAttribute(idAttr, ShadowElementNames::pickerIndicator()); | 104 element->setAttribute(idAttr, ShadowElementNames::pickerIndicator()); |
105 return element.release(); | 105 return element.release(); |
106 } | 106 } |
107 | 107 |
108 }; | 108 }; |
109 | 109 |
110 TextFieldInputType::TextFieldInputType(HTMLInputElement& element) | 110 TextFieldInputType::TextFieldInputType(HTMLInputElement& element) |
111 : InputType(element) | 111 : InputType(element) |
112 { | 112 { |
113 } | 113 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 bool shouldHaveDataListIndicator = element().hasValidDataListOptions(); | 287 bool shouldHaveDataListIndicator = element().hasValidDataListOptions(); |
288 bool createsContainer = shouldHaveSpinButton || shouldHaveDataListIndicator
|| needsContainer(); | 288 bool createsContainer = shouldHaveSpinButton || shouldHaveDataListIndicator
|| needsContainer(); |
289 | 289 |
290 RefPtrWillBeRawPtr<TextControlInnerEditorElement> innerEditor = TextControlI
nnerEditorElement::create(document); | 290 RefPtrWillBeRawPtr<TextControlInnerEditorElement> innerEditor = TextControlI
nnerEditorElement::create(document); |
291 if (!createsContainer) { | 291 if (!createsContainer) { |
292 shadowRoot->appendChild(innerEditor.release()); | 292 shadowRoot->appendChild(innerEditor.release()); |
293 return; | 293 return; |
294 } | 294 } |
295 | 295 |
296 RefPtrWillBeRawPtr<TextControlInnerContainer> container = TextControlInnerCo
ntainer::create(document); | 296 RefPtrWillBeRawPtr<TextControlInnerContainer> container = TextControlInnerCo
ntainer::create(document); |
297 container->setShadowPseudoId(AtomicString("-webkit-textfield-decoration-cont
ainer", AtomicString::ConstructFromLiteral)); | 297 container->setShadowPseudoId(AtomicString("-webkit-textfield-decoration-cont
ainer")); |
298 shadowRoot->appendChild(container); | 298 shadowRoot->appendChild(container); |
299 | 299 |
300 RefPtrWillBeRawPtr<EditingViewPortElement> editingViewPort = EditingViewPort
Element::create(document); | 300 RefPtrWillBeRawPtr<EditingViewPortElement> editingViewPort = EditingViewPort
Element::create(document); |
301 editingViewPort->appendChild(innerEditor.release()); | 301 editingViewPort->appendChild(innerEditor.release()); |
302 container->appendChild(editingViewPort.release()); | 302 container->appendChild(editingViewPort.release()); |
303 | 303 |
304 if (shouldHaveDataListIndicator) | 304 if (shouldHaveDataListIndicator) |
305 container->appendChild(DataListIndicatorElement::create(document)); | 305 container->appendChild(DataListIndicatorElement::create(document)); |
306 // FIXME: Because of a special handling for a spin button in | 306 // FIXME: Because of a special handling for a spin button in |
307 // LayoutTextControlSingleLine, we need to put it to the last position. It's | 307 // LayoutTextControlSingleLine, we need to put it to the last position. It's |
(...skipping 28 matching lines...) Expand all Loading... |
336 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 336 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
337 if (willHavePickerIndicator) { | 337 if (willHavePickerIndicator) { |
338 Document& document = element().document(); | 338 Document& document = element().document(); |
339 if (Element* container = containerElement()) { | 339 if (Element* container = containerElement()) { |
340 container->insertBefore(DataListIndicatorElement::create(document),
spinButtonElement()); | 340 container->insertBefore(DataListIndicatorElement::create(document),
spinButtonElement()); |
341 } else { | 341 } else { |
342 // FIXME: The following code is similar to createShadowSubtree(), | 342 // FIXME: The following code is similar to createShadowSubtree(), |
343 // but they are different. We should simplify the code by making | 343 // but they are different. We should simplify the code by making |
344 // containerElement mandatory. | 344 // containerElement mandatory. |
345 RefPtrWillBeRawPtr<Element> rpContainer = TextControlInnerContainer:
:create(document); | 345 RefPtrWillBeRawPtr<Element> rpContainer = TextControlInnerContainer:
:create(document); |
346 rpContainer->setShadowPseudoId(AtomicString("-webkit-textfield-decor
ation-container", AtomicString::ConstructFromLiteral)); | 346 rpContainer->setShadowPseudoId(AtomicString("-webkit-textfield-decor
ation-container")); |
347 RefPtrWillBeRawPtr<Element> innerEditor = element().innerEditorEleme
nt(); | 347 RefPtrWillBeRawPtr<Element> innerEditor = element().innerEditorEleme
nt(); |
348 innerEditor->parentNode()->replaceChild(rpContainer.get(), innerEdit
or.get()); | 348 innerEditor->parentNode()->replaceChild(rpContainer.get(), innerEdit
or.get()); |
349 RefPtrWillBeRawPtr<Element> editingViewPort = EditingViewPortElement
::create(document); | 349 RefPtrWillBeRawPtr<Element> editingViewPort = EditingViewPortElement
::create(document); |
350 editingViewPort->appendChild(innerEditor.release()); | 350 editingViewPort->appendChild(innerEditor.release()); |
351 rpContainer->appendChild(editingViewPort.release()); | 351 rpContainer->appendChild(editingViewPort.release()); |
352 rpContainer->appendChild(DataListIndicatorElement::create(document))
; | 352 rpContainer->appendChild(DataListIndicatorElement::create(document))
; |
353 if (element().document().focusedElement() == element()) | 353 if (element().document().focusedElement() == element()) |
354 element().updateFocusAppearance(SelectionBehaviorOnFocus::Restor
e); | 354 element().updateFocusAppearance(SelectionBehaviorOnFocus::Restor
e); |
355 } | 355 } |
356 } else { | 356 } else { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 HTMLElement* placeholder = element().placeholderElement(); | 452 HTMLElement* placeholder = element().placeholderElement(); |
453 String placeholderText = element().strippedPlaceholder(); | 453 String placeholderText = element().strippedPlaceholder(); |
454 if (placeholderText.isEmpty()) { | 454 if (placeholderText.isEmpty()) { |
455 if (placeholder) | 455 if (placeholder) |
456 placeholder->remove(ASSERT_NO_EXCEPTION); | 456 placeholder->remove(ASSERT_NO_EXCEPTION); |
457 return; | 457 return; |
458 } | 458 } |
459 if (!placeholder) { | 459 if (!placeholder) { |
460 RefPtrWillBeRawPtr<HTMLElement> newElement = HTMLDivElement::create(elem
ent().document()); | 460 RefPtrWillBeRawPtr<HTMLElement> newElement = HTMLDivElement::create(elem
ent().document()); |
461 placeholder = newElement.get(); | 461 placeholder = newElement.get(); |
462 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder",
AtomicString::ConstructFromLiteral)); | 462 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder")
); |
463 placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlac
eholderVisible() ? CSSValueBlock : CSSValueNone, true); | 463 placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlac
eholderVisible() ? CSSValueBlock : CSSValueNone, true); |
464 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); | 464 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); |
465 Element* container = containerElement(); | 465 Element* container = containerElement(); |
466 Node* previous = container ? container : element().innerEditorElement(); | 466 Node* previous = container ? container : element().innerEditorElement(); |
467 previous->parentNode()->insertBefore(placeholder, previous); | 467 previous->parentNode()->insertBefore(placeholder, previous); |
468 ASSERT_WITH_SECURITY_IMPLICATION(placeholder->parentNode() == previous->
parentNode()); | 468 ASSERT_WITH_SECURITY_IMPLICATION(placeholder->parentNode() == previous->
parentNode()); |
469 } | 469 } |
470 placeholder->setTextContent(placeholderText); | 470 placeholder->setTextContent(placeholderText); |
471 } | 471 } |
472 | 472 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 548 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
549 } | 549 } |
550 | 550 |
551 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve
ntDispatch eventDispatch) | 551 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve
ntDispatch eventDispatch) |
552 { | 552 { |
553 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 553 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
554 element().dispatchFormControlChangeEvent(); | 554 element().dispatchFormControlChangeEvent(); |
555 } | 555 } |
556 | 556 |
557 } // namespace blink | 557 } // namespace blink |
OLD | NEW |