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

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

Issue 307943002: Oilpan: Prepare moving InspectorController and InspectorAgents to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 6 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
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message(); 224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message();
225 return ""; 225 return "";
226 } 226 }
227 227
228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) 228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay)
229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") 229 : InspectorBaseAgent<InspectorDOMAgent>("DOM")
230 , m_pageAgent(pageAgent) 230 , m_pageAgent(pageAgent)
231 , m_injectedScriptManager(injectedScriptManager) 231 , m_injectedScriptManager(injectedScriptManager)
232 , m_overlay(overlay) 232 , m_overlay(overlay)
233 , m_frontend(0) 233 , m_frontend(0)
234 , m_domListener(0) 234 , m_domListener(nullptr)
235 , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap())) 235 , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap()))
236 , m_lastNodeId(1) 236 , m_lastNodeId(1)
237 , m_searchingForNode(NotSearching) 237 , m_searchingForNode(NotSearching)
238 , m_suppressAttributeModifiedEvent(false) 238 , m_suppressAttributeModifiedEvent(false)
239 , m_listener(0) 239 , m_listener(nullptr)
240 { 240 {
241 } 241 }
242 242
243 InspectorDOMAgent::~InspectorDOMAgent() 243 InspectorDOMAgent::~InspectorDOMAgent()
244 { 244 {
245 #if !ENABLE(OILPAN)
245 reset(); 246 reset();
246 ASSERT(m_searchingForNode == NotSearching); 247 ASSERT(m_searchingForNode == NotSearching);
248 #endif
247 } 249 }
248 250
249 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend) 251 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
250 { 252 {
251 ASSERT(!m_frontend); 253 ASSERT(!m_frontend);
252 m_history = adoptPtrWillBeNoop(new InspectorHistory()); 254 m_history = adoptPtrWillBeNoop(new InspectorHistory());
253 m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get())); 255 m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get()));
254 256
255 m_frontend = frontend->dom(); 257 m_frontend = frontend->dom();
256 m_instrumentingAgents->setInspectorDOMAgent(this); 258 m_instrumentingAgents->setInspectorDOMAgent(this);
(...skipping 17 matching lines...) Expand all
274 reset(); 276 reset();
275 } 277 }
276 278
277 void InspectorDOMAgent::restore() 279 void InspectorDOMAgent::restore()
278 { 280 {
279 // Reset document to avoid early return from setDocument. 281 // Reset document to avoid early return from setDocument.
280 m_document = nullptr; 282 m_document = nullptr;
281 setDocument(m_pageAgent->mainFrame()->document()); 283 setDocument(m_pageAgent->mainFrame()->document());
282 } 284 }
283 285
284 Vector<Document*> InspectorDOMAgent::documents() 286 WillBeHeapVector<RawPtrWillBeMember<Document> > InspectorDOMAgent::documents()
285 { 287 {
286 Vector<Document*> result; 288 WillBeHeapVector<RawPtrWillBeMember<Document> > result;
287 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) { 289 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) {
288 if (!frame->isLocalFrame()) 290 if (!frame->isLocalFrame())
289 continue; 291 continue;
290 Document* document = toLocalFrame(frame)->document(); 292 Document* document = toLocalFrame(frame)->document();
291 if (!document) 293 if (!document)
292 continue; 294 continue;
293 result.append(document); 295 result.append(document);
294 } 296 }
295 return result; 297 return result;
296 } 298 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 String attributeQuery = whitespaceTrimmedQuery; 946 String attributeQuery = whitespaceTrimmedQuery;
945 if (startTagFound) 947 if (startTagFound)
946 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1); 948 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1);
947 if (endTagFound) 949 if (endTagFound)
948 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1); 950 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1);
949 if (startQuoteFound) 951 if (startQuoteFound)
950 attributeQuery = attributeQuery.right(attributeQuery.length() - 1); 952 attributeQuery = attributeQuery.right(attributeQuery.length() - 1);
951 if (endQuoteFound) 953 if (endQuoteFound)
952 attributeQuery = attributeQuery.left(attributeQuery.length() - 1); 954 attributeQuery = attributeQuery.left(attributeQuery.length() - 1);
953 955
954 Vector<Document*> docs = documents(); 956 WillBeHeapVector<RawPtrWillBeMember<Document> > docs = documents();
955 ListHashSet<Node*> resultCollector; 957 ListHashSet<Node*> resultCollector;
956 958
957 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++it) { 959 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs.beg in(); it != docs.end(); ++it) {
958 Document* document = *it; 960 Document* document = *it;
959 Node* node = document->documentElement(); 961 Node* node = document->documentElement();
960 if (!node) 962 if (!node)
961 continue; 963 continue;
962 964
963 // Manual plain text search. 965 // Manual plain text search.
964 while ((node = NodeTraversal::next(*node, document->documentElement()))) { 966 while ((node = NodeTraversal::next(*node, document->documentElement()))) {
965 switch (node->nodeType()) { 967 switch (node->nodeType()) {
966 case Node::TEXT_NODE: 968 case Node::TEXT_NODE:
967 case Node::COMMENT_NODE: 969 case Node::COMMENT_NODE:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 } 1003 }
1002 } 1004 }
1003 break; 1005 break;
1004 } 1006 }
1005 default: 1007 default:
1006 break; 1008 break;
1007 } 1009 }
1008 } 1010 }
1009 1011
1010 // XPath evaluation 1012 // XPath evaluation
1011 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++ it) { 1013 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs .begin(); it != docs.end(); ++it) {
1012 Document* document = *it; 1014 Document* document = *it;
1013 ASSERT(document); 1015 ASSERT(document);
1014 TrackExceptionState exceptionState; 1016 TrackExceptionState exceptionState;
1015 RefPtrWillBeRawPtr<XPathResult> result = DocumentXPathEvaluator::eva luate(*document, whitespaceTrimmedQuery, document, nullptr, XPathResult::ORDERED _NODE_SNAPSHOT_TYPE, 0, exceptionState); 1017 RefPtrWillBeRawPtr<XPathResult> result = DocumentXPathEvaluator::eva luate(*document, whitespaceTrimmedQuery, document, nullptr, XPathResult::ORDERED _NODE_SNAPSHOT_TYPE, 0, exceptionState);
1016 if (exceptionState.hadException() || !result) 1018 if (exceptionState.hadException() || !result)
1017 continue; 1019 continue;
1018 1020
1019 unsigned long size = result->snapshotLength(exceptionState); 1021 unsigned long size = result->snapshotLength(exceptionState);
1020 for (unsigned long i = 0; !exceptionState.hadException() && i < size ; ++i) { 1022 for (unsigned long i = 0; !exceptionState.hadException() && i < size ; ++i) {
1021 Node* node = result->snapshotItem(i, exceptionState); 1023 Node* node = result->snapshotItem(i, exceptionState);
1022 if (exceptionState.hadException()) 1024 if (exceptionState.hadException())
1023 break; 1025 break;
1024 1026
1025 if (node->nodeType() == Node::ATTRIBUTE_NODE) 1027 if (node->nodeType() == Node::ATTRIBUTE_NODE)
1026 node = toAttr(node)->ownerElement(); 1028 node = toAttr(node)->ownerElement();
1027 resultCollector.add(node); 1029 resultCollector.add(node);
1028 } 1030 }
1029 } 1031 }
1030 1032
1031 // Selector evaluation 1033 // Selector evaluation
1032 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++ it) { 1034 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs .begin(); it != docs.end(); ++it) {
1033 Document* document = *it; 1035 Document* document = *it;
1034 TrackExceptionState exceptionState; 1036 TrackExceptionState exceptionState;
1035 RefPtrWillBeRawPtr<NodeList> nodeList = document->querySelectorAll(A tomicString(whitespaceTrimmedQuery), exceptionState); 1037 RefPtrWillBeRawPtr<NodeList> nodeList = document->querySelectorAll(A tomicString(whitespaceTrimmedQuery), exceptionState);
1036 if (exceptionState.hadException() || !nodeList) 1038 if (exceptionState.hadException() || !nodeList)
1037 continue; 1039 continue;
1038 1040
1039 unsigned size = nodeList->length(); 1041 unsigned size = nodeList->length();
1040 for (unsigned i = 0; i < size; ++i) 1042 for (unsigned i = 0; i < size; ++i)
1041 resultCollector.add(nodeList->item(i)); 1043 resultCollector.add(nodeList->item(i));
1042 } 1044 }
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 { 2098 {
2097 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. 2099 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>.
2098 if (!m_documentNodeToIdMap->contains(m_document.get())) { 2100 if (!m_documentNodeToIdMap->contains(m_document.get())) {
2099 RefPtr<TypeBuilder::DOM::Node> root; 2101 RefPtr<TypeBuilder::DOM::Node> root;
2100 getDocument(errorString, root); 2102 getDocument(errorString, root);
2101 return errorString->isEmpty(); 2103 return errorString->isEmpty();
2102 } 2104 }
2103 return true; 2105 return true;
2104 } 2106 }
2105 2107
2108 void InspectorDOMAgent::trace(Visitor* visitor)
2109 {
2110 visitor->trace(m_domListener);
2111 visitor->trace(m_pageAgent);
2112 #if ENABLE(OILPAN)
2113 visitor->trace(m_documentNodeToIdMap);
2114 visitor->trace(m_danglingNodeToIdMaps);
2115 visitor->trace(m_idToNode);
2116 #endif
2117 visitor->trace(m_idToNodesMap);
2118 visitor->trace(m_document);
2119 visitor->trace(m_searchResults);
2120 visitor->trace(m_history);
2121 visitor->trace(m_domEditor);
2122 visitor->trace(m_listener);
2123 InspectorBaseAgent::trace(visitor);
2124 }
2125
2106 } // namespace WebCore 2126 } // namespace WebCore
2107 2127
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698