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 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this) { | 178 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this) { |
179 // We might want to call blur(), but it's dangerous to dispatch events | 179 // We might want to call blur(), but it's dangerous to dispatch events |
180 // here. | 180 // here. |
181 document().setNeedsFocusedElementCheck(); | 181 document().setNeedsFocusedElementCheck(); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 void HTMLFormControlElement::requiredAttributeChanged() | 185 void HTMLFormControlElement::requiredAttributeChanged() |
186 { | 186 { |
187 setNeedsValidityCheck(); | 187 setNeedsValidityCheck(); |
188 // Style recalculation is needed because style selectors may include | 188 pseudoStateChanged(CSSSelector::PseudoRequired); |
189 // :required and :optional pseudo-classes. | 189 pseudoStateChanged(CSSSelector::PseudoOptional); |
tkent
2014/10/27 01:47:19
Are they enough? Updating |required| attribute ca
tkent
2014/10/27 01:53:05
Ignore the comment. We calls setNeedsValidityChec
| |
190 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fromAtt ribute(requiredAttr)); | |
191 } | 190 } |
192 | 191 |
193 bool HTMLFormControlElement::supportsAutofocus() const | 192 bool HTMLFormControlElement::supportsAutofocus() const |
194 { | 193 { |
195 return false; | 194 return false; |
196 } | 195 } |
197 | 196 |
198 bool HTMLFormControlElement::isAutofocusable() const | 197 bool HTMLFormControlElement::isAutofocusable() const |
199 { | 198 { |
200 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); | 199 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 { | 283 { |
285 HTMLFormElement* form = formOwner(); | 284 HTMLFormElement* form = formOwner(); |
286 if (form) | 285 if (form) |
287 form->setNeedsValidityCheck(); | 286 form->setNeedsValidityCheck(); |
288 } | 287 } |
289 | 288 |
290 void HTMLFormControlElement::fieldSetAncestorsSetNeedsValidityCheck(Node* node) | 289 void HTMLFormControlElement::fieldSetAncestorsSetNeedsValidityCheck(Node* node) |
291 { | 290 { |
292 if (!node) | 291 if (!node) |
293 return; | 292 return; |
294 HTMLFieldSetElement* fieldSet = Traversal<HTMLFieldSetElement>::firstAncesto rOrSelf(*node); | 293 for (HTMLFieldSetElement* fieldSet = Traversal<HTMLFieldSetElement>::firstAn cestorOrSelf(*node); fieldSet; fieldSet = Traversal<HTMLFieldSetElement>::firstA ncestor(*fieldSet)) |
295 HTMLFieldSetElement* lastFieldSet = 0; | 294 fieldSet->setNeedsValidityCheck(); |
296 while (fieldSet) { | |
297 lastFieldSet = fieldSet; | |
298 fieldSet = Traversal<HTMLFieldSetElement>::firstAncestor(*fieldSet); | |
299 } | |
300 if (lastFieldSet) | |
301 lastFieldSet->setNeedsValidityCheck(); | |
302 } | 295 } |
303 | 296 |
304 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan ged) | 297 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan ged) |
305 { | 298 { |
306 m_wasChangedSinceLastFormControlChangeEvent = changed; | 299 m_wasChangedSinceLastFormControlChangeEvent = changed; |
307 } | 300 } |
308 | 301 |
309 void HTMLFormControlElement::dispatchChangeEvent() | 302 void HTMLFormControlElement::dispatchChangeEvent() |
310 { | 303 { |
311 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); | 304 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 return m_isValid; | 554 return m_isValid; |
562 } | 555 } |
563 | 556 |
564 void HTMLFormControlElement::setNeedsValidityCheck() | 557 void HTMLFormControlElement::setNeedsValidityCheck() |
565 { | 558 { |
566 bool newIsValid = valid(); | 559 bool newIsValid = valid(); |
567 if (willValidate() && newIsValid != m_isValid) { | 560 if (willValidate() && newIsValid != m_isValid) { |
568 formOwnerSetNeedsValidityCheck(); | 561 formOwnerSetNeedsValidityCheck(); |
569 fieldSetAncestorsSetNeedsValidityCheck(parentNode()); | 562 fieldSetAncestorsSetNeedsValidityCheck(parentNode()); |
570 // Update style for pseudo classes such as :valid :invalid. | 563 // Update style for pseudo classes such as :valid :invalid. |
571 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid)) ; | 564 pseudoStateChanged(CSSSelector::PseudoValid); |
565 pseudoStateChanged(CSSSelector::PseudoInvalid); | |
572 } | 566 } |
573 m_isValid = newIsValid; | 567 m_isValid = newIsValid; |
574 | 568 |
575 // Updates only if this control already has a validation message. | 569 // Updates only if this control already has a validation message. |
576 if (isValidationMessageVisible()) { | 570 if (isValidationMessageVisible()) { |
577 // Calls updateVisibleValidationMessage() even if m_isValid is not | 571 // Calls updateVisibleValidationMessage() even if m_isValid is not |
578 // changed because a validation message can be changed. | 572 // changed because a validation message can be changed. |
579 updateVisibleValidationMessage(); | 573 updateVisibleValidationMessage(); |
580 } | 574 } |
581 } | 575 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 | 616 |
623 void HTMLFormControlElement::setFocus(bool flag) | 617 void HTMLFormControlElement::setFocus(bool flag) |
624 { | 618 { |
625 LabelableElement::setFocus(flag); | 619 LabelableElement::setFocus(flag); |
626 | 620 |
627 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 621 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
628 dispatchFormControlChangeEvent(); | 622 dispatchFormControlChangeEvent(); |
629 } | 623 } |
630 | 624 |
631 } // namespace blink | 625 } // namespace blink |
OLD | NEW |