| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 HTMLElement* element = toHTMLElement(this); | 79 HTMLElement* element = toHTMLElement(this); |
| 80 if (element->fastHasAttribute(formAttr)) | 80 if (element->fastHasAttribute(formAttr)) |
| 81 setFormAttributeTargetObserver(nullptr); | 81 setFormAttributeTargetObserver(nullptr); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void FormAssociatedElement::insertedInto(ContainerNode* insertionPoint) | 84 void FormAssociatedElement::insertedInto(ContainerNode* insertionPoint) |
| 85 { | 85 { |
| 86 if (!m_formWasSetByParser || !m_form || NodeTraversal::highestAncestorOrSelf
(*insertionPoint) != NodeTraversal::highestAncestorOrSelf(*m_form.get())) | 86 if (!m_formWasSetByParser || !m_form || NodeTraversal::highestAncestorOrSelf
(*insertionPoint) != NodeTraversal::highestAncestorOrSelf(*m_form.get())) |
| 87 resetFormOwner(); | 87 resetFormOwner(); |
| 88 | 88 |
| 89 if (!insertionPoint->inDocument()) | 89 if (!insertionPoint->inShadowIncludingDocument()) |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 HTMLElement* element = toHTMLElement(this); | 92 HTMLElement* element = toHTMLElement(this); |
| 93 if (element->fastHasAttribute(formAttr)) | 93 if (element->fastHasAttribute(formAttr)) |
| 94 resetFormAttributeTargetObserver(); | 94 resetFormAttributeTargetObserver(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void FormAssociatedElement::removedFrom(ContainerNode* insertionPoint) | 97 void FormAssociatedElement::removedFrom(ContainerNode* insertionPoint) |
| 98 { | 98 { |
| 99 HTMLElement* element = toHTMLElement(this); | 99 HTMLElement* element = toHTMLElement(this); |
| 100 if (insertionPoint->inDocument() && element->fastHasAttribute(formAttr)) { | 100 if (insertionPoint->inShadowIncludingDocument() && element->fastHasAttribute
(formAttr)) { |
| 101 setFormAttributeTargetObserver(nullptr); | 101 setFormAttributeTargetObserver(nullptr); |
| 102 resetFormOwner(); | 102 resetFormOwner(); |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 // If the form and element are both in the same tree, preserve the connectio
n to the form. | 105 // If the form and element are both in the same tree, preserve the connectio
n to the form. |
| 106 // Otherwise, null out our form and remove ourselves from the form's list of
elements. | 106 // Otherwise, null out our form and remove ourselves from the form's list of
elements. |
| 107 if (m_form && NodeTraversal::highestAncestorOrSelf(*element) != NodeTraversa
l::highestAncestorOrSelf(*m_form.get())) | 107 if (m_form && NodeTraversal::highestAncestorOrSelf(*element) != NodeTraversa
l::highestAncestorOrSelf(*m_form.get())) |
| 108 resetFormOwner(); | 108 resetFormOwner(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el
ement) | 111 HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el
ement) |
| 112 { | 112 { |
| 113 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 113 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| 114 // 3. If the element is reassociateable, has a form content attribute, and | 114 // 3. If the element is reassociateable, has a form content attribute, and |
| 115 // is itself in a Document, then run these substeps: | 115 // is itself in a Document, then run these substeps: |
| 116 if (!formId.isNull() && element->inDocument()) { | 116 if (!formId.isNull() && element->inShadowIncludingDocument()) { |
| 117 // 3.1. If the first element in the Document to have an ID that is | 117 // 3.1. If the first element in the Document to have an ID that is |
| 118 // case-sensitively equal to the element's form content attribute's | 118 // case-sensitively equal to the element's form content attribute's |
| 119 // value is a form element, then associate the form-associated element | 119 // value is a form element, then associate the form-associated element |
| 120 // with that form element. | 120 // with that form element. |
| 121 // 3.2. Abort the "reset the form owner" steps. | 121 // 3.2. Abort the "reset the form owner" steps. |
| 122 Element* newFormCandidate = element->treeScope().getElementById(formId); | 122 Element* newFormCandidate = element->treeScope().getElementById(formId); |
| 123 return isHTMLFormElement(newFormCandidate) ? toHTMLFormElement(newFormCa
ndidate) : 0; | 123 return isHTMLFormElement(newFormCandidate) ? toHTMLFormElement(newFormCa
ndidate) : 0; |
| 124 } | 124 } |
| 125 // 4. Otherwise, if the form-associated element in question has an ancestor | 125 // 4. Otherwise, if the form-associated element in question has an ancestor |
| 126 // form element, then associate the form-associated element with the nearest | 126 // form element, then associate the form-associated element with the nearest |
| 127 // such ancestor form element. | 127 // such ancestor form element. |
| 128 return element->findFormAncestor(); | 128 return element->findFormAncestor(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void FormAssociatedElement::formRemovedFromTree(const Node& formRoot) | 131 void FormAssociatedElement::formRemovedFromTree(const Node& formRoot) |
| 132 { | 132 { |
| 133 ASSERT(m_form); | 133 ASSERT(m_form); |
| 134 if (NodeTraversal::highestAncestorOrSelf(toHTMLElement(*this)) == formRoot) | 134 if (NodeTraversal::highestAncestorOrSelf(toHTMLElement(*this)) == formRoot) |
| 135 return; | 135 return; |
| 136 resetFormOwner(); | 136 resetFormOwner(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void FormAssociatedElement::associateByParser(HTMLFormElement* form) | 139 void FormAssociatedElement::associateByParser(HTMLFormElement* form) |
| 140 { | 140 { |
| 141 if (form && form->inDocument()) { | 141 if (form && form->inShadowIncludingDocument()) { |
| 142 m_formWasSetByParser = true; | 142 m_formWasSetByParser = true; |
| 143 setForm(form); | 143 setForm(form); |
| 144 form->didAssociateByParser(); | 144 form->didAssociateByParser(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void FormAssociatedElement::setForm(HTMLFormElement* newForm) | 148 void FormAssociatedElement::setForm(HTMLFormElement* newForm) |
| 149 { | 149 { |
| 150 if (m_form.get() == newForm) | 150 if (m_form.get() == newForm) |
| 151 return; | 151 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 164 } | 164 } |
| 165 didChangeForm(); | 165 didChangeForm(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void FormAssociatedElement::willChangeForm() | 168 void FormAssociatedElement::willChangeForm() |
| 169 { | 169 { |
| 170 } | 170 } |
| 171 | 171 |
| 172 void FormAssociatedElement::didChangeForm() | 172 void FormAssociatedElement::didChangeForm() |
| 173 { | 173 { |
| 174 if (!m_formWasSetByParser && m_form && m_form->inDocument()) { | 174 if (!m_formWasSetByParser && m_form && m_form->inShadowIncludingDocument())
{ |
| 175 HTMLElement* element = toHTMLElement(this); | 175 HTMLElement* element = toHTMLElement(this); |
| 176 element->document().didAssociateFormControl(element); | 176 element->document().didAssociateFormControl(element); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 void FormAssociatedElement::resetFormOwner() | 180 void FormAssociatedElement::resetFormOwner() |
| 181 { | 181 { |
| 182 m_formWasSetByParser = false; | 182 m_formWasSetByParser = false; |
| 183 HTMLElement* element = toHTMLElement(this); | 183 HTMLElement* element = toHTMLElement(this); |
| 184 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 184 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 { | 282 { |
| 283 if (m_formAttributeTargetObserver) | 283 if (m_formAttributeTargetObserver) |
| 284 m_formAttributeTargetObserver->unregister(); | 284 m_formAttributeTargetObserver->unregister(); |
| 285 m_formAttributeTargetObserver = newObserver; | 285 m_formAttributeTargetObserver = newObserver; |
| 286 } | 286 } |
| 287 | 287 |
| 288 void FormAssociatedElement::resetFormAttributeTargetObserver() | 288 void FormAssociatedElement::resetFormAttributeTargetObserver() |
| 289 { | 289 { |
| 290 HTMLElement* element = toHTMLElement(this); | 290 HTMLElement* element = toHTMLElement(this); |
| 291 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 291 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| 292 if (!formId.isNull() && element->inDocument()) | 292 if (!formId.isNull() && element->inShadowIncludingDocument()) |
| 293 setFormAttributeTargetObserver(FormAttributeTargetObserver::create(formI
d, this)); | 293 setFormAttributeTargetObserver(FormAttributeTargetObserver::create(formI
d, this)); |
| 294 else | 294 else |
| 295 setFormAttributeTargetObserver(nullptr); | 295 setFormAttributeTargetObserver(nullptr); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void FormAssociatedElement::formAttributeTargetChanged() | 298 void FormAssociatedElement::formAttributeTargetChanged() |
| 299 { | 299 { |
| 300 resetFormOwner(); | 300 resetFormOwner(); |
| 301 } | 301 } |
| 302 | 302 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 visitor->trace(m_element); | 352 visitor->trace(m_element); |
| 353 IdTargetObserver::trace(visitor); | 353 IdTargetObserver::trace(visitor); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void FormAttributeTargetObserver::idTargetChanged() | 356 void FormAttributeTargetObserver::idTargetChanged() |
| 357 { | 357 { |
| 358 m_element->formAttributeTargetChanged(); | 358 m_element->formAttributeTargetChanged(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |