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

Side by Side Diff: third_party/WebKit/Source/core/dom/ContainerNode.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, 2008, 2009, 2013 Apple Inc. All rights 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
6 * reserved. 6 * reserved.
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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/dom/ContainerNode.h" 24 #include "core/dom/ContainerNode.h"
25 25
26 #include "bindings/core/v8/ExceptionState.h" 26 #include "bindings/core/v8/ExceptionState.h"
27 #include "core/dom/AllDescendantsCollection.h"
27 #include "core/dom/ChildFrameDisconnector.h" 28 #include "core/dom/ChildFrameDisconnector.h"
28 #include "core/dom/ChildListMutationScope.h" 29 #include "core/dom/ChildListMutationScope.h"
29 #include "core/dom/ClassCollection.h" 30 #include "core/dom/ClassCollection.h"
30 #include "core/dom/ElementTraversal.h" 31 #include "core/dom/ElementTraversal.h"
31 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/NameNodeList.h" 33 #include "core/dom/NameNodeList.h"
33 #include "core/dom/NodeChildRemovalTracker.h" 34 #include "core/dom/NodeChildRemovalTracker.h"
34 #include "core/dom/NodeComputedStyle.h" 35 #include "core/dom/NodeComputedStyle.h"
35 #include "core/dom/NodeRareData.h" 36 #include "core/dom/NodeRareData.h"
36 #include "core/dom/NodeTraversal.h" 37 #include "core/dom/NodeTraversal.h"
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 return; 1434 return;
1434 1435
1435 GetDocument().InvalidateNodeListCaches(attr_name); 1436 GetDocument().InvalidateNodeListCaches(attr_name);
1436 1437
1437 for (ContainerNode* node = this; node; node = node->parentNode()) { 1438 for (ContainerNode* node = this; node; node = node->parentNode()) {
1438 if (NodeListsNodeData* lists = node->NodeLists()) 1439 if (NodeListsNodeData* lists = node->NodeLists())
1439 lists->InvalidateCaches(attr_name); 1440 lists->InvalidateCaches(attr_name);
1440 } 1441 }
1441 } 1442 }
1442 1443
1443 TagCollection* ContainerNode::getElementsByTagName( 1444 HTMLCollection* ContainerNode::getElementsByTagName(
1444 const AtomicString& local_name) { 1445 const AtomicString& qualified_name) {
1445 if (GetDocument().IsHTMLDocument()) 1446 DCHECK(!qualified_name.IsNull());
1447
1448 if (qualified_name == g_star_atom) {
1449 return EnsureCachedCollection<AllDescendantsCollection>(
1450 kAllDescendantsCollectionType);
1451 }
1452
1453 if (GetDocument().IsHTMLDocument()) {
1446 return EnsureCachedCollection<HTMLTagCollection>(kHTMLTagCollectionType, 1454 return EnsureCachedCollection<HTMLTagCollection>(kHTMLTagCollectionType,
1447 local_name); 1455 qualified_name);
1448 return EnsureCachedCollection<TagCollection>(kTagCollectionType, local_name); 1456 }
1457 return EnsureCachedCollection<TagCollection>(kTagCollectionType,
1458 qualified_name);
1449 } 1459 }
1450 1460
1451 TagCollection* ContainerNode::getElementsByTagNameNS( 1461 HTMLCollection* ContainerNode::getElementsByTagNameNS(
1452 const AtomicString& namespace_uri, 1462 const AtomicString& namespace_uri,
1453 const AtomicString& local_name) { 1463 const AtomicString& local_name) {
1454 if (namespace_uri == g_star_atom) 1464 return EnsureCachedCollection<TagCollectionNS>(
1455 return getElementsByTagName(local_name); 1465 kTagCollectionNSType,
1456 1466 namespace_uri.IsEmpty() ? g_null_atom : namespace_uri, local_name);
1457 return EnsureCachedCollection<TagCollection>(
1458 kTagCollectionType, namespace_uri.IsEmpty() ? g_null_atom : namespace_uri,
1459 local_name);
1460 } 1467 }
1461 1468
1462 // Takes an AtomicString in argument because it is common for elements to share 1469 // Takes an AtomicString in argument because it is common for elements to share
1463 // the same name attribute. Therefore, the NameNodeList factory function 1470 // the same name attribute. Therefore, the NameNodeList factory function
1464 // expects an AtomicString type. 1471 // expects an AtomicString type.
1465 NameNodeList* ContainerNode::getElementsByName( 1472 NameNodeList* ContainerNode::getElementsByName(
1466 const AtomicString& element_name) { 1473 const AtomicString& element_name) {
1467 return EnsureCachedCollection<NameNodeList>(kNameNodeListType, element_name); 1474 return EnsureCachedCollection<NameNodeList>(kNameNodeListType, element_name);
1468 } 1475 }
1469 1476
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 return true; 1527 return true;
1521 1528
1522 if (node->IsElementNode() && ToElement(node)->Shadow()) 1529 if (node->IsElementNode() && ToElement(node)->Shadow())
1523 return true; 1530 return true;
1524 1531
1525 return false; 1532 return false;
1526 } 1533 }
1527 #endif 1534 #endif
1528 1535
1529 } // namespace blink 1536 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698