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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void FormAssociatedElement::resetFormOwner(HTMLFormElement* form) | 125 void FormAssociatedElement::resetFormOwner(HTMLFormElement* form) |
126 { | 126 { |
127 HTMLElement* element = toHTMLElement(this); | 127 HTMLElement* element = toHTMLElement(this); |
128 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 128 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
129 if (m_form) { | 129 if (m_form) { |
130 if (formId.isNull()) | 130 if (formId.isNull()) |
131 return; | 131 return; |
132 m_form->removeFormElement(this); | 132 m_form->removeFormElement(this); |
133 } | 133 } |
134 m_form = 0; | 134 m_form = 0; |
135 if (!formId.isNull()) { | 135 if (!formId.isNull() && element->inDocument()) { |
136 // The HTML5 spec says that the element should be associated with | 136 // The HTML5 spec says that the element should be associated with |
137 // the first element in the document to have an ID that equal to | 137 // the first element in the document to have an ID that equal to |
138 // the value of form attribute, so we put the result of | 138 // the value of form attribute, so we put the result of |
139 // document()->getElementById() over the given element. | 139 // document()->getElementById() over the given element. |
140 Element* firstElement = element->document()->getElementById(formId); | 140 Element* firstElement = element->document()->getElementById(formId); |
141 if (firstElement && firstElement->hasTagName(formTag)) | 141 if (firstElement && firstElement->hasTagName(formTag)) |
142 m_form = static_cast<HTMLFormElement*>(firstElement); | 142 m_form = static_cast<HTMLFormElement*>(firstElement); |
143 else | 143 else |
144 m_form = form; | 144 m_form = form; |
145 } else | 145 } else |
(...skipping 26 matching lines...) Expand all Loading... |
172 ASSERT(element->hasTagName(objectTag)); | 172 ASSERT(element->hasTagName(objectTag)); |
173 return element; | 173 return element; |
174 } | 174 } |
175 | 175 |
176 HTMLElement* toHTMLElement(FormAssociatedElement* associatedElement) | 176 HTMLElement* toHTMLElement(FormAssociatedElement* associatedElement) |
177 { | 177 { |
178 return const_cast<HTMLElement*>(toHTMLElement(static_cast<const FormAssociat
edElement*>(associatedElement))); | 178 return const_cast<HTMLElement*>(toHTMLElement(static_cast<const FormAssociat
edElement*>(associatedElement))); |
179 } | 179 } |
180 | 180 |
181 } // namespace Webcore | 181 } // namespace Webcore |
OLD | NEW |