| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "core/html/HTMLLinkElement.h" | 57 #include "core/html/HTMLLinkElement.h" |
| 58 #include "core/html/HTMLTemplateElement.h" | 58 #include "core/html/HTMLTemplateElement.h" |
| 59 #include "core/html/imports/HTMLImportChild.h" | 59 #include "core/html/imports/HTMLImportChild.h" |
| 60 #include "core/html/imports/HTMLImportLoader.h" | 60 #include "core/html/imports/HTMLImportLoader.h" |
| 61 #include "core/inspector/DOMEditor.h" | 61 #include "core/inspector/DOMEditor.h" |
| 62 #include "core/inspector/DOMPatchSupport.h" | 62 #include "core/inspector/DOMPatchSupport.h" |
| 63 #include "core/inspector/IdentifiersFactory.h" | 63 #include "core/inspector/IdentifiersFactory.h" |
| 64 #include "core/inspector/InspectedFrames.h" | 64 #include "core/inspector/InspectedFrames.h" |
| 65 #include "core/inspector/InspectorHighlight.h" | 65 #include "core/inspector/InspectorHighlight.h" |
| 66 #include "core/inspector/InspectorHistory.h" | 66 #include "core/inspector/InspectorHistory.h" |
| 67 #include "core/inspector/V8InspectorStringConversion.h" |
| 67 #include "core/layout/HitTestResult.h" | 68 #include "core/layout/HitTestResult.h" |
| 68 #include "core/layout/api/LayoutViewItem.h" | 69 #include "core/layout/api/LayoutViewItem.h" |
| 69 #include "core/loader/DocumentLoader.h" | 70 #include "core/loader/DocumentLoader.h" |
| 70 #include "core/page/FrameTree.h" | 71 #include "core/page/FrameTree.h" |
| 71 #include "core/page/Page.h" | 72 #include "core/page/Page.h" |
| 72 #include "core/xml/DocumentXPathEvaluator.h" | 73 #include "core/xml/DocumentXPathEvaluator.h" |
| 73 #include "core/xml/XPathResult.h" | 74 #include "core/xml/XPathResult.h" |
| 74 #include "platform/PlatformGestureEvent.h" | 75 #include "platform/PlatformGestureEvent.h" |
| 75 #include "platform/PlatformMouseEvent.h" | 76 #include "platform/PlatformMouseEvent.h" |
| 76 #include "platform/PlatformTouchEvent.h" | 77 #include "platform/PlatformTouchEvent.h" |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 highlightConfig->contentOutline = parseColor(outlineColor.fromMaybe(nullptr)
); | 1159 highlightConfig->contentOutline = parseColor(outlineColor.fromMaybe(nullptr)
); |
| 1159 if (m_client) | 1160 if (m_client) |
| 1160 m_client->highlightQuad(std::move(quad), *highlightConfig); | 1161 m_client->highlightQuad(std::move(quad), *highlightConfig); |
| 1161 } | 1162 } |
| 1162 | 1163 |
| 1163 Node* InspectorDOMAgent::nodeForRemoteId(ErrorString* errorString, const String&
objectId) | 1164 Node* InspectorDOMAgent::nodeForRemoteId(ErrorString* errorString, const String&
objectId) |
| 1164 { | 1165 { |
| 1165 v8::HandleScope handles(m_isolate); | 1166 v8::HandleScope handles(m_isolate); |
| 1166 v8::Local<v8::Value> value; | 1167 v8::Local<v8::Value> value; |
| 1167 v8::Local<v8::Context> context; | 1168 v8::Local<v8::Context> context; |
| 1168 String16 objectGroup; | 1169 v8_inspector::String16 objectGroup; |
| 1169 if (!m_v8Session->unwrapObject(errorString, objectId, &value, &context, &obj
ectGroup)) | 1170 v8_inspector::String16 error; |
| 1171 if (!m_v8Session->unwrapObject(&error, toV8InspectorString(objectId), &value
, &context, &objectGroup)) { |
| 1172 *errorString = toCoreString(error); |
| 1170 return nullptr; | 1173 return nullptr; |
| 1174 } |
| 1171 if (!V8Node::hasInstance(value, m_isolate)) { | 1175 if (!V8Node::hasInstance(value, m_isolate)) { |
| 1172 *errorString = "Object id doesn't reference a Node"; | 1176 *errorString = "Object id doesn't reference a Node"; |
| 1173 return nullptr; | 1177 return nullptr; |
| 1174 } | 1178 } |
| 1175 Node* node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value)); | 1179 Node* node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value)); |
| 1176 if (!node) | 1180 if (!node) |
| 1177 *errorString = "Couldn't convert object with given objectId to Node"; | 1181 *errorString = "Couldn't convert object with given objectId to Node"; |
| 1178 return node; | 1182 return node; |
| 1179 } | 1183 } |
| 1180 | 1184 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 Node* node = result.innerPossiblyPseudoNode(); | 1360 Node* node = result.innerPossiblyPseudoNode(); |
| 1357 while (node && node->getNodeType() == Node::kTextNode) | 1361 while (node && node->getNodeType() == Node::kTextNode) |
| 1358 node = node->parentNode(); | 1362 node = node->parentNode(); |
| 1359 if (!node) { | 1363 if (!node) { |
| 1360 *errorString = "No node found at given location"; | 1364 *errorString = "No node found at given location"; |
| 1361 return; | 1365 return; |
| 1362 } | 1366 } |
| 1363 *nodeId = pushNodePathToFrontend(node); | 1367 *nodeId = pushNodePathToFrontend(node); |
| 1364 } | 1368 } |
| 1365 | 1369 |
| 1366 void InspectorDOMAgent::resolveNode(ErrorString* errorString, int nodeId, const
Maybe<String>& objectGroup, std::unique_ptr<protocol::Runtime::API::RemoteObject
>* result) | 1370 void InspectorDOMAgent::resolveNode(ErrorString* errorString, int nodeId, const
Maybe<String>& objectGroup, std::unique_ptr<v8_inspector::protocol::Runtime::API
::RemoteObject>* result) |
| 1367 { | 1371 { |
| 1368 String objectGroupName = objectGroup.fromMaybe(""); | 1372 String objectGroupName = objectGroup.fromMaybe(""); |
| 1369 Node* node = nodeForId(nodeId); | 1373 Node* node = nodeForId(nodeId); |
| 1370 if (!node) { | 1374 if (!node) { |
| 1371 *errorString = "No node with given id found"; | 1375 *errorString = "No node with given id found"; |
| 1372 return; | 1376 return; |
| 1373 } | 1377 } |
| 1374 *result = resolveNode(node, objectGroupName); | 1378 *result = resolveNode(node, objectGroupName); |
| 1375 if (!*result) | 1379 if (!*result) |
| 1376 *errorString = "Node with given id does not belong to the document"; | 1380 *errorString = "Node with given id does not belong to the document"; |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 | 2037 |
| 2034 void InspectorDOMAgent::getHighlightObjectForTest(ErrorString* errorString, int
nodeId, std::unique_ptr<protocol::DictionaryValue>* result) | 2038 void InspectorDOMAgent::getHighlightObjectForTest(ErrorString* errorString, int
nodeId, std::unique_ptr<protocol::DictionaryValue>* result) |
| 2035 { | 2039 { |
| 2036 Node* node = assertNode(errorString, nodeId); | 2040 Node* node = assertNode(errorString, nodeId); |
| 2037 if (!node) | 2041 if (!node) |
| 2038 return; | 2042 return; |
| 2039 InspectorHighlight highlight(node, InspectorHighlight::defaultConfig(), true
); | 2043 InspectorHighlight highlight(node, InspectorHighlight::defaultConfig(), true
); |
| 2040 *result = highlight.asProtocolValue(); | 2044 *result = highlight.asProtocolValue(); |
| 2041 } | 2045 } |
| 2042 | 2046 |
| 2043 std::unique_ptr<protocol::Runtime::API::RemoteObject> InspectorDOMAgent::resolve
Node(Node* node, const String& objectGroup) | 2047 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> InspectorDOM
Agent::resolveNode(Node* node, const String& objectGroup) |
| 2044 { | 2048 { |
| 2045 Document* document = node->isDocumentNode() ? &node->document() : node->owne
rDocument(); | 2049 Document* document = node->isDocumentNode() ? &node->document() : node->owne
rDocument(); |
| 2046 LocalFrame* frame = document ? document->frame() : nullptr; | 2050 LocalFrame* frame = document ? document->frame() : nullptr; |
| 2047 if (!frame) | 2051 if (!frame) |
| 2048 return nullptr; | 2052 return nullptr; |
| 2049 | 2053 |
| 2050 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 2054 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 2051 if (!scriptState) | 2055 if (!scriptState) |
| 2052 return nullptr; | 2056 return nullptr; |
| 2053 | 2057 |
| 2054 ScriptState::Scope scope(scriptState); | 2058 ScriptState::Scope scope(scriptState); |
| 2055 return m_v8Session->wrapObject(scriptState->context(), nodeV8Value(scriptSta
te->context(), node), objectGroup); | 2059 return m_v8Session->wrapObject(scriptState->context(), nodeV8Value(scriptSta
te->context(), node), toV8InspectorString(objectGroup)); |
| 2056 } | 2060 } |
| 2057 | 2061 |
| 2058 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt
ring) | 2062 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt
ring) |
| 2059 { | 2063 { |
| 2060 if (!m_documentNodeToIdMap->contains(m_document)) { | 2064 if (!m_documentNodeToIdMap->contains(m_document)) { |
| 2061 std::unique_ptr<protocol::DOM::Node> root; | 2065 std::unique_ptr<protocol::DOM::Node> root; |
| 2062 getDocument(errorString, &root); | 2066 getDocument(errorString, &root); |
| 2063 return errorString->isEmpty(); | 2067 return errorString->isEmpty(); |
| 2064 } | 2068 } |
| 2065 return true; | 2069 return true; |
| 2066 } | 2070 } |
| 2067 | 2071 |
| 2068 DEFINE_TRACE(InspectorDOMAgent) | 2072 DEFINE_TRACE(InspectorDOMAgent) |
| 2069 { | 2073 { |
| 2070 visitor->trace(m_domListener); | 2074 visitor->trace(m_domListener); |
| 2071 visitor->trace(m_inspectedFrames); | 2075 visitor->trace(m_inspectedFrames); |
| 2072 visitor->trace(m_documentNodeToIdMap); | 2076 visitor->trace(m_documentNodeToIdMap); |
| 2073 visitor->trace(m_danglingNodeToIdMaps); | 2077 visitor->trace(m_danglingNodeToIdMaps); |
| 2074 visitor->trace(m_idToNode); | 2078 visitor->trace(m_idToNode); |
| 2075 visitor->trace(m_idToNodesMap); | 2079 visitor->trace(m_idToNodesMap); |
| 2076 visitor->trace(m_document); | 2080 visitor->trace(m_document); |
| 2077 visitor->trace(m_revalidateTask); | 2081 visitor->trace(m_revalidateTask); |
| 2078 visitor->trace(m_searchResults); | 2082 visitor->trace(m_searchResults); |
| 2079 visitor->trace(m_history); | 2083 visitor->trace(m_history); |
| 2080 visitor->trace(m_domEditor); | 2084 visitor->trace(m_domEditor); |
| 2081 InspectorBaseAgent::trace(visitor); | 2085 InspectorBaseAgent::trace(visitor); |
| 2082 } | 2086 } |
| 2083 | 2087 |
| 2084 } // namespace blink | 2088 } // namespace blink |
| OLD | NEW |