Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: Source/core/html/HTMLCollection.cpp

Issue 120383002: HTMLCollection should not inherit NodeList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLCollection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2008, 2011, 2012 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (!element->isHTMLElement()) 640 if (!element->isHTMLElement())
641 continue; 641 continue;
642 const AtomicString& nameAttrVal = element->getNameAttribute(); 642 const AtomicString& nameAttrVal = element->getNameAttribute();
643 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (type() != Doc All || nameShouldBeVisibleInDocumentAll(toHTMLElement(element)))) 643 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (type() != Doc All || nameShouldBeVisibleInDocumentAll(toHTMLElement(element))))
644 appendNameCache(nameAttrVal, element); 644 appendNameCache(nameAttrVal, element);
645 } 645 }
646 646
647 setHasNameCache(); 647 setHasNameCache();
648 } 648 }
649 649
650 bool HTMLCollection::hasNamedItem(const AtomicString& name) const
651 {
652 if (name.isEmpty())
653 return false;
654
655 updateNameCache();
656
657 if (Vector<Element*>* cache = idCache(name)) {
658 if (!cache->isEmpty())
659 return true;
660 }
661
662 if (Vector<Element*>* cache = nameCache(name)) {
663 if (!cache->isEmpty())
664 return true;
665 }
666
667 return false;
668 }
669
670 void HTMLCollection::namedItems(const AtomicString& name, Vector<RefPtr<Node> >& result) const 650 void HTMLCollection::namedItems(const AtomicString& name, Vector<RefPtr<Node> >& result) const
671 { 651 {
672 ASSERT(result.isEmpty()); 652 ASSERT(result.isEmpty());
673 if (name.isEmpty()) 653 if (name.isEmpty())
674 return; 654 return;
675 655
676 updateNameCache(); 656 updateNameCache();
677 657
678 Vector<Element*>* idResults = idCache(name); 658 Vector<Element*>* idResults = idCache(name);
679 Vector<Element*>* nameResults = nameCache(name); 659 Vector<Element*>* nameResults = nameCache(name);
680 660
681 for (unsigned i = 0; idResults && i < idResults->size(); ++i) 661 for (unsigned i = 0; idResults && i < idResults->size(); ++i)
682 result.append(idResults->at(i)); 662 result.append(idResults->at(i));
683 663
684 for (unsigned i = 0; nameResults && i < nameResults->size(); ++i) 664 for (unsigned i = 0; nameResults && i < nameResults->size(); ++i)
685 result.append(nameResults->at(i)); 665 result.append(nameResults->at(i));
686 } 666 }
687 667
688 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element) 668 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element)
689 { 669 {
690 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue; 670 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue;
691 if (!vector) 671 if (!vector)
692 vector = adoptPtr(new Vector<Element*>); 672 vector = adoptPtr(new Vector<Element*>);
693 vector->append(element); 673 vector->append(element);
694 } 674 }
695 675
696 } // namespace WebCore 676 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCollection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698