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 10 matching lines...) Expand all Loading... |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/html/HTMLFormControlElement.h" | 26 #include "core/html/HTMLFormControlElement.h" |
27 | 27 |
28 #include "core/dom/PostAttachCallbacks.h" | 28 #include "core/dom/PostAttachCallbacks.h" |
29 #include "core/events/Event.h" | 29 #include "core/events/Event.h" |
30 #include "core/events/ThreadLocalEventNames.h" | 30 #include "core/events/ThreadLocalEventNames.h" |
| 31 #include "core/html/HTMLDataListElement.h" |
31 #include "core/html/HTMLFieldSetElement.h" | 32 #include "core/html/HTMLFieldSetElement.h" |
32 #include "core/html/HTMLFormElement.h" | 33 #include "core/html/HTMLFormElement.h" |
33 #include "core/html/HTMLInputElement.h" | 34 #include "core/html/HTMLInputElement.h" |
34 #include "core/html/HTMLLegendElement.h" | 35 #include "core/html/HTMLLegendElement.h" |
35 #include "core/html/ValidityState.h" | 36 #include "core/html/ValidityState.h" |
36 #include "core/html/forms/ValidationMessage.h" | 37 #include "core/html/forms/ValidationMessage.h" |
37 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
38 #include "core/rendering/RenderBox.h" | 39 #include "core/rendering/RenderBox.h" |
39 #include "core/rendering/RenderTheme.h" | 40 #include "core/rendering/RenderTheme.h" |
40 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 bool HTMLFormControlElement::formNoValidate() const | 98 bool HTMLFormControlElement::formNoValidate() const |
98 { | 99 { |
99 return fastHasAttribute(formnovalidateAttr); | 100 return fastHasAttribute(formnovalidateAttr); |
100 } | 101 } |
101 | 102 |
102 void HTMLFormControlElement::updateAncestorDisabledState() const | 103 void HTMLFormControlElement::updateAncestorDisabledState() const |
103 { | 104 { |
104 HTMLFieldSetElement* fieldSetAncestor = 0; | 105 HTMLFieldSetElement* fieldSetAncestor = 0; |
105 ContainerNode* legendAncestor = 0; | 106 ContainerNode* legendAncestor = 0; |
106 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->
parentNode()) { | 107 for (HTMLElement* ancestor = Traversal<HTMLElement>::firstAncestor(*this); a
ncestor; ancestor = Traversal<HTMLElement>::firstAncestor(*ancestor)) { |
107 if (!legendAncestor && isHTMLLegendElement(*ancestor)) | 108 if (!legendAncestor && isHTMLLegendElement(*ancestor)) |
108 legendAncestor = ancestor; | 109 legendAncestor = ancestor; |
109 if (isHTMLFieldSetElement(*ancestor)) { | 110 if (isHTMLFieldSetElement(*ancestor)) { |
110 fieldSetAncestor = toHTMLFieldSetElement(ancestor); | 111 fieldSetAncestor = toHTMLFieldSetElement(ancestor); |
111 break; | 112 break; |
112 } | 113 } |
113 } | 114 } |
114 m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledF
ormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend()
)) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled; | 115 m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledF
ormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend()
)) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled; |
115 } | 116 } |
116 | 117 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 351 |
351 short HTMLFormControlElement::tabIndex() const | 352 short HTMLFormControlElement::tabIndex() const |
352 { | 353 { |
353 // Skip the supportsFocus check in HTMLElement. | 354 // Skip the supportsFocus check in HTMLElement. |
354 return Element::tabIndex(); | 355 return Element::tabIndex(); |
355 } | 356 } |
356 | 357 |
357 bool HTMLFormControlElement::recalcWillValidate() const | 358 bool HTMLFormControlElement::recalcWillValidate() const |
358 { | 359 { |
359 if (m_dataListAncestorState == Unknown) { | 360 if (m_dataListAncestorState == Unknown) { |
360 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest
or->parentNode()) { | 361 if (Traversal<HTMLDataListElement>::firstAncestor(*this)) |
361 if (isHTMLDataListElement(*ancestor)) { | 362 m_dataListAncestorState = InsideDataList; |
362 m_dataListAncestorState = InsideDataList; | 363 else |
363 break; | |
364 } | |
365 } | |
366 if (m_dataListAncestorState == Unknown) | |
367 m_dataListAncestorState = NotInsideDataList; | 364 m_dataListAncestorState = NotInsideDataList; |
368 } | 365 } |
369 return m_dataListAncestorState == NotInsideDataList && !isDisabledOrReadOnly
(); | 366 return m_dataListAncestorState == NotInsideDataList && !isDisabledOrReadOnly
(); |
370 } | 367 } |
371 | 368 |
372 bool HTMLFormControlElement::willValidate() const | 369 bool HTMLFormControlElement::willValidate() const |
373 { | 370 { |
374 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) { | 371 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) { |
375 m_willValidateInitialized = true; | 372 m_willValidateInitialized = true; |
376 bool newWillValidate = recalcWillValidate(); | 373 bool newWillValidate = recalcWillValidate(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return canBeSuccessfulSubmitButton() && !isDisabledFormControl(); | 474 return canBeSuccessfulSubmitButton() && !isDisabledFormControl(); |
478 } | 475 } |
479 | 476 |
480 bool HTMLFormControlElement::isDefaultButtonForForm() const | 477 bool HTMLFormControlElement::isDefaultButtonForForm() const |
481 { | 478 { |
482 return isSuccessfulSubmitButton() && form() && form()->defaultButton() == th
is; | 479 return isSuccessfulSubmitButton() && form() && form()->defaultButton() == th
is; |
483 } | 480 } |
484 | 481 |
485 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node
* node) | 482 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node
* node) |
486 { | 483 { |
487 for (; node; node = node->parentNode()) { | 484 if (!node || isHTMLFormControlElement(*node)) |
488 if (node->isElementNode() && toElement(node)->isFormControlElement()) | 485 return toHTMLFormControlElement(node); |
489 return toHTMLFormControlElement(node); | 486 return Traversal<HTMLFormControlElement>::firstAncestor(*node); |
490 } | |
491 return 0; | |
492 } | 487 } |
493 | 488 |
494 String HTMLFormControlElement::nameForAutofill() const | 489 String HTMLFormControlElement::nameForAutofill() const |
495 { | 490 { |
496 String fullName = name(); | 491 String fullName = name(); |
497 String trimmedName = fullName.stripWhiteSpace(); | 492 String trimmedName = fullName.stripWhiteSpace(); |
498 if (!trimmedName.isEmpty()) | 493 if (!trimmedName.isEmpty()) |
499 return trimmedName; | 494 return trimmedName; |
500 fullName = getIdAttribute(); | 495 fullName = getIdAttribute(); |
501 trimmedName = fullName.stripWhiteSpace(); | 496 trimmedName = fullName.stripWhiteSpace(); |
502 return trimmedName; | 497 return trimmedName; |
503 } | 498 } |
504 | 499 |
505 void HTMLFormControlElement::setFocus(bool flag) | 500 void HTMLFormControlElement::setFocus(bool flag) |
506 { | 501 { |
507 LabelableElement::setFocus(flag); | 502 LabelableElement::setFocus(flag); |
508 | 503 |
509 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 504 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
510 dispatchFormControlChangeEvent(); | 505 dispatchFormControlChangeEvent(); |
511 } | 506 } |
512 | 507 |
513 } // namespace Webcore | 508 } // namespace Webcore |
OLD | NEW |