| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 HTMLAllCollection::~HTMLAllCollection() | 46 HTMLAllCollection::~HTMLAllCollection() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigne
d index) const | 50 Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigne
d index) const |
| 51 { | 51 { |
| 52 updateIdNameCache(); | 52 updateIdNameCache(); |
| 53 | 53 |
| 54 const NamedItemCache& cache = namedItemCache(); | 54 const NamedItemCache& cache = namedItemCache(); |
| 55 if (WillBeHeapVector<RawPtrWillBeMember<Element> >* elements = cache.getElem
entsById(name)) { | 55 if (WillBeHeapVector<RawPtrWillBeMember<Element>>* elements = cache.getEleme
ntsById(name)) { |
| 56 if (index < elements->size()) | 56 if (index < elements->size()) |
| 57 return elements->at(index); | 57 return elements->at(index); |
| 58 index -= elements->size(); | 58 index -= elements->size(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (WillBeHeapVector<RawPtrWillBeMember<Element> >* elements = cache.getElem
entsByName(name)) { | 61 if (WillBeHeapVector<RawPtrWillBeMember<Element>>* elements = cache.getEleme
ntsByName(name)) { |
| 62 if (index < elements->size()) | 62 if (index < elements->size()) |
| 63 return elements->at(index); | 63 return elements->at(index); |
| 64 } | 64 } |
| 65 | 65 |
| 66 return 0; | 66 return 0; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void HTMLAllCollection::namedGetter(const AtomicString& name, NodeListOrElement&
returnValue) | 69 void HTMLAllCollection::namedGetter(const AtomicString& name, NodeListOrElement&
returnValue) |
| 70 { | 70 { |
| 71 WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems; | 71 WillBeHeapVector<RefPtrWillBeMember<Element>> namedItems; |
| 72 this->namedItems(name, namedItems); | 72 this->namedItems(name, namedItems); |
| 73 | 73 |
| 74 if (!namedItems.size()) | 74 if (!namedItems.size()) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 if (namedItems.size() == 1) { | 77 if (namedItems.size() == 1) { |
| 78 returnValue.setElement(namedItems.at(0)); | 78 returnValue.setElement(namedItems.at(0)); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // FIXME: HTML5 specification says this should be a HTMLCollection. | 82 // FIXME: HTML5 specification says this should be a HTMLCollection. |
| 83 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlallcollection | 83 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlallcollection |
| 84 returnValue.setNodeList(StaticElementList::adopt(namedItems)); | 84 returnValue.setNodeList(StaticElementList::adopt(namedItems)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |