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

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

Issue 884753003: Fix template angle bracket syntax in inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Some more fixes Created 5 years, 10 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) 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); 187 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*);
188 void scheduleStyleAttrRevalidationFor(Element*); 188 void scheduleStyleAttrRevalidationFor(Element*);
189 void scheduleContentDistributionRevalidationFor(Element*); 189 void scheduleContentDistributionRevalidationFor(Element*);
190 void reset() { m_timer.stop(); } 190 void reset() { m_timer.stop(); }
191 void onTimer(Timer<InspectorRevalidateDOMTask>*); 191 void onTimer(Timer<InspectorRevalidateDOMTask>*);
192 void trace(Visitor*); 192 void trace(Visitor*);
193 193
194 private: 194 private:
195 RawPtrWillBeMember<InspectorDOMAgent> m_domAgent; 195 RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
196 Timer<InspectorRevalidateDOMTask> m_timer; 196 Timer<InspectorRevalidateDOMTask> m_timer;
197 WillBeHeapHashSet<RefPtrWillBeMember<Element> > m_styleAttrInvalidatedElemen ts; 197 WillBeHeapHashSet<RefPtrWillBeMember<Element>> m_styleAttrInvalidatedElement s;
198 WillBeHeapHashSet<RefPtrWillBeMember<Element> > m_contentDistributionInvalid atedElements; 198 WillBeHeapHashSet<RefPtrWillBeMember<Element>> m_contentDistributionInvalida tedElements;
199 }; 199 };
200 200
201 InspectorRevalidateDOMTask::InspectorRevalidateDOMTask(InspectorDOMAgent* domAge nt) 201 InspectorRevalidateDOMTask::InspectorRevalidateDOMTask(InspectorDOMAgent* domAge nt)
202 : m_domAgent(domAgent) 202 : m_domAgent(domAgent)
203 , m_timer(this, &InspectorRevalidateDOMTask::onTimer) 203 , m_timer(this, &InspectorRevalidateDOMTask::onTimer)
204 { 204 {
205 } 205 }
206 206
207 void InspectorRevalidateDOMTask::scheduleStyleAttrRevalidationFor(Element* eleme nt) 207 void InspectorRevalidateDOMTask::scheduleStyleAttrRevalidationFor(Element* eleme nt)
208 { 208 {
209 m_styleAttrInvalidatedElements.add(element); 209 m_styleAttrInvalidatedElements.add(element);
210 if (!m_timer.isActive()) 210 if (!m_timer.isActive())
211 m_timer.startOneShot(0, FROM_HERE); 211 m_timer.startOneShot(0, FROM_HERE);
212 } 212 }
213 213
214 void InspectorRevalidateDOMTask::scheduleContentDistributionRevalidationFor(Elem ent* element) 214 void InspectorRevalidateDOMTask::scheduleContentDistributionRevalidationFor(Elem ent* element)
215 { 215 {
216 m_contentDistributionInvalidatedElements.add(element); 216 m_contentDistributionInvalidatedElements.add(element);
217 if (!m_timer.isActive()) 217 if (!m_timer.isActive())
218 m_timer.startOneShot(0, FROM_HERE); 218 m_timer.startOneShot(0, FROM_HERE);
219 } 219 }
220 220
221 void InspectorRevalidateDOMTask::onTimer(Timer<InspectorRevalidateDOMTask>*) 221 void InspectorRevalidateDOMTask::onTimer(Timer<InspectorRevalidateDOMTask>*)
222 { 222 {
223 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed. 223 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed.
224 WillBeHeapVector<RawPtrWillBeMember<Element> > elements; 224 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
225 for (auto& attribute : m_styleAttrInvalidatedElements) 225 for (auto& attribute : m_styleAttrInvalidatedElements)
226 elements.append(attribute.get()); 226 elements.append(attribute.get());
227 m_domAgent->styleAttributeInvalidated(elements); 227 m_domAgent->styleAttributeInvalidated(elements);
228 228
229 m_styleAttrInvalidatedElements.clear(); 229 m_styleAttrInvalidatedElements.clear();
230 230
231 elements.clear(); 231 elements.clear();
232 for (const RefPtrWillBeMember<Element>& it : m_contentDistributionInvalidate dElements) 232 for (const RefPtrWillBeMember<Element>& it : m_contentDistributionInvalidate dElements)
233 elements.append(it.get()); 233 elements.append(it.get());
234 m_domAgent->contentDistributionInvalidated(elements); 234 m_domAgent->contentDistributionInvalidated(elements);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 reset(); 303 reset();
304 } 304 }
305 305
306 void InspectorDOMAgent::restore() 306 void InspectorDOMAgent::restore()
307 { 307 {
308 if (!enabled()) 308 if (!enabled())
309 return; 309 return;
310 innerEnable(); 310 innerEnable();
311 } 311 }
312 312
313 WillBeHeapVector<RawPtrWillBeMember<Document> > InspectorDOMAgent::documents() 313 WillBeHeapVector<RawPtrWillBeMember<Document>> InspectorDOMAgent::documents()
314 { 314 {
315 WillBeHeapVector<RawPtrWillBeMember<Document> > result; 315 WillBeHeapVector<RawPtrWillBeMember<Document>> result;
316 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) { 316 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) {
317 if (!frame->isLocalFrame()) 317 if (!frame->isLocalFrame())
318 continue; 318 continue;
319 Document* document = toLocalFrame(frame)->document(); 319 Document* document = toLocalFrame(frame)->document();
320 if (!document) 320 if (!document)
321 continue; 321 continue;
322 result.append(document); 322 result.append(document);
323 } 323 }
324 return result; 324 return result;
325 } 325 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 for (node = innerFirstChild(node); node; node = innerNextSibling(node)) { 595 for (node = innerFirstChild(node); node; node = innerNextSibling(node)) {
596 int childNodeId = nodeMap->get(node); 596 int childNodeId = nodeMap->get(node);
597 ASSERT(childNodeId); 597 ASSERT(childNodeId);
598 pushChildNodesToFrontend(childNodeId, depth); 598 pushChildNodesToFrontend(childNodeId, depth);
599 } 599 }
600 600
601 return; 601 return;
602 } 602 }
603 603
604 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArrayFor ContainerChildren(node, depth, nodeMap); 604 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = buildArrayForC ontainerChildren(node, depth, nodeMap);
605 m_frontend->setChildNodes(nodeId, children.release()); 605 m_frontend->setChildNodes(nodeId, children.release());
606 } 606 }
607 607
608 void InspectorDOMAgent::discardFrontendBindings() 608 void InspectorDOMAgent::discardFrontendBindings()
609 { 609 {
610 if (m_history) 610 if (m_history)
611 m_history->reset(); 611 m_history->reset();
612 m_searchResults.clear(); 612 m_searchResults.clear();
613 m_documentNodeToIdMap->clear(); 613 m_documentNodeToIdMap->clear();
614 m_idToNode.clear(); 614 m_idToNode.clear();
615 m_idToNodesMap.clear(); 615 m_idToNodesMap.clear();
616 releaseDanglingNodes(); 616 releaseDanglingNodes();
617 m_childrenRequested.clear(); 617 m_childrenRequested.clear();
618 m_distributedNodesRequested.clear(); 618 m_distributedNodesRequested.clear();
619 m_cachedChildCount.clear(); 619 m_cachedChildCount.clear();
620 if (m_revalidateTask) 620 if (m_revalidateTask)
621 m_revalidateTask->reset(); 621 m_revalidateTask->reset();
622 } 622 }
623 623
624 Node* InspectorDOMAgent::nodeForId(int id) 624 Node* InspectorDOMAgent::nodeForId(int id)
625 { 625 {
626 if (!id) 626 if (!id)
627 return nullptr; 627 return nullptr;
628 628
629 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode. find(id); 629 WillBeHeapHashMap<int, RawPtrWillBeMember<Node>>::iterator it = m_idToNode.f ind(id);
630 if (it != m_idToNode.end()) 630 if (it != m_idToNode.end())
631 return it->value; 631 return it->value;
632 return nullptr; 632 return nullptr;
633 } 633 }
634 634
635 void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const int* depth) 635 void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const int* depth)
636 { 636 {
637 int sanitizedDepth; 637 int sanitizedDepth;
638 638
639 if (!depth) 639 if (!depth)
640 sanitizedDepth = 1; 640 sanitizedDepth = 1;
641 else if (*depth == -1) 641 else if (*depth == -1)
642 sanitizedDepth = INT_MAX; 642 sanitizedDepth = INT_MAX;
643 else if (*depth > 0) 643 else if (*depth > 0)
644 sanitizedDepth = *depth; 644 sanitizedDepth = *depth;
645 else { 645 else {
646 *errorString = "Please provide a positive integer as a depth or -1 for e ntire subtree"; 646 *errorString = "Please provide a positive integer as a depth or -1 for e ntire subtree";
647 return; 647 return;
648 } 648 }
649 649
650 pushChildNodesToFrontend(nodeId, sanitizedDepth); 650 pushChildNodesToFrontend(nodeId, sanitizedDepth);
651 } 651 }
652 652
653 void InspectorDOMAgent::requestShadowHostDistributedNodes(ErrorString* errorStri ng, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::InsertionPointDistri bution> >& insertionPointDistributions) 653 void InspectorDOMAgent::requestShadowHostDistributedNodes(ErrorString* errorStri ng, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::InsertionPointDistri bution>>& insertionPointDistributions)
654 { 654 {
655 Node* shadowHost = assertNode(errorString, nodeId); 655 Node* shadowHost = assertNode(errorString, nodeId);
656 if (!shadowHost) 656 if (!shadowHost)
657 return; 657 return;
658 658
659 ASSERT(!shadowHost->document().childNeedsDistributionRecalc()); 659 ASSERT(!shadowHost->document().childNeedsDistributionRecalc());
660 660
661 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); 661 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId);
662 ASSERT(nodeMap); 662 ASSERT(nodeMap);
663 663
664 m_distributedNodesRequested.add(nodeId); 664 m_distributedNodesRequested.add(nodeId);
665 665
666 insertionPointDistributions = TypeBuilder::Array<TypeBuilder::DOM::Insertion PointDistribution>::create(); 666 insertionPointDistributions = TypeBuilder::Array<TypeBuilder::DOM::Insertion PointDistribution>::create();
667 for (ShadowRoot* root = shadowHost->youngestShadowRoot(); root; root = root- >olderShadowRoot()) { 667 for (ShadowRoot* root = shadowHost->youngestShadowRoot(); root; root = root- >olderShadowRoot()) {
668 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint> >& insertionPo ints = root->descendantInsertionPoints(); 668 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& insertionPoi nts = root->descendantInsertionPoints();
669 for (const auto& it : insertionPoints) { 669 for (const auto& it : insertionPoints) {
670 InsertionPoint* insertionPoint = it.get(); 670 InsertionPoint* insertionPoint = it.get();
671 int insertionPointId = pushNodePathToFrontend(insertionPoint, nodeMa p); 671 int insertionPointId = pushNodePathToFrontend(insertionPoint, nodeMa p);
672 ASSERT(insertionPointId); 672 ASSERT(insertionPointId);
673 673
674 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::DistributedNode> > distr ibutedNodes = TypeBuilder::Array<TypeBuilder::DOM::DistributedNode>::create(); 674 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::DistributedNode>> distri butedNodes = TypeBuilder::Array<TypeBuilder::DOM::DistributedNode>::create();
675 for (size_t i = 0; i < insertionPoint->size(); ++i) { 675 for (size_t i = 0; i < insertionPoint->size(); ++i) {
676 Node* distributedNode = insertionPoint->at(i); 676 Node* distributedNode = insertionPoint->at(i);
677 if (isWhitespace(distributedNode)) 677 if (isWhitespace(distributedNode))
678 continue; 678 continue;
679 679
680 int distributedNodeId = pushNodePathToFrontend(distributedNode, nodeMap); 680 int distributedNodeId = pushNodePathToFrontend(distributedNode, nodeMap);
681 ASSERT(distributedNodeId); 681 ASSERT(distributedNodeId);
682 682
683 RefPtr<TypeBuilder::DOM::DistributedNode> distributedNodeObject = TypeBuilder::DOM::DistributedNode::create() 683 RefPtr<TypeBuilder::DOM::DistributedNode> distributedNodeObject = TypeBuilder::DOM::DistributedNode::create()
684 .setNodeId(distributedNodeId); 684 .setNodeId(distributedNodeId);
685 685
686 RefPtr<TypeBuilder::Array<int> > destinationInsertionPointIds = TypeBuilder::Array<int>::create(); 686 RefPtr<TypeBuilder::Array<int>> destinationInsertionPointIds = T ypeBuilder::Array<int>::create();
687 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> destinat ionInsertionPoints; 687 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> destinat ionInsertionPoints;
688 collectDestinationInsertionPoints(*distributedNode, destinationI nsertionPoints); 688 collectDestinationInsertionPoints(*distributedNode, destinationI nsertionPoints);
689 // If this node has only one destination insertion point (often) , then we already know it and don't need any additional information. 689 // If this node has only one destination insertion point (often) , then we already know it and don't need any additional information.
690 if (destinationInsertionPoints.size() != 1) { 690 if (destinationInsertionPoints.size() != 1) {
691 for (size_t j = 0; j < destinationInsertionPoints.size(); ++ j) { 691 for (size_t j = 0; j < destinationInsertionPoints.size(); ++ j) {
692 int destinationInsertionPointId = pushNodePathToFrontend (destinationInsertionPoints.at(j), nodeMap); 692 int destinationInsertionPointId = pushNodePathToFrontend (destinationInsertionPoints.at(j), nodeMap);
693 ASSERT(destinationInsertionPointId); 693 ASSERT(destinationInsertionPointId);
694 destinationInsertionPointIds->addItem(destinationInserti onPointId); 694 destinationInsertionPointIds->addItem(destinationInserti onPointId);
695 } 695 }
696 distributedNodeObject->setDestinationInsertionPointIds(desti nationInsertionPointIds); 696 distributedNodeObject->setDestinationInsertionPointIds(desti nationInsertionPointIds);
(...skipping 22 matching lines...) Expand all
719 RefPtrWillBeRawPtr<Element> element = toContainerNode(node)->querySelector(A tomicString(selectors), exceptionState); 719 RefPtrWillBeRawPtr<Element> element = toContainerNode(node)->querySelector(A tomicString(selectors), exceptionState);
720 if (exceptionState.hadException()) { 720 if (exceptionState.hadException()) {
721 *errorString = "DOM Error while querying"; 721 *errorString = "DOM Error while querying";
722 return; 722 return;
723 } 723 }
724 724
725 if (element) 725 if (element)
726 *elementId = pushNodePathToFrontend(element.get()); 726 *elementId = pushNodePathToFrontend(element.get());
727 } 727 }
728 728
729 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int> >& result) 729 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int>>& result)
730 { 730 {
731 Node* node = assertNode(errorString, nodeId); 731 Node* node = assertNode(errorString, nodeId);
732 if (!node || !node->isContainerNode()) 732 if (!node || !node->isContainerNode())
733 return; 733 return;
734 734
735 TrackExceptionState exceptionState; 735 TrackExceptionState exceptionState;
736 RefPtrWillBeRawPtr<StaticElementList> elements = toContainerNode(node)->quer ySelectorAll(AtomicString(selectors), exceptionState); 736 RefPtrWillBeRawPtr<StaticElementList> elements = toContainerNode(node)->quer ySelectorAll(AtomicString(selectors), exceptionState);
737 if (exceptionState.hadException()) { 737 if (exceptionState.hadException()) {
738 *errorString = "DOM Error while querying"; 738 *errorString = "DOM Error while querying";
739 return; 739 return;
(...skipping 13 matching lines...) Expand all
753 return 0; 753 return 0;
754 if (!m_documentNodeToIdMap->contains(m_document)) 754 if (!m_documentNodeToIdMap->contains(m_document))
755 return 0; 755 return 0;
756 756
757 // Return id in case the node is known. 757 // Return id in case the node is known.
758 int result = nodeMap->get(nodeToPush); 758 int result = nodeMap->get(nodeToPush);
759 if (result) 759 if (result)
760 return result; 760 return result;
761 761
762 Node* node = nodeToPush; 762 Node* node = nodeToPush;
763 WillBeHeapVector<RawPtrWillBeMember<Node> > path; 763 WillBeHeapVector<RawPtrWillBeMember<Node>> path;
764 764
765 while (true) { 765 while (true) {
766 Node* parent = innerParentNode(node); 766 Node* parent = innerParentNode(node);
767 if (!parent) 767 if (!parent)
768 return 0; 768 return 0;
769 path.append(parent); 769 path.append(parent);
770 if (nodeMap->get(parent)) 770 if (nodeMap->get(parent))
771 break; 771 break;
772 node = parent; 772 node = parent;
773 } 773 }
(...skipping 16 matching lines...) Expand all
790 return nodeId; 790 return nodeId;
791 791
792 Node* node = nodeToPush; 792 Node* node = nodeToPush;
793 while (Node* parent = innerParentNode(node)) 793 while (Node* parent = innerParentNode(node))
794 node = parent; 794 node = parent;
795 795
796 // Node being pushed is detached -> push subtree root. 796 // Node being pushed is detached -> push subtree root.
797 OwnPtrWillBeRawPtr<NodeToIdMap> newMap = adoptPtrWillBeNoop(new NodeToIdMap) ; 797 OwnPtrWillBeRawPtr<NodeToIdMap> newMap = adoptPtrWillBeNoop(new NodeToIdMap) ;
798 NodeToIdMap* danglingMap = newMap.get(); 798 NodeToIdMap* danglingMap = newMap.get();
799 m_danglingNodeToIdMaps.append(newMap.release()); 799 m_danglingNodeToIdMaps.append(newMap.release());
800 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create(); 800 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = TypeBuilder::A rray<TypeBuilder::DOM::Node>::create();
801 children->addItem(buildObjectForNode(node, 0, danglingMap)); 801 children->addItem(buildObjectForNode(node, 0, danglingMap));
802 m_frontend->setChildNodes(0, children); 802 m_frontend->setChildNodes(0, children);
803 803
804 return pushNodePathToFrontend(nodeToPush, danglingMap); 804 return pushNodePathToFrontend(nodeToPush, danglingMap);
805 } 805 }
806 806
807 int InspectorDOMAgent::boundNodeId(Node* node) 807 int InspectorDOMAgent::boundNodeId(Node* node)
808 { 808 {
809 return m_documentNodeToIdMap->get(node); 809 return m_documentNodeToIdMap->get(node);
810 } 810 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 return; 972 return;
973 973
974 if (node->nodeType() != Node::TEXT_NODE) { 974 if (node->nodeType() != Node::TEXT_NODE) {
975 *errorString = "Can only set value of text nodes"; 975 *errorString = "Can only set value of text nodes";
976 return; 976 return;
977 } 977 }
978 978
979 m_domEditor->replaceWholeText(toText(node), value, errorString); 979 m_domEditor->replaceWholeText(toText(node), value, errorString);
980 } 980 }
981 981
982 void InspectorDOMAgent::getEventListenersForNode(ErrorString* errorString, int n odeId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Ev entListener> >& listenersArray) 982 void InspectorDOMAgent::getEventListenersForNode(ErrorString* errorString, int n odeId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Ev entListener>>& listenersArray)
983 { 983 {
984 listenersArray = TypeBuilder::Array<TypeBuilder::DOM::EventListener>::create (); 984 listenersArray = TypeBuilder::Array<TypeBuilder::DOM::EventListener>::create ();
985 Node* node = assertNode(errorString, nodeId); 985 Node* node = assertNode(errorString, nodeId);
986 if (!node) 986 if (!node)
987 return; 987 return;
988 Vector<EventListenerInfo> eventInformation; 988 Vector<EventListenerInfo> eventInformation;
989 getEventListeners(node, eventInformation, true); 989 getEventListeners(node, eventInformation, true);
990 990
991 // Get Capturing Listeners (in this order) 991 // Get Capturing Listeners (in this order)
992 size_t eventInformationLength = eventInformation.size(); 992 size_t eventInformationLength = eventInformation.size();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 String attributeQuery = whitespaceTrimmedQuery; 1106 String attributeQuery = whitespaceTrimmedQuery;
1107 if (startTagFound) 1107 if (startTagFound)
1108 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1); 1108 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1);
1109 if (endTagFound) 1109 if (endTagFound)
1110 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1); 1110 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1);
1111 if (startQuoteFound) 1111 if (startQuoteFound)
1112 attributeQuery = attributeQuery.right(attributeQuery.length() - 1); 1112 attributeQuery = attributeQuery.right(attributeQuery.length() - 1);
1113 if (endQuoteFound) 1113 if (endQuoteFound)
1114 attributeQuery = attributeQuery.left(attributeQuery.length() - 1); 1114 attributeQuery = attributeQuery.left(attributeQuery.length() - 1);
1115 1115
1116 WillBeHeapVector<RawPtrWillBeMember<Document> > docs = documents(); 1116 WillBeHeapVector<RawPtrWillBeMember<Document>> docs = documents();
1117 WillBeHeapListHashSet<RawPtrWillBeMember<Node> > resultCollector; 1117 WillBeHeapListHashSet<RawPtrWillBeMember<Node>> resultCollector;
1118 1118
1119 for (Document* document : docs) { 1119 for (Document* document : docs) {
1120 Node* documentElement = document->documentElement(); 1120 Node* documentElement = document->documentElement();
1121 Node* node = documentElement; 1121 Node* node = documentElement;
1122 if (!node) 1122 if (!node)
1123 continue; 1123 continue;
1124 1124
1125 // Manual plain text search. 1125 // Manual plain text search.
1126 for (; node; node = nextNodeWithShadowDOMInMind(*node, documentElement, includeUserAgentShadowDOM)) { 1126 for (; node; node = nextNodeWithShadowDOMInMind(*node, documentElement, includeUserAgentShadowDOM)) {
1127 switch (node->nodeType()) { 1127 switch (node->nodeType()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if (exceptionState.hadException() || !elementList) 1192 if (exceptionState.hadException() || !elementList)
1193 continue; 1193 continue;
1194 1194
1195 unsigned size = elementList->length(); 1195 unsigned size = elementList->length();
1196 for (unsigned i = 0; i < size; ++i) 1196 for (unsigned i = 0; i < size; ++i)
1197 resultCollector.add(elementList->item(i)); 1197 resultCollector.add(elementList->item(i));
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 *searchId = IdentifiersFactory::createIdentifier(); 1201 *searchId = IdentifiersFactory::createIdentifier();
1202 WillBeHeapVector<RefPtrWillBeMember<Node> >* resultsIt = &m_searchResults.ad d(*searchId, WillBeHeapVector<RefPtrWillBeMember<Node> >()).storedValue->value; 1202 WillBeHeapVector<RefPtrWillBeMember<Node>>* resultsIt = &m_searchResults.add (*searchId, WillBeHeapVector<RefPtrWillBeMember<Node>>()).storedValue->value;
1203 1203
1204 for (auto& result : resultCollector) 1204 for (auto& result : resultCollector)
1205 resultsIt->append(result); 1205 resultsIt->append(result);
1206 1206
1207 *resultCount = resultsIt->size(); 1207 *resultCount = resultsIt->size();
1208 } 1208 }
1209 1209
1210 void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& searchId, int fromIndex, int toIndex, RefPtr<TypeBuilder::Array<int> >& nodeIds ) 1210 void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& searchId, int fromIndex, int toIndex, RefPtr<TypeBuilder::Array<int>>& nodeIds)
1211 { 1211 {
1212 SearchResults::iterator it = m_searchResults.find(searchId); 1212 SearchResults::iterator it = m_searchResults.find(searchId);
1213 if (it == m_searchResults.end()) { 1213 if (it == m_searchResults.end()) {
1214 *errorString = "No search session with given id found"; 1214 *errorString = "No search session with given id found";
1215 return; 1215 return;
1216 } 1216 }
1217 1217
1218 int size = it->value.size(); 1218 int size = it->value.size();
1219 if (fromIndex < 0 || toIndex > size || fromIndex >= toIndex) { 1219 if (fromIndex < 0 || toIndex > size || fromIndex >= toIndex) {
1220 *errorString = "Invalid search result range"; 1220 *errorString = "Invalid search result range";
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 return; 1593 return;
1594 } 1594 }
1595 RefPtr<TypeBuilder::Runtime::RemoteObject> object = resolveNode(node, object GroupName); 1595 RefPtr<TypeBuilder::Runtime::RemoteObject> object = resolveNode(node, object GroupName);
1596 if (!object) { 1596 if (!object) {
1597 *errorString = "Node with given id does not belong to the document"; 1597 *errorString = "Node with given id does not belong to the document";
1598 return; 1598 return;
1599 } 1599 }
1600 result = object; 1600 result = object;
1601 } 1601 }
1602 1602
1603 void InspectorDOMAgent::getAttributes(ErrorString* errorString, int nodeId, RefP tr<TypeBuilder::Array<String> >& result) 1603 void InspectorDOMAgent::getAttributes(ErrorString* errorString, int nodeId, RefP tr<TypeBuilder::Array<String>>& result)
1604 { 1604 {
1605 Element* element = assertElement(errorString, nodeId); 1605 Element* element = assertElement(errorString, nodeId);
1606 if (!element) 1606 if (!element)
1607 return; 1607 return;
1608 1608
1609 result = buildArrayForElementAttributes(element); 1609 result = buildArrayForElementAttributes(element);
1610 } 1610 }
1611 1611
1612 void InspectorDOMAgent::requestNode(ErrorString*, const String& objectId, int* n odeId) 1612 void InspectorDOMAgent::requestNode(ErrorString*, const String& objectId, int* n odeId)
1613 { 1613 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node); 1683 HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node);
1684 LocalFrame* frame = (frameOwner->contentFrame() && frameOwner->conte ntFrame()->isLocalFrame()) ? toLocalFrame(frameOwner->contentFrame()) : nullptr; 1684 LocalFrame* frame = (frameOwner->contentFrame() && frameOwner->conte ntFrame()->isLocalFrame()) ? toLocalFrame(frameOwner->contentFrame()) : nullptr;
1685 if (frame) 1685 if (frame)
1686 value->setFrameId(m_pageAgent->frameId(frame)); 1686 value->setFrameId(m_pageAgent->frameId(frame));
1687 if (Document* doc = frameOwner->contentDocument()) 1687 if (Document* doc = frameOwner->contentDocument())
1688 value->setContentDocument(buildObjectForNode(doc, 0, nodesMap)); 1688 value->setContentDocument(buildObjectForNode(doc, 0, nodesMap));
1689 } 1689 }
1690 1690
1691 ElementShadow* shadow = element->shadow(); 1691 ElementShadow* shadow = element->shadow();
1692 if (shadow) { 1692 if (shadow) {
1693 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > shadowRoots = Ty peBuilder::Array<TypeBuilder::DOM::Node>::create(); 1693 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> shadowRoots = Typ eBuilder::Array<TypeBuilder::DOM::Node>::create();
1694 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot()) 1694 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot())
1695 shadowRoots->addItem(buildObjectForNode(root, 0, nodesMap)); 1695 shadowRoots->addItem(buildObjectForNode(root, 0, nodesMap));
1696 value->setShadowRoots(shadowRoots); 1696 value->setShadowRoots(shadowRoots);
1697 forcePushChildren = true; 1697 forcePushChildren = true;
1698 } 1698 }
1699 1699
1700 if (isHTMLLinkElement(*element)) { 1700 if (isHTMLLinkElement(*element)) {
1701 HTMLLinkElement& linkElement = toHTMLLinkElement(*element); 1701 HTMLLinkElement& linkElement = toHTMLLinkElement(*element);
1702 if (linkElement.isImport() && linkElement.import() && innerParentNod e(linkElement.import()) == linkElement) 1702 if (linkElement.isImport() && linkElement.import() && innerParentNod e(linkElement.import()) == linkElement)
1703 value->setImportedDocument(buildObjectForNode(linkElement.import (), 0, nodesMap)); 1703 value->setImportedDocument(buildObjectForNode(linkElement.import (), 0, nodesMap));
1704 forcePushChildren = true; 1704 forcePushChildren = true;
1705 } 1705 }
1706 1706
1707 if (isHTMLTemplateElement(*element)) { 1707 if (isHTMLTemplateElement(*element)) {
1708 value->setTemplateContent(buildObjectForNode(toHTMLTemplateElement(* element).content(), 0, nodesMap)); 1708 value->setTemplateContent(buildObjectForNode(toHTMLTemplateElement(* element).content(), 0, nodesMap));
1709 forcePushChildren = true; 1709 forcePushChildren = true;
1710 } 1710 }
1711 1711
1712 switch (element->pseudoId()) { 1712 switch (element->pseudoId()) {
1713 case BEFORE: 1713 case BEFORE:
1714 value->setPseudoType(TypeBuilder::DOM::PseudoType::Before); 1714 value->setPseudoType(TypeBuilder::DOM::PseudoType::Before);
1715 break; 1715 break;
1716 case AFTER: 1716 case AFTER:
1717 value->setPseudoType(TypeBuilder::DOM::PseudoType::After); 1717 value->setPseudoType(TypeBuilder::DOM::PseudoType::After);
1718 break; 1718 break;
1719 default: { 1719 default: {
1720 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = buildArrayForPseudoElements(element, nodesMap); 1720 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> pseudoElements = buildArrayForPseudoElements(element, nodesMap);
1721 if (pseudoElements) { 1721 if (pseudoElements) {
1722 value->setPseudoElements(pseudoElements.release()); 1722 value->setPseudoElements(pseudoElements.release());
1723 forcePushChildren = true; 1723 forcePushChildren = true;
1724 } 1724 }
1725 break; 1725 break;
1726 } 1726 }
1727 } 1727 }
1728 } else if (node->isDocumentNode()) { 1728 } else if (node->isDocumentNode()) {
1729 Document* document = toDocument(node); 1729 Document* document = toDocument(node);
1730 value->setDocumentURL(documentURLString(document)); 1730 value->setDocumentURL(documentURLString(document));
(...skipping 11 matching lines...) Expand all
1742 value->setShadowRootType(shadowRootType(toShadowRoot(node))); 1742 value->setShadowRootType(shadowRootType(toShadowRoot(node)));
1743 } 1743 }
1744 1744
1745 if (node->isContainerNode()) { 1745 if (node->isContainerNode()) {
1746 int nodeCount = innerChildNodeCount(node); 1746 int nodeCount = innerChildNodeCount(node);
1747 value->setChildNodeCount(nodeCount); 1747 value->setChildNodeCount(nodeCount);
1748 if (nodesMap == m_documentNodeToIdMap) 1748 if (nodesMap == m_documentNodeToIdMap)
1749 m_cachedChildCount.set(id, nodeCount); 1749 m_cachedChildCount.set(id, nodeCount);
1750 if (forcePushChildren && !depth) 1750 if (forcePushChildren && !depth)
1751 depth = 1; 1751 depth = 1;
1752 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArra yForContainerChildren(node, depth, nodesMap); 1752 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = buildArray ForContainerChildren(node, depth, nodesMap);
1753 if (children->length() > 0 || depth) // Push children along with shadow in any case. 1753 if (children->length() > 0 || depth) // Push children along with shadow in any case.
1754 value->setChildren(children.release()); 1754 value->setChildren(children.release());
1755 } 1755 }
1756 1756
1757 return value.release(); 1757 return value.release();
1758 } 1758 }
1759 1759
1760 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element) 1760 PassRefPtr<TypeBuilder::Array<String>> InspectorDOMAgent::buildArrayForElementAt tributes(Element* element)
1761 { 1761 {
1762 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create(); 1762 RefPtr<TypeBuilder::Array<String>> attributesValue = TypeBuilder::Array<Stri ng>::create();
1763 // Go through all attributes and serialize them. 1763 // Go through all attributes and serialize them.
1764 AttributeCollection attributes = element->attributes(); 1764 AttributeCollection attributes = element->attributes();
1765 for (auto& attribute : attributes) { 1765 for (auto& attribute : attributes) {
1766 // Add attribute pair 1766 // Add attribute pair
1767 attributesValue->addItem(attribute.name().toString()); 1767 attributesValue->addItem(attribute.name().toString());
1768 attributesValue->addItem(attribute.value()); 1768 attributesValue->addItem(attribute.value());
1769 } 1769 }
1770 return attributesValue.release(); 1770 return attributesValue.release();
1771 } 1771 }
1772 1772
1773 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap) 1773 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> InspectorDOMAgent::buildA rrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap)
1774 { 1774 {
1775 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create(); 1775 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = TypeBuilder::A rray<TypeBuilder::DOM::Node>::create();
1776 if (depth == 0) { 1776 if (depth == 0) {
1777 // Special-case the only text child - pretend that container's children have been requested. 1777 // Special-case the only text child - pretend that container's children have been requested.
1778 Node* firstChild = container->firstChild(); 1778 Node* firstChild = container->firstChild();
1779 if (firstChild && firstChild->nodeType() == Node::TEXT_NODE && !firstChi ld->nextSibling()) { 1779 if (firstChild && firstChild->nodeType() == Node::TEXT_NODE && !firstChi ld->nextSibling()) {
1780 children->addItem(buildObjectForNode(firstChild, 0, nodesMap)); 1780 children->addItem(buildObjectForNode(firstChild, 0, nodesMap));
1781 m_childrenRequested.add(bind(container, nodesMap)); 1781 m_childrenRequested.add(bind(container, nodesMap));
1782 } 1782 }
1783 return children.release(); 1783 return children.release();
1784 } 1784 }
1785 1785
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 } 1830 }
1831 } 1831 }
1832 } 1832 }
1833 } 1833 }
1834 } 1834 }
1835 if (!sourceName.isEmpty()) 1835 if (!sourceName.isEmpty())
1836 value->setSourceName(sourceName); 1836 value->setSourceName(sourceName);
1837 return value.release(); 1837 return value.release();
1838 } 1838 }
1839 1839
1840 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForPseudoElements(Element* element, NodeToIdMap* nodesMap) 1840 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> InspectorDOMAgent::buildA rrayForPseudoElements(Element* element, NodeToIdMap* nodesMap)
1841 { 1841 {
1842 if (!element->pseudoElement(BEFORE) && !element->pseudoElement(AFTER)) 1842 if (!element->pseudoElement(BEFORE) && !element->pseudoElement(AFTER))
1843 return nullptr; 1843 return nullptr;
1844 1844
1845 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui lder::Array<TypeBuilder::DOM::Node>::create(); 1845 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> pseudoElements = TypeBuil der::Array<TypeBuilder::DOM::Node>::create();
1846 if (element->pseudoElement(BEFORE)) 1846 if (element->pseudoElement(BEFORE))
1847 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE ), 0, nodesMap)); 1847 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE ), 0, nodesMap));
1848 if (element->pseudoElement(AFTER)) 1848 if (element->pseudoElement(AFTER))
1849 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER) , 0, nodesMap)); 1849 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER) , 0, nodesMap));
1850 return pseudoElements.release(); 1850 return pseudoElements.release();
1851 } 1851 }
1852 1852
1853 Node* InspectorDOMAgent::innerFirstChild(Node* node) 1853 Node* InspectorDOMAgent::innerFirstChild(Node* node)
1854 { 1854 {
1855 node = node->firstChild(); 1855 node = node->firstChild();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 // If node is not mapped yet -> ignore the event. 2033 // If node is not mapped yet -> ignore the event.
2034 if (!id) 2034 if (!id)
2035 return; 2035 return;
2036 2036
2037 if (m_domListener) 2037 if (m_domListener)
2038 m_domListener->didModifyDOMAttr(element); 2038 m_domListener->didModifyDOMAttr(element);
2039 2039
2040 m_frontend->attributeRemoved(id, name.toString()); 2040 m_frontend->attributeRemoved(id, name.toString());
2041 } 2041 }
2042 2042
2043 void InspectorDOMAgent::styleAttributeInvalidated(const WillBeHeapVector<RawPtrW illBeMember<Element> >& elements) 2043 void InspectorDOMAgent::styleAttributeInvalidated(const WillBeHeapVector<RawPtrW illBeMember<Element>>& elements)
2044 { 2044 {
2045 RefPtr<TypeBuilder::Array<int> > nodeIds = TypeBuilder::Array<int>::create() ; 2045 RefPtr<TypeBuilder::Array<int>> nodeIds = TypeBuilder::Array<int>::create();
2046 for (unsigned i = 0, size = elements.size(); i < size; ++i) { 2046 for (unsigned i = 0, size = elements.size(); i < size; ++i) {
2047 Element* element = elements.at(i); 2047 Element* element = elements.at(i);
2048 int id = boundNodeId(element); 2048 int id = boundNodeId(element);
2049 // If node is not mapped yet -> ignore the event. 2049 // If node is not mapped yet -> ignore the event.
2050 if (!id) 2050 if (!id)
2051 continue; 2051 continue;
2052 2052
2053 if (m_domListener) 2053 if (m_domListener)
2054 m_domListener->didModifyDOMAttr(element); 2054 m_domListener->didModifyDOMAttr(element);
2055 nodeIds->addItem(id); 2055 nodeIds->addItem(id);
2056 } 2056 }
2057 m_frontend->inlineStyleInvalidated(nodeIds.release()); 2057 m_frontend->inlineStyleInvalidated(nodeIds.release());
2058 } 2058 }
2059 2059
2060 void InspectorDOMAgent::contentDistributionInvalidated(const WillBeHeapVector<Ra wPtrWillBeMember<Element> >& elements) 2060 void InspectorDOMAgent::contentDistributionInvalidated(const WillBeHeapVector<Ra wPtrWillBeMember<Element>>& elements)
2061 { 2061 {
2062 RefPtr<TypeBuilder::Array<int> > nodeIds = TypeBuilder::Array<int>::create() ; 2062 RefPtr<TypeBuilder::Array<int>> nodeIds = TypeBuilder::Array<int>::create();
2063 for (const auto& it : elements) { 2063 for (const auto& it : elements) {
2064 Element* element = it.get(); 2064 Element* element = it.get();
2065 int id = boundNodeId(element); 2065 int id = boundNodeId(element);
2066 if (!id) 2066 if (!id)
2067 continue; 2067 continue;
2068 nodeIds->addItem(id); 2068 nodeIds->addItem(id);
2069 } 2069 }
2070 m_frontend->shadowHostDistributionInvalidated(nodeIds.release()); 2070 m_frontend->shadowHostDistributionInvalidated(nodeIds.release());
2071 } 2071 }
2072 2072
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 } 2227 }
2228 2228
2229 void InspectorDOMAgent::pushNodeByPathToFrontend(ErrorString* errorString, const String& path, int* nodeId) 2229 void InspectorDOMAgent::pushNodeByPathToFrontend(ErrorString* errorString, const String& path, int* nodeId)
2230 { 2230 {
2231 if (Node* node = nodeForPath(path)) 2231 if (Node* node = nodeForPath(path))
2232 *nodeId = pushNodePathToFrontend(node); 2232 *nodeId = pushNodePathToFrontend(node);
2233 else 2233 else
2234 *errorString = "No node with given path found"; 2234 *errorString = "No node with given path found";
2235 } 2235 }
2236 2236
2237 void InspectorDOMAgent::pushNodesByBackendIdsToFrontend(ErrorString* errorString , const RefPtr<JSONArray>& backendNodeIds, RefPtr<TypeBuilder::Array<int> >& res ult) 2237 void InspectorDOMAgent::pushNodesByBackendIdsToFrontend(ErrorString* errorString , const RefPtr<JSONArray>& backendNodeIds, RefPtr<TypeBuilder::Array<int>>& resu lt)
2238 { 2238 {
2239 result = TypeBuilder::Array<int>::create(); 2239 result = TypeBuilder::Array<int>::create();
2240 for (const auto& backendNode : *backendNodeIds) { 2240 for (const auto& backendNode : *backendNodeIds) {
2241 int backendNodeId; 2241 int backendNodeId;
2242 2242
2243 if (!(backendNode)->asNumber(&backendNodeId)) { 2243 if (!(backendNode)->asNumber(&backendNodeId)) {
2244 *errorString = "Invalid argument type"; 2244 *errorString = "Invalid argument type";
2245 return; 2245 return;
2246 } 2246 }
2247 2247
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 visitor->trace(m_revalidateTask); 2307 visitor->trace(m_revalidateTask);
2308 visitor->trace(m_searchResults); 2308 visitor->trace(m_searchResults);
2309 #endif 2309 #endif
2310 visitor->trace(m_history); 2310 visitor->trace(m_history);
2311 visitor->trace(m_domEditor); 2311 visitor->trace(m_domEditor);
2312 visitor->trace(m_listener); 2312 visitor->trace(m_listener);
2313 InspectorBaseAgent::trace(visitor); 2313 InspectorBaseAgent::trace(visitor);
2314 } 2314 }
2315 2315
2316 } // namespace blink 2316 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/core/inspector/InspectorDOMDebuggerAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698