| 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 * | 10 * |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return m_inputType->placeholderElement(); | 171 return m_inputType->placeholderElement(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool HTMLInputElement::shouldAutocomplete() const | 174 bool HTMLInputElement::shouldAutocomplete() const |
| 175 { | 175 { |
| 176 if (m_autocomplete != Uninitialized) | 176 if (m_autocomplete != Uninitialized) |
| 177 return m_autocomplete == On; | 177 return m_autocomplete == On; |
| 178 return HTMLTextFormControlElement::shouldAutocomplete(); | 178 return HTMLTextFormControlElement::shouldAutocomplete(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void HTMLInputElement::updateCheckedRadioButtons() |
| 182 { |
| 183 checkedRadioButtons().addButton(this); |
| 184 |
| 185 if (form()) { |
| 186 const Vector<FormAssociatedElement*>& controls = form()->associatedEleme
nts(); |
| 187 for (unsigned i = 0; i < controls.size(); ++i) { |
| 188 if (!controls[i]->isFormControlElement()) |
| 189 continue; |
| 190 HTMLFormControlElement* control = static_cast<HTMLFormControlElement
*>(controls[i]); |
| 191 if (control->name() != name()) |
| 192 continue; |
| 193 if (control->type() != type()) |
| 194 continue; |
| 195 control->setNeedsValidityCheck(); |
| 196 } |
| 197 } else { |
| 198 typedef Document::FormElementListHashSet::const_iterator Iterator; |
| 199 Iterator end = document()->formElements()->end(); |
| 200 for (Iterator it = document()->formElements()->begin(); it != end; ++it)
{ |
| 201 HTMLFormControlElementWithState* control = *it; |
| 202 if (control->formControlName() != name()) |
| 203 continue; |
| 204 if (control->formControlType() != type()) |
| 205 continue; |
| 206 if (control->form()) |
| 207 continue; |
| 208 control->setNeedsValidityCheck(); |
| 209 } |
| 210 } |
| 211 } |
| 212 |
| 181 bool HTMLInputElement::isValidValue(const String& value) const | 213 bool HTMLInputElement::isValidValue(const String& value) const |
| 182 { | 214 { |
| 183 if (!m_inputType->canSetStringValue()) { | 215 if (!m_inputType->canSetStringValue()) { |
| 184 ASSERT_NOT_REACHED(); | 216 ASSERT_NOT_REACHED(); |
| 185 return false; | 217 return false; |
| 186 } | 218 } |
| 187 return !m_inputType->typeMismatchFor(value) | 219 return !m_inputType->typeMismatchFor(value) |
| 188 && !stepMismatch(value) | 220 && !stepMismatch(value) |
| 189 && !rangeUnderflow(value) | 221 && !rangeUnderflow(value) |
| 190 && !rangeOverflow(value) | 222 && !rangeOverflow(value) |
| 191 && !tooLong(value, IgnoreDirtyFlag) | 223 && !tooLong(value, IgnoreDirtyFlag) |
| 192 && !patternMismatch(value) | 224 && !patternMismatch(value) |
| 193 && !valueMissing(value); | 225 && !valueMissing(value); |
| 194 } | 226 } |
| 195 | 227 |
| 196 bool HTMLInputElement::typeMismatch() const | 228 bool HTMLInputElement::typeMismatch() const |
| 197 { | 229 { |
| 198 return m_inputType->typeMismatch(); | 230 return m_inputType->typeMismatch(); |
| 199 } | 231 } |
| 200 | 232 |
| 201 bool HTMLInputElement::valueMissing(const String& value) const | 233 bool HTMLInputElement::valueMissing(const String& value) const |
| 202 { | 234 { |
| 235 if (!isRequiredFormControl() || readOnly() || disabled()) |
| 236 return false; |
| 203 return m_inputType->valueMissing(value); | 237 return m_inputType->valueMissing(value); |
| 204 } | 238 } |
| 205 | 239 |
| 206 bool HTMLInputElement::patternMismatch(const String& value) const | 240 bool HTMLInputElement::patternMismatch(const String& value) const |
| 207 { | 241 { |
| 208 return m_inputType->patternMismatch(value); | 242 return m_inputType->patternMismatch(value); |
| 209 } | 243 } |
| 210 | 244 |
| 211 bool HTMLInputElement::tooLong(const String& value, NeedsToCheckDirtyFlag check)
const | 245 bool HTMLInputElement::tooLong(const String& value, NeedsToCheckDirtyFlag check)
const |
| 212 { | 246 { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 bool HTMLInputElement::isTextType() const | 945 bool HTMLInputElement::isTextType() const |
| 912 { | 946 { |
| 913 return m_inputType->isTextType(); | 947 return m_inputType->isTextType(); |
| 914 } | 948 } |
| 915 | 949 |
| 916 void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent) | 950 void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent) |
| 917 { | 951 { |
| 918 if (checked() == nowChecked) | 952 if (checked() == nowChecked) |
| 919 return; | 953 return; |
| 920 | 954 |
| 955 checkedRadioButtons().removeButton(this); |
| 956 |
| 921 m_reflectsCheckedAttribute = false; | 957 m_reflectsCheckedAttribute = false; |
| 922 m_isChecked = nowChecked; | 958 m_isChecked = nowChecked; |
| 923 setNeedsStyleRecalc(); | 959 setNeedsStyleRecalc(); |
| 924 if (isRadioButton()) | 960 if (isRadioButton()) |
| 925 checkedRadioButtons().updateCheckedState(this); | 961 updateCheckedRadioButtons(); |
| 926 if (renderer() && renderer()->style()->hasAppearance()) | 962 if (renderer() && renderer()->style()->hasAppearance()) |
| 927 renderer()->theme()->stateChanged(renderer(), CheckedState); | 963 renderer()->theme()->stateChanged(renderer(), CheckedState); |
| 928 setNeedsValidityCheck(); | 964 setNeedsValidityCheck(); |
| 929 | 965 |
| 930 // Ideally we'd do this from the render tree (matching | 966 // Ideally we'd do this from the render tree (matching |
| 931 // RenderTextView), but it's not possible to do it at the moment | 967 // RenderTextView), but it's not possible to do it at the moment |
| 932 // because of the way the code is structured. | 968 // because of the way the code is structured. |
| 933 if (renderer() && AXObjectCache::accessibilityEnabled()) | 969 if (renderer() && AXObjectCache::accessibilityEnabled()) |
| 934 renderer()->document()->axObjectCache()->checkedStateChanged(renderer())
; | 970 renderer()->document()->axObjectCache()->checkedStateChanged(renderer())
; |
| 935 | 971 |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); | 1542 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); |
| 1507 | 1543 |
| 1508 addSubresourceURL(urls, src()); | 1544 addSubresourceURL(urls, src()); |
| 1509 } | 1545 } |
| 1510 | 1546 |
| 1511 bool HTMLInputElement::recalcWillValidate() const | 1547 bool HTMLInputElement::recalcWillValidate() const |
| 1512 { | 1548 { |
| 1513 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca
lcWillValidate(); | 1549 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca
lcWillValidate(); |
| 1514 } | 1550 } |
| 1515 | 1551 |
| 1516 void HTMLInputElement::requiredAttributeChanged() | |
| 1517 { | |
| 1518 HTMLTextFormControlElement::requiredAttributeChanged(); | |
| 1519 checkedRadioButtons().requiredAttributeChanged(this); | |
| 1520 } | |
| 1521 | |
| 1522 #if ENABLE(INPUT_COLOR) | 1552 #if ENABLE(INPUT_COLOR) |
| 1523 void HTMLInputElement::selectColorInColorChooser(const Color& color) | 1553 void HTMLInputElement::selectColorInColorChooser(const Color& color) |
| 1524 { | 1554 { |
| 1525 if (!m_inputType->isColorControl()) | 1555 if (!m_inputType->isColorControl()) |
| 1526 return; | 1556 return; |
| 1527 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color); | 1557 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color); |
| 1528 } | 1558 } |
| 1529 #endif | 1559 #endif |
| 1530 | 1560 |
| 1531 #if ENABLE(DATALIST) | 1561 #if ENABLE(DATALIST) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 if (newValue != m_valueIfDirty) | 1854 if (newValue != m_valueIfDirty) |
| 1825 setValue(newValue); | 1855 setValue(newValue); |
| 1826 } | 1856 } |
| 1827 | 1857 |
| 1828 String HTMLInputElement::defaultToolTip() const | 1858 String HTMLInputElement::defaultToolTip() const |
| 1829 { | 1859 { |
| 1830 return m_inputType->defaultToolTip(); | 1860 return m_inputType->defaultToolTip(); |
| 1831 } | 1861 } |
| 1832 | 1862 |
| 1833 } // namespace | 1863 } // namespace |
| OLD | NEW |