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 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef InspectorDOMAgent_h | 30 #ifndef InspectorDOMAgent_h |
31 #define InspectorDOMAgent_h | 31 #define InspectorDOMAgent_h |
32 | 32 |
33 #include <memory> | 33 #include <memory> |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/events/EventListenerMap.h" | 35 #include "core/events/EventListenerMap.h" |
36 #include "core/inspector/InspectorBaseAgent.h" | 36 #include "core/inspector/InspectorBaseAgent.h" |
37 #include "core/inspector/InspectorHighlight.h" | |
38 #include "core/inspector/protocol/DOM.h" | 37 #include "core/inspector/protocol/DOM.h" |
39 #include "core/style/ComputedStyleConstants.h" | 38 #include "core/style/ComputedStyleConstants.h" |
40 #include "platform/geometry/FloatQuad.h" | 39 #include "platform/geometry/FloatQuad.h" |
41 #include "platform/wtf/HashMap.h" | 40 #include "platform/wtf/HashMap.h" |
42 #include "platform/wtf/HashSet.h" | 41 #include "platform/wtf/HashSet.h" |
43 #include "platform/wtf/RefPtr.h" | 42 #include "platform/wtf/RefPtr.h" |
44 #include "platform/wtf/Vector.h" | 43 #include "platform/wtf/Vector.h" |
45 #include "platform/wtf/text/AtomicString.h" | 44 #include "platform/wtf/text/AtomicString.h" |
46 #include "v8/include/v8-inspector.h" | 45 #include "v8/include/v8-inspector.h" |
47 | 46 |
48 namespace blink { | 47 namespace blink { |
49 | 48 |
50 class CharacterData; | 49 class CharacterData; |
50 class Color; | |
51 class DOMEditor; | 51 class DOMEditor; |
52 class Document; | 52 class Document; |
53 class DocumentLoader; | 53 class DocumentLoader; |
54 class Element; | 54 class Element; |
55 class ExceptionState; | 55 class ExceptionState; |
56 class FloatQuad; | 56 class FloatQuad; |
57 class HTMLSlotElement; | 57 class HTMLSlotElement; |
58 class InsertionPoint; | 58 class InsertionPoint; |
59 class InspectedFrames; | 59 class InspectedFrames; |
60 class InspectorHistory; | 60 class InspectorHistory; |
61 class Node; | 61 class Node; |
62 class QualifiedName; | 62 class QualifiedName; |
63 class PseudoElement; | 63 class PseudoElement; |
64 class InspectorRevalidateDOMTask; | 64 class InspectorRevalidateDOMTask; |
65 class ShadowRoot; | 65 class ShadowRoot; |
66 | 66 |
67 class CORE_EXPORT InspectorDOMAgent final | 67 class CORE_EXPORT InspectorDOMAgent final |
68 : public InspectorBaseAgent<protocol::DOM::Metainfo> { | 68 : public InspectorBaseAgent<protocol::DOM::Metainfo> { |
69 WTF_MAKE_NONCOPYABLE(InspectorDOMAgent); | 69 WTF_MAKE_NONCOPYABLE(InspectorDOMAgent); |
70 | 70 |
71 public: | 71 public: |
72 struct CORE_EXPORT DOMListener : public GarbageCollectedMixin { | 72 struct CORE_EXPORT DOMListener : public GarbageCollectedMixin { |
73 virtual ~DOMListener() {} | 73 virtual ~DOMListener() {} |
74 virtual void DidAddDocument(Document*) = 0; | 74 virtual void DidAddDocument(Document*) = 0; |
75 virtual void DidRemoveDocument(Document*) = 0; | 75 virtual void DidRemoveDocument(Document*) = 0; |
76 virtual void DidRemoveDOMNode(Node*) = 0; | 76 virtual void DidRemoveDOMNode(Node*) = 0; |
77 virtual void DidModifyDOMAttr(Element*) = 0; | 77 virtual void DidModifyDOMAttr(Element*) = 0; |
78 }; | 78 }; |
79 | 79 |
80 enum SearchMode { | |
81 kNotSearching, | |
82 kSearchingForNormal, | |
83 kSearchingForUAShadow, | |
84 }; | |
85 | |
86 class Client { | |
87 public: | |
88 virtual ~Client() {} | |
89 virtual void HideHighlight() {} | |
90 virtual void HighlightNode(Node*, | |
91 const InspectorHighlightConfig&, | |
92 bool omit_tooltip) {} | |
93 virtual void HighlightQuad(std::unique_ptr<FloatQuad>, | |
94 const InspectorHighlightConfig&) {} | |
95 virtual void SetInspectMode(SearchMode search_mode, | |
96 std::unique_ptr<InspectorHighlightConfig>) {} | |
97 }; | |
98 | |
99 static protocol::Response ToResponse(ExceptionState&); | 80 static protocol::Response ToResponse(ExceptionState&); |
100 static bool GetPseudoElementType(PseudoId, String*); | 81 static bool GetPseudoElementType(PseudoId, String*); |
101 static ShadowRoot* UserAgentShadowRoot(Node*); | 82 static ShadowRoot* UserAgentShadowRoot(Node*); |
83 static Color ParseColor(protocol::DOM::RGBA*); | |
102 | 84 |
103 InspectorDOMAgent(v8::Isolate*, | 85 InspectorDOMAgent(v8::Isolate*, |
104 InspectedFrames*, | 86 InspectedFrames*, |
105 v8_inspector::V8InspectorSession*, | 87 v8_inspector::V8InspectorSession*); |
106 Client*); | |
107 ~InspectorDOMAgent() override; | 88 ~InspectorDOMAgent() override; |
108 DECLARE_VIRTUAL_TRACE(); | 89 DECLARE_VIRTUAL_TRACE(); |
109 | 90 |
110 void Restore() override; | 91 void Restore() override; |
111 | 92 |
112 HeapVector<Member<Document>> Documents(); | 93 HeapVector<Member<Document>> Documents(); |
113 void Reset(); | 94 void Reset(); |
114 | 95 |
115 // Methods called from the frontend for DOM nodes inspection. | 96 // Methods called from the frontend for DOM nodes inspection. |
116 protocol::Response enable() override; | 97 protocol::Response enable() override; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 String* search_id, | 139 String* search_id, |
159 int* result_count) override; | 140 int* result_count) override; |
160 protocol::Response getSearchResults( | 141 protocol::Response getSearchResults( |
161 const String& search_id, | 142 const String& search_id, |
162 int from_index, | 143 int from_index, |
163 int to_index, | 144 int to_index, |
164 std::unique_ptr<protocol::Array<int>>* node_ids) override; | 145 std::unique_ptr<protocol::Array<int>>* node_ids) override; |
165 protocol::Response discardSearchResults(const String& search_id) override; | 146 protocol::Response discardSearchResults(const String& search_id) override; |
166 protocol::Response requestNode(const String& object_id, | 147 protocol::Response requestNode(const String& object_id, |
167 int* out_node_id) override; | 148 int* out_node_id) override; |
168 protocol::Response setInspectMode( | |
169 const String& mode, | |
170 protocol::Maybe<protocol::DOM::HighlightConfig>) override; | |
171 protocol::Response highlightRect( | |
172 int x, | |
173 int y, | |
174 int width, | |
175 int height, | |
176 protocol::Maybe<protocol::DOM::RGBA> color, | |
177 protocol::Maybe<protocol::DOM::RGBA> outline_color) override; | |
178 protocol::Response highlightQuad( | |
179 std::unique_ptr<protocol::Array<double>> quad, | |
180 protocol::Maybe<protocol::DOM::RGBA> color, | |
181 protocol::Maybe<protocol::DOM::RGBA> outline_color) override; | |
182 protocol::Response highlightNode( | |
183 std::unique_ptr<protocol::DOM::HighlightConfig>, | |
184 protocol::Maybe<int> node_id, | |
185 protocol::Maybe<int> backend_node_id, | |
186 protocol::Maybe<String> object_id) override; | |
187 protocol::Response hideHighlight() override; | |
188 protocol::Response highlightFrame( | |
189 const String& frame_id, | |
190 protocol::Maybe<protocol::DOM::RGBA> content_color, | |
191 protocol::Maybe<protocol::DOM::RGBA> content_outline_color) override; | |
192 protocol::Response pushNodeByPathToFrontend(const String& path, | 149 protocol::Response pushNodeByPathToFrontend(const String& path, |
193 int* out_node_id) override; | 150 int* out_node_id) override; |
194 protocol::Response pushNodesByBackendIdsToFrontend( | 151 protocol::Response pushNodesByBackendIdsToFrontend( |
195 std::unique_ptr<protocol::Array<int>> backend_node_ids, | 152 std::unique_ptr<protocol::Array<int>> backend_node_ids, |
196 std::unique_ptr<protocol::Array<int>>* node_ids) override; | 153 std::unique_ptr<protocol::Array<int>>* node_ids) override; |
197 protocol::Response setInspectedNode(int node_id) override; | 154 protocol::Response setInspectedNode(int node_id) override; |
198 protocol::Response resolveNode( | 155 protocol::Response resolveNode( |
199 int node_id, | 156 int node_id, |
200 protocol::Maybe<String> object_group, | 157 protocol::Maybe<String> object_group, |
201 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject>*) | 158 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject>*) |
(...skipping 19 matching lines...) Expand all Loading... | |
221 protocol::Response getBoxModel( | 178 protocol::Response getBoxModel( |
222 int node_id, | 179 int node_id, |
223 std::unique_ptr<protocol::DOM::BoxModel>*) override; | 180 std::unique_ptr<protocol::DOM::BoxModel>*) override; |
224 protocol::Response getNodeForLocation( | 181 protocol::Response getNodeForLocation( |
225 int x, | 182 int x, |
226 int y, | 183 int y, |
227 protocol::Maybe<bool> include_user_agent_shadow_dom, | 184 protocol::Maybe<bool> include_user_agent_shadow_dom, |
228 int* out_node_id) override; | 185 int* out_node_id) override; |
229 protocol::Response getRelayoutBoundary(int node_id, | 186 protocol::Response getRelayoutBoundary(int node_id, |
230 int* out_node_id) override; | 187 int* out_node_id) override; |
231 protocol::Response getHighlightObjectForTest( | |
232 int node_id, | |
233 std::unique_ptr<protocol::DictionaryValue>* highlight) override; | |
234 | 188 |
235 bool Enabled() const; | 189 bool Enabled() const; |
236 void ReleaseDanglingNodes(); | 190 void ReleaseDanglingNodes(); |
237 | 191 |
238 // Methods called from the InspectorInstrumentation. | 192 // Methods called from the InspectorInstrumentation. |
239 void DomContentLoadedEventFired(LocalFrame*); | 193 void DomContentLoadedEventFired(LocalFrame*); |
240 void DidCommitLoad(LocalFrame*, DocumentLoader*); | 194 void DidCommitLoad(LocalFrame*, DocumentLoader*); |
241 void DidInsertDOMNode(Node*); | 195 void DidInsertDOMNode(Node*); |
242 void WillRemoveDOMNode(Node*); | 196 void WillRemoveDOMNode(Node*); |
243 void WillModifyDOMAttr(Element*, | 197 void WillModifyDOMAttr(Element*, |
(...skipping 10 matching lines...) Expand all Loading... | |
254 void WillPopShadowRoot(Element* host, ShadowRoot*); | 208 void WillPopShadowRoot(Element* host, ShadowRoot*); |
255 void DidPerformElementShadowDistribution(Element*); | 209 void DidPerformElementShadowDistribution(Element*); |
256 void DidPerformSlotDistribution(HTMLSlotElement*); | 210 void DidPerformSlotDistribution(HTMLSlotElement*); |
257 void FrameDocumentUpdated(LocalFrame*); | 211 void FrameDocumentUpdated(LocalFrame*); |
258 void PseudoElementCreated(PseudoElement*); | 212 void PseudoElementCreated(PseudoElement*); |
259 void PseudoElementDestroyed(PseudoElement*); | 213 void PseudoElementDestroyed(PseudoElement*); |
260 | 214 |
261 Node* NodeForId(int node_id); | 215 Node* NodeForId(int node_id); |
262 int BoundNodeId(Node*); | 216 int BoundNodeId(Node*); |
263 void SetDOMListener(DOMListener*); | 217 void SetDOMListener(DOMListener*); |
264 void Inspect(Node*); | |
265 void NodeHighlightedInOverlay(Node*); | |
266 int PushNodePathToFrontend(Node*); | 218 int PushNodePathToFrontend(Node*); |
219 protocol::Response PushDocumentUponHandlelessOperation(); | |
220 protocol::Response NodeForRemoteId(const String& id, Node*&); | |
pfeldman
2017/04/18 00:25:08
NodeForRemoteObjectId
dgozman
2017/04/18 20:39:32
Done.
| |
267 | 221 |
268 static String DocumentURLString(Document*); | 222 static String DocumentURLString(Document*); |
269 | 223 |
270 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> | 224 std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject> |
271 ResolveNode(Node*, const String& object_group); | 225 ResolveNode(Node*, const String& object_group); |
272 | 226 |
273 InspectorHistory* History() { return history_.Get(); } | 227 InspectorHistory* History() { return history_.Get(); } |
274 | 228 |
275 // We represent embedded doms as a part of the same hierarchy. Hence we treat | 229 // We represent embedded doms as a part of the same hierarchy. Hence we treat |
276 // children of frame owners differently. We also skip whitespace text nodes | 230 // children of frame owners differently. We also skip whitespace text nodes |
(...skipping 12 matching lines...) Expand all Loading... | |
289 HeapVector<Member<Node>>* result); | 243 HeapVector<Member<Node>>* result); |
290 | 244 |
291 protocol::Response AssertNode(int node_id, Node*&); | 245 protocol::Response AssertNode(int node_id, Node*&); |
292 protocol::Response AssertElement(int node_id, Element*&); | 246 protocol::Response AssertElement(int node_id, Element*&); |
293 Document* GetDocument() const { return document_.Get(); } | 247 Document* GetDocument() const { return document_.Get(); } |
294 | 248 |
295 private: | 249 private: |
296 void SetDocument(Document*); | 250 void SetDocument(Document*); |
297 void InnerEnable(); | 251 void InnerEnable(); |
298 | 252 |
299 protocol::Response SetSearchingForNode( | |
300 SearchMode, | |
301 protocol::Maybe<protocol::DOM::HighlightConfig>); | |
302 protocol::Response HighlightConfigFromInspectorObject( | |
303 protocol::Maybe<protocol::DOM::HighlightConfig> | |
304 highlight_inspector_object, | |
305 std::unique_ptr<InspectorHighlightConfig>*); | |
306 | |
307 // Node-related methods. | 253 // Node-related methods. |
308 typedef HeapHashMap<Member<Node>, int> NodeToIdMap; | 254 typedef HeapHashMap<Member<Node>, int> NodeToIdMap; |
309 int Bind(Node*, NodeToIdMap*); | 255 int Bind(Node*, NodeToIdMap*); |
310 void Unbind(Node*, NodeToIdMap*); | 256 void Unbind(Node*, NodeToIdMap*); |
311 | 257 |
312 protocol::Response AssertEditableNode(int node_id, Node*&); | 258 protocol::Response AssertEditableNode(int node_id, Node*&); |
313 protocol::Response AssertEditableChildNode(Element* parent_element, | 259 protocol::Response AssertEditableChildNode(Element* parent_element, |
314 int node_id, | 260 int node_id, |
315 Node*&); | 261 Node*&); |
316 protocol::Response AssertEditableElement(int node_id, Element*&); | 262 protocol::Response AssertEditableElement(int node_id, Element*&); |
(...skipping 21 matching lines...) Expand all Loading... | |
338 NodeToIdMap* nodes_map, | 284 NodeToIdMap* nodes_map, |
339 protocol::Array<protocol::DOM::Node>* flatten_result); | 285 protocol::Array<protocol::DOM::Node>* flatten_result); |
340 std::unique_ptr<protocol::Array<protocol::DOM::Node>> | 286 std::unique_ptr<protocol::Array<protocol::DOM::Node>> |
341 BuildArrayForPseudoElements(Element*, NodeToIdMap* nodes_map); | 287 BuildArrayForPseudoElements(Element*, NodeToIdMap* nodes_map); |
342 std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> | 288 std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> |
343 BuildArrayForDistributedNodes(InsertionPoint*); | 289 BuildArrayForDistributedNodes(InsertionPoint*); |
344 std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> | 290 std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> |
345 BuildDistributedNodesForSlot(HTMLSlotElement*); | 291 BuildDistributedNodesForSlot(HTMLSlotElement*); |
346 | 292 |
347 Node* NodeForPath(const String& path); | 293 Node* NodeForPath(const String& path); |
348 protocol::Response NodeForRemoteId(const String& id, Node*&); | |
349 | 294 |
350 void DiscardFrontendBindings(); | 295 void DiscardFrontendBindings(); |
351 | 296 |
352 void InnerHighlightQuad(std::unique_ptr<FloatQuad>, | |
353 protocol::Maybe<protocol::DOM::RGBA> color, | |
354 protocol::Maybe<protocol::DOM::RGBA> outline_color); | |
355 | |
356 protocol::Response PushDocumentUponHandlelessOperation(); | |
357 | |
358 InspectorRevalidateDOMTask* RevalidateTask(); | 297 InspectorRevalidateDOMTask* RevalidateTask(); |
359 | 298 |
360 v8::Isolate* isolate_; | 299 v8::Isolate* isolate_; |
361 Member<InspectedFrames> inspected_frames_; | 300 Member<InspectedFrames> inspected_frames_; |
362 v8_inspector::V8InspectorSession* v8_session_; | 301 v8_inspector::V8InspectorSession* v8_session_; |
363 Client* client_; | |
364 Member<DOMListener> dom_listener_; | 302 Member<DOMListener> dom_listener_; |
365 Member<NodeToIdMap> document_node_to_id_map_; | 303 Member<NodeToIdMap> document_node_to_id_map_; |
366 // Owns node mappings for dangling nodes. | 304 // Owns node mappings for dangling nodes. |
367 HeapVector<Member<NodeToIdMap>> dangling_node_to_id_maps_; | 305 HeapVector<Member<NodeToIdMap>> dangling_node_to_id_maps_; |
368 HeapHashMap<int, Member<Node>> id_to_node_; | 306 HeapHashMap<int, Member<Node>> id_to_node_; |
369 HeapHashMap<int, Member<NodeToIdMap>> id_to_nodes_map_; | 307 HeapHashMap<int, Member<NodeToIdMap>> id_to_nodes_map_; |
370 HashSet<int> children_requested_; | 308 HashSet<int> children_requested_; |
371 HashSet<int> distributed_nodes_requested_; | 309 HashSet<int> distributed_nodes_requested_; |
372 HashMap<int, int> cached_child_count_; | 310 HashMap<int, int> cached_child_count_; |
373 int last_node_id_; | 311 int last_node_id_; |
374 Member<Document> document_; | 312 Member<Document> document_; |
375 typedef HeapHashMap<String, HeapVector<Member<Node>>> SearchResults; | 313 typedef HeapHashMap<String, HeapVector<Member<Node>>> SearchResults; |
376 SearchResults search_results_; | 314 SearchResults search_results_; |
377 Member<InspectorRevalidateDOMTask> revalidate_task_; | 315 Member<InspectorRevalidateDOMTask> revalidate_task_; |
378 Member<InspectorHistory> history_; | 316 Member<InspectorHistory> history_; |
379 Member<DOMEditor> dom_editor_; | 317 Member<DOMEditor> dom_editor_; |
380 bool suppress_attribute_modified_event_; | 318 bool suppress_attribute_modified_event_; |
381 int backend_node_id_to_inspect_; | |
382 }; | 319 }; |
383 | 320 |
384 } // namespace blink | 321 } // namespace blink |
385 | 322 |
386 #endif // !defined(InspectorDOMAgent_h) | 323 #endif // !defined(InspectorDOMAgent_h) |
OLD | NEW |