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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTagCollection.h

Issue 2868823002: getElementsByTagName() should take a qualifiedName in parameter (Closed)
Patch Set: Rebased And Align with review comments Created 3 years, 7 months 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
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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 18 matching lines...) Expand all
29 #include "core/dom/TagCollection.h" 29 #include "core/dom/TagCollection.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 // Collection that limits to a particular tag and whose rootNode is in an 33 // Collection that limits to a particular tag and whose rootNode is in an
34 // HTMLDocument. 34 // HTMLDocument.
35 class HTMLTagCollection final : public TagCollection { 35 class HTMLTagCollection final : public TagCollection {
36 public: 36 public:
37 static HTMLTagCollection* Create(ContainerNode& root_node, 37 static HTMLTagCollection* Create(ContainerNode& root_node,
38 CollectionType type, 38 CollectionType type,
39 const AtomicString& local_name) { 39 const AtomicString& qualified_name) {
40 DCHECK_EQ(type, kHTMLTagCollectionType); 40 DCHECK_EQ(type, kHTMLTagCollectionType);
41 return new HTMLTagCollection(root_node, local_name); 41 return new HTMLTagCollection(root_node, qualified_name);
42 } 42 }
43 43
44 bool ElementMatches(const Element&) const; 44 bool ElementMatches(const Element&) const;
45 45
46 private: 46 private:
47 HTMLTagCollection(ContainerNode& root_node, const AtomicString& local_name); 47 HTMLTagCollection(ContainerNode& root_node,
48 const AtomicString& qualified_name);
48 49
49 AtomicString lowered_local_name_; 50 AtomicString lowered_qualified_name_;
50 }; 51 };
51 52
52 DEFINE_TYPE_CASTS(HTMLTagCollection, 53 DEFINE_TYPE_CASTS(HTMLTagCollection,
53 LiveNodeListBase, 54 LiveNodeListBase,
54 collection, 55 collection,
55 collection->GetType() == kHTMLTagCollectionType, 56 collection->GetType() == kHTMLTagCollectionType,
56 collection.GetType() == kHTMLTagCollectionType); 57 collection.GetType() == kHTMLTagCollectionType);
57 58
58 inline bool HTMLTagCollection::ElementMatches( 59 inline bool HTMLTagCollection::ElementMatches(
59 const Element& test_element) const { 60 const Element& test_element) const {
60 // Implements 61 if (qualified_name_ == g_star_atom)
61 // https://dom.spec.whatwg.org/#concept-getelementsbytagname 62 return true;
62 if (local_name_ != g_star_atom) { 63 if (test_element.IsHTMLElement())
63 const AtomicString& local_name = 64 return lowered_qualified_name_ == test_element.TagQName().ToString();
64 test_element.IsHTMLElement() ? lowered_local_name_ : local_name_; 65 return qualified_name_ == test_element.TagQName().ToString();
65 if (local_name != test_element.localName())
66 return false;
67 }
68 DCHECK_EQ(namespace_uri_, g_star_atom);
69 return true;
70 } 66 }
71 67
72 } // namespace blink 68 } // namespace blink
73 69
74 #endif // HTMLTagCollection_h 70 #endif // HTMLTagCollection_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCollection.cpp ('k') | third_party/WebKit/Source/core/html/HTMLTagCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698