Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: Source/WebCore/html/HTMLFormControlElement.cpp

Issue 10542040: Merge 118725 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/html/HTMLFormControlElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 #include "ValidityState.h" 41 #include "ValidityState.h"
42 #include <wtf/Vector.h> 42 #include <wtf/Vector.h>
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 using namespace HTMLNames; 46 using namespace HTMLNames;
47 using namespace std; 47 using namespace std;
48 48
49 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument* document, HTMLFormElement* form) 49 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument* document, HTMLFormElement* form)
50 : LabelableElement(tagName, document) 50 : LabelableElement(tagName, document)
51 , m_fieldSetAncestor(0)
52 , m_legendAncestor(0)
53 , m_fieldSetAncestorValid(false)
54 , m_disabled(false) 51 , m_disabled(false)
55 , m_readOnly(false) 52 , m_readOnly(false)
56 , m_required(false) 53 , m_required(false)
57 , m_valueMatchesRenderer(false) 54 , m_valueMatchesRenderer(false)
55 , m_ancestorDisabledState(AncestorDisabledStateUnknown)
58 , m_dataListAncestorState(Unknown) 56 , m_dataListAncestorState(Unknown)
59 , m_willValidateInitialized(false) 57 , m_willValidateInitialized(false)
60 , m_willValidate(true) 58 , m_willValidate(true)
61 , m_isValid(true) 59 , m_isValid(true)
62 , m_wasChangedSinceLastFormControlChangeEvent(false) 60 , m_wasChangedSinceLastFormControlChangeEvent(false)
63 , m_hasAutofocused(false) 61 , m_hasAutofocused(false)
64 { 62 {
65 setForm(form ? form : findFormAncestor()); 63 setForm(form ? form : findFormAncestor());
66 setHasCustomWillOrDidRecalcStyle(); 64 setHasCustomWillOrDidRecalcStyle();
67 } 65 }
(...skipping 26 matching lines...) Expand all
94 void HTMLFormControlElement::setFormMethod(const String& value) 92 void HTMLFormControlElement::setFormMethod(const String& value)
95 { 93 {
96 setAttribute(formmethodAttr, value); 94 setAttribute(formmethodAttr, value);
97 } 95 }
98 96
99 bool HTMLFormControlElement::formNoValidate() const 97 bool HTMLFormControlElement::formNoValidate() const
100 { 98 {
101 return fastHasAttribute(formnovalidateAttr); 99 return fastHasAttribute(formnovalidateAttr);
102 } 100 }
103 101
104 void HTMLFormControlElement::updateFieldSetAndLegendAncestor() const 102 void HTMLFormControlElement::updateAncestorDisabledState() const
105 { 103 {
106 m_fieldSetAncestor = 0; 104 HTMLFieldSetElement* fieldSetAncestor = 0;
107 m_legendAncestor = 0; 105 ContainerNode* legendAncestor = 0;
108 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) { 106 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) {
109 if (!m_legendAncestor && ancestor->hasTagName(legendTag)) 107 if (!legendAncestor && ancestor->hasTagName(legendTag))
110 m_legendAncestor = static_cast<HTMLLegendElement*>(ancestor); 108 legendAncestor = ancestor;
111 if (ancestor->hasTagName(fieldsetTag)) { 109 if (ancestor->hasTagName(fieldsetTag)) {
112 m_fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); 110 fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor);
113 break; 111 break;
114 } 112 }
115 } 113 }
116 m_fieldSetAncestorValid = true; 114 m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->disabled() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend())) ? Ancestor DisabledStateDisabled : AncestorDisabledStateEnabled;
117 } 115 }
118 116
119 void HTMLFormControlElement::ancestorDisabledStateWasChanged() 117 void HTMLFormControlElement::ancestorDisabledStateWasChanged()
120 { 118 {
119 m_ancestorDisabledState = AncestorDisabledStateUnknown;
121 disabledAttributeChanged(); 120 disabledAttributeChanged();
122 } 121 }
123 122
124 void HTMLFormControlElement::parseAttribute(Attribute* attr) 123 void HTMLFormControlElement::parseAttribute(Attribute* attr)
125 { 124 {
126 if (attr->name() == formAttr) 125 if (attr->name() == formAttr)
127 formAttributeChanged(); 126 formAttributeChanged();
128 else if (attr->name() == disabledAttr) { 127 else if (attr->name() == disabledAttr) {
129 bool oldDisabled = m_disabled; 128 bool oldDisabled = m_disabled;
130 m_disabled = !attr->isNull(); 129 m_disabled = !attr->isNull();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 222 }
224 223
225 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument) 224 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument)
226 { 225 {
227 FormAssociatedElement::didMoveToNewDocument(oldDocument); 226 FormAssociatedElement::didMoveToNewDocument(oldDocument);
228 HTMLElement::didMoveToNewDocument(oldDocument); 227 HTMLElement::didMoveToNewDocument(oldDocument);
229 } 228 }
230 229
231 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Node* in sertionPoint) 230 Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Node* in sertionPoint)
232 { 231 {
233 m_fieldSetAncestorValid = false; 232 m_ancestorDisabledState = AncestorDisabledStateUnknown;
234 m_dataListAncestorState = Unknown; 233 m_dataListAncestorState = Unknown;
235 setNeedsWillValidateCheck(); 234 setNeedsWillValidateCheck();
236 HTMLElement::insertedInto(insertionPoint); 235 HTMLElement::insertedInto(insertionPoint);
237 FormAssociatedElement::insertedInto(insertionPoint); 236 FormAssociatedElement::insertedInto(insertionPoint);
238 return InsertionDone; 237 return InsertionDone;
239 } 238 }
240 239
241 void HTMLFormControlElement::removedFrom(Node* insertionPoint) 240 void HTMLFormControlElement::removedFrom(Node* insertionPoint)
242 { 241 {
243 m_fieldSetAncestorValid = false; 242 m_ancestorDisabledState = AncestorDisabledStateUnknown;
244 m_dataListAncestorState = Unknown; 243 m_dataListAncestorState = Unknown;
245 HTMLElement::removedFrom(insertionPoint); 244 HTMLElement::removedFrom(insertionPoint);
246 FormAssociatedElement::removedFrom(insertionPoint); 245 FormAssociatedElement::removedFrom(insertionPoint);
247 } 246 }
248 247
249 const AtomicString& HTMLFormControlElement::formControlName() const 248 const AtomicString& HTMLFormControlElement::formControlName() const
250 { 249 {
251 const AtomicString& name = getNameAttribute(); 250 const AtomicString& name = getNameAttribute();
252 return name.isNull() ? emptyAtom : name; 251 return name.isNull() ? emptyAtom : name;
253 } 252 }
(...skipping 23 matching lines...) Expand all
277 { 276 {
278 setChangedSinceLastFormControlChangeEvent(true); 277 setChangedSinceLastFormControlChangeEvent(true);
279 HTMLElement::dispatchInputEvent(); 278 HTMLElement::dispatchInputEvent();
280 } 279 }
281 280
282 bool HTMLFormControlElement::disabled() const 281 bool HTMLFormControlElement::disabled() const
283 { 282 {
284 if (m_disabled) 283 if (m_disabled)
285 return true; 284 return true;
286 285
287 if (!m_fieldSetAncestorValid) 286 if (m_ancestorDisabledState == AncestorDisabledStateUnknown)
288 updateFieldSetAndLegendAncestor(); 287 updateAncestorDisabledState();
289 288 return m_ancestorDisabledState == AncestorDisabledStateDisabled;
290 // Form controls in the first legend element inside a fieldset are not affec ted by fieldset.disabled.
291 if (m_fieldSetAncestor && m_fieldSetAncestor->disabled())
292 return !(m_legendAncestor && m_legendAncestor == m_fieldSetAncestor->leg end());
293 return false;
294 } 289 }
295 290
296 void HTMLFormControlElement::setDisabled(bool b) 291 void HTMLFormControlElement::setDisabled(bool b)
297 { 292 {
298 setAttribute(disabledAttr, b ? "" : 0); 293 setAttribute(disabledAttr, b ? "" : 0);
299 } 294 }
300 295
301 bool HTMLFormControlElement::autofocus() const 296 bool HTMLFormControlElement::autofocus() const
302 { 297 {
303 return hasAttribute(autofocusAttr); 298 return hasAttribute(autofocusAttr);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 short HTMLFormControlElement::tabIndex() const 354 short HTMLFormControlElement::tabIndex() const
360 { 355 {
361 // Skip the supportsFocus check in HTMLElement. 356 // Skip the supportsFocus check in HTMLElement.
362 return Element::tabIndex(); 357 return Element::tabIndex();
363 } 358 }
364 359
365 bool HTMLFormControlElement::recalcWillValidate() const 360 bool HTMLFormControlElement::recalcWillValidate() const
366 { 361 {
367 if (m_dataListAncestorState == Unknown) { 362 if (m_dataListAncestorState == Unknown) {
368 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest or->parentNode()) { 363 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancest or->parentNode()) {
369 if (!m_legendAncestor && ancestor->hasTagName(datalistTag)) { 364 if (ancestor->hasTagName(datalistTag)) {
370 m_dataListAncestorState = InsideDataList; 365 m_dataListAncestorState = InsideDataList;
371 break; 366 break;
372 } 367 }
373 } 368 }
374 if (m_dataListAncestorState == Unknown) 369 if (m_dataListAncestorState == Unknown)
375 m_dataListAncestorState = NotInsideDataList; 370 m_dataListAncestorState = NotInsideDataList;
376 } 371 }
377 return m_dataListAncestorState == NotInsideDataList && !disabled() && !m_rea dOnly; 372 return m_dataListAncestorState == NotInsideDataList && !disabled() && !m_rea dOnly;
378 } 373 }
379 374
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node * node) 508 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node * node)
514 { 509 {
515 for (; node; node = node->parentNode()) { 510 for (; node; node = node->parentNode()) {
516 if (node->isElementNode() && toElement(node)->isFormControlElement()) 511 if (node->isElementNode() && toElement(node)->isFormControlElement())
517 return static_cast<HTMLFormControlElement*>(node); 512 return static_cast<HTMLFormControlElement*>(node);
518 } 513 }
519 return 0; 514 return 0;
520 } 515 }
521 516
522 } // namespace Webcore 517 } // namespace Webcore
OLDNEW
« no previous file with comments | « Source/WebCore/html/HTMLFormControlElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698