OLD | NEW |
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 Loading... |
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 18 matching lines...) Expand all Loading... |
275 } | 277 } |
276 | 278 |
277 void InspectorDOMAgent::restore() | 279 void InspectorDOMAgent::restore() |
278 { | 280 { |
279 if (!enabled()) | 281 if (!enabled()) |
280 return; | 282 return; |
281 innerEnable(); | 283 innerEnable(); |
282 notifyDocumentUpdated(); | 284 notifyDocumentUpdated(); |
283 } | 285 } |
284 | 286 |
285 Vector<Document*> InspectorDOMAgent::documents() | 287 WillBeHeapVector<RawPtrWillBeMember<Document> > InspectorDOMAgent::documents() |
286 { | 288 { |
287 Vector<Document*> result; | 289 WillBeHeapVector<RawPtrWillBeMember<Document> > result; |
288 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver
seNext()) { | 290 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver
seNext()) { |
289 if (!frame->isLocalFrame()) | 291 if (!frame->isLocalFrame()) |
290 continue; | 292 continue; |
291 Document* document = toLocalFrame(frame)->document(); | 293 Document* document = toLocalFrame(frame)->document(); |
292 if (!document) | 294 if (!document) |
293 continue; | 295 continue; |
294 result.append(document); | 296 result.append(document); |
295 } | 297 } |
296 return result; | 298 return result; |
297 } | 299 } |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 String attributeQuery = whitespaceTrimmedQuery; | 959 String attributeQuery = whitespaceTrimmedQuery; |
958 if (startTagFound) | 960 if (startTagFound) |
959 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1); | 961 tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1); |
960 if (endTagFound) | 962 if (endTagFound) |
961 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1); | 963 tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1); |
962 if (startQuoteFound) | 964 if (startQuoteFound) |
963 attributeQuery = attributeQuery.right(attributeQuery.length() - 1); | 965 attributeQuery = attributeQuery.right(attributeQuery.length() - 1); |
964 if (endQuoteFound) | 966 if (endQuoteFound) |
965 attributeQuery = attributeQuery.left(attributeQuery.length() - 1); | 967 attributeQuery = attributeQuery.left(attributeQuery.length() - 1); |
966 | 968 |
967 Vector<Document*> docs = documents(); | 969 WillBeHeapVector<RawPtrWillBeMember<Document> > docs = documents(); |
968 WillBeHeapListHashSet<RawPtrWillBeMember<Node> > resultCollector; | 970 WillBeHeapListHashSet<RawPtrWillBeMember<Node> > resultCollector; |
969 | 971 |
970 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++it)
{ | 972 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs.beg
in(); it != docs.end(); ++it) { |
971 Document* document = *it; | 973 Document* document = *it; |
972 Node* node = document->documentElement(); | 974 Node* node = document->documentElement(); |
973 if (!node) | 975 if (!node) |
974 continue; | 976 continue; |
975 | 977 |
976 // Manual plain text search. | 978 // Manual plain text search. |
977 for (node = NodeTraversal::next(*node, document->documentElement()); nod
e; node = NodeTraversal::next(*node, document->documentElement())) { | 979 for (node = NodeTraversal::next(*node, document->documentElement()); nod
e; node = NodeTraversal::next(*node, document->documentElement())) { |
978 switch (node->nodeType()) { | 980 switch (node->nodeType()) { |
979 case Node::TEXT_NODE: | 981 case Node::TEXT_NODE: |
980 case Node::COMMENT_NODE: | 982 case Node::COMMENT_NODE: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 } | 1016 } |
1015 } | 1017 } |
1016 break; | 1018 break; |
1017 } | 1019 } |
1018 default: | 1020 default: |
1019 break; | 1021 break; |
1020 } | 1022 } |
1021 } | 1023 } |
1022 | 1024 |
1023 // XPath evaluation | 1025 // XPath evaluation |
1024 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++
it) { | 1026 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs
.begin(); it != docs.end(); ++it) { |
1025 Document* document = *it; | 1027 Document* document = *it; |
1026 ASSERT(document); | 1028 ASSERT(document); |
1027 TrackExceptionState exceptionState; | 1029 TrackExceptionState exceptionState; |
1028 RefPtrWillBeRawPtr<XPathResult> result = DocumentXPathEvaluator::eva
luate(*document, whitespaceTrimmedQuery, document, nullptr, XPathResult::ORDERED
_NODE_SNAPSHOT_TYPE, 0, exceptionState); | 1030 RefPtrWillBeRawPtr<XPathResult> result = DocumentXPathEvaluator::eva
luate(*document, whitespaceTrimmedQuery, document, nullptr, XPathResult::ORDERED
_NODE_SNAPSHOT_TYPE, 0, exceptionState); |
1029 if (exceptionState.hadException() || !result) | 1031 if (exceptionState.hadException() || !result) |
1030 continue; | 1032 continue; |
1031 | 1033 |
1032 unsigned long size = result->snapshotLength(exceptionState); | 1034 unsigned long size = result->snapshotLength(exceptionState); |
1033 for (unsigned long i = 0; !exceptionState.hadException() && i < size
; ++i) { | 1035 for (unsigned long i = 0; !exceptionState.hadException() && i < size
; ++i) { |
1034 Node* node = result->snapshotItem(i, exceptionState); | 1036 Node* node = result->snapshotItem(i, exceptionState); |
1035 if (exceptionState.hadException()) | 1037 if (exceptionState.hadException()) |
1036 break; | 1038 break; |
1037 | 1039 |
1038 if (node->nodeType() == Node::ATTRIBUTE_NODE) | 1040 if (node->nodeType() == Node::ATTRIBUTE_NODE) |
1039 node = toAttr(node)->ownerElement(); | 1041 node = toAttr(node)->ownerElement(); |
1040 resultCollector.add(node); | 1042 resultCollector.add(node); |
1041 } | 1043 } |
1042 } | 1044 } |
1043 | 1045 |
1044 // Selector evaluation | 1046 // Selector evaluation |
1045 for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++
it) { | 1047 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs
.begin(); it != docs.end(); ++it) { |
1046 Document* document = *it; | 1048 Document* document = *it; |
1047 TrackExceptionState exceptionState; | 1049 TrackExceptionState exceptionState; |
1048 RefPtrWillBeRawPtr<StaticNodeList> nodeList = document->querySelecto
rAll(AtomicString(whitespaceTrimmedQuery), exceptionState); | 1050 RefPtrWillBeRawPtr<StaticNodeList> nodeList = document->querySelecto
rAll(AtomicString(whitespaceTrimmedQuery), exceptionState); |
1049 if (exceptionState.hadException() || !nodeList) | 1051 if (exceptionState.hadException() || !nodeList) |
1050 continue; | 1052 continue; |
1051 | 1053 |
1052 unsigned size = nodeList->length(); | 1054 unsigned size = nodeList->length(); |
1053 for (unsigned i = 0; i < size; ++i) | 1055 for (unsigned i = 0; i < size; ++i) |
1054 resultCollector.add(nodeList->item(i)); | 1056 resultCollector.add(nodeList->item(i)); |
1055 } | 1057 } |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 { | 2118 { |
2117 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. | 2119 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. |
2118 if (!m_documentNodeToIdMap->contains(m_document.get())) { | 2120 if (!m_documentNodeToIdMap->contains(m_document.get())) { |
2119 RefPtr<TypeBuilder::DOM::Node> root; | 2121 RefPtr<TypeBuilder::DOM::Node> root; |
2120 getDocument(errorString, root); | 2122 getDocument(errorString, root); |
2121 return errorString->isEmpty(); | 2123 return errorString->isEmpty(); |
2122 } | 2124 } |
2123 return true; | 2125 return true; |
2124 } | 2126 } |
2125 | 2127 |
| 2128 void InspectorDOMAgent::trace(Visitor* visitor) |
| 2129 { |
| 2130 visitor->trace(m_domListener); |
| 2131 visitor->trace(m_pageAgent); |
| 2132 #if ENABLE(OILPAN) |
| 2133 visitor->trace(m_documentNodeToIdMap); |
| 2134 visitor->trace(m_danglingNodeToIdMaps); |
| 2135 visitor->trace(m_idToNode); |
| 2136 visitor->trace(m_idToNodesMap); |
| 2137 visitor->trace(m_document); |
| 2138 visitor->trace(m_searchResults); |
| 2139 #endif |
| 2140 visitor->trace(m_history); |
| 2141 visitor->trace(m_domEditor); |
| 2142 visitor->trace(m_listener); |
| 2143 InspectorBaseAgent::trace(visitor); |
| 2144 } |
| 2145 |
2126 } // namespace blink | 2146 } // namespace blink |
2127 | 2147 |
OLD | NEW |