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

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

Issue 1315283002: [DevTools] Reverse dependencies between InspectorOverlay and agents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: more compile Created 5 years, 3 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
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/core/inspector/InspectorOverlay.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "core/html/HTMLTemplateElement.h" 63 #include "core/html/HTMLTemplateElement.h"
64 #include "core/html/imports/HTMLImportChild.h" 64 #include "core/html/imports/HTMLImportChild.h"
65 #include "core/html/imports/HTMLImportLoader.h" 65 #include "core/html/imports/HTMLImportLoader.h"
66 #include "core/inspector/DOMEditor.h" 66 #include "core/inspector/DOMEditor.h"
67 #include "core/inspector/DOMPatchSupport.h" 67 #include "core/inspector/DOMPatchSupport.h"
68 #include "core/inspector/IdentifiersFactory.h" 68 #include "core/inspector/IdentifiersFactory.h"
69 #include "core/inspector/InjectedScriptHost.h" 69 #include "core/inspector/InjectedScriptHost.h"
70 #include "core/inspector/InjectedScriptManager.h" 70 #include "core/inspector/InjectedScriptManager.h"
71 #include "core/inspector/InspectorHighlight.h" 71 #include "core/inspector/InspectorHighlight.h"
72 #include "core/inspector/InspectorHistory.h" 72 #include "core/inspector/InspectorHistory.h"
73 #include "core/inspector/InspectorOverlay.h"
74 #include "core/inspector/InspectorPageAgent.h" 73 #include "core/inspector/InspectorPageAgent.h"
75 #include "core/inspector/InspectorState.h" 74 #include "core/inspector/InspectorState.h"
76 #include "core/inspector/InstrumentingAgents.h" 75 #include "core/inspector/InstrumentingAgents.h"
77 #include "core/inspector/RemoteObjectId.h" 76 #include "core/inspector/RemoteObjectId.h"
78 #include "core/layout/HitTestResult.h" 77 #include "core/layout/HitTestResult.h"
79 #include "core/layout/LayoutView.h" 78 #include "core/layout/LayoutView.h"
80 #include "core/loader/DocumentLoader.h" 79 #include "core/loader/DocumentLoader.h"
81 #include "core/page/FrameTree.h" 80 #include "core/page/FrameTree.h"
82 #include "core/page/Page.h" 81 #include "core/page/Page.h"
83 #include "core/xml/DocumentXPathEvaluator.h" 82 #include "core/xml/DocumentXPathEvaluator.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 *type = TypeBuilder::DOM::PseudoType::Resizer; 298 *type = TypeBuilder::DOM::PseudoType::Resizer;
300 return true; 299 return true;
301 case INPUT_LIST_BUTTON: 300 case INPUT_LIST_BUTTON:
302 *type = TypeBuilder::DOM::PseudoType::Input_list_button; 301 *type = TypeBuilder::DOM::PseudoType::Input_list_button;
303 return true; 302 return true;
304 default: 303 default:
305 return false; 304 return false;
306 } 305 }
307 } 306 }
308 307
309 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) 308 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, Client* client)
310 : InspectorBaseAgent<InspectorDOMAgent, InspectorFrontend::DOM>("DOM") 309 : InspectorBaseAgent<InspectorDOMAgent, InspectorFrontend::DOM>("DOM")
311 , m_pageAgent(pageAgent) 310 , m_pageAgent(pageAgent)
312 , m_injectedScriptManager(injectedScriptManager) 311 , m_injectedScriptManager(injectedScriptManager)
313 , m_overlay(overlay) 312 , m_client(client)
314 , m_domListener(nullptr) 313 , m_domListener(nullptr)
315 , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap())) 314 , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap()))
316 , m_lastNodeId(1) 315 , m_lastNodeId(1)
317 , m_searchingForNode(NotSearching) 316 , m_searchingForNode(NotSearching)
318 , m_suppressAttributeModifiedEvent(false) 317 , m_suppressAttributeModifiedEvent(false)
319 , m_backendNodeIdToInspect(0) 318 , m_backendNodeIdToInspect(0)
320 { 319 {
321 } 320 }
322 321
323 InspectorDOMAgent::~InspectorDOMAgent() 322 InspectorDOMAgent::~InspectorDOMAgent()
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 } 1136 }
1138 return false; 1137 return false;
1139 } 1138 }
1140 1139
1141 bool InspectorDOMAgent::handleGestureEvent(LocalFrame* frame, const PlatformGest ureEvent& event) 1140 bool InspectorDOMAgent::handleGestureEvent(LocalFrame* frame, const PlatformGest ureEvent& event)
1142 { 1141 {
1143 if (m_searchingForNode == NotSearching || event.type() != PlatformEvent::Ges tureTap) 1142 if (m_searchingForNode == NotSearching || event.type() != PlatformEvent::Ges tureTap)
1144 return false; 1143 return false;
1145 Node* node = hoveredNodeForEvent(frame, event, false); 1144 Node* node = hoveredNodeForEvent(frame, event, false);
1146 if (node && m_inspectModeHighlightConfig) { 1145 if (node && m_inspectModeHighlightConfig) {
1147 m_overlay->highlightNode(node, 0 /* eventTarget */, *m_inspectModeHighli ghtConfig, false); 1146 if (m_client)
1147 m_client->highlightNode(node, 0 /* eventTarget */, *m_inspectModeHig hlightConfig, false);
1148 inspect(node); 1148 inspect(node);
1149 return true; 1149 return true;
1150 } 1150 }
1151 return false; 1151 return false;
1152 } 1152 }
1153 1153
1154 bool InspectorDOMAgent::handleTouchEvent(LocalFrame* frame, const PlatformTouchE vent& event) 1154 bool InspectorDOMAgent::handleTouchEvent(LocalFrame* frame, const PlatformTouchE vent& event)
1155 { 1155 {
1156 if (m_searchingForNode == NotSearching) 1156 if (m_searchingForNode == NotSearching)
1157 return false; 1157 return false;
1158 Node* node = hoveredNodeForEvent(frame, event, false); 1158 Node* node = hoveredNodeForEvent(frame, event, false);
1159 if (node && m_inspectModeHighlightConfig) { 1159 if (node && m_inspectModeHighlightConfig) {
1160 m_overlay->highlightNode(node, 0 /* eventTarget */, *m_inspectModeHighli ghtConfig, false); 1160 if (m_client)
1161 m_client->highlightNode(node, 0 /* eventTarget */, *m_inspectModeHig hlightConfig, false);
1161 inspect(node); 1162 inspect(node);
1162 return true; 1163 return true;
1163 } 1164 }
1164 return false; 1165 return false;
1165 } 1166 }
1166 1167
1167 void InspectorDOMAgent::inspect(Node* inspectedNode) 1168 void InspectorDOMAgent::inspect(Node* inspectedNode)
1168 { 1169 {
1169 if (!inspectedNode) 1170 if (!inspectedNode)
1170 return; 1171 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1207
1207 if (!node) 1208 if (!node)
1208 return true; 1209 return true;
1209 1210
1210 Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(frame, event, fal se) : nullptr; 1211 Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(frame, event, fal se) : nullptr;
1211 if (eventTarget == node) 1212 if (eventTarget == node)
1212 eventTarget = 0; 1213 eventTarget = 0;
1213 1214
1214 if (node && m_inspectModeHighlightConfig) { 1215 if (node && m_inspectModeHighlightConfig) {
1215 m_hoveredNodeForInspectMode = node; 1216 m_hoveredNodeForInspectMode = node;
1216 m_overlay->highlightNode(node, eventTarget, *m_inspectModeHighlightConfi g, event.ctrlKey() || event.metaKey()); 1217 if (m_client)
1218 m_client->highlightNode(node, eventTarget, *m_inspectModeHighlightCo nfig, event.ctrlKey() || event.metaKey());
1217 } 1219 }
1218 return true; 1220 return true;
1219 } 1221 }
1220 1222
1221 void InspectorDOMAgent::setSearchingForNode(ErrorString* errorString, SearchMode searchMode, JSONObject* highlightInspectorObject) 1223 void InspectorDOMAgent::setSearchingForNode(ErrorString* errorString, SearchMode searchMode, JSONObject* highlightInspectorObject)
1222 { 1224 {
1225 // TODO(dgozman): move this to overlay.
1223 m_searchingForNode = searchMode; 1226 m_searchingForNode = searchMode;
1224 m_overlay->setInspectModeEnabled(searchMode != NotSearching); 1227 if (m_client)
1228 m_client->setInspectModeEnabled(searchMode != NotSearching);
1225 if (searchMode != NotSearching) { 1229 if (searchMode != NotSearching) {
1226 m_inspectModeHighlightConfig = highlightConfigFromInspectorObject(errorS tring, highlightInspectorObject); 1230 m_inspectModeHighlightConfig = highlightConfigFromInspectorObject(errorS tring, highlightInspectorObject);
1227 } else { 1231 } else {
1228 m_hoveredNodeForInspectMode.clear(); 1232 m_hoveredNodeForInspectMode.clear();
1229 hideHighlight(errorString); 1233 hideHighlight(errorString);
1230 } 1234 }
1231 } 1235 }
1232 1236
1233 PassOwnPtr<InspectorHighlightConfig> InspectorDOMAgent::highlightConfigFromInspe ctorObject(ErrorString* errorString, JSONObject* highlightInspectorObject) 1237 PassOwnPtr<InspectorHighlightConfig> InspectorDOMAgent::highlightConfigFromInspe ctorObject(ErrorString* errorString, JSONObject* highlightInspectorObject)
1234 { 1238 {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 return; 1291 return;
1288 } 1292 }
1289 innerHighlightQuad(quad.release(), color, outlineColor); 1293 innerHighlightQuad(quad.release(), color, outlineColor);
1290 } 1294 }
1291 1295
1292 void InspectorDOMAgent::innerHighlightQuad(PassOwnPtr<FloatQuad> quad, const Ref Ptr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor) 1296 void InspectorDOMAgent::innerHighlightQuad(PassOwnPtr<FloatQuad> quad, const Ref Ptr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor)
1293 { 1297 {
1294 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHig hlightConfig()); 1298 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHig hlightConfig());
1295 highlightConfig->content = parseColor(color); 1299 highlightConfig->content = parseColor(color);
1296 highlightConfig->contentOutline = parseColor(outlineColor); 1300 highlightConfig->contentOutline = parseColor(outlineColor);
1297 m_overlay->highlightQuad(quad, *highlightConfig); 1301 if (m_client)
1302 m_client->highlightQuad(quad, *highlightConfig);
1298 } 1303 }
1299 1304
1300 Node* InspectorDOMAgent::nodeForRemoteId(ErrorString* errorString, const String& objectId) 1305 Node* InspectorDOMAgent::nodeForRemoteId(ErrorString* errorString, const String& objectId)
1301 { 1306 {
1302 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); 1307 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId);
1303 if (!remoteId) { 1308 if (!remoteId) {
1304 *errorString = "Invalid remote object id"; 1309 *errorString = "Invalid remote object id";
1305 return nullptr; 1310 return nullptr;
1306 } 1311 }
1307 InjectedScript injectedScript = m_injectedScriptManager->findInjectedScript( remoteId.get()); 1312 InjectedScript injectedScript = m_injectedScriptManager->findInjectedScript( remoteId.get());
(...skipping 30 matching lines...) Expand all
1338 } else 1343 } else
1339 *errorString = "Either nodeId or objectId must be specified"; 1344 *errorString = "Either nodeId or objectId must be specified";
1340 1345
1341 if (!node) 1346 if (!node)
1342 return; 1347 return;
1343 1348
1344 OwnPtr<InspectorHighlightConfig> highlightConfig = highlightConfigFromInspec torObject(errorString, highlightInspectorObject.get()); 1349 OwnPtr<InspectorHighlightConfig> highlightConfig = highlightConfigFromInspec torObject(errorString, highlightInspectorObject.get());
1345 if (!highlightConfig) 1350 if (!highlightConfig)
1346 return; 1351 return;
1347 1352
1348 m_overlay->highlightNode(node, 0 /* eventTarget */, *highlightConfig, false) ; 1353 if (m_client)
1354 m_client->highlightNode(node, 0 /* eventTarget */, *highlightConfig, fal se);
1349 } 1355 }
1350 1356
1351 void InspectorDOMAgent::highlightFrame( 1357 void InspectorDOMAgent::highlightFrame(
1352 ErrorString*, 1358 ErrorString*,
1353 const String& frameId, 1359 const String& frameId,
1354 const RefPtr<JSONObject>* color, 1360 const RefPtr<JSONObject>* color,
1355 const RefPtr<JSONObject>* outlineColor) 1361 const RefPtr<JSONObject>* outlineColor)
1356 { 1362 {
1357 LocalFrame* frame = IdentifiersFactory::frameById(m_pageAgent->inspectedFram e(), frameId); 1363 LocalFrame* frame = IdentifiersFactory::frameById(m_pageAgent->inspectedFram e(), frameId);
1358 // FIXME: Inspector doesn't currently work cross process. 1364 // FIXME: Inspector doesn't currently work cross process.
1359 if (frame && frame->deprecatedLocalOwner()) { 1365 if (frame && frame->deprecatedLocalOwner()) {
1360 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new Inspecto rHighlightConfig()); 1366 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new Inspecto rHighlightConfig());
1361 highlightConfig->showInfo = true; // Always show tooltips for frames. 1367 highlightConfig->showInfo = true; // Always show tooltips for frames.
1362 highlightConfig->content = parseColor(color); 1368 highlightConfig->content = parseColor(color);
1363 highlightConfig->contentOutline = parseColor(outlineColor); 1369 highlightConfig->contentOutline = parseColor(outlineColor);
1364 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget */, *highlightConfig, false); 1370 if (m_client)
1371 m_client->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTar get */, *highlightConfig, false);
1365 } 1372 }
1366 } 1373 }
1367 1374
1368 void InspectorDOMAgent::hideHighlight(ErrorString*) 1375 void InspectorDOMAgent::hideHighlight(ErrorString*)
1369 { 1376 {
1370 m_overlay->hideHighlight(); 1377 if (m_client)
1378 m_client->hideHighlight();
1371 } 1379 }
1372 1380
1373 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId) 1381 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId)
1374 { 1382 {
1375 Node* node = assertEditableNode(errorString, nodeId); 1383 Node* node = assertEditableNode(errorString, nodeId);
1376 if (!node) 1384 if (!node)
1377 return; 1385 return;
1378 1386
1379 Element* targetElement = assertEditableElement(errorString, targetElementId) ; 1387 Element* targetElement = assertEditableElement(errorString, targetElementId) ;
1380 if (!targetElement) 1388 if (!targetElement)
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 return errorString->isEmpty(); 2228 return errorString->isEmpty();
2221 } 2229 }
2222 return true; 2230 return true;
2223 } 2231 }
2224 2232
2225 DEFINE_TRACE(InspectorDOMAgent) 2233 DEFINE_TRACE(InspectorDOMAgent)
2226 { 2234 {
2227 visitor->trace(m_domListener); 2235 visitor->trace(m_domListener);
2228 visitor->trace(m_pageAgent); 2236 visitor->trace(m_pageAgent);
2229 visitor->trace(m_injectedScriptManager); 2237 visitor->trace(m_injectedScriptManager);
2230 visitor->trace(m_overlay);
2231 #if ENABLE(OILPAN) 2238 #if ENABLE(OILPAN)
2232 visitor->trace(m_documentNodeToIdMap); 2239 visitor->trace(m_documentNodeToIdMap);
2233 visitor->trace(m_danglingNodeToIdMaps); 2240 visitor->trace(m_danglingNodeToIdMaps);
2234 visitor->trace(m_idToNode); 2241 visitor->trace(m_idToNode);
2235 visitor->trace(m_idToNodesMap); 2242 visitor->trace(m_idToNodesMap);
2236 visitor->trace(m_document); 2243 visitor->trace(m_document);
2237 visitor->trace(m_revalidateTask); 2244 visitor->trace(m_revalidateTask);
2238 visitor->trace(m_searchResults); 2245 visitor->trace(m_searchResults);
2239 #endif 2246 #endif
2240 visitor->trace(m_hoveredNodeForInspectMode); 2247 visitor->trace(m_hoveredNodeForInspectMode);
2241 visitor->trace(m_history); 2248 visitor->trace(m_history);
2242 visitor->trace(m_domEditor); 2249 visitor->trace(m_domEditor);
2243 InspectorBaseAgent::trace(visitor); 2250 InspectorBaseAgent::trace(visitor);
2244 } 2251 }
2245 2252
2246 } // namespace blink 2253 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/core/inspector/InspectorOverlay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698