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

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

Issue 2868823002: getElementsByTagName() should take a qualifiedName in parameter (Closed)
Patch Set: Added new file AllDescendantsCollection.h 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 (test_element.IsHTMLElement())
tkent 2017/05/09 00:28:01 The specification says "if root’s node document is
Shanmuga Pandi 2017/05/10 06:35:45 I have tried to replace the if condition with belo
fs 2017/05/10 08:34:15 FWIW, I think this "IsHTMLElement" check correspon
tkent 2017/05/11 04:14:02 You're right. "if root’s node document is an HTML
61 // https://dom.spec.whatwg.org/#concept-getelementsbytagname 62 return lowered_qualified_name_ == test_element.TagQName().ToString();
62 if (local_name_ != g_star_atom) { 63 return qualified_name_ == test_element.TagQName().ToString();
fs 2017/05/08 14:20:36 This creates a temporary string for each compariso
Shanmuga Pandi 2017/05/10 06:35:45 I think initially webkit tried this approach and l
Shanmuga Pandi 2017/05/10 07:05:28 Can we use Document::ParseQualifiedName() and stor
fs 2017/05/10 08:34:15 Fair enough. We could add a "CompareQualifiedName(
Shanmuga Pandi 2017/05/10 09:03:12 Ok. I will keep the current comparision as it is a
63 const AtomicString& local_name =
64 test_element.IsHTMLElement() ? lowered_local_name_ : local_name_;
65 if (local_name != test_element.localName())
66 return false;
67 }
68 DCHECK_EQ(namespace_uri_, g_star_atom);
69 return true;
70 } 64 }
71 65
72 } // namespace blink 66 } // namespace blink
73 67
74 #endif // HTMLTagCollection_h 68 #endif // HTMLTagCollection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698