Chromium Code Reviews| 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 "core/html/FormAssociatedElement.h" | 25 #include "core/html/ListedElement.h" |
| 26 | 26 |
| 27 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 28 #include "core/dom/IdTargetObserver.h" | 28 #include "core/dom/IdTargetObserver.h" |
| 29 #include "core/dom/NodeTraversal.h" | 29 #include "core/dom/NodeTraversal.h" |
| 30 #include "core/html/HTMLFormControlElement.h" | 30 #include "core/html/HTMLFormControlElement.h" |
| 31 #include "core/html/HTMLFormElement.h" | 31 #include "core/html/HTMLFormElement.h" |
| 32 #include "core/html/HTMLObjectElement.h" | 32 #include "core/html/HTMLObjectElement.h" |
| 33 #include "core/html/ValidityState.h" | 33 #include "core/html/ValidityState.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 using namespace HTMLNames; | 37 using namespace HTMLNames; |
| 38 | 38 |
| 39 class FormAttributeTargetObserver : public IdTargetObserver { | 39 class FormAttributeTargetObserver : public IdTargetObserver { |
| 40 public: | 40 public: |
| 41 static FormAttributeTargetObserver* create(const AtomicString& id, | 41 static FormAttributeTargetObserver* create(const AtomicString& id, |
| 42 FormAssociatedElement*); | 42 ListedElement*); |
| 43 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
| 44 void idTargetChanged() override; | 44 void idTargetChanged() override; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement*); | 47 FormAttributeTargetObserver(const AtomicString& id, ListedElement*); |
| 48 | 48 |
| 49 Member<FormAssociatedElement> m_element; | 49 Member<ListedElement> m_element; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 FormAssociatedElement::FormAssociatedElement() : m_formWasSetByParser(false) {} | 52 ListedElement::ListedElement() : m_formWasSetByParser(false) {} |
| 53 | 53 |
| 54 FormAssociatedElement::~FormAssociatedElement() { | 54 ListedElement::~ListedElement() { |
| 55 // We can't call setForm here because it contains virtual calls. | 55 // We can't call setForm here because it contains virtual calls. |
| 56 } | 56 } |
| 57 | 57 |
| 58 DEFINE_TRACE(FormAssociatedElement) { | 58 DEFINE_TRACE(ListedElement) { |
| 59 visitor->trace(m_formAttributeTargetObserver); | 59 visitor->trace(m_formAttributeTargetObserver); |
| 60 visitor->trace(m_form); | 60 visitor->trace(m_form); |
| 61 visitor->trace(m_validityState); | 61 visitor->trace(m_validityState); |
| 62 } | 62 } |
| 63 | 63 |
| 64 ValidityState* FormAssociatedElement::validity() { | 64 ValidityState* ListedElement::validity() { |
| 65 if (!m_validityState) | 65 if (!m_validityState) |
| 66 m_validityState = ValidityState::create(this); | 66 m_validityState = ValidityState::create(this); |
| 67 | 67 |
| 68 return m_validityState.get(); | 68 return m_validityState.get(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void FormAssociatedElement::didMoveToNewDocument(Document& oldDocument) { | 71 void ListedElement::didMoveToNewDocument(Document& oldDocument) { |
| 72 HTMLElement* element = toHTMLElement(this); | 72 HTMLElement* element = toHTMLElement(this); |
| 73 if (element->fastHasAttribute(formAttr)) | 73 if (element->fastHasAttribute(formAttr)) |
| 74 setFormAttributeTargetObserver(nullptr); | 74 setFormAttributeTargetObserver(nullptr); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void FormAssociatedElement::insertedInto(ContainerNode* insertionPoint) { | 77 void ListedElement::insertedInto(ContainerNode* insertionPoint) { |
| 78 if (!m_formWasSetByParser || !m_form || | 78 if (!m_formWasSetByParser || !m_form || |
| 79 NodeTraversal::highestAncestorOrSelf(*insertionPoint) != | 79 NodeTraversal::highestAncestorOrSelf(*insertionPoint) != |
| 80 NodeTraversal::highestAncestorOrSelf(*m_form.get())) | 80 NodeTraversal::highestAncestorOrSelf(*m_form.get())) |
| 81 resetFormOwner(); | 81 resetFormOwner(); |
| 82 | 82 |
| 83 if (!insertionPoint->isConnected()) | 83 if (!insertionPoint->isConnected()) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 HTMLElement* element = toHTMLElement(this); | 86 HTMLElement* element = toHTMLElement(this); |
| 87 if (element->fastHasAttribute(formAttr)) | 87 if (element->fastHasAttribute(formAttr)) |
| 88 resetFormAttributeTargetObserver(); | 88 resetFormAttributeTargetObserver(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void FormAssociatedElement::removedFrom(ContainerNode* insertionPoint) { | 91 void ListedElement::removedFrom(ContainerNode* insertionPoint) { |
| 92 HTMLElement* element = toHTMLElement(this); | 92 HTMLElement* element = toHTMLElement(this); |
| 93 if (insertionPoint->isConnected() && element->fastHasAttribute(formAttr)) { | 93 if (insertionPoint->isConnected() && element->fastHasAttribute(formAttr)) { |
| 94 setFormAttributeTargetObserver(nullptr); | 94 setFormAttributeTargetObserver(nullptr); |
| 95 resetFormOwner(); | 95 resetFormOwner(); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 // If the form and element are both in the same tree, preserve the connection | 98 // If the form and element are both in the same tree, preserve the connection |
| 99 // to the form. Otherwise, null out our form and remove ourselves from the | 99 // to the form. Otherwise, null out our form and remove ourselves from the |
| 100 // form's list of elements. | 100 // form's list of elements. |
| 101 if (m_form && | 101 if (m_form && |
| 102 NodeTraversal::highestAncestorOrSelf(*element) != | 102 NodeTraversal::highestAncestorOrSelf(*element) != |
| 103 NodeTraversal::highestAncestorOrSelf(*m_form.get())) | 103 NodeTraversal::highestAncestorOrSelf(*m_form.get())) |
| 104 resetFormOwner(); | 104 resetFormOwner(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 HTMLFormElement* FormAssociatedElement::findAssociatedForm( | 107 HTMLFormElement* ListedElement::findAssociatedForm(const HTMLElement* element) { |
| 108 const HTMLElement* element) { | |
| 109 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 108 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| 110 // 3. If the element is reassociateable, has a form content attribute, and | 109 // 3. If the element is reassociateable, has a form content attribute, and |
| 111 // is itself in a Document, then run these substeps: | 110 // is itself in a Document, then run these substeps: |
| 112 if (!formId.isNull() && element->isConnected()) { | 111 if (!formId.isNull() && element->isConnected()) { |
| 113 // 3.1. If the first element in the Document to have an ID that is | 112 // 3.1. If the first element in the Document to have an ID that is |
| 114 // case-sensitively equal to the element's form content attribute's | 113 // case-sensitively equal to the element's form content attribute's |
| 115 // value is a form element, then associate the form-associated element | 114 // value is a form element, then associate the form-associated element |
| 116 // with that form element. | 115 // with that form element. |
| 117 // 3.2. Abort the "reset the form owner" steps. | 116 // 3.2. Abort the "reset the form owner" steps. |
| 118 Element* newFormCandidate = element->treeScope().getElementById(formId); | 117 Element* newFormCandidate = element->treeScope().getElementById(formId); |
| 119 return isHTMLFormElement(newFormCandidate) | 118 return isHTMLFormElement(newFormCandidate) |
| 120 ? toHTMLFormElement(newFormCandidate) | 119 ? toHTMLFormElement(newFormCandidate) |
| 121 : 0; | 120 : 0; |
| 122 } | 121 } |
| 123 // 4. Otherwise, if the form-associated element in question has an ancestor | 122 // 4. Otherwise, if the form-associated element in question has an ancestor |
| 124 // form element, then associate the form-associated element with the nearest | 123 // form element, then associate the form-associated element with the nearest |
| 125 // such ancestor form element. | 124 // such ancestor form element. |
| 126 return element->findFormAncestor(); | 125 return element->findFormAncestor(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void FormAssociatedElement::formRemovedFromTree(const Node& formRoot) { | 128 void ListedElement::formRemovedFromTree(const Node& formRoot) { |
| 130 DCHECK(m_form); | 129 DCHECK(m_form); |
| 131 if (NodeTraversal::highestAncestorOrSelf(toHTMLElement(*this)) == formRoot) | 130 if (NodeTraversal::highestAncestorOrSelf(toHTMLElement(*this)) == formRoot) |
| 132 return; | 131 return; |
| 133 resetFormOwner(); | 132 resetFormOwner(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 void FormAssociatedElement::associateByParser(HTMLFormElement* form) { | 135 void ListedElement::associateByParser(HTMLFormElement* form) { |
| 137 if (form && form->isConnected()) { | 136 if (form && form->isConnected()) { |
| 138 m_formWasSetByParser = true; | 137 m_formWasSetByParser = true; |
| 139 setForm(form); | 138 setForm(form); |
| 140 form->didAssociateByParser(); | 139 form->didAssociateByParser(); |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 | 142 |
| 144 void FormAssociatedElement::setForm(HTMLFormElement* newForm) { | 143 void ListedElement::setForm(HTMLFormElement* newForm) { |
| 145 if (m_form.get() == newForm) | 144 if (m_form.get() == newForm) |
| 146 return; | 145 return; |
| 147 willChangeForm(); | 146 willChangeForm(); |
| 148 if (m_form) | 147 if (m_form) |
| 149 m_form->disassociate(*this); | 148 m_form->disassociate(*this); |
| 150 if (newForm) { | 149 if (newForm) { |
| 151 m_form = newForm; | 150 m_form = newForm; |
| 152 m_form->associate(*this); | 151 m_form->associate(*this); |
| 153 } else { | 152 } else { |
| 154 m_form = nullptr; | 153 m_form = nullptr; |
| 155 } | 154 } |
| 156 didChangeForm(); | 155 didChangeForm(); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void FormAssociatedElement::willChangeForm() {} | 158 void ListedElement::willChangeForm() {} |
| 160 | 159 |
| 161 void FormAssociatedElement::didChangeForm() { | 160 void ListedElement::didChangeForm() { |
| 162 if (!m_formWasSetByParser && m_form && m_form->isConnected()) { | 161 if (!m_formWasSetByParser && m_form && m_form->isConnected()) { |
| 163 HTMLElement* element = toHTMLElement(this); | 162 HTMLElement* element = toHTMLElement(this); |
| 164 element->document().didAssociateFormControl(element); | 163 element->document().didAssociateFormControl(element); |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 | 166 |
| 168 void FormAssociatedElement::resetFormOwner() { | 167 void ListedElement::resetFormOwner() { |
| 169 m_formWasSetByParser = false; | 168 m_formWasSetByParser = false; |
| 170 HTMLElement* element = toHTMLElement(this); | 169 HTMLElement* element = toHTMLElement(this); |
| 171 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 170 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| 172 HTMLFormElement* nearestForm = element->findFormAncestor(); | 171 HTMLFormElement* nearestForm = element->findFormAncestor(); |
| 173 // 1. If the element's form owner is not null, and either the element is not | 172 // 1. If the element's form owner is not null, and either the element is not |
| 174 // reassociateable or its form content attribute is not present, and the | 173 // reassociateable or its form content attribute is not present, and the |
| 175 // element's form owner is its nearest form element ancestor after the | 174 // element's form owner is its nearest form element ancestor after the |
| 176 // change to the ancestor chain, then do nothing, and abort these steps. | 175 // change to the ancestor chain, then do nothing, and abort these steps. |
| 177 if (m_form && formId.isNull() && m_form.get() == nearestForm) | 176 if (m_form && formId.isNull() && m_form.get() == nearestForm) |
| 178 return; | 177 return; |
| 179 | 178 |
| 180 setForm(findAssociatedForm(element)); | 179 setForm(findAssociatedForm(element)); |
| 181 } | 180 } |
| 182 | 181 |
| 183 void FormAssociatedElement::formAttributeChanged() { | 182 void ListedElement::formAttributeChanged() { |
| 184 resetFormOwner(); | 183 resetFormOwner(); |
| 185 resetFormAttributeTargetObserver(); | 184 resetFormAttributeTargetObserver(); |
| 186 } | 185 } |
| 187 | 186 |
| 188 bool FormAssociatedElement::customError() const { | 187 bool ListedElement::customError() const { |
| 189 const HTMLElement* element = toHTMLElement(this); | 188 const HTMLElement* element = toHTMLElement(this); |
| 190 return element->willValidate() && !m_customValidationMessage.isEmpty(); | 189 return element->willValidate() && !m_customValidationMessage.isEmpty(); |
| 191 } | 190 } |
| 192 | 191 |
| 193 bool FormAssociatedElement::hasBadInput() const { | 192 bool ListedElement::hasBadInput() const { |
| 194 return false; | 193 return false; |
| 195 } | 194 } |
| 196 | 195 |
| 197 bool FormAssociatedElement::patternMismatch() const { | 196 bool ListedElement::patternMismatch() const { |
| 198 return false; | 197 return false; |
| 199 } | 198 } |
| 200 | 199 |
| 201 bool FormAssociatedElement::rangeOverflow() const { | 200 bool ListedElement::rangeOverflow() const { |
| 202 return false; | 201 return false; |
| 203 } | 202 } |
| 204 | 203 |
| 205 bool FormAssociatedElement::rangeUnderflow() const { | 204 bool ListedElement::rangeUnderflow() const { |
| 206 return false; | 205 return false; |
| 207 } | 206 } |
| 208 | 207 |
| 209 bool FormAssociatedElement::stepMismatch() const { | 208 bool ListedElement::stepMismatch() const { |
| 210 return false; | 209 return false; |
| 211 } | 210 } |
| 212 | 211 |
| 213 bool FormAssociatedElement::tooLong() const { | 212 bool ListedElement::tooLong() const { |
| 214 return false; | 213 return false; |
| 215 } | 214 } |
| 216 | 215 |
| 217 bool FormAssociatedElement::tooShort() const { | 216 bool ListedElement::tooShort() const { |
| 218 return false; | 217 return false; |
| 219 } | 218 } |
| 220 | 219 |
| 221 bool FormAssociatedElement::typeMismatch() const { | 220 bool ListedElement::typeMismatch() const { |
| 222 return false; | 221 return false; |
| 223 } | 222 } |
| 224 | 223 |
| 225 bool FormAssociatedElement::valid() const { | 224 bool ListedElement::valid() const { |
| 226 bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || | 225 bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || |
| 227 rangeOverflow() || tooLong() || tooShort() || | 226 rangeOverflow() || tooLong() || tooShort() || |
| 228 patternMismatch() || valueMissing() || hasBadInput() || | 227 patternMismatch() || valueMissing() || hasBadInput() || |
| 229 customError(); | 228 customError(); |
| 230 return !someError; | 229 return !someError; |
| 231 } | 230 } |
| 232 | 231 |
| 233 bool FormAssociatedElement::valueMissing() const { | 232 bool ListedElement::valueMissing() const { |
| 234 return false; | 233 return false; |
| 235 } | 234 } |
| 236 | 235 |
| 237 String FormAssociatedElement::customValidationMessage() const { | 236 String ListedElement::customValidationMessage() const { |
| 238 return m_customValidationMessage; | 237 return m_customValidationMessage; |
| 239 } | 238 } |
| 240 | 239 |
| 241 String FormAssociatedElement::validationMessage() const { | 240 String ListedElement::validationMessage() const { |
| 242 return customError() ? m_customValidationMessage : String(); | 241 return customError() ? m_customValidationMessage : String(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 String FormAssociatedElement::validationSubMessage() const { | 244 String ListedElement::validationSubMessage() const { |
| 246 return String(); | 245 return String(); |
| 247 } | 246 } |
| 248 | 247 |
| 249 void FormAssociatedElement::setCustomValidity(const String& error) { | 248 void ListedElement::setCustomValidity(const String& error) { |
| 250 m_customValidationMessage = error; | 249 m_customValidationMessage = error; |
| 251 } | 250 } |
| 252 | 251 |
| 253 void FormAssociatedElement::setFormAttributeTargetObserver( | 252 void ListedElement::setFormAttributeTargetObserver( |
| 254 FormAttributeTargetObserver* newObserver) { | 253 FormAttributeTargetObserver* newObserver) { |
| 255 if (m_formAttributeTargetObserver) | 254 if (m_formAttributeTargetObserver) |
| 256 m_formAttributeTargetObserver->unregister(); | 255 m_formAttributeTargetObserver->unregister(); |
| 257 m_formAttributeTargetObserver = newObserver; | 256 m_formAttributeTargetObserver = newObserver; |
| 258 } | 257 } |
| 259 | 258 |
| 260 void FormAssociatedElement::resetFormAttributeTargetObserver() { | 259 void ListedElement::resetFormAttributeTargetObserver() { |
| 261 HTMLElement* element = toHTMLElement(this); | 260 HTMLElement* element = toHTMLElement(this); |
| 262 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 261 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
| 263 if (!formId.isNull() && element->isConnected()) | 262 if (!formId.isNull() && element->isConnected()) { |
| 264 setFormAttributeTargetObserver( | 263 setFormAttributeTargetObserver( |
| 265 FormAttributeTargetObserver::create(formId, this)); | 264 FormAttributeTargetObserver::create(formId, this)); |
| 266 else | 265 } else { |
| 267 setFormAttributeTargetObserver(nullptr); | 266 setFormAttributeTargetObserver(nullptr); |
| 267 } | |
| 268 } | 268 } |
| 269 | 269 |
| 270 void FormAssociatedElement::formAttributeTargetChanged() { | 270 void ListedElement::formAttributeTargetChanged() { |
| 271 resetFormOwner(); | 271 resetFormOwner(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 const AtomicString& FormAssociatedElement::name() const { | 274 const AtomicString& ListedElement::name() const { |
| 275 const AtomicString& name = toHTMLElement(this)->getNameAttribute(); | 275 const AtomicString& name = toHTMLElement(this)->getNameAttribute(); |
| 276 return name.isNull() ? emptyAtom : name; | 276 return name.isNull() ? emptyAtom : name; |
| 277 } | 277 } |
| 278 | 278 |
| 279 bool FormAssociatedElement::isFormControlElementWithState() const { | 279 bool ListedElement::isFormControlElementWithState() const { |
| 280 return false; | 280 return false; |
| 281 } | 281 } |
| 282 | 282 |
| 283 const HTMLElement& toHTMLElement( | 283 const HTMLElement& toHTMLElement(const ListedElement& associatedElement) { |
|
tkent
2016/12/02 13:24:37
Rename this argument to listedElement.
| |
| 284 const FormAssociatedElement& associatedElement) { | |
| 285 if (associatedElement.isFormControlElement()) | 284 if (associatedElement.isFormControlElement()) |
| 286 return toHTMLFormControlElement(associatedElement); | 285 return toHTMLFormControlElement(associatedElement); |
| 287 return toHTMLObjectElement(associatedElement); | 286 return toHTMLObjectElement(associatedElement); |
| 288 } | 287 } |
| 289 | 288 |
| 290 const HTMLElement* toHTMLElement( | 289 const HTMLElement* toHTMLElement(const ListedElement* associatedElement) { |
|
tkent
2016/12/02 13:24:37
Rename this argument to listedElement.
| |
| 291 const FormAssociatedElement* associatedElement) { | |
| 292 DCHECK(associatedElement); | 290 DCHECK(associatedElement); |
| 293 return &toHTMLElement(*associatedElement); | 291 return &toHTMLElement(*associatedElement); |
| 294 } | 292 } |
| 295 | 293 |
| 296 HTMLElement* toHTMLElement(FormAssociatedElement* associatedElement) { | 294 HTMLElement* toHTMLElement(ListedElement* associatedElement) { |
|
tkent
2016/12/02 13:24:37
Rename this argument to listedElement.
| |
| 297 return const_cast<HTMLElement*>(toHTMLElement( | 295 return const_cast<HTMLElement*>( |
| 298 static_cast<const FormAssociatedElement*>(associatedElement))); | 296 toHTMLElement(static_cast<const ListedElement*>(associatedElement))); |
| 299 } | 297 } |
| 300 | 298 |
| 301 HTMLElement& toHTMLElement(FormAssociatedElement& associatedElement) { | 299 HTMLElement& toHTMLElement(ListedElement& associatedElement) { |
|
tkent
2016/12/02 13:24:37
Rename this argument to listedElement.
| |
| 302 return const_cast<HTMLElement&>(toHTMLElement( | 300 return const_cast<HTMLElement&>( |
| 303 static_cast<const FormAssociatedElement&>(associatedElement))); | 301 toHTMLElement(static_cast<const ListedElement&>(associatedElement))); |
| 304 } | 302 } |
| 305 | 303 |
| 306 FormAttributeTargetObserver* FormAttributeTargetObserver::create( | 304 FormAttributeTargetObserver* FormAttributeTargetObserver::create( |
| 307 const AtomicString& id, | 305 const AtomicString& id, |
| 308 FormAssociatedElement* element) { | 306 ListedElement* element) { |
| 309 return new FormAttributeTargetObserver(id, element); | 307 return new FormAttributeTargetObserver(id, element); |
| 310 } | 308 } |
| 311 | 309 |
| 312 FormAttributeTargetObserver::FormAttributeTargetObserver( | 310 FormAttributeTargetObserver::FormAttributeTargetObserver(const AtomicString& id, |
| 313 const AtomicString& id, | 311 ListedElement* element) |
| 314 FormAssociatedElement* element) | |
| 315 : IdTargetObserver( | 312 : IdTargetObserver( |
| 316 toHTMLElement(element)->treeScope().idTargetObserverRegistry(), | 313 toHTMLElement(element)->treeScope().idTargetObserverRegistry(), |
| 317 id), | 314 id), |
| 318 m_element(element) {} | 315 m_element(element) {} |
| 319 | 316 |
| 320 DEFINE_TRACE(FormAttributeTargetObserver) { | 317 DEFINE_TRACE(FormAttributeTargetObserver) { |
| 321 visitor->trace(m_element); | 318 visitor->trace(m_element); |
| 322 IdTargetObserver::trace(visitor); | 319 IdTargetObserver::trace(visitor); |
| 323 } | 320 } |
| 324 | 321 |
| 325 void FormAttributeTargetObserver::idTargetChanged() { | 322 void FormAttributeTargetObserver::idTargetChanged() { |
| 326 m_element->formAttributeTargetChanged(); | 323 m_element->formAttributeTargetChanged(); |
| 327 } | 324 } |
| 328 | 325 |
| 329 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |