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

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 465483002: Merge NamedNodesCollection and StaticNodeList classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLOptionsCollection.cpp ('k') | Source/core/testing/Internals.h » ('j') | 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 *elementId = pushNodePathToFrontend(element.get()); 650 *elementId = pushNodePathToFrontend(element.get());
651 } 651 }
652 652
653 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int> >& result) 653 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int> >& result)
654 { 654 {
655 Node* node = assertNode(errorString, nodeId); 655 Node* node = assertNode(errorString, nodeId);
656 if (!node || !node->isContainerNode()) 656 if (!node || !node->isContainerNode())
657 return; 657 return;
658 658
659 TrackExceptionState exceptionState; 659 TrackExceptionState exceptionState;
660 RefPtrWillBeRawPtr<StaticNodeList> nodes = toContainerNode(node)->querySelec torAll(AtomicString(selectors), exceptionState); 660 RefPtrWillBeRawPtr<StaticElementList> elements = toContainerNode(node)->quer ySelectorAll(AtomicString(selectors), exceptionState);
661 if (exceptionState.hadException()) { 661 if (exceptionState.hadException()) {
662 *errorString = "DOM Error while querying"; 662 *errorString = "DOM Error while querying";
663 return; 663 return;
664 } 664 }
665 665
666 result = TypeBuilder::Array<int>::create(); 666 result = TypeBuilder::Array<int>::create();
667 667
668 for (unsigned i = 0; i < nodes->length(); ++i) 668 for (unsigned i = 0; i < elements->length(); ++i)
669 result->addItem(pushNodePathToFrontend(nodes->item(i))); 669 result->addItem(pushNodePathToFrontend(elements->item(i)));
670 } 670 }
671 671
672 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) 672 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
673 { 673 {
674 ASSERT(nodeToPush); // Invalid input 674 ASSERT(nodeToPush); // Invalid input
675 675
676 if (!m_document) 676 if (!m_document)
677 return 0; 677 return 0;
678 if (!m_documentNodeToIdMap->contains(m_document)) 678 if (!m_documentNodeToIdMap->contains(m_document))
679 return 0; 679 return 0;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 if (node->nodeType() == Node::ATTRIBUTE_NODE) 1094 if (node->nodeType() == Node::ATTRIBUTE_NODE)
1095 node = toAttr(node)->ownerElement(); 1095 node = toAttr(node)->ownerElement();
1096 resultCollector.add(node); 1096 resultCollector.add(node);
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 // Selector evaluation 1100 // Selector evaluation
1101 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs .begin(); it != docs.end(); ++it) { 1101 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs .begin(); it != docs.end(); ++it) {
1102 Document* document = *it; 1102 Document* document = *it;
1103 TrackExceptionState exceptionState; 1103 TrackExceptionState exceptionState;
1104 RefPtrWillBeRawPtr<StaticNodeList> nodeList = document->querySelecto rAll(AtomicString(whitespaceTrimmedQuery), exceptionState); 1104 RefPtrWillBeRawPtr<StaticElementList> elementList = document->queryS electorAll(AtomicString(whitespaceTrimmedQuery), exceptionState);
1105 if (exceptionState.hadException() || !nodeList) 1105 if (exceptionState.hadException() || !elementList)
1106 continue; 1106 continue;
1107 1107
1108 unsigned size = nodeList->length(); 1108 unsigned size = elementList->length();
1109 for (unsigned i = 0; i < size; ++i) 1109 for (unsigned i = 0; i < size; ++i)
1110 resultCollector.add(nodeList->item(i)); 1110 resultCollector.add(elementList->item(i));
1111 } 1111 }
1112 } 1112 }
1113 1113
1114 *searchId = IdentifiersFactory::createIdentifier(); 1114 *searchId = IdentifiersFactory::createIdentifier();
1115 WillBeHeapVector<RefPtrWillBeMember<Node> >* resultsIt = &m_searchResults.ad d(*searchId, WillBeHeapVector<RefPtrWillBeMember<Node> >()).storedValue->value; 1115 WillBeHeapVector<RefPtrWillBeMember<Node> >* resultsIt = &m_searchResults.ad d(*searchId, WillBeHeapVector<RefPtrWillBeMember<Node> >()).storedValue->value;
1116 1116
1117 for (WillBeHeapListHashSet<RawPtrWillBeMember<Node> >::iterator it = resultC ollector.begin(); it != resultCollector.end(); ++it) 1117 for (WillBeHeapListHashSet<RawPtrWillBeMember<Node> >::iterator it = resultC ollector.begin(); it != resultCollector.end(); ++it)
1118 resultsIt->append(*it); 1118 resultsIt->append(*it);
1119 1119
1120 *resultCount = resultsIt->size(); 1120 *resultCount = resultsIt->size();
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 visitor->trace(m_searchResults); 2195 visitor->trace(m_searchResults);
2196 #endif 2196 #endif
2197 visitor->trace(m_history); 2197 visitor->trace(m_history);
2198 visitor->trace(m_domEditor); 2198 visitor->trace(m_domEditor);
2199 visitor->trace(m_listener); 2199 visitor->trace(m_listener);
2200 InspectorBaseAgent::trace(visitor); 2200 InspectorBaseAgent::trace(visitor);
2201 } 2201 }
2202 2202
2203 } // namespace blink 2203 } // namespace blink
2204 2204
OLDNEW
« no previous file with comments | « Source/core/html/HTMLOptionsCollection.cpp ('k') | Source/core/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698