Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: Source/core/html/HTMLInputElement.cpp

Issue 23458005: Add HTMLInputType::m_inputTypeView. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLInputElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 , m_autocomplete(Uninitialized) 111 , m_autocomplete(Uninitialized)
112 , m_isAutofilled(false) 112 , m_isAutofilled(false)
113 , m_hasNonEmptyList(false) 113 , m_hasNonEmptyList(false)
114 , m_stateRestored(false) 114 , m_stateRestored(false)
115 , m_parsingInProgress(createdByParser) 115 , m_parsingInProgress(createdByParser)
116 , m_valueAttributeWasUpdatedAfterParsing(false) 116 , m_valueAttributeWasUpdatedAfterParsing(false)
117 , m_wasModifiedByUser(false) 117 , m_wasModifiedByUser(false)
118 , m_canReceiveDroppedFiles(false) 118 , m_canReceiveDroppedFiles(false)
119 , m_hasTouchEventHandler(false) 119 , m_hasTouchEventHandler(false)
120 , m_inputType(InputType::createText(this)) 120 , m_inputType(InputType::createText(this))
121 , m_inputTypeView(m_inputType)
121 { 122 {
122 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag)); 123 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
123 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 124 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
124 setHasCustomStyleCallbacks(); 125 setHasCustomStyleCallbacks();
125 #endif 126 #endif
126 ScriptWrappable::init(this); 127 ScriptWrappable::init(this);
127 } 128 }
128 129
129 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagNa me, Document* document, HTMLFormElement* form, bool createdByParser) 130 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagNa me, Document* document, HTMLFormElement* form, bool createdByParser)
130 { 131 {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 m_inputType->stepUp(n, es); 315 m_inputType->stepUp(n, es);
315 } 316 }
316 317
317 void HTMLInputElement::stepDown(int n, ExceptionState& es) 318 void HTMLInputElement::stepDown(int n, ExceptionState& es)
318 { 319 {
319 m_inputType->stepUp(-n, es); 320 m_inputType->stepUp(-n, es);
320 } 321 }
321 322
322 void HTMLInputElement::blur() 323 void HTMLInputElement::blur()
323 { 324 {
324 m_inputType->blur(); 325 m_inputTypeView->blur();
325 } 326 }
326 327
327 void HTMLInputElement::defaultBlur() 328 void HTMLInputElement::defaultBlur()
328 { 329 {
329 HTMLTextFormControlElement::blur(); 330 HTMLTextFormControlElement::blur();
330 } 331 }
331 332
332 bool HTMLInputElement::hasCustomFocusLogic() const 333 bool HTMLInputElement::hasCustomFocusLogic() const
333 { 334 {
334 return m_inputType->hasCustomFocusLogic(); 335 return m_inputTypeView->hasCustomFocusLogic();
335 } 336 }
336 337
337 bool HTMLInputElement::isKeyboardFocusable() const 338 bool HTMLInputElement::isKeyboardFocusable() const
338 { 339 {
339 return m_inputType->isKeyboardFocusable(); 340 return m_inputType->isKeyboardFocusable();
340 } 341 }
341 342
342 bool HTMLInputElement::shouldShowFocusRingOnMouseFocus() const 343 bool HTMLInputElement::shouldShowFocusRingOnMouseFocus() const
343 { 344 {
344 return m_inputType->shouldShowFocusRingOnMouseFocus(); 345 return m_inputType->shouldShowFocusRingOnMouseFocus();
(...skipping 30 matching lines...) Expand all
375 frame->editor().textFieldDidEndEditing(this); 376 frame->editor().textFieldDidEndEditing(this);
376 } 377 }
377 378
378 bool HTMLInputElement::shouldUseInputMethod() 379 bool HTMLInputElement::shouldUseInputMethod()
379 { 380 {
380 return m_inputType->shouldUseInputMethod(); 381 return m_inputType->shouldUseInputMethod();
381 } 382 }
382 383
383 void HTMLInputElement::handleFocusEvent(Element* oldFocusedElement, FocusDirecti on direction) 384 void HTMLInputElement::handleFocusEvent(Element* oldFocusedElement, FocusDirecti on direction)
384 { 385 {
385 m_inputType->handleFocusEvent(oldFocusedElement, direction); 386 m_inputTypeView->handleFocusEvent(oldFocusedElement, direction);
386 m_inputType->enableSecureTextInput(); 387 m_inputType->enableSecureTextInput();
387 } 388 }
388 389
389 void HTMLInputElement::handleBlurEvent() 390 void HTMLInputElement::handleBlurEvent()
390 { 391 {
391 m_inputType->disableSecureTextInput(); 392 m_inputType->disableSecureTextInput();
392 m_inputType->handleBlurEvent(); 393 m_inputTypeView->handleBlurEvent();
393 } 394 }
394 395
395 void HTMLInputElement::setType(const String& type) 396 void HTMLInputElement::setType(const String& type)
396 { 397 {
397 // FIXME: This should just call setAttribute. No reason to handle the empty string specially. 398 // FIXME: This should just call setAttribute. No reason to handle the empty string specially.
398 // We should write a test case to show that setting to the empty string does not remove the 399 // We should write a test case to show that setting to the empty string does not remove the
399 // attribute in other browsers and then fix this. Note that setting to null *does* remove 400 // attribute in other browsers and then fix this. Note that setting to null *does* remove
400 // the attribute and setAttribute implements that. 401 // the attribute and setAttribute implements that.
401 if (type.isEmpty()) 402 if (type.isEmpty())
402 removeAttribute(typeAttr); 403 removeAttribute(typeAttr);
(...skipping 22 matching lines...) Expand all
425 bool didStoreValue = m_inputType->storesValueSeparateFromAttribute(); 426 bool didStoreValue = m_inputType->storesValueSeparateFromAttribute();
426 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes(); 427 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes();
427 428
428 m_inputType->destroyShadowSubtree(); 429 m_inputType->destroyShadowSubtree();
429 430
430 bool wasAttached = attached(); 431 bool wasAttached = attached();
431 if (wasAttached) 432 if (wasAttached)
432 detach(); 433 detach();
433 434
434 m_inputType = newType.release(); 435 m_inputType = newType.release();
436 m_inputTypeView = m_inputType;
435 m_inputType->createShadowSubtree(); 437 m_inputType->createShadowSubtree();
436 438
437 bool hasTouchEventHandler = m_inputType->hasTouchEventHandler(); 439 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler();
438 if (hasTouchEventHandler != m_hasTouchEventHandler) { 440 if (hasTouchEventHandler != m_hasTouchEventHandler) {
439 if (hasTouchEventHandler) 441 if (hasTouchEventHandler)
440 document()->didAddTouchEventHandler(this); 442 document()->didAddTouchEventHandler(this);
441 else 443 else
442 document()->didRemoveTouchEventHandler(this); 444 document()->didRemoveTouchEventHandler(this);
443 m_hasTouchEventHandler = hasTouchEventHandler; 445 m_hasTouchEventHandler = hasTouchEventHandler;
444 } 446 }
445 447
446 setNeedsWillValidateCheck(); 448 setNeedsWillValidateCheck();
447 449
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 setChangedSinceLastFormControlChangeEvent(false); 483 setChangedSinceLastFormControlChangeEvent(false);
482 484
483 addToRadioButtonGroup(); 485 addToRadioButtonGroup();
484 486
485 setNeedsValidityCheck(); 487 setNeedsValidityCheck();
486 notifyFormStateChanged(); 488 notifyFormStateChanged();
487 } 489 }
488 490
489 void HTMLInputElement::subtreeHasChanged() 491 void HTMLInputElement::subtreeHasChanged()
490 { 492 {
491 m_inputType->subtreeHasChanged(); 493 m_inputTypeView->subtreeHasChanged();
492 // When typing in an input field, childrenChanged is not called, so we need to force the directionality check. 494 // When typing in an input field, childrenChanged is not called, so we need to force the directionality check.
493 calculateAndAdjustDirectionality(); 495 calculateAndAdjustDirectionality();
494 } 496 }
495 497
496 const AtomicString& HTMLInputElement::formControlType() const 498 const AtomicString& HTMLInputElement::formControlType() const
497 { 499 {
498 return m_inputType->formControlType(); 500 return m_inputType->formControlType();
499 } 501 }
500 502
501 bool HTMLInputElement::shouldSaveAndRestoreFormControlState() const 503 bool HTMLInputElement::shouldSaveAndRestoreFormControlState() const
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 updateType(); 657 updateType();
656 else if (name == valueAttr) { 658 else if (name == valueAttr) {
657 // We only need to setChanged if the form is looking at the default valu e right now. 659 // We only need to setChanged if the form is looking at the default valu e right now.
658 if (!hasDirtyValue()) { 660 if (!hasDirtyValue()) {
659 updatePlaceholderVisibility(false); 661 updatePlaceholderVisibility(false);
660 setNeedsStyleRecalc(); 662 setNeedsStyleRecalc();
661 } 663 }
662 setFormControlValueMatchesRenderer(false); 664 setFormControlValueMatchesRenderer(false);
663 setNeedsValidityCheck(); 665 setNeedsValidityCheck();
664 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress; 666 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
665 m_inputType->valueAttributeChanged(); 667 m_inputTypeView->valueAttributeChanged();
666 } else if (name == checkedAttr) { 668 } else if (name == checkedAttr) {
667 // Another radio button in the same group might be checked by state 669 // Another radio button in the same group might be checked by state
668 // restore. We shouldn't call setChecked() even if this has the checked 670 // restore. We shouldn't call setChecked() even if this has the checked
669 // attribute. So, delay the setChecked() call until 671 // attribute. So, delay the setChecked() call until
670 // finishParsingChildren() is called if parsing is in progress. 672 // finishParsingChildren() is called if parsing is in progress.
671 if (!m_parsingInProgress && m_reflectsCheckedAttribute) { 673 if (!m_parsingInProgress && m_reflectsCheckedAttribute) {
672 setChecked(!value.isNull()); 674 setChecked(!value.isNull());
673 m_reflectsCheckedAttribute = true; 675 m_reflectsCheckedAttribute = true;
674 } 676 }
675 } else if (name == maxlengthAttr) 677 } else if (name == maxlengthAttr)
676 parseMaxLengthAttribute(value); 678 parseMaxLengthAttribute(value);
677 else if (name == sizeAttr) { 679 else if (name == sizeAttr) {
678 int oldSize = m_size; 680 int oldSize = m_size;
679 int valueAsInteger = value.toInt(); 681 int valueAsInteger = value.toInt();
680 m_size = valueAsInteger > 0 ? valueAsInteger : defaultSize; 682 m_size = valueAsInteger > 0 ? valueAsInteger : defaultSize;
681 if (m_size != oldSize && renderer()) 683 if (m_size != oldSize && renderer())
682 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); 684 renderer()->setNeedsLayoutAndPrefWidthsRecalc();
683 } else if (name == altAttr) 685 } else if (name == altAttr)
684 m_inputType->altAttributeChanged(); 686 m_inputTypeView->altAttributeChanged();
685 else if (name == srcAttr) 687 else if (name == srcAttr)
686 m_inputType->srcAttributeChanged(); 688 m_inputTypeView->srcAttributeChanged();
687 else if (name == usemapAttr || name == accesskeyAttr) { 689 else if (name == usemapAttr || name == accesskeyAttr) {
688 // FIXME: ignore for the moment 690 // FIXME: ignore for the moment
689 } else if (name == onsearchAttr) { 691 } else if (name == onsearchAttr) {
690 // Search field and slider attributes all just cause updateFromElement t o be called through style recalcing. 692 // Search field and slider attributes all just cause updateFromElement t o be called through style recalcing.
691 setAttributeEventListener(eventNames().searchEvent, createAttributeEvent Listener(this, name, value)); 693 setAttributeEventListener(eventNames().searchEvent, createAttributeEvent Listener(this, name, value));
692 } else if (name == resultsAttr) { 694 } else if (name == resultsAttr) {
693 int oldResults = m_maxResults; 695 int oldResults = m_maxResults;
694 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults ) : -1; 696 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults ) : -1;
695 // FIXME: Detaching just for maxResults change is not ideal. We should figure out the right 697 // FIXME: Detaching just for maxResults change is not ideal. We should figure out the right
696 // time to relayout for this change. 698 // time to relayout for this change.
697 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) ) 699 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) )
698 lazyReattachIfAttached(); 700 lazyReattachIfAttached();
699 setNeedsStyleRecalc(); 701 setNeedsStyleRecalc();
700 UseCounter::count(document(), UseCounter::ResultsAttribute); 702 UseCounter::count(document(), UseCounter::ResultsAttribute);
701 } else if (name == incrementalAttr) { 703 } else if (name == incrementalAttr) {
702 setNeedsStyleRecalc(); 704 setNeedsStyleRecalc();
703 UseCounter::count(document(), UseCounter::IncrementalAttribute); 705 UseCounter::count(document(), UseCounter::IncrementalAttribute);
704 } else if (name == minAttr) { 706 } else if (name == minAttr) {
705 m_inputType->minOrMaxAttributeChanged(); 707 m_inputTypeView->minOrMaxAttributeChanged();
706 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange(); 708 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange();
707 setNeedsValidityCheck(); 709 setNeedsValidityCheck();
708 UseCounter::count(document(), UseCounter::MinAttribute); 710 UseCounter::count(document(), UseCounter::MinAttribute);
709 } else if (name == maxAttr) { 711 } else if (name == maxAttr) {
710 m_inputType->minOrMaxAttributeChanged(); 712 m_inputTypeView->minOrMaxAttributeChanged();
711 setNeedsValidityCheck(); 713 setNeedsValidityCheck();
712 UseCounter::count(document(), UseCounter::MaxAttribute); 714 UseCounter::count(document(), UseCounter::MaxAttribute);
713 } else if (name == multipleAttr) { 715 } else if (name == multipleAttr) {
714 m_inputType->multipleAttributeChanged(); 716 m_inputTypeView->multipleAttributeChanged();
715 setNeedsValidityCheck(); 717 setNeedsValidityCheck();
716 } else if (name == stepAttr) { 718 } else if (name == stepAttr) {
717 m_inputType->stepAttributeChanged(); 719 m_inputTypeView->stepAttributeChanged();
718 setNeedsValidityCheck(); 720 setNeedsValidityCheck();
719 UseCounter::count(document(), UseCounter::StepAttribute); 721 UseCounter::count(document(), UseCounter::StepAttribute);
720 } else if (name == patternAttr) { 722 } else if (name == patternAttr) {
721 setNeedsValidityCheck(); 723 setNeedsValidityCheck();
722 UseCounter::count(document(), UseCounter::PatternAttribute); 724 UseCounter::count(document(), UseCounter::PatternAttribute);
723 } else if (name == precisionAttr) { 725 } else if (name == precisionAttr) {
724 setNeedsValidityCheck(); 726 setNeedsValidityCheck();
725 UseCounter::count(document(), UseCounter::PrecisionAttribute); 727 UseCounter::count(document(), UseCounter::PrecisionAttribute);
726 } else if (name == disabledAttr) { 728 } else if (name == disabledAttr) {
727 HTMLTextFormControlElement::parseAttribute(name, value); 729 HTMLTextFormControlElement::parseAttribute(name, value);
728 m_inputType->disabledAttributeChanged(); 730 m_inputTypeView->disabledAttributeChanged();
729 } else if (name == readonlyAttr) { 731 } else if (name == readonlyAttr) {
730 HTMLTextFormControlElement::parseAttribute(name, value); 732 HTMLTextFormControlElement::parseAttribute(name, value);
731 m_inputType->readonlyAttributeChanged(); 733 m_inputTypeView->readonlyAttributeChanged();
732 } else if (name == listAttr) { 734 } else if (name == listAttr) {
733 m_hasNonEmptyList = !value.isEmpty(); 735 m_hasNonEmptyList = !value.isEmpty();
734 if (m_hasNonEmptyList) { 736 if (m_hasNonEmptyList) {
735 resetListAttributeTargetObserver(); 737 resetListAttributeTargetObserver();
736 listAttributeTargetChanged(); 738 listAttributeTargetChanged();
737 } 739 }
738 UseCounter::count(document(), UseCounter::ListAttribute); 740 UseCounter::count(document(), UseCounter::ListAttribute);
739 } 741 }
740 #if ENABLE(INPUT_SPEECH) 742 #if ENABLE(INPUT_SPEECH)
741 else if (name == webkitspeechAttr) { 743 else if (name == webkitspeechAttr) {
(...skipping 10 matching lines...) Expand all
752 UseCounter::count(document(), UseCounter::PrefixedSpeechAttribute); 754 UseCounter::count(document(), UseCounter::PrefixedSpeechAttribute);
753 } else if (name == onwebkitspeechchangeAttr) 755 } else if (name == onwebkitspeechchangeAttr)
754 setAttributeEventListener(eventNames().webkitspeechchangeEvent, createAt tributeEventListener(this, name, value)); 756 setAttributeEventListener(eventNames().webkitspeechchangeEvent, createAt tributeEventListener(this, name, value));
755 #endif 757 #endif
756 else if (name == webkitdirectoryAttr) { 758 else if (name == webkitdirectoryAttr) {
757 HTMLTextFormControlElement::parseAttribute(name, value); 759 HTMLTextFormControlElement::parseAttribute(name, value);
758 UseCounter::count(document(), UseCounter::PrefixedDirectoryAttribute); 760 UseCounter::count(document(), UseCounter::PrefixedDirectoryAttribute);
759 } 761 }
760 else 762 else
761 HTMLTextFormControlElement::parseAttribute(name, value); 763 HTMLTextFormControlElement::parseAttribute(name, value);
762 m_inputType->attributeChanged(); 764 m_inputTypeView->attributeChanged();
763 } 765 }
764 766
765 void HTMLInputElement::finishParsingChildren() 767 void HTMLInputElement::finishParsingChildren()
766 { 768 {
767 m_parsingInProgress = false; 769 m_parsingInProgress = false;
768 HTMLTextFormControlElement::finishParsingChildren(); 770 HTMLTextFormControlElement::finishParsingChildren();
769 if (!m_stateRestored) { 771 if (!m_stateRestored) {
770 bool checked = hasAttribute(checkedAttr); 772 bool checked = hasAttribute(checkedAttr);
771 if (checked) 773 if (checked)
772 setChecked(checked); 774 setChecked(checked);
773 m_reflectsCheckedAttribute = true; 775 m_reflectsCheckedAttribute = true;
774 } 776 }
775 } 777 }
776 778
777 bool HTMLInputElement::rendererIsNeeded(const NodeRenderingContext& context) 779 bool HTMLInputElement::rendererIsNeeded(const NodeRenderingContext& context)
778 { 780 {
779 return m_inputType->rendererIsNeeded() && HTMLTextFormControlElement::render erIsNeeded(context); 781 return m_inputType->rendererIsNeeded() && HTMLTextFormControlElement::render erIsNeeded(context);
780 } 782 }
781 783
782 RenderObject* HTMLInputElement::createRenderer(RenderStyle* style) 784 RenderObject* HTMLInputElement::createRenderer(RenderStyle* style)
783 { 785 {
784 return m_inputType->createRenderer(style); 786 return m_inputTypeView->createRenderer(style);
785 } 787 }
786 788
787 void HTMLInputElement::attach(const AttachContext& context) 789 void HTMLInputElement::attach(const AttachContext& context)
788 { 790 {
789 PostAttachCallbackDisabler disabler(this); 791 PostAttachCallbackDisabler disabler(this);
790 792
791 if (!m_hasType) 793 if (!m_hasType)
792 updateType(); 794 updateType();
793 795
794 HTMLTextFormControlElement::attach(context); 796 HTMLTextFormControlElement::attach(context);
795 797
796 m_inputType->attach(); 798 m_inputTypeView->attach();
797 m_inputType->countUsage(); 799 m_inputType->countUsage();
798 800
799 if (document()->focusedElement() == this) 801 if (document()->focusedElement() == this)
800 document()->updateFocusAppearanceSoon(true /* restore selection */); 802 document()->updateFocusAppearanceSoon(true /* restore selection */);
801 } 803 }
802 804
803 void HTMLInputElement::detach(const AttachContext& context) 805 void HTMLInputElement::detach(const AttachContext& context)
804 { 806 {
805 HTMLTextFormControlElement::detach(context); 807 HTMLTextFormControlElement::detach(context);
806 setFormControlValueMatchesRenderer(false); 808 setFormControlValueMatchesRenderer(false);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 renderer()->theme()->stateChanged(renderer(), CheckedState); 916 renderer()->theme()->stateChanged(renderer(), CheckedState);
915 } 917 }
916 918
917 int HTMLInputElement::size() const 919 int HTMLInputElement::size() const
918 { 920 {
919 return m_size; 921 return m_size;
920 } 922 }
921 923
922 bool HTMLInputElement::sizeShouldIncludeDecoration(int& preferredSize) const 924 bool HTMLInputElement::sizeShouldIncludeDecoration(int& preferredSize) const
923 { 925 {
924 return m_inputType->sizeShouldIncludeDecoration(defaultSize, preferredSize); 926 return m_inputTypeView->sizeShouldIncludeDecoration(defaultSize, preferredSi ze);
925 } 927 }
926 928
927 void HTMLInputElement::copyNonAttributePropertiesFromElement(const Element& sour ce) 929 void HTMLInputElement::copyNonAttributePropertiesFromElement(const Element& sour ce)
928 { 930 {
929 const HTMLInputElement& sourceElement = static_cast<const HTMLInputElement&> (source); 931 const HTMLInputElement& sourceElement = static_cast<const HTMLInputElement&> (source);
930 932
931 m_valueIfDirty = sourceElement.m_valueIfDirty; 933 m_valueIfDirty = sourceElement.m_valueIfDirty;
932 m_wasModifiedByUser = false; 934 m_wasModifiedByUser = false;
933 setChecked(sourceElement.m_isChecked); 935 setChecked(sourceElement.m_isChecked);
934 m_reflectsCheckedAttribute = sourceElement.m_reflectsCheckedAttribute; 936 m_reflectsCheckedAttribute = sourceElement.m_reflectsCheckedAttribute;
935 m_isIndeterminate = sourceElement.m_isIndeterminate; 937 m_isIndeterminate = sourceElement.m_isIndeterminate;
936 938
937 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); 939 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
938 940
939 setFormControlValueMatchesRenderer(false); 941 setFormControlValueMatchesRenderer(false);
940 m_inputType->updateInnerTextValue(); 942 m_inputTypeView->updateInnerTextValue();
941 } 943 }
942 944
943 String HTMLInputElement::value() const 945 String HTMLInputElement::value() const
944 { 946 {
945 String value; 947 String value;
946 if (m_inputType->getTypeSpecificValue(value)) 948 if (m_inputType->getTypeSpecificValue(value))
947 return value; 949 return value;
948 950
949 value = m_valueIfDirty; 951 value = m_valueIfDirty;
950 if (!value.isNull()) 952 if (!value.isNull())
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 notifyFormStateChanged(); 1088 notifyFormStateChanged();
1087 1089
1088 setNeedsValidityCheck(); 1090 setNeedsValidityCheck();
1089 1091
1090 // Clear autofill flag (and yellow background) on user edit. 1092 // Clear autofill flag (and yellow background) on user edit.
1091 setAutofilled(false); 1093 setAutofilled(false);
1092 } 1094 }
1093 1095
1094 void* HTMLInputElement::preDispatchEventHandler(Event* event) 1096 void* HTMLInputElement::preDispatchEventHandler(Event* event)
1095 { 1097 {
1096 if (event->type() == eventNames().textInputEvent && m_inputType->shouldSubmi tImplicitly(event)) { 1098 if (event->type() == eventNames().textInputEvent && m_inputTypeView->shouldS ubmitImplicitly(event)) {
1097 event->stopPropagation(); 1099 event->stopPropagation();
1098 return 0; 1100 return 0;
1099 } 1101 }
1100 if (event->type() != eventNames().clickEvent) 1102 if (event->type() != eventNames().clickEvent)
1101 return 0; 1103 return 0;
1102 if (!event->isMouseEvent() || toMouseEvent(event)->button() != LeftButton) 1104 if (!event->isMouseEvent() || toMouseEvent(event)->button() != LeftButton)
1103 return 0; 1105 return 0;
1104 // FIXME: Check whether there are any cases where this actually ends up leak ing. 1106 // FIXME: Check whether there are any cases where this actually ends up leak ing.
1105 return m_inputType->willDispatchClick().leakPtr(); 1107 return m_inputTypeView->willDispatchClick().leakPtr();
1106 } 1108 }
1107 1109
1108 void HTMLInputElement::postDispatchEventHandler(Event* event, void* dataFromPreD ispatch) 1110 void HTMLInputElement::postDispatchEventHandler(Event* event, void* dataFromPreD ispatch)
1109 { 1111 {
1110 OwnPtr<ClickHandlingState> state = adoptPtr(static_cast<ClickHandlingState*> (dataFromPreDispatch)); 1112 OwnPtr<ClickHandlingState> state = adoptPtr(static_cast<ClickHandlingState*> (dataFromPreDispatch));
1111 if (!state) 1113 if (!state)
1112 return; 1114 return;
1113 m_inputType->didDispatchClick(event, *state); 1115 m_inputTypeView->didDispatchClick(event, *state);
1114 } 1116 }
1115 1117
1116 void HTMLInputElement::defaultEventHandler(Event* evt) 1118 void HTMLInputElement::defaultEventHandler(Event* evt)
1117 { 1119 {
1118 if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && toMouse Event(evt)->button() == LeftButton) { 1120 if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && toMouse Event(evt)->button() == LeftButton) {
1119 m_inputType->handleClickEvent(toMouseEvent(evt)); 1121 m_inputTypeView->handleClickEvent(toMouseEvent(evt));
1120 if (evt->defaultHandled()) 1122 if (evt->defaultHandled())
1121 return; 1123 return;
1122 } 1124 }
1123 1125
1124 if (evt->isTouchEvent()) { 1126 if (evt->isTouchEvent()) {
1125 m_inputType->handleTouchEvent(static_cast<TouchEvent*>(evt)); 1127 m_inputTypeView->handleTouchEvent(static_cast<TouchEvent*>(evt));
1126 if (evt->defaultHandled()) 1128 if (evt->defaultHandled())
1127 return; 1129 return;
1128 } 1130 }
1129 1131
1130 if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) { 1132 if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) {
1131 m_inputType->handleKeydownEvent(toKeyboardEvent(evt)); 1133 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt));
1132 if (evt->defaultHandled()) 1134 if (evt->defaultHandled())
1133 return; 1135 return;
1134 } 1136 }
1135 1137
1136 // Call the base event handler before any of our own event handling for almo st all events in text fields. 1138 // Call the base event handler before any of our own event handling for almo st all events in text fields.
1137 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function. 1139 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function.
1138 bool callBaseClassEarly = isTextField() && (evt->type() == eventNames().keyd ownEvent || evt->type() == eventNames().keypressEvent); 1140 bool callBaseClassEarly = isTextField() && (evt->type() == eventNames().keyd ownEvent || evt->type() == eventNames().keypressEvent);
1139 if (callBaseClassEarly) { 1141 if (callBaseClassEarly) {
1140 HTMLTextFormControlElement::defaultEventHandler(evt); 1142 HTMLTextFormControlElement::defaultEventHandler(evt);
1141 if (evt->defaultHandled()) 1143 if (evt->defaultHandled())
1142 return; 1144 return;
1143 } 1145 }
1144 1146
1145 // DOMActivate events cause the input to be "activated" - in the case of ima ge and submit inputs, this means 1147 // DOMActivate events cause the input to be "activated" - in the case of ima ge and submit inputs, this means
1146 // actually submitting the form. For reset inputs, the form is reset. These events are sent when the user clicks 1148 // actually submitting the form. For reset inputs, the form is reset. These events are sent when the user clicks
1147 // on the element, or presses enter while it is the active element. JavaScri pt code wishing to activate the element 1149 // on the element, or presses enter while it is the active element. JavaScri pt code wishing to activate the element
1148 // must dispatch a DOMActivate event - a click event will not do the job. 1150 // must dispatch a DOMActivate event - a click event will not do the job.
1149 if (evt->type() == eventNames().DOMActivateEvent) { 1151 if (evt->type() == eventNames().DOMActivateEvent) {
1150 m_inputType->handleDOMActivateEvent(evt); 1152 m_inputTypeView->handleDOMActivateEvent(evt);
1151 if (evt->defaultHandled()) 1153 if (evt->defaultHandled())
1152 return; 1154 return;
1153 } 1155 }
1154 1156
1155 // Use key press event here since sending simulated mouse events 1157 // Use key press event here since sending simulated mouse events
1156 // on key down blocks the proper sending of the key press event. 1158 // on key down blocks the proper sending of the key press event.
1157 if (evt->isKeyboardEvent() && evt->type() == eventNames().keypressEvent) { 1159 if (evt->isKeyboardEvent() && evt->type() == eventNames().keypressEvent) {
1158 m_inputType->handleKeypressEvent(toKeyboardEvent(evt)); 1160 m_inputTypeView->handleKeypressEvent(toKeyboardEvent(evt));
1159 if (evt->defaultHandled()) 1161 if (evt->defaultHandled())
1160 return; 1162 return;
1161 } 1163 }
1162 1164
1163 if (evt->isKeyboardEvent() && evt->type() == eventNames().keyupEvent) { 1165 if (evt->isKeyboardEvent() && evt->type() == eventNames().keyupEvent) {
1164 m_inputType->handleKeyupEvent(toKeyboardEvent(evt)); 1166 m_inputTypeView->handleKeyupEvent(toKeyboardEvent(evt));
1165 if (evt->defaultHandled()) 1167 if (evt->defaultHandled())
1166 return; 1168 return;
1167 } 1169 }
1168 1170
1169 if (m_inputType->shouldSubmitImplicitly(evt)) { 1171 if (m_inputTypeView->shouldSubmitImplicitly(evt)) {
1170 if (isSearchField()) 1172 if (isSearchField())
1171 onSearch(); 1173 onSearch();
1172 // Form submission finishes editing, just as loss of focus does. 1174 // Form submission finishes editing, just as loss of focus does.
1173 // If there was a change, send the event now. 1175 // If there was a change, send the event now.
1174 if (wasChangedSinceLastFormControlChangeEvent()) 1176 if (wasChangedSinceLastFormControlChangeEvent())
1175 dispatchFormControlChangeEvent(); 1177 dispatchFormControlChangeEvent();
1176 1178
1177 RefPtr<HTMLFormElement> formForSubmission = m_inputType->formForSubmissi on(); 1179 RefPtr<HTMLFormElement> formForSubmission = m_inputTypeView->formForSubm ission();
1178 // Form may never have been present, or may have been destroyed by code responding to the change event. 1180 // Form may never have been present, or may have been destroyed by code responding to the change event.
1179 if (formForSubmission) 1181 if (formForSubmission)
1180 formForSubmission->submitImplicitly(evt, canTriggerImplicitSubmissio n()); 1182 formForSubmission->submitImplicitly(evt, canTriggerImplicitSubmissio n());
1181 1183
1182 evt->setDefaultHandled(); 1184 evt->setDefaultHandled();
1183 return; 1185 return;
1184 } 1186 }
1185 1187
1186 if (evt->isBeforeTextInsertedEvent()) 1188 if (evt->isBeforeTextInsertedEvent())
1187 m_inputType->handleBeforeTextInsertedEvent(static_cast<BeforeTextInserte dEvent*>(evt)); 1189 m_inputTypeView->handleBeforeTextInsertedEvent(static_cast<BeforeTextIns ertedEvent*>(evt));
1188 1190
1189 if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) { 1191 if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) {
1190 m_inputType->handleMouseDownEvent(toMouseEvent(evt)); 1192 m_inputTypeView->handleMouseDownEvent(toMouseEvent(evt));
1191 if (evt->defaultHandled()) 1193 if (evt->defaultHandled())
1192 return; 1194 return;
1193 } 1195 }
1194 1196
1195 m_inputType->forwardEvent(evt); 1197 m_inputTypeView->forwardEvent(evt);
1196 1198
1197 if (!callBaseClassEarly && !evt->defaultHandled()) 1199 if (!callBaseClassEarly && !evt->defaultHandled())
1198 HTMLTextFormControlElement::defaultEventHandler(evt); 1200 HTMLTextFormControlElement::defaultEventHandler(evt);
1199 } 1201 }
1200 1202
1201 bool HTMLInputElement::willRespondToMouseClickEvents() 1203 bool HTMLInputElement::willRespondToMouseClickEvents()
1202 { 1204 {
1203 // FIXME: Consider implementing willRespondToMouseClickEvents() in InputType if more accurate results are necessary. 1205 // FIXME: Consider implementing willRespondToMouseClickEvents() in InputType if more accurate results are necessary.
1204 if (!isDisabledFormControl()) 1206 if (!isDisabledFormControl())
1205 return true; 1207 return true;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 void HTMLInputElement::onSearch() 1414 void HTMLInputElement::onSearch()
1413 { 1415 {
1414 ASSERT(isSearchField()); 1416 ASSERT(isSearchField());
1415 if (m_inputType) 1417 if (m_inputType)
1416 static_cast<SearchInputType*>(m_inputType.get())->stopSearchEventTimer() ; 1418 static_cast<SearchInputType*>(m_inputType.get())->stopSearchEventTimer() ;
1417 dispatchEvent(Event::create(eventNames().searchEvent, true, false)); 1419 dispatchEvent(Event::create(eventNames().searchEvent, true, false));
1418 } 1420 }
1419 1421
1420 void HTMLInputElement::updateClearButtonVisibility() 1422 void HTMLInputElement::updateClearButtonVisibility()
1421 { 1423 {
1422 m_inputType->updateClearButtonVisibility(); 1424 m_inputTypeView->updateClearButtonVisibility();
1423 } 1425 }
1424 1426
1425 void HTMLInputElement::willChangeForm() 1427 void HTMLInputElement::willChangeForm()
1426 { 1428 {
1427 removeFromRadioButtonGroup(); 1429 removeFromRadioButtonGroup();
1428 HTMLTextFormControlElement::willChangeForm(); 1430 HTMLTextFormControlElement::willChangeForm();
1429 } 1431 }
1430 1432
1431 void HTMLInputElement::didChangeForm() 1433 void HTMLInputElement::didChangeForm()
1432 { 1434 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 bool HTMLInputElement::recalcWillValidate() const 1482 bool HTMLInputElement::recalcWillValidate() const
1481 { 1483 {
1482 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate(); 1484 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate();
1483 } 1485 }
1484 1486
1485 void HTMLInputElement::requiredAttributeChanged() 1487 void HTMLInputElement::requiredAttributeChanged()
1486 { 1488 {
1487 HTMLTextFormControlElement::requiredAttributeChanged(); 1489 HTMLTextFormControlElement::requiredAttributeChanged();
1488 if (CheckedRadioButtons* buttons = checkedRadioButtons()) 1490 if (CheckedRadioButtons* buttons = checkedRadioButtons())
1489 buttons->requiredAttributeChanged(this); 1491 buttons->requiredAttributeChanged(this);
1490 m_inputType->requiredAttributeChanged(); 1492 m_inputTypeView->requiredAttributeChanged();
1491 } 1493 }
1492 1494
1493 void HTMLInputElement::selectColorInColorChooser(const Color& color) 1495 void HTMLInputElement::selectColorInColorChooser(const Color& color)
1494 { 1496 {
1495 if (!m_inputType->isColorControl()) 1497 if (!m_inputType->isColorControl())
1496 return; 1498 return;
1497 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color); 1499 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color);
1498 } 1500 }
1499 1501
1500 HTMLElement* HTMLInputElement::list() const 1502 HTMLElement* HTMLInputElement::list() const
(...skipping 21 matching lines...) Expand all
1522 void HTMLInputElement::resetListAttributeTargetObserver() 1524 void HTMLInputElement::resetListAttributeTargetObserver()
1523 { 1525 {
1524 if (inDocument()) 1526 if (inDocument())
1525 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this); 1527 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this);
1526 else 1528 else
1527 m_listAttributeTargetObserver = nullptr; 1529 m_listAttributeTargetObserver = nullptr;
1528 } 1530 }
1529 1531
1530 void HTMLInputElement::listAttributeTargetChanged() 1532 void HTMLInputElement::listAttributeTargetChanged()
1531 { 1533 {
1532 m_inputType->listAttributeTargetChanged(); 1534 m_inputTypeView->listAttributeTargetChanged();
1533 } 1535 }
1534 1536
1535 bool HTMLInputElement::isSteppable() const 1537 bool HTMLInputElement::isSteppable() const
1536 { 1538 {
1537 return m_inputType->isSteppable(); 1539 return m_inputType->isSteppable();
1538 } 1540 }
1539 1541
1540 #if ENABLE(INPUT_SPEECH) 1542 #if ENABLE(INPUT_SPEECH)
1541 1543
1542 bool HTMLInputElement::isSpeechEnabled() const 1544 bool HTMLInputElement::isSpeechEnabled() const
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 } 1869 }
1868 1870
1869 bool HTMLInputElement::supportsInputModeAttribute() const 1871 bool HTMLInputElement::supportsInputModeAttribute() const
1870 { 1872 {
1871 return m_inputType->supportsInputModeAttribute(); 1873 return m_inputType->supportsInputModeAttribute();
1872 } 1874 }
1873 1875
1874 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1876 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1875 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1877 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1876 { 1878 {
1877 return m_inputType->customStyleForRenderer(originalStyleForRenderer()); 1879 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer());
1878 } 1880 }
1879 #endif 1881 #endif
1880 1882
1881 } // namespace 1883 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLInputElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698