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

Side by Side Diff: third_party/WebKit/Source/core/dom/TagCollection.cpp

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 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 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 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 12 matching lines...) Expand all
23 23
24 #include "core/dom/TagCollection.h" 24 #include "core/dom/TagCollection.h"
25 25
26 #include "core/dom/NodeRareData.h" 26 #include "core/dom/NodeRareData.h"
27 #include "platform/wtf/Assertions.h" 27 #include "platform/wtf/Assertions.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 TagCollection::TagCollection(ContainerNode& root_node, 31 TagCollection::TagCollection(ContainerNode& root_node,
32 CollectionType type, 32 CollectionType type,
33 const AtomicString& namespace_uri, 33 const AtomicString& qualified_name)
34 const AtomicString& local_name) 34 : HTMLCollection(root_node, type, kDoesNotOverrideItemAfter),
35 qualified_name_(qualified_name) {
36 DCHECK_NE(qualified_name, g_star_atom);
37 }
38
39 TagCollection::~TagCollection() {}
40
41 bool TagCollection::ElementMatches(const Element& test_node) const {
42 return qualified_name_ == test_node.TagQName().ToString();
fs 2017/05/08 14:20:36 See comment in HTMLTagCollection.
43 }
44
45 TagCollectionNS::TagCollectionNS(ContainerNode& root_node,
46 CollectionType type,
47 const AtomicString& namespace_uri,
48 const AtomicString& local_name)
35 : HTMLCollection(root_node, type, kDoesNotOverrideItemAfter), 49 : HTMLCollection(root_node, type, kDoesNotOverrideItemAfter),
36 namespace_uri_(namespace_uri), 50 namespace_uri_(namespace_uri),
37 local_name_(local_name) { 51 local_name_(local_name) {
38 DCHECK(namespace_uri_.IsNull() || !namespace_uri_.IsEmpty()); 52 DCHECK(namespace_uri_.IsNull() || !namespace_uri_.IsEmpty());
39 } 53 }
40 54
41 TagCollection::~TagCollection() {} 55 TagCollectionNS::~TagCollectionNS() {}
42 56
43 bool TagCollection::ElementMatches(const Element& test_node) const { 57 bool TagCollectionNS::ElementMatches(const Element& test_node) const {
44 // Implements 58 // Implements
45 // https://dom.spec.whatwg.org/#concept-getelementsbytagnamens 59 // https://dom.spec.whatwg.org/#concept-getelementsbytagnamens
46 if (local_name_ != g_star_atom && local_name_ != test_node.localName()) 60 if (local_name_ != g_star_atom && local_name_ != test_node.localName())
47 return false; 61 return false;
48 62
49 return namespace_uri_ == g_star_atom || 63 return namespace_uri_ == g_star_atom ||
50 namespace_uri_ == test_node.namespaceURI(); 64 namespace_uri_ == test_node.namespaceURI();
51 } 65 }
52 66
53 } // namespace blink 67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698