| 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 Apple Inc. All r
ights reserved. |
| 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 using namespace HTMLNames; | 36 using namespace HTMLNames; |
| 37 | 37 |
| 38 // Since the collections are to be "live", we have to do the | 38 // Since the collections are to be "live", we have to do the |
| 39 // calculation every time if anything has changed. | 39 // calculation every time if anything has changed. |
| 40 | 40 |
| 41 HTMLFormControlsCollection::HTMLFormControlsCollection(ContainerNode& ownerNode) | 41 HTMLFormControlsCollection::HTMLFormControlsCollection(ContainerNode& ownerNode) |
| 42 : HTMLCollection(ownerNode, FormControls, OverridesItemAfter) | 42 : HTMLCollection(ownerNode, FormControls, OverridesItemAfter) |
| 43 , m_cachedElement(nullptr) | 43 , m_cachedElement(nullptr) |
| 44 , m_cachedElementOffsetInArray(0) | 44 , m_cachedElementOffsetInArray(0) |
| 45 { | 45 { |
| 46 ASSERT(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode)); | 46 DCHECK(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 HTMLFormControlsCollection* HTMLFormControlsCollection::create(ContainerNode& ow
nerNode, CollectionType type) | 49 HTMLFormControlsCollection* HTMLFormControlsCollection::create(ContainerNode& ow
nerNode, CollectionType type) |
| 50 { | 50 { |
| 51 ASSERT_UNUSED(type, type == FormControls); | 51 DCHECK_EQ(type, FormControls); |
| 52 return new HTMLFormControlsCollection(ownerNode); | 52 return new HTMLFormControlsCollection(ownerNode); |
| 53 } | 53 } |
| 54 | 54 |
| 55 HTMLFormControlsCollection::~HTMLFormControlsCollection() | 55 HTMLFormControlsCollection::~HTMLFormControlsCollection() |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 const FormAssociatedElement::List& HTMLFormControlsCollection::formControlElemen
ts() const | 59 const FormAssociatedElement::List& HTMLFormControlsCollection::formControlElemen
ts() const |
| 60 { | 60 { |
| 61 ASSERT(isHTMLFormElement(ownerNode()) || isHTMLFieldSetElement(ownerNode()))
; | 61 DCHECK(isHTMLFormElement(ownerNode()) || isHTMLFieldSetElement(ownerNode()))
; |
| 62 if (isHTMLFormElement(ownerNode())) | 62 if (isHTMLFormElement(ownerNode())) |
| 63 return toHTMLFormElement(ownerNode()).associatedElements(); | 63 return toHTMLFormElement(ownerNode()).associatedElements(); |
| 64 return toHTMLFieldSetElement(ownerNode()).associatedElements(); | 64 return toHTMLFieldSetElement(ownerNode()).associatedElements(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 const HeapVector<Member<HTMLImageElement>>& HTMLFormControlsCollection::formImag
eElements() const | 67 const HeapVector<Member<HTMLImageElement>>& HTMLFormControlsCollection::formImag
eElements() const |
| 68 { | 68 { |
| 69 return toHTMLFormElement(ownerNode()).imageElements(); | 69 return toHTMLFormElement(ownerNode()).imageElements(); |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 void HTMLFormControlsCollection::invalidateCache(Document* oldDocument) const | 105 void HTMLFormControlsCollection::invalidateCache(Document* oldDocument) const |
| 106 { | 106 { |
| 107 HTMLCollection::invalidateCache(oldDocument); | 107 HTMLCollection::invalidateCache(oldDocument); |
| 108 m_cachedElement = nullptr; | 108 m_cachedElement = nullptr; |
| 109 m_cachedElementOffsetInArray = 0; | 109 m_cachedElementOffsetInArray = 0; |
| 110 } | 110 } |
| 111 | 111 |
| 112 static HTMLElement* firstNamedItem(const FormAssociatedElement::List& elementsAr
ray, const QualifiedName& attrName, const String& name) | 112 static HTMLElement* firstNamedItem(const FormAssociatedElement::List& elementsAr
ray, const QualifiedName& attrName, const String& name) |
| 113 { | 113 { |
| 114 ASSERT(attrName == idAttr || attrName == nameAttr); | 114 DCHECK(attrName == idAttr || attrName == nameAttr); |
| 115 | 115 |
| 116 for (unsigned i = 0; i < elementsArray.size(); ++i) { | 116 for (unsigned i = 0; i < elementsArray.size(); ++i) { |
| 117 HTMLElement* element = toHTMLElement(elementsArray[i]); | 117 HTMLElement* element = toHTMLElement(elementsArray[i]); |
| 118 if (elementsArray[i]->isEnumeratable() && element->fastGetAttribute(attr
Name) == name) | 118 if (elementsArray[i]->isEnumeratable() && element->fastGetAttribute(attr
Name) == name) |
| 119 return element; | 119 return element; |
| 120 } | 120 } |
| 121 return nullptr; | 121 return nullptr; |
| 122 } | 122 } |
| 123 | 123 |
| 124 HTMLElement* HTMLFormControlsCollection::namedItem(const AtomicString& name) con
st | 124 HTMLElement* HTMLFormControlsCollection::namedItem(const AtomicString& name) con
st |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 { | 205 { |
| 206 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlformcontrolscollection-0: | 206 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlformcontrolscollection-0: |
| 207 // The supported property names consist of the non-empty values of all the i
d and name attributes | 207 // The supported property names consist of the non-empty values of all the i
d and name attributes |
| 208 // of all the elements represented by the collection, in tree order, ignorin
g later duplicates, | 208 // of all the elements represented by the collection, in tree order, ignorin
g later duplicates, |
| 209 // with the id of an element preceding its name if it contributes both, they
differ from each | 209 // with the id of an element preceding its name if it contributes both, they
differ from each |
| 210 // other, and neither is the duplicate of an earlier entry. | 210 // other, and neither is the duplicate of an earlier entry. |
| 211 HashSet<AtomicString> existingNames; | 211 HashSet<AtomicString> existingNames; |
| 212 unsigned length = this->length(); | 212 unsigned length = this->length(); |
| 213 for (unsigned i = 0; i < length; ++i) { | 213 for (unsigned i = 0; i < length; ++i) { |
| 214 HTMLElement* element = item(i); | 214 HTMLElement* element = item(i); |
| 215 ASSERT(element); | 215 DCHECK(element); |
| 216 const AtomicString& idAttribute = element->getIdAttribute(); | 216 const AtomicString& idAttribute = element->getIdAttribute(); |
| 217 if (!idAttribute.isEmpty()) { | 217 if (!idAttribute.isEmpty()) { |
| 218 HashSet<AtomicString>::AddResult addResult = existingNames.add(idAtt
ribute); | 218 HashSet<AtomicString>::AddResult addResult = existingNames.add(idAtt
ribute); |
| 219 if (addResult.isNewEntry) | 219 if (addResult.isNewEntry) |
| 220 names.append(idAttribute); | 220 names.append(idAttribute); |
| 221 } | 221 } |
| 222 const AtomicString& nameAttribute = element->getNameAttribute(); | 222 const AtomicString& nameAttribute = element->getNameAttribute(); |
| 223 if (!nameAttribute.isEmpty()) { | 223 if (!nameAttribute.isEmpty()) { |
| 224 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 224 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
| 225 if (addResult.isNewEntry) | 225 if (addResult.isNewEntry) |
| 226 names.append(nameAttribute); | 226 names.append(nameAttribute); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 DEFINE_TRACE(HTMLFormControlsCollection) | 231 DEFINE_TRACE(HTMLFormControlsCollection) |
| 232 { | 232 { |
| 233 visitor->trace(m_cachedElement); | 233 visitor->trace(m_cachedElement); |
| 234 HTMLCollection::trace(visitor); | 234 HTMLCollection::trace(visitor); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |