Changeset 54274 in webkit
- Timestamp:
- Feb 2, 2010 10:56:30 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r54273 r54274 1 2010-02-02 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Fix a bug that changes for some constraint attributes doesn't 6 update validation CSS selectors. 7 https://bugs.webkit.org/show_bug.cgi?id=31716 8 9 Add tests for maxLength changes and step changes. 10 11 * fast/forms/input-live-pseudo-selectors-expected.txt: 12 * fast/forms/resources/input-live-pseudo-selectors.js: 13 * fast/forms/resources/textarea-live-pseudo-selectors.js: 14 * fast/forms/textarea-live-pseudo-selectors-expected.txt: 15 1 16 2010-02-02 Roland Steiner <rolandsteiner@chromium.org> 2 17 -
trunk/LayoutTests/fast/forms/input-live-pseudo-selectors-expected.txt
r49105 r54274 31 31 PASS backgroundOf(el) is invalidColor 32 32 PASS backgroundOf(el) is validColor 33 Change step: 34 PASS backgroundOf(el) is validColor 35 PASS backgroundOf(el) is invalidColor 36 PASS backgroundOf(el) is validColor 33 37 PASS successfullyParsed is true 34 38 -
trunk/LayoutTests/fast/forms/resources/input-live-pseudo-selectors.js
r49105 r54274 99 99 shouldBe(elBackground, 'validColor'); 100 100 101 debug('Change step:'); 102 el = makeInvalid(); 103 el.value = '1'; 104 el.type = 'number'; 105 shouldBe(elBackground, 'validColor'); 106 el.step = '2'; 107 shouldBe(elBackground, 'invalidColor'); 108 el.step = '0.5'; 109 shouldBe(elBackground, 'validColor'); 101 110 102 111 var successfullyParsed = true; -
trunk/LayoutTests/fast/forms/resources/textarea-live-pseudo-selectors.js
r49105 r54274 90 90 shouldBe(elBackground, 'invalidColor'); 91 91 92 debug('Change maxlength:'); 93 el = makeInvalid(); 94 el.value = '1234567890'; 95 shouldBe(elBackground, 'validColor'); 96 // Make the value dirty by deleting the last character. 97 el.focus(); 98 el.setSelectionRange(10, 10); 99 document.execCommand('delete'); 100 el.maxLength = 5; 101 shouldBe(elBackground, 'invalidColor'); 102 el.maxLength = 10; 103 shouldBe(elBackground, 'validColor'); 92 104 93 105 var successfullyParsed = true; -
trunk/LayoutTests/fast/forms/textarea-live-pseudo-selectors-expected.txt
r49105 r54274 27 27 PASS backgroundOf(el) is validColor 28 28 PASS backgroundOf(el) is invalidColor 29 Change maxlength: 30 PASS backgroundOf(el) is validColor 31 PASS backgroundOf(el) is invalidColor 32 PASS backgroundOf(el) is validColor 29 33 PASS successfullyParsed is true 30 34 -
trunk/WebCore/ChangeLog
r54273 r54274 1 2010-02-02 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Fix a bug that changes for some constraint attributes doesn't 6 update validation CSS selectors. 7 https://bugs.webkit.org/show_bug.cgi?id=31716 8 9 - Rename HTMLFormControlElement::updateValidity() to setNeedsValidityCheck() 10 - Introduce HTMLFormControlElement::setNeedsWillValidate() 11 - Introduce HTMLFormControlElement::m_hasName to make willValidate() 12 work in parseMappedAttribute(). 13 - We need to call setNeedsValidityCheck() when HTMLInputElement::step or 14 HTMLTextAreaElement::maxLength is changed. 15 16 * html/HTMLFormControlElement.cpp: 17 (WebCore::HTMLFormControlElement::HTMLFormControlElement): 18 (WebCore::HTMLFormControlElement::parseMappedAttribute): 19 (WebCore::HTMLFormControlElement::insertedIntoTree): 20 (WebCore::HTMLFormControlElement::removedFromTree): 21 (WebCore::HTMLFormControlElement::formDestroyed): 22 (WebCore::HTMLFormControlElement::willValidate): Avoids function calls. 23 (WebCore::HTMLFormControlElement::setNeedsWillValidateCheck): 24 (WebCore::HTMLFormControlElement::setNeedsValidityCheck): 25 * html/HTMLFormControlElement.h: 26 (WebCore::HTMLFormControlElement::disabled): Move the code from .cpp. 27 * html/HTMLInputElement.cpp: 28 (WebCore::HTMLInputElement::setInputType): 29 (WebCore::HTMLInputElement::parseMappedAttribute): 30 (WebCore::HTMLInputElement::setValue): 31 (WebCore::HTMLInputElement::setValueFromRenderer): 32 (WebCore::HTMLInputElement::setFileListFromRenderer): 33 * html/HTMLTextAreaElement.cpp: 34 (WebCore::HTMLTextAreaElement::parseMappedAttribute): 35 (WebCore::HTMLTextAreaElement::setValue): 36 * rendering/RenderTextControlMultiLine.cpp: 37 (WebCore::RenderTextControlMultiLine::subtreeHasChanged): 38 1 39 2010-02-02 Roland Steiner <rolandsteiner@chromium.org> 2 40 -
trunk/WebCore/html/HTMLFormControlElement.cpp
r52967 r54274 53 53 : HTMLElement(tagName, doc) 54 54 , m_form(f) 55 , m_hasName(false) 55 56 , m_disabled(false) 56 57 , m_readOnly(false) … … 90 91 void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) 91 92 { 93 bool oldWillValidate = willValidate(); 92 94 if (attr->name() == nameAttr) 93 setNeedsStyleRecalc();95 m_hasName = !attr->isEmpty(); 94 96 else if (attr->name() == disabledAttr) { 95 97 bool oldDisabled = m_disabled; … … 115 117 } else 116 118 HTMLElement::parseMappedAttribute(attr); 119 if (oldWillValidate != willValidate()) 120 setNeedsWillValidateCheck(); 117 121 } 118 122 … … 150 154 // and so we don't need to do anything. 151 155 m_form = findFormAncestor(); 152 if (m_form) 156 if (m_form) { 153 157 m_form->registerFormElement(this); 154 else 158 setNeedsWillValidateCheck(); 159 } else 155 160 document()->checkedRadioButtons().addButton(this); 156 161 } … … 179 184 m_form->removeFormElement(this); 180 185 m_form = 0; 186 setNeedsWillValidateCheck(); 181 187 } 182 188 183 189 HTMLElement::removedFromTree(deep); 190 } 191 192 void HTMLFormControlElement::formDestroyed() 193 { 194 if (m_form) 195 setNeedsWillValidateCheck(); 196 m_form = 0; 184 197 } 185 198 … … 198 211 { 199 212 dispatchEvent(Event::create(eventNames().changeEvent, true, false)); 200 }201 202 bool HTMLFormControlElement::disabled() const203 {204 return m_disabled;205 213 } 206 214 … … 298 306 // The control does not have a datalist element as an ancestor. 299 307 // The control is not an output element. 300 return form() && !name().isEmpty() && !disabled() && !isReadOnlyFormControl();308 return m_form && m_hasName && !m_disabled && !m_readOnly; 301 309 } 302 310 … … 304 312 { 305 313 return validity()->validationMessage(); 314 } 315 316 void HTMLFormControlElement::setNeedsWillValidateCheck() 317 { 318 setNeedsStyleRecalc(); 319 // FIXME: Show/hide a validation message. 306 320 } 307 321 … … 316 330 } 317 331 318 void HTMLFormControlElement:: updateValidity()332 void HTMLFormControlElement::setNeedsValidityCheck() 319 333 { 320 334 if (willValidate()) { … … 322 336 setNeedsStyleRecalc(); 323 337 } 338 // FIXME: show/hide a validation message. 324 339 } 325 340 -
trunk/WebCore/html/HTMLFormControlElement.h
r53709 r54274 64 64 virtual void dispatchFormControlChangeEvent(); 65 65 66 bool disabled() const ;66 bool disabled() const { return m_disabled; } 67 67 void setDisabled(bool); 68 68 … … 110 110 String validationMessage(); 111 111 bool checkValidity(); 112 void updateValidity(); 112 // This must be called when a validation constraint or control value is changed. 113 void setNeedsValidityCheck(); 113 114 void setCustomValidity(const String&); 114 115 virtual bool valueMissing() const { return false; } … … 116 117 virtual bool tooLong() const { return false; } 117 118 118 void formDestroyed() { m_form = 0; }119 void formDestroyed(); 119 120 120 121 virtual void dispatchFocusEvent(); … … 123 124 protected: 124 125 void removeFromForm(); 126 // This must be called any time the result of willValidate() has changed. 127 void setNeedsWillValidateCheck(); 125 128 126 129 private: … … 131 134 HTMLFormElement* m_form; 132 135 OwnPtr<ValidityState> m_validityState; 136 bool m_hasName : 1; 133 137 bool m_disabled : 1; 134 138 bool m_readOnly : 1; -
trunk/WebCore/html/HTMLInputElement.cpp
r54271 r54274 714 714 // field's value to something like /etc/passwd and then change it to a file field. 715 715 if (inputType() != newType) { 716 bool oldWillValidate = willValidate(); 716 717 if (newType == FILE && m_haveType) 717 718 // Set the attribute back to the old value. … … 770 771 } 771 772 773 setNeedsValidityCheck(); 774 if (oldWillValidate != willValidate()) 775 setNeedsWillValidateCheck(); 772 776 InputElement::notifyFormStateChanged(this); 773 updateValidity();774 777 } 775 778 m_haveType = true; … … 993 996 setNeedsStyleRecalc(); 994 997 setFormControlValueMatchesRenderer(false); 995 updateValidity();998 setNeedsValidityCheck(); 996 999 } else if (attr->name() == checkedAttr) { 997 1000 m_defaultChecked = !attr->isNull(); … … 1000 1003 m_useDefaultChecked = true; 1001 1004 } 1002 updateValidity();1003 } else if (attr->name() == maxlengthAttr) 1005 setNeedsValidityCheck(); 1006 } else if (attr->name() == maxlengthAttr) { 1004 1007 InputElement::parseMaxLengthAttribute(m_data, this, this, attr); 1005 else if (attr->name() == sizeAttr) 1008 setNeedsValidityCheck(); 1009 } else if (attr->name() == sizeAttr) 1006 1010 InputElement::parseSizeAttribute(m_data, this, attr); 1007 1011 else if (attr->name() == altAttr) { … … 1047 1051 } 1048 1052 setNeedsStyleRecalc(); 1049 } else if (attr->name() == autosaveAttr || 1050 attr->name() == incrementalAttr || 1051 attr->name() == minAttr || 1052 attr->name() == maxAttr || 1053 attr->name() == multipleAttr || 1054 attr->name() == precisionAttr) 1053 } else if (attr->name() == autosaveAttr 1054 || attr->name() == incrementalAttr) 1055 1055 setNeedsStyleRecalc(); 1056 else if (attr->name() == patternAttr) 1057 updateValidity(); 1056 else if (attr->name() == minAttr 1057 || attr->name() == maxAttr 1058 || attr->name() == multipleAttr 1059 || attr->name() == patternAttr 1060 || attr->name() == precisionAttr 1061 || attr->name() == stepAttr) 1062 setNeedsValidityCheck(); 1058 1063 #if ENABLE(DATALIST) 1059 1064 else if (attr->name() == listAttr) … … 1497 1502 1498 1503 InputElement::notifyFormStateChanged(this); 1499 updateValidity();1504 setNeedsValidityCheck(); 1500 1505 } 1501 1506 … … 1771 1776 updatePlaceholderVisibility(false); 1772 1777 InputElement::setValueFromRenderer(m_data, this, this, value); 1773 updateValidity();1778 setNeedsValidityCheck(); 1774 1779 } 1775 1780 … … 1783 1788 setFormControlValueMatchesRenderer(true); 1784 1789 InputElement::notifyFormStateChanged(this); 1785 updateValidity();1790 setNeedsValidityCheck(); 1786 1791 } 1787 1792 -
trunk/WebCore/html/HTMLTextAreaElement.cpp
r53132 r54274 151 151 // Don't map 'align' attribute. This matches what Firefox, Opera and IE do. 152 152 // See http://bugs.webkit.org/show_bug.cgi?id=7075 153 } else 153 } else if (attr->name() == maxlengthAttr) 154 setNeedsValidityCheck(); 155 else 154 156 HTMLTextFormControlElement::parseMappedAttribute(attr); 155 157 } … … 298 300 } 299 301 300 setNeeds StyleRecalc();302 setNeedsValidityCheck(); 301 303 notifyFormStateChanged(this); 302 updateValidity();303 304 } 304 305 -
trunk/WebCore/rendering/RenderTextControlMultiLine.cpp
r50675 r54274 48 48 HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node()); 49 49 textArea->setFormControlValueMatchesRenderer(false); 50 textArea-> updateValidity();50 textArea->setNeedsValidityCheck(); 51 51 52 52 if (!node()->focused())
Note: See TracChangeset
for help on using the changeset viewer.