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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return m_validityState.get(); | 52 return m_validityState.get(); |
53 } | 53 } |
54 | 54 |
55 void FormAssociatedElement::willMoveToNewOwnerDocument() | 55 void FormAssociatedElement::willMoveToNewOwnerDocument() |
56 { | 56 { |
57 HTMLElement* element = toHTMLElement(this); | 57 HTMLElement* element = toHTMLElement(this); |
58 if (element->fastHasAttribute(formAttr)) | 58 if (element->fastHasAttribute(formAttr)) |
59 element->document()->unregisterFormElementWithFormAttribute(this); | 59 element->document()->unregisterFormElementWithFormAttribute(this); |
60 } | 60 } |
61 | 61 |
| 62 void FormAssociatedElement::insertedIntoDocument() |
| 63 { |
| 64 HTMLElement* element = toHTMLElement(this); |
| 65 if (element->fastHasAttribute(formAttr)) |
| 66 element->document()->registerFormElementWithFormAttribute(this); |
| 67 } |
| 68 |
| 69 void FormAssociatedElement::removedFromDocument() |
| 70 { |
| 71 HTMLElement* element = toHTMLElement(this); |
| 72 if (element->fastHasAttribute(formAttr)) |
| 73 element->document()->unregisterFormElementWithFormAttribute(this); |
| 74 } |
| 75 |
62 void FormAssociatedElement::insertedIntoTree() | 76 void FormAssociatedElement::insertedIntoTree() |
63 { | 77 { |
64 HTMLElement* element = toHTMLElement(this); | 78 HTMLElement* element = toHTMLElement(this); |
65 if (element->fastHasAttribute(formAttr)) { | 79 if (element->fastHasAttribute(formAttr)) { |
66 element->document()->registerFormElementWithFormAttribute(this); | |
67 Element* formElement = element->document()->getElementById(element->fast
GetAttribute(formAttr)); | 80 Element* formElement = element->document()->getElementById(element->fast
GetAttribute(formAttr)); |
68 if (formElement && formElement->hasTagName(formTag)) { | 81 if (formElement && formElement->hasTagName(formTag)) { |
69 if (m_form) | 82 if (m_form) |
70 m_form->removeFormElement(this); | 83 m_form->removeFormElement(this); |
71 m_form = static_cast<HTMLFormElement*>(formElement); | 84 m_form = static_cast<HTMLFormElement*>(formElement); |
72 m_form->registerFormElement(this); | 85 m_form->registerFormElement(this); |
73 } | 86 } |
74 } | 87 } |
75 if (!m_form) { | 88 if (!m_form) { |
76 // This handles the case of a new form element being created by | 89 // This handles the case of a new form element being created by |
(...skipping 10 matching lines...) Expand all Loading... |
87 { | 100 { |
88 Node* root = n; | 101 Node* root = n; |
89 for (; n; n = n->parentNode()) | 102 for (; n; n = n->parentNode()) |
90 root = n; | 103 root = n; |
91 return root; | 104 return root; |
92 } | 105 } |
93 | 106 |
94 void FormAssociatedElement::removedFromTree() | 107 void FormAssociatedElement::removedFromTree() |
95 { | 108 { |
96 HTMLElement* element = toHTMLElement(this); | 109 HTMLElement* element = toHTMLElement(this); |
97 if (element->fastHasAttribute(formAttr)) | |
98 element->document()->unregisterFormElementWithFormAttribute(this); | |
99 | 110 |
100 // If the form and element are both in the same tree, preserve the connectio
n to the form. | 111 // If the form and element are both in the same tree, preserve the connectio
n to the form. |
101 // Otherwise, null out our form and remove ourselves from the form's list of
elements. | 112 // Otherwise, null out our form and remove ourselves from the form's list of
elements. |
102 if (m_form && findRoot(element) != findRoot(m_form)) | 113 if (m_form && findRoot(element) != findRoot(m_form)) |
103 removeFromForm(); | 114 removeFromForm(); |
104 } | 115 } |
105 | 116 |
106 void FormAssociatedElement::removeFromForm() | 117 void FormAssociatedElement::removeFromForm() |
107 { | 118 { |
108 if (!m_form) | 119 if (!m_form) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ASSERT(element->hasTagName(objectTag)); | 172 ASSERT(element->hasTagName(objectTag)); |
162 return element; | 173 return element; |
163 } | 174 } |
164 | 175 |
165 HTMLElement* toHTMLElement(FormAssociatedElement* associatedElement) | 176 HTMLElement* toHTMLElement(FormAssociatedElement* associatedElement) |
166 { | 177 { |
167 return const_cast<HTMLElement*>(toHTMLElement(static_cast<const FormAssociat
edElement*>(associatedElement))); | 178 return const_cast<HTMLElement*>(toHTMLElement(static_cast<const FormAssociat
edElement*>(associatedElement))); |
168 } | 179 } |
169 | 180 |
170 } // namespace Webcore | 181 } // namespace Webcore |
OLD | NEW |