OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 , m_isChecked(false) | 110 , m_isChecked(false) |
111 , m_reflectsCheckedAttribute(true) | 111 , m_reflectsCheckedAttribute(true) |
112 , m_isIndeterminate(false) | 112 , m_isIndeterminate(false) |
113 , m_hasType(false) | 113 , m_hasType(false) |
114 , m_isActivatedSubmit(false) | 114 , m_isActivatedSubmit(false) |
115 , m_autocomplete(Uninitialized) | 115 , m_autocomplete(Uninitialized) |
116 , m_hasNonEmptyList(false) | 116 , m_hasNonEmptyList(false) |
117 , m_stateRestored(false) | 117 , m_stateRestored(false) |
118 , m_parsingInProgress(createdByParser) | 118 , m_parsingInProgress(createdByParser) |
119 , m_valueAttributeWasUpdatedAfterParsing(false) | 119 , m_valueAttributeWasUpdatedAfterParsing(false) |
120 , m_wasModifiedByUser(false) | |
121 , m_canReceiveDroppedFiles(false) | 120 , m_canReceiveDroppedFiles(false) |
122 , m_hasTouchEventHandler(false) | 121 , m_hasTouchEventHandler(false) |
123 , m_inputType(InputType::createText(*this)) | 122 , m_inputType(InputType::createText(*this)) |
124 , m_inputTypeView(m_inputType) | 123 , m_inputTypeView(m_inputType) |
125 { | 124 { |
126 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 125 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
127 setHasCustomStyleCallbacks(); | 126 setHasCustomStyleCallbacks(); |
128 #endif | 127 #endif |
129 ScriptWrappable::init(this); | 128 ScriptWrappable::init(this); |
130 } | 129 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // We use isTextType() instead of supportsMaxLength() because of the | 236 // We use isTextType() instead of supportsMaxLength() because of the |
238 // 'virtual' overhead. | 237 // 'virtual' overhead. |
239 if (!isTextType()) | 238 if (!isTextType()) |
240 return false; | 239 return false; |
241 int max = maxLength(); | 240 int max = maxLength(); |
242 if (max < 0) | 241 if (max < 0) |
243 return false; | 242 return false; |
244 if (check == CheckDirtyFlag) { | 243 if (check == CheckDirtyFlag) { |
245 // Return false for the default value or a value set by a script even if | 244 // Return false for the default value or a value set by a script even if |
246 // it is longer than maxLength. | 245 // it is longer than maxLength. |
247 if (!hasDirtyValue() || !m_wasModifiedByUser) | 246 if (!hasDirtyValue() || !lastChangeWasUserEdit()) |
248 return false; | 247 return false; |
249 } | 248 } |
250 return value.length() > static_cast<unsigned>(max); | 249 return value.length() > static_cast<unsigned>(max); |
251 } | 250 } |
252 | 251 |
253 bool HTMLInputElement::rangeUnderflow() const | 252 bool HTMLInputElement::rangeUnderflow() const |
254 { | 253 { |
255 return willValidate() && m_inputType->rangeUnderflow(value()); | 254 return willValidate() && m_inputType->rangeUnderflow(value()); |
256 } | 255 } |
257 | 256 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 448 } |
450 if (!didStoreValue && willStoreValue) { | 449 if (!didStoreValue && willStoreValue) { |
451 AtomicString valueString = fastGetAttribute(valueAttr); | 450 AtomicString valueString = fastGetAttribute(valueAttr); |
452 m_valueIfDirty = sanitizeValue(valueString); | 451 m_valueIfDirty = sanitizeValue(valueString); |
453 } else | 452 } else |
454 updateValueIfNeeded(); | 453 updateValueIfNeeded(); |
455 | 454 |
456 setFormControlValueMatchesRenderer(false); | 455 setFormControlValueMatchesRenderer(false); |
457 m_inputTypeView->updateView(); | 456 m_inputTypeView->updateView(); |
458 | 457 |
459 m_wasModifiedByUser = false; | |
460 | |
461 if (didRespectHeightAndWidth != m_inputType->shouldRespectHeightAndWidthAttr
ibutes()) { | 458 if (didRespectHeightAndWidth != m_inputType->shouldRespectHeightAndWidthAttr
ibutes()) { |
462 ASSERT(elementData()); | 459 ASSERT(elementData()); |
463 if (const Attribute* height = getAttributeItem(heightAttr)) | 460 if (const Attribute* height = getAttributeItem(heightAttr)) |
464 attributeChanged(heightAttr, height->value()); | 461 attributeChanged(heightAttr, height->value()); |
465 if (const Attribute* width = getAttributeItem(widthAttr)) | 462 if (const Attribute* width = getAttributeItem(widthAttr)) |
466 attributeChanged(widthAttr, width->value()); | 463 attributeChanged(widthAttr, width->value()); |
467 if (const Attribute* align = getAttributeItem(alignAttr)) | 464 if (const Attribute* align = getAttributeItem(alignAttr)) |
468 attributeChanged(alignAttr, align->value()); | 465 attributeChanged(alignAttr, align->value()); |
469 } | 466 } |
470 | 467 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 bool HTMLInputElement::sizeShouldIncludeDecoration(int& preferredSize) const | 913 bool HTMLInputElement::sizeShouldIncludeDecoration(int& preferredSize) const |
917 { | 914 { |
918 return m_inputTypeView->sizeShouldIncludeDecoration(defaultSize, preferredSi
ze); | 915 return m_inputTypeView->sizeShouldIncludeDecoration(defaultSize, preferredSi
ze); |
919 } | 916 } |
920 | 917 |
921 void HTMLInputElement::copyNonAttributePropertiesFromElement(const Element& sour
ce) | 918 void HTMLInputElement::copyNonAttributePropertiesFromElement(const Element& sour
ce) |
922 { | 919 { |
923 const HTMLInputElement& sourceElement = static_cast<const HTMLInputElement&>
(source); | 920 const HTMLInputElement& sourceElement = static_cast<const HTMLInputElement&>
(source); |
924 | 921 |
925 m_valueIfDirty = sourceElement.m_valueIfDirty; | 922 m_valueIfDirty = sourceElement.m_valueIfDirty; |
926 m_wasModifiedByUser = false; | |
927 setChecked(sourceElement.m_isChecked); | 923 setChecked(sourceElement.m_isChecked); |
928 m_reflectsCheckedAttribute = sourceElement.m_reflectsCheckedAttribute; | 924 m_reflectsCheckedAttribute = sourceElement.m_reflectsCheckedAttribute; |
929 m_isIndeterminate = sourceElement.m_isIndeterminate; | 925 m_isIndeterminate = sourceElement.m_isIndeterminate; |
930 | 926 |
931 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 927 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); |
932 | 928 |
933 setFormControlValueMatchesRenderer(false); | 929 setFormControlValueMatchesRenderer(false); |
934 m_inputTypeView->updateView(); | 930 m_inputTypeView->updateView(); |
935 } | 931 } |
936 | 932 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 | 1024 |
1029 if (!valueChanged) | 1025 if (!valueChanged) |
1030 return; | 1026 return; |
1031 | 1027 |
1032 notifyFormStateChanged(); | 1028 notifyFormStateChanged(); |
1033 } | 1029 } |
1034 | 1030 |
1035 void HTMLInputElement::setValueInternal(const String& sanitizedValue, TextFieldE
ventBehavior eventBehavior) | 1031 void HTMLInputElement::setValueInternal(const String& sanitizedValue, TextFieldE
ventBehavior eventBehavior) |
1036 { | 1032 { |
1037 m_valueIfDirty = sanitizedValue; | 1033 m_valueIfDirty = sanitizedValue; |
1038 m_wasModifiedByUser = eventBehavior != DispatchNoEvent; | |
1039 setNeedsValidityCheck(); | 1034 setNeedsValidityCheck(); |
1040 } | 1035 } |
1041 | 1036 |
1042 double HTMLInputElement::valueAsDate() const | 1037 double HTMLInputElement::valueAsDate() const |
1043 { | 1038 { |
1044 return m_inputType->valueAsDate(); | 1039 return m_inputType->valueAsDate(); |
1045 } | 1040 } |
1046 | 1041 |
1047 void HTMLInputElement::setValueAsDate(double value, ExceptionState& exceptionSta
te) | 1042 void HTMLInputElement::setValueAsDate(double value, ExceptionState& exceptionSta
te) |
1048 { | 1043 { |
(...skipping 20 matching lines...) Expand all Loading... |
1069 ASSERT(!isFileUpload()); | 1064 ASSERT(!isFileUpload()); |
1070 | 1065 |
1071 m_suggestedValue = String(); | 1066 m_suggestedValue = String(); |
1072 | 1067 |
1073 // Renderer and our event handler are responsible for sanitizing values. | 1068 // Renderer and our event handler are responsible for sanitizing values. |
1074 ASSERT(value == sanitizeValue(value) || sanitizeValue(value).isEmpty()); | 1069 ASSERT(value == sanitizeValue(value) || sanitizeValue(value).isEmpty()); |
1075 | 1070 |
1076 m_valueIfDirty = value; | 1071 m_valueIfDirty = value; |
1077 | 1072 |
1078 setFormControlValueMatchesRenderer(true); | 1073 setFormControlValueMatchesRenderer(true); |
1079 m_wasModifiedByUser = true; | |
1080 | 1074 |
1081 // Input event is fired by the Node::defaultEventHandler for editable contro
ls. | 1075 // Input event is fired by the Node::defaultEventHandler for editable contro
ls. |
1082 if (!isTextField()) | 1076 if (!isTextField()) |
1083 dispatchInputEvent(); | 1077 dispatchInputEvent(); |
1084 notifyFormStateChanged(); | 1078 notifyFormStateChanged(); |
1085 | 1079 |
1086 setNeedsValidityCheck(); | 1080 setNeedsValidityCheck(); |
1087 | 1081 |
1088 // Clear autofill flag (and yellow background) on user edit. | 1082 // Clear autofill flag (and yellow background) on user edit. |
1089 setAutofilled(false); | 1083 setAutofilled(false); |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 } | 1858 } |
1865 | 1859 |
1866 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 1860 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
1867 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() | 1861 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() |
1868 { | 1862 { |
1869 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); | 1863 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); |
1870 } | 1864 } |
1871 #endif | 1865 #endif |
1872 | 1866 |
1873 } // namespace | 1867 } // namespace |
OLD | NEW |