| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void HTMLFormControlElement::willMoveToNewOwnerDocument() | 155 void HTMLFormControlElement::willMoveToNewOwnerDocument() |
| 156 { | 156 { |
| 157 if (fastHasAttribute(formAttr)) | 157 if (fastHasAttribute(formAttr)) |
| 158 document()->unregisterFormElementWithFormAttribute(this); | 158 document()->unregisterFormElementWithFormAttribute(this); |
| 159 HTMLElement::willMoveToNewOwnerDocument(); | 159 HTMLElement::willMoveToNewOwnerDocument(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void HTMLFormControlElement::insertedIntoTree(bool deep) | 162 void HTMLFormControlElement::insertedIntoTree(bool deep) |
| 163 { | 163 { |
| 164 if (fastHasAttribute(formAttr)) { | 164 if (fastHasAttribute(formAttr)) { |
| 165 document()->registerFormElementWithFormAttribute(this); |
| 165 Element* element = document()->getElementById(fastGetAttribute(formAttr)
); | 166 Element* element = document()->getElementById(fastGetAttribute(formAttr)
); |
| 166 if (element && element->hasTagName(formTag)) { | 167 if (element && element->hasTagName(formTag)) { |
| 167 if (m_form) | 168 if (m_form) |
| 168 m_form->removeFormElement(this); | 169 m_form->removeFormElement(this); |
| 169 m_form = static_cast<HTMLFormElement*>(element); | 170 m_form = static_cast<HTMLFormElement*>(element); |
| 170 m_form->registerFormElement(this); | 171 m_form->registerFormElement(this); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 if (!m_form) { | 174 if (!m_form) { |
| 174 // This handles the case of a new form element being created by | 175 // This handles the case of a new form element being created by |
| (...skipping 13 matching lines...) Expand all Loading... |
| 188 static inline Node* findRoot(Node* n) | 189 static inline Node* findRoot(Node* n) |
| 189 { | 190 { |
| 190 Node* root = n; | 191 Node* root = n; |
| 191 for (; n; n = n->parentNode()) | 192 for (; n; n = n->parentNode()) |
| 192 root = n; | 193 root = n; |
| 193 return root; | 194 return root; |
| 194 } | 195 } |
| 195 | 196 |
| 196 void HTMLFormControlElement::removedFromTree(bool deep) | 197 void HTMLFormControlElement::removedFromTree(bool deep) |
| 197 { | 198 { |
| 199 if (fastHasAttribute(formAttr)) |
| 200 document()->unregisterFormElementWithFormAttribute(this); |
| 201 |
| 198 // If the form and element are both in the same tree, preserve the connectio
n to the form. | 202 // If the form and element are both in the same tree, preserve the connectio
n to the form. |
| 199 // Otherwise, null out our form and remove ourselves from the form's list of
elements. | 203 // Otherwise, null out our form and remove ourselves from the form's list of
elements. |
| 200 if (m_form && findRoot(this) != findRoot(m_form)) { | 204 if (m_form && findRoot(this) != findRoot(m_form)) { |
| 201 m_form->removeFormElement(this); | 205 m_form->removeFormElement(this); |
| 202 m_form = 0; | 206 m_form = 0; |
| 203 } | 207 } |
| 204 | 208 |
| 205 HTMLElement::removedFromTree(deep); | 209 HTMLElement::removedFromTree(deep); |
| 206 } | 210 } |
| 207 | 211 |
| 208 void HTMLFormControlElement::insertedIntoDocument() | |
| 209 { | |
| 210 if (fastHasAttribute(formAttr)) | |
| 211 document()->registerFormElementWithFormAttribute(this); | |
| 212 } | |
| 213 | |
| 214 void HTMLFormControlElement::removedFromDocument() | |
| 215 { | |
| 216 if (fastHasAttribute(formAttr)) | |
| 217 document()->unregisterFormElementWithFormAttribute(this); | |
| 218 } | |
| 219 | |
| 220 const AtomicString& HTMLFormControlElement::formControlName() const | 212 const AtomicString& HTMLFormControlElement::formControlName() const |
| 221 { | 213 { |
| 222 const AtomicString& name = fastGetAttribute(nameAttr); | 214 const AtomicString& name = fastGetAttribute(nameAttr); |
| 223 return name.isNull() ? emptyAtom : name; | 215 return name.isNull() ? emptyAtom : name; |
| 224 } | 216 } |
| 225 | 217 |
| 226 void HTMLFormControlElement::setName(const AtomicString& value) | 218 void HTMLFormControlElement::setName(const AtomicString& value) |
| 227 { | 219 { |
| 228 setAttribute(nameAttr, value); | 220 setAttribute(nameAttr, value); |
| 229 } | 221 } |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 updatePlaceholderVisibility(true); | 719 updatePlaceholderVisibility(true); |
| 728 else if (attr->name() == onselectAttr) | 720 else if (attr->name() == onselectAttr) |
| 729 setAttributeEventListener(eventNames().selectEvent, createAttributeEvent
Listener(this, attr)); | 721 setAttributeEventListener(eventNames().selectEvent, createAttributeEvent
Listener(this, attr)); |
| 730 else if (attr->name() == onchangeAttr) | 722 else if (attr->name() == onchangeAttr) |
| 731 setAttributeEventListener(eventNames().changeEvent, createAttributeEvent
Listener(this, attr)); | 723 setAttributeEventListener(eventNames().changeEvent, createAttributeEvent
Listener(this, attr)); |
| 732 else | 724 else |
| 733 HTMLFormControlElementWithState::parseMappedAttribute(attr); | 725 HTMLFormControlElementWithState::parseMappedAttribute(attr); |
| 734 } | 726 } |
| 735 | 727 |
| 736 } // namespace Webcore | 728 } // namespace Webcore |
| OLD | NEW |