| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | |
| 81 #include "platform/wtf/ListHashSet.h" | 80 #include "platform/wtf/ListHashSet.h" |
| 82 #include "platform/wtf/PtrUtil.h" | 81 #include "platform/wtf/PtrUtil.h" |
| 83 #include "platform/wtf/text/CString.h" | 82 #include "platform/wtf/text/CString.h" |
| 84 #include "platform/wtf/text/WTFString.h" | 83 #include "platform/wtf/text/WTFString.h" |
| 85 | 84 |
| 86 namespace blink { | 85 namespace blink { |
| 87 | 86 |
| 88 using namespace HTMLNames; | 87 using namespace HTMLNames; |
| 89 using protocol::Maybe; | 88 using protocol::Maybe; |
| 90 using protocol::Response; | 89 using protocol::Response; |
| 91 | 90 |
| 92 namespace DOMAgentState { | 91 namespace DOMAgentState { |
| 93 static const char kDomAgentEnabled[] = "domAgentEnabled"; | 92 static const char kDomAgentEnabled[] = "domAgentEnabled"; |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 namespace { | 95 namespace { |
| 97 | 96 |
| 98 const size_t kMaxTextSize = 10000; | 97 const size_t kMaxTextSize = 10000; |
| 99 const UChar kEllipsisUChar[] = {0x2026, 0}; | 98 const UChar kEllipsisUChar[] = {0x2026, 0}; |
| 100 | 99 |
| 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 |
| 101 } // namespace | 132 } // namespace |
| 102 | 133 |
| 103 class InspectorRevalidateDOMTask final | 134 class InspectorRevalidateDOMTask final |
| 104 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> { | 135 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> { |
| 105 public: | 136 public: |
| 106 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); | 137 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); |
| 107 void ScheduleStyleAttrRevalidationFor(Element*); | 138 void ScheduleStyleAttrRevalidationFor(Element*); |
| 108 void Reset() { timer_.Stop(); } | 139 void Reset() { timer_.Stop(); } |
| 109 void OnTimer(TimerBase*); | 140 void OnTimer(TimerBase*); |
| 110 DECLARE_TRACE(); | 141 DECLARE_TRACE(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 *type = protocol::DOM::PseudoTypeEnum::Resizer; | 227 *type = protocol::DOM::PseudoTypeEnum::Resizer; |
| 197 return true; | 228 return true; |
| 198 case kPseudoIdInputListButton: | 229 case kPseudoIdInputListButton: |
| 199 *type = protocol::DOM::PseudoTypeEnum::InputListButton; | 230 *type = protocol::DOM::PseudoTypeEnum::InputListButton; |
| 200 return true; | 231 return true; |
| 201 default: | 232 default: |
| 202 return false; | 233 return false; |
| 203 } | 234 } |
| 204 } | 235 } |
| 205 | 236 |
| 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 | |
| 227 InspectorDOMAgent::InspectorDOMAgent( | 237 InspectorDOMAgent::InspectorDOMAgent( |
| 228 v8::Isolate* isolate, | 238 v8::Isolate* isolate, |
| 229 InspectedFrames* inspected_frames, | 239 InspectedFrames* inspected_frames, |
| 230 v8_inspector::V8InspectorSession* v8_session) | 240 v8_inspector::V8InspectorSession* v8_session, |
| 241 Client* client) |
| 231 : isolate_(isolate), | 242 : isolate_(isolate), |
| 232 inspected_frames_(inspected_frames), | 243 inspected_frames_(inspected_frames), |
| 233 v8_session_(v8_session), | 244 v8_session_(v8_session), |
| 245 client_(client), |
| 234 dom_listener_(nullptr), | 246 dom_listener_(nullptr), |
| 235 document_node_to_id_map_(new NodeToIdMap()), | 247 document_node_to_id_map_(new NodeToIdMap()), |
| 236 last_node_id_(1), | 248 last_node_id_(1), |
| 237 suppress_attribute_modified_event_(false) {} | 249 suppress_attribute_modified_event_(false), |
| 250 backend_node_id_to_inspect_(0) {} |
| 238 | 251 |
| 239 InspectorDOMAgent::~InspectorDOMAgent() {} | 252 InspectorDOMAgent::~InspectorDOMAgent() {} |
| 240 | 253 |
| 241 void InspectorDOMAgent::Restore() { | 254 void InspectorDOMAgent::Restore() { |
| 242 if (!Enabled()) | 255 if (!Enabled()) |
| 243 return; | 256 return; |
| 244 InnerEnable(); | 257 InnerEnable(); |
| 245 } | 258 } |
| 246 | 259 |
| 247 HeapVector<Member<Document>> InspectorDOMAgent::Documents() { | 260 HeapVector<Member<Document>> InspectorDOMAgent::Documents() { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 431 |
| 419 return Response::OK(); | 432 return Response::OK(); |
| 420 } | 433 } |
| 421 | 434 |
| 422 void InspectorDOMAgent::InnerEnable() { | 435 void InspectorDOMAgent::InnerEnable() { |
| 423 state_->setBoolean(DOMAgentState::kDomAgentEnabled, true); | 436 state_->setBoolean(DOMAgentState::kDomAgentEnabled, true); |
| 424 history_ = new InspectorHistory(); | 437 history_ = new InspectorHistory(); |
| 425 dom_editor_ = new DOMEditor(history_.Get()); | 438 dom_editor_ = new DOMEditor(history_.Get()); |
| 426 document_ = inspected_frames_->Root()->GetDocument(); | 439 document_ = inspected_frames_->Root()->GetDocument(); |
| 427 instrumenting_agents_->addInspectorDOMAgent(this); | 440 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; |
| 428 } | 444 } |
| 429 | 445 |
| 430 Response InspectorDOMAgent::enable() { | 446 Response InspectorDOMAgent::enable() { |
| 431 if (!Enabled()) | 447 if (!Enabled()) |
| 432 InnerEnable(); | 448 InnerEnable(); |
| 433 return Response::OK(); | 449 return Response::OK(); |
| 434 } | 450 } |
| 435 | 451 |
| 436 bool InspectorDOMAgent::Enabled() const { | 452 bool InspectorDOMAgent::Enabled() const { |
| 437 return state_->booleanProperty(DOMAgentState::kDomAgentEnabled, false); | 453 return state_->booleanProperty(DOMAgentState::kDomAgentEnabled, false); |
| 438 } | 454 } |
| 439 | 455 |
| 440 Response InspectorDOMAgent::disable() { | 456 Response InspectorDOMAgent::disable() { |
| 441 if (!Enabled()) | 457 if (!Enabled()) |
| 442 return Response::Error("DOM agent hasn't been enabled"); | 458 return Response::Error("DOM agent hasn't been enabled"); |
| 443 state_->setBoolean(DOMAgentState::kDomAgentEnabled, false); | 459 state_->setBoolean(DOMAgentState::kDomAgentEnabled, false); |
| 460 SetSearchingForNode(kNotSearching, Maybe<protocol::DOM::HighlightConfig>()); |
| 444 instrumenting_agents_->removeInspectorDOMAgent(this); | 461 instrumenting_agents_->removeInspectorDOMAgent(this); |
| 445 history_.Clear(); | 462 history_.Clear(); |
| 446 dom_editor_.Clear(); | 463 dom_editor_.Clear(); |
| 447 SetDocument(nullptr); | 464 SetDocument(nullptr); |
| 448 return Response::OK(); | 465 return Response::OK(); |
| 449 } | 466 } |
| 450 | 467 |
| 451 Response InspectorDOMAgent::getDocument( | 468 Response InspectorDOMAgent::getDocument( |
| 452 Maybe<int> depth, | 469 Maybe<int> depth, |
| 453 Maybe<bool> pierce, | 470 Maybe<bool> pierce, |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 for (int i = from_index; i < to_index; ++i) | 1117 for (int i = from_index; i < to_index; ++i) |
| 1101 (*node_ids)->addItem(PushNodePathToFrontend((it->value)[i].Get())); | 1118 (*node_ids)->addItem(PushNodePathToFrontend((it->value)[i].Get())); |
| 1102 return Response::OK(); | 1119 return Response::OK(); |
| 1103 } | 1120 } |
| 1104 | 1121 |
| 1105 Response InspectorDOMAgent::discardSearchResults(const String& search_id) { | 1122 Response InspectorDOMAgent::discardSearchResults(const String& search_id) { |
| 1106 search_results_.erase(search_id); | 1123 search_results_.erase(search_id); |
| 1107 return Response::OK(); | 1124 return Response::OK(); |
| 1108 } | 1125 } |
| 1109 | 1126 |
| 1110 Response InspectorDOMAgent::NodeForRemoteObjectId(const String& object_id, | 1127 void InspectorDOMAgent::Inspect(Node* inspected_node) { |
| 1111 Node*& node) { | 1128 if (!inspected_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) { |
| 1112 v8::HandleScope handles(isolate_); | 1276 v8::HandleScope handles(isolate_); |
| 1113 v8::Local<v8::Value> value; | 1277 v8::Local<v8::Value> value; |
| 1114 v8::Local<v8::Context> context; | 1278 v8::Local<v8::Context> context; |
| 1115 std::unique_ptr<v8_inspector::StringBuffer> error; | 1279 std::unique_ptr<v8_inspector::StringBuffer> error; |
| 1116 if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), | 1280 if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), |
| 1117 &value, &context, nullptr)) | 1281 &value, &context, nullptr)) |
| 1118 return Response::Error(ToCoreString(std::move(error))); | 1282 return Response::Error(ToCoreString(std::move(error))); |
| 1119 if (!V8Node::hasInstance(value, isolate_)) | 1283 if (!V8Node::hasInstance(value, isolate_)) |
| 1120 return Response::Error("Object id doesn't reference a Node"); | 1284 return Response::Error("Object id doesn't reference a Node"); |
| 1121 node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value)); | 1285 node = V8Node::toImpl(v8::Local<v8::Object>::Cast(value)); |
| 1122 if (!node) { | 1286 if (!node) { |
| 1123 return Response::Error( | 1287 return Response::Error( |
| 1124 "Couldn't convert object with given objectId to Node"); | 1288 "Couldn't convert object with given objectId to Node"); |
| 1125 } | 1289 } |
| 1126 return Response::OK(); | 1290 return Response::OK(); |
| 1127 } | 1291 } |
| 1128 | 1292 |
| 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 |
| 1129 Response InspectorDOMAgent::copyTo(int node_id, | 1353 Response InspectorDOMAgent::copyTo(int node_id, |
| 1130 int target_element_id, | 1354 int target_element_id, |
| 1131 Maybe<int> anchor_node_id, | 1355 Maybe<int> anchor_node_id, |
| 1132 int* new_node_id) { | 1356 int* new_node_id) { |
| 1133 Node* node = nullptr; | 1357 Node* node = nullptr; |
| 1134 Response response = AssertEditableNode(node_id, node); | 1358 Response response = AssertEditableNode(node_id, node); |
| 1135 if (!response.isSuccess()) | 1359 if (!response.isSuccess()) |
| 1136 return response; | 1360 return response; |
| 1137 | 1361 |
| 1138 Element* target_element = nullptr; | 1362 Element* target_element = nullptr; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 Response response = AssertElement(node_id, element); | 1533 Response response = AssertElement(node_id, element); |
| 1310 if (!response.isSuccess()) | 1534 if (!response.isSuccess()) |
| 1311 return response; | 1535 return response; |
| 1312 | 1536 |
| 1313 *result = BuildArrayForElementAttributes(element); | 1537 *result = BuildArrayForElementAttributes(element); |
| 1314 return Response::OK(); | 1538 return Response::OK(); |
| 1315 } | 1539 } |
| 1316 | 1540 |
| 1317 Response InspectorDOMAgent::requestNode(const String& object_id, int* node_id) { | 1541 Response InspectorDOMAgent::requestNode(const String& object_id, int* node_id) { |
| 1318 Node* node = nullptr; | 1542 Node* node = nullptr; |
| 1319 Response response = NodeForRemoteObjectId(object_id, node); | 1543 Response response = NodeForRemoteId(object_id, node); |
| 1320 if (!response.isSuccess()) | 1544 if (!response.isSuccess()) |
| 1321 return response; | 1545 return response; |
| 1322 *node_id = PushNodePathToFrontend(node); | 1546 *node_id = PushNodePathToFrontend(node); |
| 1323 return Response::OK(); | 1547 return Response::OK(); |
| 1324 } | 1548 } |
| 1325 | 1549 |
| 1326 // static | 1550 // static |
| 1327 String InspectorDOMAgent::DocumentURLString(Document* document) { | 1551 String InspectorDOMAgent::DocumentURLString(Document* document) { |
| 1328 if (!document || document->Url().IsNull()) | 1552 if (!document || document->Url().IsNull()) |
| 1329 return ""; | 1553 return ""; |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 } | 2347 } |
| 2124 while (layout_object && !layout_object->IsDocumentElement() && | 2348 while (layout_object && !layout_object->IsDocumentElement() && |
| 2125 !layout_object->IsRelayoutBoundaryForInspector()) | 2349 !layout_object->IsRelayoutBoundaryForInspector()) |
| 2126 layout_object = layout_object->Container(); | 2350 layout_object = layout_object->Container(); |
| 2127 Node* result_node = | 2351 Node* result_node = |
| 2128 layout_object ? layout_object->GeneratingNode() : node->ownerDocument(); | 2352 layout_object ? layout_object->GeneratingNode() : node->ownerDocument(); |
| 2129 *relayout_boundary_node_id = PushNodePathToFrontend(result_node); | 2353 *relayout_boundary_node_id = PushNodePathToFrontend(result_node); |
| 2130 return Response::OK(); | 2354 return Response::OK(); |
| 2131 } | 2355 } |
| 2132 | 2356 |
| 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 |
| 2133 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> | 2369 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> |
| 2134 InspectorDOMAgent::ResolveNode(Node* node, const String& object_group) { | 2370 InspectorDOMAgent::ResolveNode(Node* node, const String& object_group) { |
| 2135 Document* document = | 2371 Document* document = |
| 2136 node->IsDocumentNode() ? &node->GetDocument() : node->ownerDocument(); | 2372 node->IsDocumentNode() ? &node->GetDocument() : node->ownerDocument(); |
| 2137 LocalFrame* frame = document ? document->GetFrame() : nullptr; | 2373 LocalFrame* frame = document ? document->GetFrame() : nullptr; |
| 2138 if (!frame) | 2374 if (!frame) |
| 2139 return nullptr; | 2375 return nullptr; |
| 2140 | 2376 |
| 2141 ScriptState* script_state = ToScriptStateForMainWorld(frame); | 2377 ScriptState* script_state = ToScriptStateForMainWorld(frame); |
| 2142 if (!script_state) | 2378 if (!script_state) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2165 visitor->Trace(id_to_nodes_map_); | 2401 visitor->Trace(id_to_nodes_map_); |
| 2166 visitor->Trace(document_); | 2402 visitor->Trace(document_); |
| 2167 visitor->Trace(revalidate_task_); | 2403 visitor->Trace(revalidate_task_); |
| 2168 visitor->Trace(search_results_); | 2404 visitor->Trace(search_results_); |
| 2169 visitor->Trace(history_); | 2405 visitor->Trace(history_); |
| 2170 visitor->Trace(dom_editor_); | 2406 visitor->Trace(dom_editor_); |
| 2171 InspectorBaseAgent::Trace(visitor); | 2407 InspectorBaseAgent::Trace(visitor); |
| 2172 } | 2408 } |
| 2173 | 2409 |
| 2174 } // namespace blink | 2410 } // namespace blink |
| OLD | NEW |