| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 #include "FormAssociatedElement.h" | 26 #include "FormAssociatedElement.h" |
| 27 | 27 |
| 28 #include "EditorClient.h" | |
| 29 #include "FormController.h" | 28 #include "FormController.h" |
| 30 #include "Frame.h" | |
| 31 #include "HTMLFormControlElement.h" | 29 #include "HTMLFormControlElement.h" |
| 32 #include "HTMLFormElement.h" | 30 #include "HTMLFormElement.h" |
| 33 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 34 #include "HTMLObjectElement.h" | 32 #include "HTMLObjectElement.h" |
| 35 #include "IdTargetObserver.h" | 33 #include "IdTargetObserver.h" |
| 36 #include "ValidityState.h" | 34 #include "ValidityState.h" |
| 37 | 35 |
| 38 namespace WebCore { | 36 namespace WebCore { |
| 39 | 37 |
| 40 using namespace HTMLNames; | 38 using namespace HTMLNames; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 ASSERT(m_form); | 150 ASSERT(m_form); |
| 153 if (!m_form) | 151 if (!m_form) |
| 154 return; | 152 return; |
| 155 willChangeForm(); | 153 willChangeForm(); |
| 156 m_form = 0; | 154 m_form = 0; |
| 157 didChangeForm(); | 155 didChangeForm(); |
| 158 } | 156 } |
| 159 | 157 |
| 160 void FormAssociatedElement::resetFormOwner() | 158 void FormAssociatedElement::resetFormOwner() |
| 161 { | 159 { |
| 162 HTMLFormElement* originalForm = m_form; | |
| 163 setForm(findAssociatedForm(toHTMLElement(this), m_form)); | 160 setForm(findAssociatedForm(toHTMLElement(this), m_form)); |
| 164 HTMLElement* element = toHTMLElement(this); | |
| 165 if (m_form && m_form != originalForm && m_form->inDocument()) | |
| 166 element->document()->didAssociateFormControl(element); | |
| 167 } | 161 } |
| 168 | 162 |
| 169 void FormAssociatedElement::formAttributeChanged() | 163 void FormAssociatedElement::formAttributeChanged() |
| 170 { | 164 { |
| 171 HTMLElement* element = toHTMLElement(this); | 165 HTMLElement* element = toHTMLElement(this); |
| 172 if (!element->fastHasAttribute(formAttr)) { | 166 if (!element->fastHasAttribute(formAttr)) { |
| 173 // The form attribute removed. We need to reset form owner here. | 167 // The form attribute removed. We need to reset form owner here. |
| 174 HTMLFormElement* originalForm = m_form; | |
| 175 setForm(element->findFormAncestor()); | 168 setForm(element->findFormAncestor()); |
| 176 HTMLElement* element = toHTMLElement(this); | |
| 177 if (m_form && m_form != originalForm && m_form->inDocument()) | |
| 178 element->document()->didAssociateFormControl(element); | |
| 179 m_formAttributeTargetObserver = nullptr; | 169 m_formAttributeTargetObserver = nullptr; |
| 180 } else { | 170 } else { |
| 181 resetFormOwner(); | 171 resetFormOwner(); |
| 182 resetFormAttributeTargetObserver(); | 172 resetFormAttributeTargetObserver(); |
| 183 } | 173 } |
| 184 } | 174 } |
| 185 | 175 |
| 186 bool FormAssociatedElement::customError() const | 176 bool FormAssociatedElement::customError() const |
| 187 { | 177 { |
| 188 const HTMLElement* element = toHTMLElement(this); | 178 const HTMLElement* element = toHTMLElement(this); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 , m_element(element) | 287 , m_element(element) |
| 298 { | 288 { |
| 299 } | 289 } |
| 300 | 290 |
| 301 void FormAttributeTargetObserver::idTargetChanged() | 291 void FormAttributeTargetObserver::idTargetChanged() |
| 302 { | 292 { |
| 303 m_element->formAttributeTargetChanged(); | 293 m_element->formAttributeTargetChanged(); |
| 304 } | 294 } |
| 305 | 295 |
| 306 } // namespace Webcore | 296 } // namespace Webcore |
| OLD | NEW |