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