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

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

Issue 679273004: Set element value to its default value on reset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added isReset as a parameter to not allow setValue change value of m_textAsOfLastFormControlChangeE… Created 6 years, 1 month 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
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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 832 }
833 833
834 String HTMLInputElement::resultForDialogSubmit() 834 String HTMLInputElement::resultForDialogSubmit()
835 { 835 {
836 return m_inputType->resultForDialogSubmit(); 836 return m_inputType->resultForDialogSubmit();
837 } 837 }
838 838
839 void HTMLInputElement::resetImpl() 839 void HTMLInputElement::resetImpl()
840 { 840 {
841 if (m_inputType->storesValueSeparateFromAttribute()) { 841 if (m_inputType->storesValueSeparateFromAttribute()) {
842 setValue(String()); 842 setValue(String(), DispatchNoEvent, true);
843 setNeedsValidityCheck(); 843 setNeedsValidityCheck();
844 } 844 }
845 845
846 setChecked(hasAttribute(checkedAttr)); 846 setChecked(hasAttribute(checkedAttr));
847 m_reflectsCheckedAttribute = true; 847 m_reflectsCheckedAttribute = true;
848 } 848 }
849 849
850 bool HTMLInputElement::isTextField() const 850 bool HTMLInputElement::isTextField() const
851 { 851 {
852 return m_inputType->isTextField(); 852 return m_inputType->isTextField();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 void HTMLInputElement::setValue(const String& value, ExceptionState& exceptionSt ate, TextFieldEventBehavior eventBehavior) 1002 void HTMLInputElement::setValue(const String& value, ExceptionState& exceptionSt ate, TextFieldEventBehavior eventBehavior)
1003 { 1003 {
1004 // FIXME: Remove type check. 1004 // FIXME: Remove type check.
1005 if (type() == InputTypeNames::file && !value.isEmpty()) { 1005 if (type() == InputTypeNames::file && !value.isEmpty()) {
1006 exceptionState.throwDOMException(InvalidStateError, "This input element accepts a filename, which may only be programmatically set to the empty string." ); 1006 exceptionState.throwDOMException(InvalidStateError, "This input element accepts a filename, which may only be programmatically set to the empty string." );
1007 return; 1007 return;
1008 } 1008 }
1009 setValue(value, eventBehavior); 1009 setValue(value, eventBehavior);
1010 } 1010 }
1011 1011
1012 void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even tBehavior) 1012 void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even tBehavior, bool isReset)
1013 { 1013 {
1014 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value); 1014 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value);
1015 if (!m_inputType->canSetValue(value)) 1015 if (!m_inputType->canSetValue(value))
1016 return; 1016 return;
1017 1017
1018 RefPtrWillBeRawPtr<HTMLInputElement> protector(this); 1018 RefPtrWillBeRawPtr<HTMLInputElement> protector(this);
1019 EventQueueScope scope; 1019 EventQueueScope scope;
1020 String sanitizedValue = sanitizeValue(value); 1020 String sanitizedValue = sanitizeValue(value);
1021 bool valueChanged = sanitizedValue != this->value(); 1021 bool valueChanged = sanitizedValue != this->value();
1022 1022
1023 setLastChangeWasNotUserEdit(); 1023 setLastChangeWasNotUserEdit();
1024 m_needsToUpdateViewValue = true; 1024 m_needsToUpdateViewValue = true;
1025 m_suggestedValue = String(); // Prevent TextFieldInputType::setValue from us ing the suggested value. 1025 m_suggestedValue = String(); // Prevent TextFieldInputType::setValue from us ing the suggested value.
1026 1026
1027 m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior); 1027 m_inputType->setValue(sanitizedValue, valueChanged, isReset, eventBehavior);
1028 1028
1029 if (valueChanged && eventBehavior == DispatchNoEvent) 1029 if (valueChanged && eventBehavior == DispatchNoEvent && !isReset)
tkent 2014/11/06 00:11:16 Skipping setTextAsOfLastFormControlChangeEvent doe
Habib Virji 2014/11/06 14:23:08 <input type=text value=seed> During HTMLParsing, v
tkent 2014/11/07 00:34:19 Ok, HTMLTextFormControlElement::insertedInto() doe
Habib Virji 2014/11/07 14:10:43 Thanks above suggested change does work and looks
1030 setTextAsOfLastFormControlChangeEvent(sanitizedValue); 1030 setTextAsOfLastFormControlChangeEvent(sanitizedValue);
1031 1031
1032 if (!valueChanged) 1032 if (!valueChanged)
1033 return; 1033 return;
1034 1034
1035 notifyFormStateChanged(); 1035 notifyFormStateChanged();
1036 } 1036 }
1037 1037
1038 void HTMLInputElement::setValueInternal(const String& sanitizedValue, TextFieldE ventBehavior eventBehavior) 1038 void HTMLInputElement::setValueInternal(const String& sanitizedValue, TextFieldE ventBehavior eventBehavior)
1039 { 1039 {
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 { 1847 {
1848 listAttributeTargetChanged(); 1848 listAttributeTargetChanged();
1849 } 1849 }
1850 1850
1851 AXObject* HTMLInputElement::popupRootAXObject() 1851 AXObject* HTMLInputElement::popupRootAXObject()
1852 { 1852 {
1853 return m_inputTypeView->popupRootAXObject(); 1853 return m_inputTypeView->popupRootAXObject();
1854 } 1854 }
1855 1855
1856 } // namespace 1856 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698