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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 HTMLElement::didMoveToNewDocument(oldDocument); | 246 HTMLElement::didMoveToNewDocument(oldDocument); |
247 } | 247 } |
248 | 248 |
249 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Containe
rNode* insertionPoint) | 249 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Containe
rNode* insertionPoint) |
250 { | 250 { |
251 m_ancestorDisabledState = AncestorDisabledStateUnknown; | 251 m_ancestorDisabledState = AncestorDisabledStateUnknown; |
252 m_dataListAncestorState = Unknown; | 252 m_dataListAncestorState = Unknown; |
253 setNeedsWillValidateCheck(); | 253 setNeedsWillValidateCheck(); |
254 HTMLElement::insertedInto(insertionPoint); | 254 HTMLElement::insertedInto(insertionPoint); |
255 FormAssociatedElement::insertedInto(insertionPoint); | 255 FormAssociatedElement::insertedInto(insertionPoint); |
| 256 fieldSetAncestorsSetNeedsValidityCheck(insertionPoint); |
256 return InsertionDone; | 257 return InsertionDone; |
257 } | 258 } |
258 | 259 |
259 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) | 260 void HTMLFormControlElement::removedFrom(ContainerNode* insertionPoint) |
260 { | 261 { |
| 262 fieldSetAncestorsSetNeedsValidityCheck(insertionPoint); |
261 hideVisibleValidationMessage(); | 263 hideVisibleValidationMessage(); |
262 m_hasValidationMessage = false; | 264 m_hasValidationMessage = false; |
263 m_ancestorDisabledState = AncestorDisabledStateUnknown; | 265 m_ancestorDisabledState = AncestorDisabledStateUnknown; |
264 m_dataListAncestorState = Unknown; | 266 m_dataListAncestorState = Unknown; |
265 HTMLElement::removedFrom(insertionPoint); | 267 HTMLElement::removedFrom(insertionPoint); |
266 FormAssociatedElement::removedFrom(insertionPoint); | 268 FormAssociatedElement::removedFrom(insertionPoint); |
267 } | 269 } |
268 | 270 |
269 void HTMLFormControlElement::willChangeForm() | 271 void HTMLFormControlElement::willChangeForm() |
270 { | 272 { |
271 formOwnerSetNeedsValidityCheck(); | 273 formOwnerSetNeedsValidityCheck(); |
272 FormAssociatedElement::willChangeForm(); | 274 FormAssociatedElement::willChangeForm(); |
273 } | 275 } |
274 | 276 |
275 void HTMLFormControlElement::didChangeForm() | 277 void HTMLFormControlElement::didChangeForm() |
276 { | 278 { |
277 formOwnerSetNeedsValidityCheck(); | 279 formOwnerSetNeedsValidityCheck(); |
278 FormAssociatedElement::didChangeForm(); | 280 FormAssociatedElement::didChangeForm(); |
279 } | 281 } |
280 | 282 |
281 void HTMLFormControlElement::formOwnerSetNeedsValidityCheck() | 283 void HTMLFormControlElement::formOwnerSetNeedsValidityCheck() |
282 { | 284 { |
283 HTMLFormElement* form = formOwner(); | 285 HTMLFormElement* form = formOwner(); |
284 if (form) | 286 if (form) |
285 form->setNeedsValidityCheck(); | 287 form->setNeedsValidityCheck(); |
286 } | 288 } |
287 | 289 |
| 290 void HTMLFormControlElement::fieldSetAncestorsSetNeedsValidityCheck(Node* node) |
| 291 { |
| 292 if (!node) |
| 293 return; |
| 294 HTMLFieldSetElement* fieldSet = Traversal<HTMLFieldSetElement>::firstAncesto
rOrSelf(*node); |
| 295 HTMLFieldSetElement* lastFieldSet = 0; |
| 296 while (fieldSet) { |
| 297 lastFieldSet = fieldSet; |
| 298 fieldSet = Traversal<HTMLFieldSetElement>::firstAncestor(*fieldSet); |
| 299 } |
| 300 if (lastFieldSet) |
| 301 lastFieldSet->setNeedsValidityCheck(); |
| 302 } |
| 303 |
288 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan
ged) | 304 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool chan
ged) |
289 { | 305 { |
290 m_wasChangedSinceLastFormControlChangeEvent = changed; | 306 m_wasChangedSinceLastFormControlChangeEvent = changed; |
291 } | 307 } |
292 | 308 |
293 void HTMLFormControlElement::dispatchChangeEvent() | 309 void HTMLFormControlElement::dispatchChangeEvent() |
294 { | 310 { |
295 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); | 311 dispatchScopedEvent(Event::createBubble(EventTypeNames::change)); |
296 } | 312 } |
297 | 313 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // correctly when something which changes validity is updated. | 528 // correctly when something which changes validity is updated. |
513 ASSERT(m_isValid == valid()); | 529 ASSERT(m_isValid == valid()); |
514 return m_isValid; | 530 return m_isValid; |
515 } | 531 } |
516 | 532 |
517 void HTMLFormControlElement::setNeedsValidityCheck() | 533 void HTMLFormControlElement::setNeedsValidityCheck() |
518 { | 534 { |
519 bool newIsValid = valid(); | 535 bool newIsValid = valid(); |
520 if (willValidate() && newIsValid != m_isValid) { | 536 if (willValidate() && newIsValid != m_isValid) { |
521 formOwnerSetNeedsValidityCheck(); | 537 formOwnerSetNeedsValidityCheck(); |
| 538 fieldSetAncestorsSetNeedsValidityCheck(parentNode()); |
522 // Update style for pseudo classes such as :valid :invalid. | 539 // Update style for pseudo classes such as :valid :invalid. |
523 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid))
; | 540 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid))
; |
524 } | 541 } |
525 m_isValid = newIsValid; | 542 m_isValid = newIsValid; |
526 | 543 |
527 // Updates only if this control already has a validation message. | 544 // Updates only if this control already has a validation message. |
528 if (isValidationMessageVisible()) { | 545 if (isValidationMessageVisible()) { |
529 // Calls updateVisibleValidationMessage() even if m_isValid is not | 546 // Calls updateVisibleValidationMessage() even if m_isValid is not |
530 // changed because a validation message can be changed. | 547 // changed because a validation message can be changed. |
531 updateVisibleValidationMessage(); | 548 updateVisibleValidationMessage(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 591 |
575 void HTMLFormControlElement::setFocus(bool flag) | 592 void HTMLFormControlElement::setFocus(bool flag) |
576 { | 593 { |
577 LabelableElement::setFocus(flag); | 594 LabelableElement::setFocus(flag); |
578 | 595 |
579 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 596 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
580 dispatchFormControlChangeEvent(); | 597 dispatchFormControlChangeEvent(); |
581 } | 598 } |
582 | 599 |
583 } // namespace blink | 600 } // namespace blink |
OLD | NEW |