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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 if (shouldAutofocusOnAttach(this)) | 239 if (shouldAutofocusOnAttach(this)) |
240 document().setAutofocusElement(this); | 240 document().setAutofocusElement(this); |
241 } | 241 } |
242 | 242 |
243 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) | 243 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) |
244 { | 244 { |
245 FormAssociatedElement::didMoveToNewDocument(oldDocument); | 245 FormAssociatedElement::didMoveToNewDocument(oldDocument); |
246 HTMLElement::didMoveToNewDocument(oldDocument); | 246 HTMLElement::didMoveToNewDocument(oldDocument); |
247 } | 247 } |
248 | 248 |
249 void HTMLFormControlElement::formOwnerSetNeedsValidityCheck() | |
250 { | |
251 HTMLFormElement* form = formOwner(); | |
252 if (form) | |
253 form->setNeedsValidityCheck(); | |
254 } | |
255 | |
249 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Containe rNode* insertionPoint) | 256 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Containe rNode* insertionPoint) |
250 { | 257 { |
251 m_ancestorDisabledState = AncestorDisabledStateUnknown; | 258 m_ancestorDisabledState = AncestorDisabledStateUnknown; |
252 m_dataListAncestorState = Unknown; | 259 m_dataListAncestorState = Unknown; |
253 setNeedsWillValidateCheck(); | 260 setNeedsWillValidateCheck(); |
254 HTMLElement::insertedInto(insertionPoint); | 261 HTMLElement::insertedInto(insertionPoint); |
255 FormAssociatedElement::insertedInto(insertionPoint); | 262 FormAssociatedElement::insertedInto(insertionPoint); |
263 | |
264 formOwnerSetNeedsValidityCheck(); | |
keishi
2014/10/03 06:34:41
I'm sorry. I told you to put it here yesterday but
Bartek Nowierski
2014/10/03 07:16:57
That makes sense! I added a test for that too.
keishi
2014/10/03 08:01:59
Thanks!
| |
265 | |
256 return InsertionDone; | 266 return InsertionDone; |
257 } | 267 } |
258 | 268 |
259 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) | 269 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) |
260 { | 270 { |
271 formOwnerSetNeedsValidityCheck(); | |
272 | |
261 hideVisibleValidationMessage(); | 273 hideVisibleValidationMessage(); |
262 m_hasValidationMessage = false; | 274 m_hasValidationMessage = false; |
263 m_ancestorDisabledState = AncestorDisabledStateUnknown; | 275 m_ancestorDisabledState = AncestorDisabledStateUnknown; |
264 m_dataListAncestorState = Unknown; | 276 m_dataListAncestorState = Unknown; |
265 HTMLElement::removedFrom(insertionPoint); | 277 HTMLElement::removedFrom(insertionPoint); |
266 FormAssociatedElement::removedFrom(insertionPoint); | 278 FormAssociatedElement::removedFrom(insertionPoint); |
267 } | 279 } |
268 | 280 |
269 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan ged) | 281 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan ged) |
270 { | 282 { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 { | 474 { |
463 Page* page = document().page(); | 475 Page* page = document().page(); |
464 if (!page) | 476 if (!page) |
465 return 0; | 477 return 0; |
466 | 478 |
467 return &page->validationMessageClient(); | 479 return &page->validationMessageClient(); |
468 } | 480 } |
469 | 481 |
470 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F ormAssociatedElement> >* unhandledInvalidControls) | 482 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F ormAssociatedElement> >* unhandledInvalidControls) |
471 { | 483 { |
472 if (!willValidate() || isValidFormControlElement()) | 484 if (!willValidate() || isValidElement()) |
473 return true; | 485 return true; |
474 // An event handler can deref this object. | 486 // An event handler can deref this object. |
475 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 487 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); |
476 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 488 RefPtrWillBeRawPtr<Document> originalDocument(document()); |
477 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); | 489 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); |
478 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) | 490 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) |
479 unhandledInvalidControls->append(this); | 491 unhandledInvalidControls->append(this); |
480 return false; | 492 return false; |
481 } | 493 } |
482 | 494 |
483 bool HTMLFormControlElement::isValidFormControlElement() | 495 bool HTMLFormControlElement::isValidElement() |
484 { | 496 { |
485 // If the following assertion fails, setNeedsValidityCheck() is not called | 497 // If the following assertion fails, setNeedsValidityCheck() is not called |
486 // correctly when something which changes validity is updated. | 498 // correctly when something which changes validity is updated. |
487 ASSERT(m_isValid == valid()); | 499 ASSERT(m_isValid == valid()); |
488 return m_isValid; | 500 return m_isValid; |
489 } | 501 } |
490 | 502 |
491 void HTMLFormControlElement::setNeedsValidityCheck() | 503 void HTMLFormControlElement::setNeedsValidityCheck() |
492 { | 504 { |
493 bool newIsValid = valid(); | 505 bool newIsValid = valid(); |
494 if (willValidate() && newIsValid != m_isValid) { | 506 if (willValidate() && newIsValid != m_isValid) { |
507 formOwnerSetNeedsValidityCheck(); | |
495 // Update style for pseudo classes such as :valid :invalid. | 508 // Update style for pseudo classes such as :valid :invalid. |
496 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid)) ; | 509 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid)) ; |
497 } | 510 } |
498 m_isValid = newIsValid; | 511 m_isValid = newIsValid; |
499 | 512 |
500 // Updates only if this control already has a validation message. | 513 // Updates only if this control already has a validation message. |
501 if (isValidationMessageVisible()) { | 514 if (isValidationMessageVisible()) { |
502 // Calls updateVisibleValidationMessage() even if m_isValid is not | 515 // Calls updateVisibleValidationMessage() even if m_isValid is not |
503 // changed because a validation message can be changed. | 516 // changed because a validation message can be changed. |
504 updateVisibleValidationMessage(); | 517 updateVisibleValidationMessage(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 | 560 |
548 void HTMLFormControlElement::setFocus(bool flag) | 561 void HTMLFormControlElement::setFocus(bool flag) |
549 { | 562 { |
550 LabelableElement::setFocus(flag); | 563 LabelableElement::setFocus(flag); |
551 | 564 |
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 565 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
553 dispatchFormControlChangeEvent(); | 566 dispatchFormControlChangeEvent(); |
554 } | 567 } |
555 | 568 |
556 } // namespace blink | 569 } // namespace blink |
OLD | NEW |