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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 String placeholderText = element().strippedPlaceholder(); | 455 String placeholderText = element().strippedPlaceholder(); |
456 if (placeholderText.isEmpty()) { | 456 if (placeholderText.isEmpty()) { |
457 if (placeholder) | 457 if (placeholder) |
458 placeholder->remove(ASSERT_NO_EXCEPTION); | 458 placeholder->remove(ASSERT_NO_EXCEPTION); |
459 return; | 459 return; |
460 } | 460 } |
461 if (!placeholder) { | 461 if (!placeholder) { |
462 RefPtrWillBeRawPtr<HTMLElement> newElement = HTMLDivElement::create(elem ent().document()); | 462 RefPtrWillBeRawPtr<HTMLElement> newElement = HTMLDivElement::create(elem ent().document()); |
463 placeholder = newElement.get(); | 463 placeholder = newElement.get(); |
464 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); | 464 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); |
465 placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlac eholderVisible() ? CSSValueBlock : CSSValueNone, true); | |
esprehn
2015/08/21 10:18:10
Can we just call updatePlaceholderVisibility inste
ramya.v
2015/08/25 10:24:45
updatePlaceholderText is called from inside update
| |
465 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); | 466 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); |
466 Element* container = containerElement(); | 467 Element* container = containerElement(); |
467 Node* previous = container ? container : element().innerEditorElement(); | 468 Node* previous = container ? container : element().innerEditorElement(); |
468 previous->parentNode()->insertBefore(placeholder, previous->nextSibling( )); | 469 previous->parentNode()->insertBefore(placeholder, previous->nextSibling( )); |
469 ASSERT_WITH_SECURITY_IMPLICATION(placeholder->parentNode() == previous-> parentNode()); | 470 ASSERT_WITH_SECURITY_IMPLICATION(placeholder->parentNode() == previous-> parentNode()); |
470 } | 471 } |
471 placeholder->setTextContent(placeholderText); | 472 placeholder->setTextContent(placeholderText); |
472 } | 473 } |
473 | 474 |
474 bool TextFieldInputType::appendFormData(FormDataList& list, bool multipart) cons t | 475 bool TextFieldInputType::appendFormData(FormDataList& list, bool multipart) cons t |
(...skipping 15 matching lines...) Expand all Loading... | |
490 ASSERT(element().layoutObject()); | 491 ASSERT(element().layoutObject()); |
491 | 492 |
492 bool wasChanged = element().wasChangedSinceLastFormControlChangeEvent(); | 493 bool wasChanged = element().wasChangedSinceLastFormControlChangeEvent(); |
493 element().setChangedSinceLastFormControlChangeEvent(true); | 494 element().setChangedSinceLastFormControlChangeEvent(true); |
494 | 495 |
495 // We don't need to call sanitizeUserInputValue() function here because | 496 // We don't need to call sanitizeUserInputValue() function here because |
496 // HTMLInputElement::handleBeforeTextInsertedEvent() has already called | 497 // HTMLInputElement::handleBeforeTextInsertedEvent() has already called |
497 // sanitizeUserInputValue(). | 498 // sanitizeUserInputValue(). |
498 // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextIn sertedEvent. | 499 // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextIn sertedEvent. |
499 element().setValueFromRenderer(sanitizeValue(convertFromVisibleValue(element ().innerEditorValue()))); | 500 element().setValueFromRenderer(sanitizeValue(convertFromVisibleValue(element ().innerEditorValue()))); |
500 element().updatePlaceholderVisibility(false); | 501 element().updatePlaceholderVisibility(); |
501 element().pseudoStateChanged(CSSSelector::PseudoValid); | 502 element().pseudoStateChanged(CSSSelector::PseudoValid); |
502 element().pseudoStateChanged(CSSSelector::PseudoInvalid); | 503 element().pseudoStateChanged(CSSSelector::PseudoInvalid); |
503 | 504 |
504 didSetValueByUserEdit(wasChanged ? ValueChangeStateChanged : ValueChangeStat eNone); | 505 didSetValueByUserEdit(wasChanged ? ValueChangeStateChanged : ValueChangeStat eNone); |
505 } | 506 } |
506 | 507 |
507 void TextFieldInputType::didSetValueByUserEdit(ValueChangeState state) | 508 void TextFieldInputType::didSetValueByUserEdit(ValueChangeState state) |
508 { | 509 { |
509 if (!element().focused()) | 510 if (!element().focused()) |
510 return; | 511 return; |
511 if (ChromeClient* chromeClient = this->chromeClient()) | 512 if (ChromeClient* chromeClient = this->chromeClient()) |
512 chromeClient->didChangeValueInTextField(element()); | 513 chromeClient->didChangeValueInTextField(element()); |
513 } | 514 } |
514 | 515 |
515 void TextFieldInputType::spinButtonStepDown() | 516 void TextFieldInputType::spinButtonStepDown() |
516 { | 517 { |
517 stepUpFromLayoutObject(-1); | 518 stepUpFromLayoutObject(-1); |
518 } | 519 } |
519 | 520 |
520 void TextFieldInputType::spinButtonStepUp() | 521 void TextFieldInputType::spinButtonStepUp() |
521 { | 522 { |
522 stepUpFromLayoutObject(1); | 523 stepUpFromLayoutObject(1); |
523 } | 524 } |
524 | 525 |
525 void TextFieldInputType::updateView() | 526 void TextFieldInputType::updateView() |
526 { | 527 { |
527 if (!element().suggestedValue().isNull()) { | 528 if (!element().suggestedValue().isNull()) { |
528 element().setInnerEditorValue(element().suggestedValue()); | 529 element().setInnerEditorValue(element().suggestedValue()); |
529 element().updatePlaceholderVisibility(false); | 530 element().updatePlaceholderVisibility(); |
530 } else if (element().needsToUpdateViewValue()) { | 531 } else if (element().needsToUpdateViewValue()) { |
531 // Update the view only if needsToUpdateViewValue is true. It protects | 532 // Update the view only if needsToUpdateViewValue is true. It protects |
532 // an unacceptable view value from being overwritten with the DOM value. | 533 // an unacceptable view value from being overwritten with the DOM value. |
533 // | 534 // |
534 // e.g. <input type=number> has a view value "abc", and input.max is | 535 // e.g. <input type=number> has a view value "abc", and input.max is |
535 // updated. In this case, updateView() is called but we should not | 536 // updated. In this case, updateView() is called but we should not |
536 // update the view value. | 537 // update the view value. |
537 element().setInnerEditorValue(visibleValue()); | 538 element().setInnerEditorValue(visibleValue()); |
538 element().updatePlaceholderVisibility(false); | 539 element().updatePlaceholderVisibility(); |
539 } | 540 } |
540 } | 541 } |
541 | 542 |
542 void TextFieldInputType::focusAndSelectSpinButtonOwner() | 543 void TextFieldInputType::focusAndSelectSpinButtonOwner() |
543 { | 544 { |
544 RefPtrWillBeRawPtr<HTMLInputElement> input(element()); | 545 RefPtrWillBeRawPtr<HTMLInputElement> input(element()); |
545 input->focus(); | 546 input->focus(); |
546 input->select(NotDispatchSelectEvent); | 547 input->select(NotDispatchSelectEvent); |
547 } | 548 } |
548 | 549 |
549 bool TextFieldInputType::shouldSpinButtonRespondToMouseEvents() | 550 bool TextFieldInputType::shouldSpinButtonRespondToMouseEvents() |
550 { | 551 { |
551 return !element().isDisabledOrReadOnly(); | 552 return !element().isDisabledOrReadOnly(); |
552 } | 553 } |
553 | 554 |
554 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() | 555 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() |
555 { | 556 { |
556 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 557 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
557 } | 558 } |
558 | 559 |
559 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) | 560 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) |
560 { | 561 { |
561 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 562 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
562 element().dispatchFormControlChangeEvent(); | 563 element().dispatchFormControlChangeEvent(); |
563 } | 564 } |
564 | 565 |
565 } // namespace blink | 566 } // namespace blink |
OLD | NEW |