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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (!m_legendAncestor && ancestor->hasTagName(legendTag)) | 109 if (!m_legendAncestor && ancestor->hasTagName(legendTag)) |
110 m_legendAncestor = static_cast<HTMLLegendElement*>(ancestor); | 110 m_legendAncestor = static_cast<HTMLLegendElement*>(ancestor); |
111 if (ancestor->hasTagName(fieldsetTag)) { | 111 if (ancestor->hasTagName(fieldsetTag)) { |
112 m_fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); | 112 m_fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); |
113 break; | 113 break; |
114 } | 114 } |
115 } | 115 } |
116 m_fieldSetAncestorValid = true; | 116 m_fieldSetAncestorValid = true; |
117 } | 117 } |
118 | 118 |
| 119 void HTMLFormControlElement::ancestorDisabledStateWasChanged() |
| 120 { |
| 121 disabledAttributeChanged(); |
| 122 } |
| 123 |
119 void HTMLFormControlElement::parseAttribute(Attribute* attr) | 124 void HTMLFormControlElement::parseAttribute(Attribute* attr) |
120 { | 125 { |
121 if (attr->name() == formAttr) | 126 if (attr->name() == formAttr) |
122 formAttributeChanged(); | 127 formAttributeChanged(); |
123 else if (attr->name() == disabledAttr) { | 128 else if (attr->name() == disabledAttr) { |
124 bool oldDisabled = m_disabled; | 129 bool oldDisabled = m_disabled; |
125 m_disabled = !attr->isNull(); | 130 m_disabled = !attr->isNull(); |
126 if (oldDisabled != m_disabled) | 131 if (oldDisabled != m_disabled) |
127 disabledAttributeChanged(); | 132 disabledAttributeChanged(); |
128 } else if (attr->name() == readonlyAttr) { | 133 } else if (attr->name() == readonlyAttr) { |
129 bool oldReadOnly = m_readOnly; | 134 bool oldReadOnly = m_readOnly; |
130 m_readOnly = !attr->isNull(); | 135 m_readOnly = !attr->isNull(); |
131 if (oldReadOnly != m_readOnly) { | 136 if (oldReadOnly != m_readOnly) { |
| 137 setNeedsWillValidateCheck(); |
132 setNeedsStyleRecalc(); | 138 setNeedsStyleRecalc(); |
133 if (renderer() && renderer()->style()->hasAppearance()) | 139 if (renderer() && renderer()->style()->hasAppearance()) |
134 renderer()->theme()->stateChanged(renderer(), ReadOnlyState); | 140 renderer()->theme()->stateChanged(renderer(), ReadOnlyState); |
135 } | 141 } |
136 } else if (attr->name() == requiredAttr) { | 142 } else if (attr->name() == requiredAttr) { |
137 bool oldRequired = m_required; | 143 bool oldRequired = m_required; |
138 m_required = !attr->isNull(); | 144 m_required = !attr->isNull(); |
139 if (oldRequired != m_required) | 145 if (oldRequired != m_required) |
140 requiredAttributeChanged(); | 146 requiredAttributeChanged(); |
141 } else | 147 } else |
142 HTMLElement::parseAttribute(attr); | 148 HTMLElement::parseAttribute(attr); |
143 setNeedsWillValidateCheck(); | |
144 } | 149 } |
145 | 150 |
146 void HTMLFormControlElement::disabledAttributeChanged() | 151 void HTMLFormControlElement::disabledAttributeChanged() |
147 { | 152 { |
| 153 setNeedsWillValidateCheck(); |
148 setNeedsStyleRecalc(); | 154 setNeedsStyleRecalc(); |
149 if (renderer() && renderer()->style()->hasAppearance()) | 155 if (renderer() && renderer()->style()->hasAppearance()) |
150 renderer()->theme()->stateChanged(renderer(), EnabledState); | 156 renderer()->theme()->stateChanged(renderer(), EnabledState); |
151 } | 157 } |
152 | 158 |
153 void HTMLFormControlElement::requiredAttributeChanged() | 159 void HTMLFormControlElement::requiredAttributeChanged() |
154 { | 160 { |
155 setNeedsValidityCheck(); | 161 setNeedsValidityCheck(); |
156 // Style recalculation is needed because style selectors may include | 162 // Style recalculation is needed because style selectors may include |
157 // :required and :optional pseudo-classes. | 163 // :required and :optional pseudo-classes. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 223 } |
218 | 224 |
219 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument) | 225 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument) |
220 { | 226 { |
221 FormAssociatedElement::didMoveToNewDocument(oldDocument); | 227 FormAssociatedElement::didMoveToNewDocument(oldDocument); |
222 HTMLElement::didMoveToNewDocument(oldDocument); | 228 HTMLElement::didMoveToNewDocument(oldDocument); |
223 } | 229 } |
224 | 230 |
225 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Node* in
sertionPoint) | 231 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Node* in
sertionPoint) |
226 { | 232 { |
| 233 m_fieldSetAncestorValid = false; |
227 m_dataListAncestorState = Unknown; | 234 m_dataListAncestorState = Unknown; |
228 setNeedsWillValidateCheck(); | 235 setNeedsWillValidateCheck(); |
229 HTMLElement::insertedInto(insertionPoint); | 236 HTMLElement::insertedInto(insertionPoint); |
230 FormAssociatedElement::insertedInto(insertionPoint); | 237 FormAssociatedElement::insertedInto(insertionPoint); |
231 return InsertionDone; | 238 return InsertionDone; |
232 } | 239 } |
233 | 240 |
234 void HTMLFormControlElement::removedFrom(Node* insertionPoint) | 241 void HTMLFormControlElement::removedFrom(Node* insertionPoint) |
235 { | 242 { |
236 m_fieldSetAncestorValid = false; | 243 m_fieldSetAncestorValid = false; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (m_dataListAncestorState == Unknown) { | 367 if (m_dataListAncestorState == Unknown) { |
361 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest
or->parentNode()) { | 368 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest
or->parentNode()) { |
362 if (!m_legendAncestor && ancestor->hasTagName(datalistTag)) { | 369 if (!m_legendAncestor && ancestor->hasTagName(datalistTag)) { |
363 m_dataListAncestorState = InsideDataList; | 370 m_dataListAncestorState = InsideDataList; |
364 break; | 371 break; |
365 } | 372 } |
366 } | 373 } |
367 if (m_dataListAncestorState == Unknown) | 374 if (m_dataListAncestorState == Unknown) |
368 m_dataListAncestorState = NotInsideDataList; | 375 m_dataListAncestorState = NotInsideDataList; |
369 } | 376 } |
370 return m_dataListAncestorState == NotInsideDataList && !m_disabled && !m_rea
dOnly; | 377 return m_dataListAncestorState == NotInsideDataList && !disabled() && !m_rea
dOnly; |
371 } | 378 } |
372 | 379 |
373 bool HTMLFormControlElement::willValidate() const | 380 bool HTMLFormControlElement::willValidate() const |
374 { | 381 { |
375 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) { | 382 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) { |
376 m_willValidateInitialized = true; | 383 m_willValidateInitialized = true; |
377 m_willValidate = recalcWillValidate(); | 384 m_willValidate = recalcWillValidate(); |
378 } else { | 385 } else { |
379 // If the following assertion fails, setNeedsWillValidateCheck() is not | 386 // If the following assertion fails, setNeedsWillValidateCheck() is not |
380 // called correctly when something which changes recalcWillValidate() re
sult | 387 // called correctly when something which changes recalcWillValidate() re
sult |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node
* node) | 513 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node
* node) |
507 { | 514 { |
508 for (; node; node = node->parentNode()) { | 515 for (; node; node = node->parentNode()) { |
509 if (node->isElementNode() && toElement(node)->isFormControlElement()) | 516 if (node->isElementNode() && toElement(node)->isFormControlElement()) |
510 return static_cast<HTMLFormControlElement*>(node); | 517 return static_cast<HTMLFormControlElement*>(node); |
511 } | 518 } |
512 return 0; | 519 return 0; |
513 } | 520 } |
514 | 521 |
515 } // namespace Webcore | 522 } // namespace Webcore |
OLD | NEW |