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 18 matching lines...) Expand all Loading... | |
29 #include "core/dom/IdTargetObserver.h" | 29 #include "core/dom/IdTargetObserver.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 WebCore { | 35 namespace WebCore { |
36 | 36 |
37 using namespace HTMLNames; | 37 using namespace HTMLNames; |
38 | 38 |
39 class FormAttributeTargetObserver : IdTargetObserver { | 39 class FormAttributeTargetObserver : public IdTargetObserver { |
40 WTF_MAKE_FAST_ALLOCATED; | 40 WTF_MAKE_FAST_ALLOCATED; |
41 public: | 41 public: |
42 static PassOwnPtr<FormAttributeTargetObserver> create(const AtomicString& id , FormAssociatedElement*); | 42 static PassOwnPtr<FormAttributeTargetObserver> create(const AtomicString& id , FormAssociatedElement*); |
43 virtual void idTargetChanged() OVERRIDE; | 43 virtual void idTargetChanged() OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement*); | 46 FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement*); |
47 | 47 |
48 FormAssociatedElement* m_element; | 48 FormAssociatedElement* m_element; |
49 }; | 49 }; |
(...skipping 13 matching lines...) Expand all Loading... | |
63 if (!m_validityState) | 63 if (!m_validityState) |
64 m_validityState = ValidityState::create(this); | 64 m_validityState = ValidityState::create(this); |
65 | 65 |
66 return m_validityState.get(); | 66 return m_validityState.get(); |
67 } | 67 } |
68 | 68 |
69 void FormAssociatedElement::didMoveToNewDocument(Document& oldDocument) | 69 void FormAssociatedElement::didMoveToNewDocument(Document& oldDocument) |
70 { | 70 { |
71 HTMLElement* element = toHTMLElement(this); | 71 HTMLElement* element = toHTMLElement(this); |
72 if (element->fastHasAttribute(formAttr)) | 72 if (element->fastHasAttribute(formAttr)) |
73 m_formAttributeTargetObserver = nullptr; | 73 setFormAttributeTargetObserver(nullptr); |
74 } | 74 } |
75 | 75 |
76 void FormAssociatedElement::insertedInto(ContainerNode* insertionPoint) | 76 void FormAssociatedElement::insertedInto(ContainerNode* insertionPoint) |
77 { | 77 { |
78 if (!m_formWasSetByParser || insertionPoint->highestAncestorOrSelf() != m_fo rm->highestAncestorOrSelf()) | 78 if (!m_formWasSetByParser || insertionPoint->highestAncestorOrSelf() != m_fo rm->highestAncestorOrSelf()) |
79 resetFormOwner(); | 79 resetFormOwner(); |
80 | 80 |
81 if (!insertionPoint->inDocument()) | 81 if (!insertionPoint->inDocument()) |
82 return; | 82 return; |
83 | 83 |
84 HTMLElement* element = toHTMLElement(this); | 84 HTMLElement* element = toHTMLElement(this); |
85 if (element->fastHasAttribute(formAttr)) | 85 if (element->fastHasAttribute(formAttr)) |
86 resetFormAttributeTargetObserver(); | 86 resetFormAttributeTargetObserver(); |
87 } | 87 } |
88 | 88 |
89 void FormAssociatedElement::removedFrom(ContainerNode* insertionPoint) | 89 void FormAssociatedElement::removedFrom(ContainerNode* insertionPoint) |
90 { | 90 { |
91 HTMLElement* element = toHTMLElement(this); | 91 HTMLElement* element = toHTMLElement(this); |
92 if (insertionPoint->inDocument() && element->fastHasAttribute(formAttr)) | 92 if (insertionPoint->inDocument() && element->fastHasAttribute(formAttr)) |
93 m_formAttributeTargetObserver = nullptr; | 93 setFormAttributeTargetObserver(nullptr); |
94 // If the form and element are both in the same tree, preserve the connectio n to the form. | 94 // If the form and element are both in the same tree, preserve the connectio n to the form. |
95 // Otherwise, null out our form and remove ourselves from the form's list of elements. | 95 // Otherwise, null out our form and remove ourselves from the form's list of elements. |
96 if (m_form && element->highestAncestorOrSelf() != m_form->highestAncestorOrS elf()) | 96 if (m_form && element->highestAncestorOrSelf() != m_form->highestAncestorOrS elf()) |
97 resetFormOwner(); | 97 resetFormOwner(); |
98 } | 98 } |
99 | 99 |
100 HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el ement) | 100 HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el ement) |
101 { | 101 { |
102 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 102 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
103 // 3. If the element is reassociateable, has a form content attribute, and | 103 // 3. If the element is reassociateable, has a form content attribute, and |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 String FormAssociatedElement::validationMessage() const | 246 String FormAssociatedElement::validationMessage() const |
247 { | 247 { |
248 return customError() ? m_customValidationMessage : String(); | 248 return customError() ? m_customValidationMessage : String(); |
249 } | 249 } |
250 | 250 |
251 void FormAssociatedElement::setCustomValidity(const String& error) | 251 void FormAssociatedElement::setCustomValidity(const String& error) |
252 { | 252 { |
253 m_customValidationMessage = error; | 253 m_customValidationMessage = error; |
254 } | 254 } |
255 | 255 |
256 void FormAssociatedElement::setFormAttributeTargetObserver(PassOwnPtr<FormAttrib uteTargetObserver> newObserver) | |
haraken
2014/05/06 15:59:42
This complexity will be removed once we move IdTar
Mads Ager (chromium)
2014/05/07 12:13:16
Yes, if that is the right thing to do. It will mak
| |
257 { | |
258 if (m_formAttributeTargetObserver) | |
259 m_formAttributeTargetObserver->unregister(); | |
260 m_formAttributeTargetObserver = newObserver; | |
261 } | |
262 | |
256 void FormAssociatedElement::resetFormAttributeTargetObserver() | 263 void FormAssociatedElement::resetFormAttributeTargetObserver() |
257 { | 264 { |
258 HTMLElement* element = toHTMLElement(this); | 265 HTMLElement* element = toHTMLElement(this); |
259 const AtomicString& formId(element->fastGetAttribute(formAttr)); | 266 const AtomicString& formId(element->fastGetAttribute(formAttr)); |
260 if (!formId.isNull() && element->inDocument()) | 267 if (!formId.isNull() && element->inDocument()) |
261 m_formAttributeTargetObserver = FormAttributeTargetObserver::create(form Id, this); | 268 setFormAttributeTargetObserver(FormAttributeTargetObserver::create(formI d, this)); |
262 else | 269 else |
263 m_formAttributeTargetObserver = nullptr; | 270 setFormAttributeTargetObserver(nullptr); |
264 } | 271 } |
265 | 272 |
266 void FormAssociatedElement::formAttributeTargetChanged() | 273 void FormAssociatedElement::formAttributeTargetChanged() |
267 { | 274 { |
268 resetFormOwner(); | 275 resetFormOwner(); |
269 } | 276 } |
270 | 277 |
271 const AtomicString& FormAssociatedElement::name() const | 278 const AtomicString& FormAssociatedElement::name() const |
272 { | 279 { |
273 const AtomicString& name = toHTMLElement(this)->getNameAttribute(); | 280 const AtomicString& name = toHTMLElement(this)->getNameAttribute(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 , m_element(element) | 320 , m_element(element) |
314 { | 321 { |
315 } | 322 } |
316 | 323 |
317 void FormAttributeTargetObserver::idTargetChanged() | 324 void FormAttributeTargetObserver::idTargetChanged() |
318 { | 325 { |
319 m_element->formAttributeTargetChanged(); | 326 m_element->formAttributeTargetChanged(); |
320 } | 327 } |
321 | 328 |
322 } // namespace Webcore | 329 } // namespace Webcore |
OLD | NEW |