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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) | 259 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) |
260 { | 260 { |
261 hideVisibleValidationMessage(); | 261 hideVisibleValidationMessage(); |
262 m_hasValidationMessage = false; | 262 m_hasValidationMessage = false; |
263 m_ancestorDisabledState = AncestorDisabledStateUnknown; | 263 m_ancestorDisabledState = AncestorDisabledStateUnknown; |
264 m_dataListAncestorState = Unknown; | 264 m_dataListAncestorState = Unknown; |
265 HTMLElement::removedFrom(insertionPoint); | 265 HTMLElement::removedFrom(insertionPoint); |
266 FormAssociatedElement::removedFrom(insertionPoint); | 266 FormAssociatedElement::removedFrom(insertionPoint); |
267 } | 267 } |
268 | 268 |
| 269 void HTMLFormControlElement::willChangeForm() |
| 270 { |
| 271 formOwnerSetNeedsValidityCheck(); |
| 272 FormAssociatedElement::willChangeForm(); |
| 273 } |
| 274 |
| 275 void HTMLFormControlElement::didChangeForm() |
| 276 { |
| 277 formOwnerSetNeedsValidityCheck(); |
| 278 FormAssociatedElement::didChangeForm(); |
| 279 } |
| 280 |
| 281 void HTMLFormControlElement::formOwnerSetNeedsValidityCheck() |
| 282 { |
| 283 HTMLFormElement* form = formOwner(); |
| 284 if (form) |
| 285 form->setNeedsValidityCheck(); |
| 286 } |
| 287 |
269 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan
ged) | 288 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan
ged) |
270 { | 289 { |
271 m_wasChangedSinceLastFormControlChangeEvent = changed; | 290 m_wasChangedSinceLastFormControlChangeEvent = changed; |
272 } | 291 } |
273 | 292 |
274 void HTMLFormControlElement::dispatchChangeEvent() | 293 void HTMLFormControlElement::dispatchChangeEvent() |
275 { | 294 { |
276 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); | 295 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); |
277 } | 296 } |
278 | 297 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 { | 481 { |
463 Page* page = document().page(); | 482 Page* page = document().page(); |
464 if (!page) | 483 if (!page) |
465 return 0; | 484 return 0; |
466 | 485 |
467 return &page->validationMessageClient(); | 486 return &page->validationMessageClient(); |
468 } | 487 } |
469 | 488 |
470 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F
ormAssociatedElement> >* unhandledInvalidControls) | 489 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F
ormAssociatedElement> >* unhandledInvalidControls) |
471 { | 490 { |
472 if (!willValidate() || isValidFormControlElement()) | 491 if (!willValidate() || isValidElement()) |
473 return true; | 492 return true; |
474 // An event handler can deref this object. | 493 // An event handler can deref this object. |
475 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 494 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); |
476 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 495 RefPtrWillBeRawPtr<Document> originalDocument(document()); |
477 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); | 496 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); |
478 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) | 497 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) |
479 unhandledInvalidControls->append(this); | 498 unhandledInvalidControls->append(this); |
480 return false; | 499 return false; |
481 } | 500 } |
482 | 501 |
483 bool HTMLFormControlElement::isValidFormControlElement() | 502 bool HTMLFormControlElement::matchesValidityPseudoClasses() const |
| 503 { |
| 504 return willValidate(); |
| 505 } |
| 506 |
| 507 bool HTMLFormControlElement::isValidElement() |
484 { | 508 { |
485 // If the following assertion fails, setNeedsValidityCheck() is not called | 509 // If the following assertion fails, setNeedsValidityCheck() is not called |
486 // correctly when something which changes validity is updated. | 510 // correctly when something which changes validity is updated. |
487 ASSERT(m_isValid == valid()); | 511 ASSERT(m_isValid == valid()); |
488 return m_isValid; | 512 return m_isValid; |
489 } | 513 } |
490 | 514 |
491 void HTMLFormControlElement::setNeedsValidityCheck() | 515 void HTMLFormControlElement::setNeedsValidityCheck() |
492 { | 516 { |
493 bool newIsValid = valid(); | 517 bool newIsValid = valid(); |
494 if (willValidate() && newIsValid != m_isValid) { | 518 if (willValidate() && newIsValid != m_isValid) { |
| 519 formOwnerSetNeedsValidityCheck(); |
495 // Update style for pseudo classes such as :valid :invalid. | 520 // Update style for pseudo classes such as :valid :invalid. |
496 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid))
; | 521 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid))
; |
497 } | 522 } |
498 m_isValid = newIsValid; | 523 m_isValid = newIsValid; |
499 | 524 |
500 // Updates only if this control already has a validation message. | 525 // Updates only if this control already has a validation message. |
501 if (isValidationMessageVisible()) { | 526 if (isValidationMessageVisible()) { |
502 // Calls updateVisibleValidationMessage() even if m_isValid is not | 527 // Calls updateVisibleValidationMessage() even if m_isValid is not |
503 // changed because a validation message can be changed. | 528 // changed because a validation message can be changed. |
504 updateVisibleValidationMessage(); | 529 updateVisibleValidationMessage(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 572 |
548 void HTMLFormControlElement::setFocus(bool flag) | 573 void HTMLFormControlElement::setFocus(bool flag) |
549 { | 574 { |
550 LabelableElement::setFocus(flag); | 575 LabelableElement::setFocus(flag); |
551 | 576 |
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 577 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
553 dispatchFormControlChangeEvent(); | 578 dispatchFormControlChangeEvent(); |
554 } | 579 } |
555 | 580 |
556 } // namespace blink | 581 } // namespace blink |
OLD | NEW |