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

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

Issue 2819183002: [DevTools] Consolidate overlay-related functionality in Overlay domain (Closed)
Patch Set: rebased bad merge Created 3 years, 7 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
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "core/inspector/V8InspectorString.h" 70 #include "core/inspector/V8InspectorString.h"
71 #include "core/layout/HitTestResult.h" 71 #include "core/layout/HitTestResult.h"
72 #include "core/layout/LayoutInline.h" 72 #include "core/layout/LayoutInline.h"
73 #include "core/layout/api/LayoutViewItem.h" 73 #include "core/layout/api/LayoutViewItem.h"
74 #include "core/layout/line/InlineTextBox.h" 74 #include "core/layout/line/InlineTextBox.h"
75 #include "core/loader/DocumentLoader.h" 75 #include "core/loader/DocumentLoader.h"
76 #include "core/page/FrameTree.h" 76 #include "core/page/FrameTree.h"
77 #include "core/page/Page.h" 77 #include "core/page/Page.h"
78 #include "core/xml/DocumentXPathEvaluator.h" 78 #include "core/xml/DocumentXPathEvaluator.h"
79 #include "core/xml/XPathResult.h" 79 #include "core/xml/XPathResult.h"
80 #include "platform/graphics/Color.h"
80 #include "platform/wtf/ListHashSet.h" 81 #include "platform/wtf/ListHashSet.h"
81 #include "platform/wtf/PtrUtil.h" 82 #include "platform/wtf/PtrUtil.h"
82 #include "platform/wtf/text/CString.h" 83 #include "platform/wtf/text/CString.h"
83 #include "platform/wtf/text/WTFString.h" 84 #include "platform/wtf/text/WTFString.h"
84 85
85 namespace blink { 86 namespace blink {
86 87
87 using namespace HTMLNames; 88 using namespace HTMLNames;
88 using protocol::Maybe; 89 using protocol::Maybe;
89 using protocol::Response; 90 using protocol::Response;
90 91
91 namespace DOMAgentState { 92 namespace DOMAgentState {
92 static const char kDomAgentEnabled[] = "domAgentEnabled"; 93 static const char kDomAgentEnabled[] = "domAgentEnabled";
93 }; 94 };
94 95
95 namespace { 96 namespace {
96 97
97 const size_t kMaxTextSize = 10000; 98 const size_t kMaxTextSize = 10000;
98 const UChar kEllipsisUChar[] = {0x2026, 0}; 99 const UChar kEllipsisUChar[] = {0x2026, 0};
99 100
100 Color ParseColor(protocol::DOM::RGBA* rgba) {
101 if (!rgba)
102 return Color::kTransparent;
103
104 int r = rgba->getR();
105 int g = rgba->getG();
106 int b = rgba->getB();
107 if (!rgba->hasA())
108 return Color(r, g, b);
109
110 double a = rgba->getA(1);
111 // Clamp alpha to the [0..1] range.
112 if (a < 0)
113 a = 0;
114 else if (a > 1)
115 a = 1;
116
117 return Color(r, g, b, static_cast<int>(a * 255));
118 }
119
120 bool ParseQuad(std::unique_ptr<protocol::Array<double>> quad_array,
121 FloatQuad* quad) {
122 const size_t kCoordinatesInQuad = 8;
123 if (!quad_array || quad_array->length() != kCoordinatesInQuad)
124 return false;
125 quad->SetP1(FloatPoint(quad_array->get(0), quad_array->get(1)));
126 quad->SetP2(FloatPoint(quad_array->get(2), quad_array->get(3)));
127 quad->SetP3(FloatPoint(quad_array->get(4), quad_array->get(5)));
128 quad->SetP4(FloatPoint(quad_array->get(6), quad_array->get(7)));
129 return true;
130 }
131
132 } // namespace 101 } // namespace
133 102
134 class InspectorRevalidateDOMTask final 103 class InspectorRevalidateDOMTask final
135 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> { 104 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> {
136 public: 105 public:
137 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); 106 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*);
138 void ScheduleStyleAttrRevalidationFor(Element*); 107 void ScheduleStyleAttrRevalidationFor(Element*);
139 void Reset() { timer_.Stop(); } 108 void Reset() { timer_.Stop(); }
140 void OnTimer(TimerBase*); 109 void OnTimer(TimerBase*);
141 DECLARE_TRACE(); 110 DECLARE_TRACE();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 *type = protocol::DOM::PseudoTypeEnum::Resizer; 196 *type = protocol::DOM::PseudoTypeEnum::Resizer;
228 return true; 197 return true;
229 case kPseudoIdInputListButton: 198 case kPseudoIdInputListButton:
230 *type = protocol::DOM::PseudoTypeEnum::InputListButton; 199 *type = protocol::DOM::PseudoTypeEnum::InputListButton;
231 return true; 200 return true;
232 default: 201 default:
233 return false; 202 return false;
234 } 203 }
235 } 204 }
236 205
206 // static
207 Color InspectorDOMAgent::ParseColor(protocol::DOM::RGBA* rgba) {
208 if (!rgba)
209 return Color::kTransparent;
210
211 int r = rgba->getR();
212 int g = rgba->getG();
213 int b = rgba->getB();
214 if (!rgba->hasA())
215 return Color(r, g, b);
216
217 double a = rgba->getA(1);
218 // Clamp alpha to the [0..1] range.
219 if (a < 0)
220 a = 0;
221 else if (a > 1)
222 a = 1;
223
224 return Color(r, g, b, static_cast<int>(a * 255));
225 }
226
237 InspectorDOMAgent::InspectorDOMAgent( 227 InspectorDOMAgent::InspectorDOMAgent(
238 v8::Isolate* isolate, 228 v8::Isolate* isolate,
239 InspectedFrames* inspected_frames, 229 InspectedFrames* inspected_frames,
240 v8_inspector::V8InspectorSession* v8_session, 230 v8_inspector::V8InspectorSession* v8_session)
241 Client* client)
242 : isolate_(isolate), 231 : isolate_(isolate),
243 inspected_frames_(inspected_frames), 232 inspected_frames_(inspected_frames),
244 v8_session_(v8_session), 233 v8_session_(v8_session),
245 client_(client),
246 dom_listener_(nullptr), 234 dom_listener_(nullptr),
247 document_node_to_id_map_(new NodeToIdMap()), 235 document_node_to_id_map_(new NodeToIdMap()),
248 last_node_id_(1), 236 last_node_id_(1),
249 suppress_attribute_modified_event_(false), 237 suppress_attribute_modified_event_(false) {}
250 backend_node_id_to_inspect_(0) {}
251 238
252 InspectorDOMAgent::~InspectorDOMAgent() {} 239 InspectorDOMAgent::~InspectorDOMAgent() {}
253 240
254 void InspectorDOMAgent::Restore() { 241 void InspectorDOMAgent::Restore() {
255 if (!Enabled()) 242 if (!Enabled())
256 return; 243 return;
257 InnerEnable(); 244 InnerEnable();
258 } 245 }
259 246
260 HeapVector<Member<Document>> InspectorDOMAgent::Documents() { 247 HeapVector<Member<Document>> InspectorDOMAgent::Documents() {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 418
432 return Response::OK(); 419 return Response::OK();
433 } 420 }
434 421
435 void InspectorDOMAgent::InnerEnable() { 422 void InspectorDOMAgent::InnerEnable() {
436 state_->setBoolean(DOMAgentState::kDomAgentEnabled, true); 423 state_->setBoolean(DOMAgentState::kDomAgentEnabled, true);
437 history_ = new InspectorHistory(); 424 history_ = new InspectorHistory();
438 dom_editor_ = new DOMEditor(history_.Get()); 425 dom_editor_ = new DOMEditor(history_.Get());
439 document_ = inspected_frames_->Root()->GetDocument(); 426 document_ = inspected_frames_->Root()->GetDocument();
440 instrumenting_agents_->addInspectorDOMAgent(this); 427 instrumenting_agents_->addInspectorDOMAgent(this);
441 if (backend_node_id_to_inspect_)
442 GetFrontend()->inspectNodeRequested(backend_node_id_to_inspect_);
443 backend_node_id_to_inspect_ = 0;
444 } 428 }
445 429
446 Response InspectorDOMAgent::enable() { 430 Response InspectorDOMAgent::enable() {
447 if (!Enabled()) 431 if (!Enabled())
448 InnerEnable(); 432 InnerEnable();
449 return Response::OK(); 433 return Response::OK();
450 } 434 }
451 435
452 bool InspectorDOMAgent::Enabled() const { 436 bool InspectorDOMAgent::Enabled() const {
453 return state_->booleanProperty(DOMAgentState::kDomAgentEnabled, false); 437 return state_->booleanProperty(DOMAgentState::kDomAgentEnabled, false);
454 } 438 }
455 439
456 Response InspectorDOMAgent::disable() { 440 Response InspectorDOMAgent::disable() {
457 if (!Enabled()) 441 if (!Enabled())
458 return Response::Error("DOM agent hasn't been enabled"); 442 return Response::Error("DOM agent hasn't been enabled");
459 state_->setBoolean(DOMAgentState::kDomAgentEnabled, false); 443 state_->setBoolean(DOMAgentState::kDomAgentEnabled, false);
460 SetSearchingForNode(kNotSearching, Maybe<protocol::DOM::HighlightConfig>());
461 instrumenting_agents_->removeInspectorDOMAgent(this); 444 instrumenting_agents_->removeInspectorDOMAgent(this);
462 history_.Clear(); 445 history_.Clear();
463 dom_editor_.Clear(); 446 dom_editor_.Clear();
464 SetDocument(nullptr); 447 SetDocument(nullptr);
465 return Response::OK(); 448 return Response::OK();
466 } 449 }
467 450
468 Response InspectorDOMAgent::getDocument( 451 Response InspectorDOMAgent::getDocument(
469 Maybe<int> depth, 452 Maybe<int> depth,
470 Maybe<bool> pierce, 453 Maybe<bool> pierce,
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 for (int i = from_index; i < to_index; ++i) 1100 for (int i = from_index; i < to_index; ++i)
1118 (*node_ids)->addItem(PushNodePathToFrontend((it->value)[i].Get())); 1101 (*node_ids)->addItem(PushNodePathToFrontend((it->value)[i].Get()));
1119 return Response::OK(); 1102 return Response::OK();
1120 } 1103 }
1121 1104
1122 Response InspectorDOMAgent::discardSearchResults(const String& search_id) { 1105 Response InspectorDOMAgent::discardSearchResults(const String& search_id) {
1123 search_results_.erase(search_id); 1106 search_results_.erase(search_id);
1124 return Response::OK(); 1107 return Response::OK();
1125 } 1108 }
1126 1109
1127 void InspectorDOMAgent::Inspect(Node* inspected_node) { 1110 Response InspectorDOMAgent::NodeForRemoteObjectId(const String& object_id,
1128 if (!inspected_node) 1111 Node*& node) {
1129 return;
1130
1131 Node* node = inspected_node;
1132 while (node && !node->IsElementNode() && !node->IsDocumentNode() &&
1133 !node->IsDocumentFragment())
1134 node = node->ParentOrShadowHostNode();
1135 if (!node)
1136 return;
1137
1138 int backend_node_id = DOMNodeIds::IdForNode(node);
1139 if (!GetFrontend() || !Enabled()) {
1140 backend_node_id_to_inspect_ = backend_node_id;
1141 return;
1142 }
1143
1144 GetFrontend()->inspectNodeRequested(backend_node_id);
1145 }
1146
1147 void InspectorDOMAgent::NodeHighlightedInOverlay(Node* node) {
1148 if (!GetFrontend() || !Enabled())
1149 return;
1150
1151 while (node && !node->IsElementNode() && !node->IsDocumentNode() &&
1152 !node->IsDocumentFragment())
1153 node = node->ParentOrShadowHostNode();
1154
1155 if (!node)
1156 return;
1157
1158 int node_id = PushNodePathToFrontend(node);
1159 GetFrontend()->nodeHighlightRequested(node_id);
1160 }
1161
1162 Response InspectorDOMAgent::SetSearchingForNode(
1163 SearchMode search_mode,
1164 Maybe<protocol::DOM::HighlightConfig> highlight_inspector_object) {
1165 if (!client_)
1166 return Response::OK();
1167 if (search_mode == kNotSearching) {
1168 client_->SetInspectMode(kNotSearching, nullptr);
1169 return Response::OK();
1170 }
1171 std::unique_ptr<InspectorHighlightConfig> config;
1172 Response response = HighlightConfigFromInspectorObject(
1173 std::move(highlight_inspector_object), &config);
1174 if (!response.isSuccess())
1175 return response;
1176 client_->SetInspectMode(search_mode, std::move(config));
1177 return Response::OK();
1178 }
1179
1180 Response InspectorDOMAgent::HighlightConfigFromInspectorObject(
1181 Maybe<protocol::DOM::HighlightConfig> highlight_inspector_object,
1182 std::unique_ptr<InspectorHighlightConfig>* out_config) {
1183 if (!highlight_inspector_object.isJust()) {
1184 return Response::Error(
1185 "Internal error: highlight configuration parameter is missing");
1186 }
1187
1188 protocol::DOM::HighlightConfig* config =
1189 highlight_inspector_object.fromJust();
1190 std::unique_ptr<InspectorHighlightConfig> highlight_config =
1191 WTF::MakeUnique<InspectorHighlightConfig>();
1192 highlight_config->show_info = config->getShowInfo(false);
1193 highlight_config->show_rulers = config->getShowRulers(false);
1194 highlight_config->show_extension_lines = config->getShowExtensionLines(false);
1195 highlight_config->display_as_material = config->getDisplayAsMaterial(false);
1196 highlight_config->content = ParseColor(config->getContentColor(nullptr));
1197 highlight_config->padding = ParseColor(config->getPaddingColor(nullptr));
1198 highlight_config->border = ParseColor(config->getBorderColor(nullptr));
1199 highlight_config->margin = ParseColor(config->getMarginColor(nullptr));
1200 highlight_config->event_target =
1201 ParseColor(config->getEventTargetColor(nullptr));
1202 highlight_config->shape = ParseColor(config->getShapeColor(nullptr));
1203 highlight_config->shape_margin =
1204 ParseColor(config->getShapeMarginColor(nullptr));
1205 highlight_config->selector_list = config->getSelectorList("");
1206
1207 *out_config = std::move(highlight_config);
1208 return Response::OK();
1209 }
1210
1211 Response InspectorDOMAgent::setInspectMode(
1212 const String& mode,
1213 Maybe<protocol::DOM::HighlightConfig> highlight_config) {
1214 SearchMode search_mode;
1215 if (mode == protocol::DOM::InspectModeEnum::SearchForNode) {
1216 search_mode = kSearchingForNormal;
1217 } else if (mode == protocol::DOM::InspectModeEnum::SearchForUAShadowDOM) {
1218 search_mode = kSearchingForUAShadow;
1219 } else if (mode == protocol::DOM::InspectModeEnum::None) {
1220 search_mode = kNotSearching;
1221 } else {
1222 return Response::Error(
1223 String("Unknown mode \"" + mode + "\" was provided."));
1224 }
1225
1226 if (search_mode != kNotSearching) {
1227 Response response = PushDocumentUponHandlelessOperation();
1228 if (!response.isSuccess())
1229 return response;
1230 }
1231
1232 return SetSearchingForNode(search_mode, std::move(highlight_config));
1233 }
1234
1235 Response InspectorDOMAgent::highlightRect(
1236 int x,
1237 int y,
1238 int width,
1239 int height,
1240 Maybe<protocol::DOM::RGBA> color,
1241 Maybe<protocol::DOM::RGBA> outline_color) {
1242 std::unique_ptr<FloatQuad> quad =
1243 WTF::WrapUnique(new FloatQuad(FloatRect(x, y, width, height)));
1244 InnerHighlightQuad(std::move(quad), std::move(color),
1245 std::move(outline_color));
1246 return Response::OK();
1247 }
1248
1249 Response InspectorDOMAgent::highlightQuad(
1250 std::unique_ptr<protocol::Array<double>> quad_array,
1251 Maybe<protocol::DOM::RGBA> color,
1252 Maybe<protocol::DOM::RGBA> outline_color) {
1253 std::unique_ptr<FloatQuad> quad = WTF::MakeUnique<FloatQuad>();
1254 if (!ParseQuad(std::move(quad_array), quad.get()))
1255 return Response::Error("Invalid Quad format");
1256 InnerHighlightQuad(std::move(quad), std::move(color),
1257 std::move(outline_color));
1258 return Response::OK();
1259 }
1260
1261 void InspectorDOMAgent::InnerHighlightQuad(
1262 std::unique_ptr<FloatQuad> quad,
1263 Maybe<protocol::DOM::RGBA> color,
1264 Maybe<protocol::DOM::RGBA> outline_color) {
1265 std::unique_ptr<InspectorHighlightConfig> highlight_config =
1266 WTF::MakeUnique<InspectorHighlightConfig>();
1267 highlight_config->content = ParseColor(color.fromMaybe(nullptr));
1268 highlight_config->content_outline =
1269 ParseColor(outline_color.fromMaybe(nullptr));
1270 if (client_)
1271 client_->HighlightQuad(std::move(quad), *highlight_config);
1272 }
1273
1274 Response InspectorDOMAgent::NodeForRemoteId(const String& object_id,
1275 Node*& node) {
1276 v8::HandleScope handles(isolate_); 1112 v8::HandleScope handles(isolate_);
1277 v8::Local<v8::Value> value; 1113 v8::Local<v8::Value> value;
1278 v8::Local<v8::Context> context; 1114 v8::Local<v8::Context> context;
1279 std::unique_ptr<v8_inspector::StringBuffer> error; 1115 std::unique_ptr<v8_inspector::StringBuffer> error;
1280 if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), 1116 if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id),
1281 &value, &context, nullptr)) 1117 &value, &context, nullptr))
1282 return Response::Error(ToCoreString(std::move(error))); 1118 return Response::Error(ToCoreString(std::move(error)));
1283 if (!V8Node::hasInstance(value, isolate_)) 1119 if (!V8Node::hasInstance(value, isolate_))
1284 return Response::Error("Object id doesn't reference a Node"); 1120 return Response::Error("Object id doesn't reference a Node");
1285 node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value)); 1121 node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value));
1286 if (!node) { 1122 if (!node) {
1287 return Response::Error( 1123 return Response::Error(
1288 "Couldn't convert object with given objectId to Node"); 1124 "Couldn't convert object with given objectId to Node");
1289 } 1125 }
1290 return Response::OK(); 1126 return Response::OK();
1291 } 1127 }
1292 1128
1293 Response InspectorDOMAgent::highlightNode(
1294 std::unique_ptr<protocol::DOM::HighlightConfig> highlight_inspector_object,
1295 Maybe<int> node_id,
1296 Maybe<int> backend_node_id,
1297 Maybe<String> object_id) {
1298 Node* node = nullptr;
1299 Response response;
1300 if (node_id.isJust()) {
1301 response = AssertNode(node_id.fromJust(), node);
1302 } else if (backend_node_id.isJust()) {
1303 node = DOMNodeIds::NodeForId(backend_node_id.fromJust());
1304 response = !node ? Response::Error("No node found for given backend id")
1305 : Response::OK();
1306 } else if (object_id.isJust()) {
1307 response = NodeForRemoteId(object_id.fromJust(), node);
1308 } else {
1309 response = Response::Error("Either nodeId or objectId must be specified");
1310 }
1311
1312 if (!response.isSuccess())
1313 return response;
1314
1315 std::unique_ptr<InspectorHighlightConfig> highlight_config;
1316 response = HighlightConfigFromInspectorObject(
1317 std::move(highlight_inspector_object), &highlight_config);
1318 if (!response.isSuccess())
1319 return response;
1320
1321 if (client_)
1322 client_->HighlightNode(node, *highlight_config, false);
1323 return Response::OK();
1324 }
1325
1326 Response InspectorDOMAgent::highlightFrame(
1327 const String& frame_id,
1328 Maybe<protocol::DOM::RGBA> color,
1329 Maybe<protocol::DOM::RGBA> outline_color) {
1330 LocalFrame* frame =
1331 IdentifiersFactory::FrameById(inspected_frames_, frame_id);
1332 // FIXME: Inspector doesn't currently work cross process.
1333 if (frame && frame->DeprecatedLocalOwner()) {
1334 std::unique_ptr<InspectorHighlightConfig> highlight_config =
1335 WTF::MakeUnique<InspectorHighlightConfig>();
1336 highlight_config->show_info = true; // Always show tooltips for frames.
1337 highlight_config->content = ParseColor(color.fromMaybe(nullptr));
1338 highlight_config->content_outline =
1339 ParseColor(outline_color.fromMaybe(nullptr));
1340 if (client_)
1341 client_->HighlightNode(frame->DeprecatedLocalOwner(), *highlight_config,
1342 false);
1343 }
1344 return Response::OK();
1345 }
1346
1347 Response InspectorDOMAgent::hideHighlight() {
1348 if (client_)
1349 client_->HideHighlight();
1350 return Response::OK();
1351 }
1352
1353 Response InspectorDOMAgent::copyTo(int node_id, 1129 Response InspectorDOMAgent::copyTo(int node_id,
1354 int target_element_id, 1130 int target_element_id,
1355 Maybe<int> anchor_node_id, 1131 Maybe<int> anchor_node_id,
1356 int* new_node_id) { 1132 int* new_node_id) {
1357 Node* node = nullptr; 1133 Node* node = nullptr;
1358 Response response = AssertEditableNode(node_id, node); 1134 Response response = AssertEditableNode(node_id, node);
1359 if (!response.isSuccess()) 1135 if (!response.isSuccess())
1360 return response; 1136 return response;
1361 1137
1362 Element* target_element = nullptr; 1138 Element* target_element = nullptr;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 Response response = AssertElement(node_id, element); 1309 Response response = AssertElement(node_id, element);
1534 if (!response.isSuccess()) 1310 if (!response.isSuccess())
1535 return response; 1311 return response;
1536 1312
1537 *result = BuildArrayForElementAttributes(element); 1313 *result = BuildArrayForElementAttributes(element);
1538 return Response::OK(); 1314 return Response::OK();
1539 } 1315 }
1540 1316
1541 Response InspectorDOMAgent::requestNode(const String& object_id, int* node_id) { 1317 Response InspectorDOMAgent::requestNode(const String& object_id, int* node_id) {
1542 Node* node = nullptr; 1318 Node* node = nullptr;
1543 Response response = NodeForRemoteId(object_id, node); 1319 Response response = NodeForRemoteObjectId(object_id, node);
1544 if (!response.isSuccess()) 1320 if (!response.isSuccess())
1545 return response; 1321 return response;
1546 *node_id = PushNodePathToFrontend(node); 1322 *node_id = PushNodePathToFrontend(node);
1547 return Response::OK(); 1323 return Response::OK();
1548 } 1324 }
1549 1325
1550 // static 1326 // static
1551 String InspectorDOMAgent::DocumentURLString(Document* document) { 1327 String InspectorDOMAgent::DocumentURLString(Document* document) {
1552 if (!document || document->Url().IsNull()) 1328 if (!document || document->Url().IsNull())
1553 return ""; 1329 return "";
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 } 2123 }
2348 while (layout_object && !layout_object->IsDocumentElement() && 2124 while (layout_object && !layout_object->IsDocumentElement() &&
2349 !layout_object->IsRelayoutBoundaryForInspector()) 2125 !layout_object->IsRelayoutBoundaryForInspector())
2350 layout_object = layout_object->Container(); 2126 layout_object = layout_object->Container();
2351 Node* result_node = 2127 Node* result_node =
2352 layout_object ? layout_object->GeneratingNode() : node->ownerDocument(); 2128 layout_object ? layout_object->GeneratingNode() : node->ownerDocument();
2353 *relayout_boundary_node_id = PushNodePathToFrontend(result_node); 2129 *relayout_boundary_node_id = PushNodePathToFrontend(result_node);
2354 return Response::OK(); 2130 return Response::OK();
2355 } 2131 }
2356 2132
2357 Response InspectorDOMAgent::getHighlightObjectForTest(
2358 int node_id,
2359 std::unique_ptr<protocol::DictionaryValue>* result) {
2360 Node* node = nullptr;
2361 Response response = AssertNode(node_id, node);
2362 if (!response.isSuccess())
2363 return response;
2364 InspectorHighlight highlight(node, InspectorHighlight::DefaultConfig(), true);
2365 *result = highlight.AsProtocolValue();
2366 return Response::OK();
2367 }
2368
2369 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> 2133 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject>
2370 InspectorDOMAgent::ResolveNode(Node* node, const String& object_group) { 2134 InspectorDOMAgent::ResolveNode(Node* node, const String& object_group) {
2371 Document* document = 2135 Document* document =
2372 node->IsDocumentNode() ? &node->GetDocument() : node->ownerDocument(); 2136 node->IsDocumentNode() ? &node->GetDocument() : node->ownerDocument();
2373 LocalFrame* frame = document ? document->GetFrame() : nullptr; 2137 LocalFrame* frame = document ? document->GetFrame() : nullptr;
2374 if (!frame) 2138 if (!frame)
2375 return nullptr; 2139 return nullptr;
2376 2140
2377 ScriptState* script_state = ToScriptStateForMainWorld(frame); 2141 ScriptState* script_state = ToScriptStateForMainWorld(frame);
2378 if (!script_state) 2142 if (!script_state)
(...skipping 22 matching lines...) Expand all
2401 visitor->Trace(id_to_nodes_map_); 2165 visitor->Trace(id_to_nodes_map_);
2402 visitor->Trace(document_); 2166 visitor->Trace(document_);
2403 visitor->Trace(revalidate_task_); 2167 visitor->Trace(revalidate_task_);
2404 visitor->Trace(search_results_); 2168 visitor->Trace(search_results_);
2405 visitor->Trace(history_); 2169 visitor->Trace(history_);
2406 visitor->Trace(dom_editor_); 2170 visitor->Trace(dom_editor_);
2407 InspectorBaseAgent::Trace(visitor); 2171 InspectorBaseAgent::Trace(visitor);
2408 } 2172 }
2409 2173
2410 } // namespace blink 2174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698