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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #ifndef InspectorDOMAgent_h | 30 #ifndef InspectorDOMAgent_h |
31 #define InspectorDOMAgent_h | 31 #define InspectorDOMAgent_h |
32 | 32 |
33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
34 #include "core/InspectorFrontend.h" | 34 #include "core/InspectorFrontend.h" |
35 #include "core/events/EventListenerMap.h" | 35 #include "core/events/EventListenerMap.h" |
36 #include "core/inspector/InjectedScript.h" | 36 #include "core/inspector/InjectedScript.h" |
37 #include "core/inspector/InjectedScriptManager.h" | 37 #include "core/inspector/InjectedScriptManager.h" |
38 #include "core/inspector/InspectorBaseAgent.h" | 38 #include "core/inspector/InspectorBaseAgent.h" |
| 39 #include "core/inspector/InspectorHighlight.h" |
39 #include "core/style/ComputedStyleConstants.h" | 40 #include "core/style/ComputedStyleConstants.h" |
40 #include "platform/JSONValues.h" | 41 #include "platform/JSONValues.h" |
41 #include "platform/geometry/FloatQuad.h" | 42 #include "platform/geometry/FloatQuad.h" |
42 | 43 |
43 #include "wtf/HashMap.h" | 44 #include "wtf/HashMap.h" |
44 #include "wtf/HashSet.h" | 45 #include "wtf/HashSet.h" |
45 #include "wtf/OwnPtr.h" | 46 #include "wtf/OwnPtr.h" |
46 #include "wtf/PassOwnPtr.h" | 47 #include "wtf/PassOwnPtr.h" |
47 #include "wtf/RefPtr.h" | 48 #include "wtf/RefPtr.h" |
48 #include "wtf/Vector.h" | 49 #include "wtf/Vector.h" |
(...skipping 15 matching lines...) Expand all Loading... |
64 class InspectorPageAgent; | 65 class InspectorPageAgent; |
65 class Node; | 66 class Node; |
66 class QualifiedName; | 67 class QualifiedName; |
67 class PseudoElement; | 68 class PseudoElement; |
68 class PlatformGestureEvent; | 69 class PlatformGestureEvent; |
69 class PlatformMouseEvent; | 70 class PlatformMouseEvent; |
70 class PlatformTouchEvent; | 71 class PlatformTouchEvent; |
71 class InspectorRevalidateDOMTask; | 72 class InspectorRevalidateDOMTask; |
72 class ShadowRoot; | 73 class ShadowRoot; |
73 | 74 |
74 struct InspectorHighlightConfig; | |
75 | |
76 typedef String ErrorString; | 75 typedef String ErrorString; |
77 | 76 |
78 class CORE_EXPORT InspectorDOMAgent final : public InspectorBaseAgent<InspectorD
OMAgent, InspectorFrontend::DOM>, public InspectorBackendDispatcher::DOMCommandH
andler { | 77 class CORE_EXPORT InspectorDOMAgent final : public InspectorBaseAgent<InspectorD
OMAgent, InspectorFrontend::DOM>, public InspectorBackendDispatcher::DOMCommandH
andler { |
79 WTF_MAKE_NONCOPYABLE(InspectorDOMAgent); | 78 WTF_MAKE_NONCOPYABLE(InspectorDOMAgent); |
80 public: | 79 public: |
81 struct CORE_EXPORT DOMListener : public WillBeGarbageCollectedMixin { | 80 struct CORE_EXPORT DOMListener : public WillBeGarbageCollectedMixin { |
82 virtual ~DOMListener() | 81 virtual ~DOMListener() |
83 { | 82 { |
84 } | 83 } |
85 virtual void didRemoveDocument(Document*) = 0; | 84 virtual void didRemoveDocument(Document*) = 0; |
86 virtual void didRemoveDOMNode(Node*) = 0; | 85 virtual void didRemoveDOMNode(Node*) = 0; |
87 virtual void didModifyDOMAttr(Element*) = 0; | 86 virtual void didModifyDOMAttr(Element*) = 0; |
88 }; | 87 }; |
89 | 88 |
| 89 enum SearchMode { NotSearching, SearchingForNormal, SearchingForUAShadow }; |
| 90 |
90 class Client { | 91 class Client { |
91 public: | 92 public: |
92 virtual ~Client() { } | 93 virtual ~Client() { } |
93 virtual void setInspectModeEnabled(bool) { } | |
94 virtual void hideHighlight() { } | 94 virtual void hideHighlight() { } |
95 virtual void highlightNode(Node*, Node* eventTarget, const InspectorHigh
lightConfig&, bool omitTooltip) { } | 95 virtual void highlightNode(Node*, const InspectorHighlightConfig&, bool
omitTooltip) { } |
96 virtual void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlig
htConfig&) { } | 96 virtual void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlig
htConfig&) { } |
| 97 virtual void setInspectMode(SearchMode searchMode, PassOwnPtr<InspectorH
ighlightConfig>) { } |
97 }; | 98 }; |
98 | 99 |
99 static PassOwnPtrWillBeRawPtr<InspectorDOMAgent> create(InspectorPageAgent*
pageAgent, InjectedScriptManager* injectedScriptManager, Client* client) | 100 static PassOwnPtrWillBeRawPtr<InspectorDOMAgent> create(InspectorPageAgent*
pageAgent, InjectedScriptManager* injectedScriptManager, Client* client) |
100 { | 101 { |
101 return adoptPtrWillBeNoop(new InspectorDOMAgent(pageAgent, injectedScrip
tManager, client)); | 102 return adoptPtrWillBeNoop(new InspectorDOMAgent(pageAgent, injectedScrip
tManager, client)); |
102 } | 103 } |
103 | 104 |
104 static String toErrorString(ExceptionState&); | 105 static String toErrorString(ExceptionState&); |
105 static bool getPseudoElementType(PseudoId, TypeBuilder::DOM::PseudoType::Enu
m*); | 106 static bool getPseudoElementType(PseudoId, TypeBuilder::DOM::PseudoType::Enu
m*); |
| 107 static ShadowRoot* userAgentShadowRoot(Node*); |
106 | 108 |
107 ~InspectorDOMAgent() override; | 109 ~InspectorDOMAgent() override; |
108 DECLARE_VIRTUAL_TRACE(); | 110 DECLARE_VIRTUAL_TRACE(); |
109 | 111 |
110 void disable(ErrorString*) override; | 112 void disable(ErrorString*) override; |
111 void restore() override; | 113 void restore() override; |
112 | 114 |
113 WillBeHeapVector<RawPtrWillBeMember<Document> > documents(); | 115 WillBeHeapVector<RawPtrWillBeMember<Document> > documents(); |
114 void reset(); | 116 void reset(); |
115 | 117 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void pseudoElementDestroyed(PseudoElement*); | 179 void pseudoElementDestroyed(PseudoElement*); |
178 | 180 |
179 Node* nodeForId(int nodeId); | 181 Node* nodeForId(int nodeId); |
180 int boundNodeId(Node*); | 182 int boundNodeId(Node*); |
181 void setDOMListener(DOMListener*); | 183 void setDOMListener(DOMListener*); |
182 void inspect(Node*); | 184 void inspect(Node*); |
183 | 185 |
184 static String documentURLString(Document*); | 186 static String documentURLString(Document*); |
185 | 187 |
186 PassRefPtr<TypeBuilder::Runtime::RemoteObject> resolveNode(Node*, const Stri
ng& objectGroup); | 188 PassRefPtr<TypeBuilder::Runtime::RemoteObject> resolveNode(Node*, const Stri
ng& objectGroup); |
187 bool handleMousePress(); | |
188 bool handleGestureEvent(LocalFrame*, const PlatformGestureEvent&); | |
189 bool handleTouchEvent(LocalFrame*, const PlatformTouchEvent&); | |
190 bool handleMouseMove(LocalFrame*, const PlatformMouseEvent&); | |
191 | 189 |
192 InspectorHistory* history() { return m_history.get(); } | 190 InspectorHistory* history() { return m_history.get(); } |
193 | 191 |
194 // We represent embedded doms as a part of the same hierarchy. Hence we trea
t children of frame owners differently. | 192 // We represent embedded doms as a part of the same hierarchy. Hence we trea
t children of frame owners differently. |
195 // We also skip whitespace text nodes conditionally. Following methods encap
sulate these specifics. | 193 // We also skip whitespace text nodes conditionally. Following methods encap
sulate these specifics. |
196 static Node* innerFirstChild(Node*); | 194 static Node* innerFirstChild(Node*); |
197 static Node* innerNextSibling(Node*); | 195 static Node* innerNextSibling(Node*); |
198 static Node* innerPreviousSibling(Node*); | 196 static Node* innerPreviousSibling(Node*); |
199 static unsigned innerChildNodeCount(Node*); | 197 static unsigned innerChildNodeCount(Node*); |
200 static Node* innerParentNode(Node*); | 198 static Node* innerParentNode(Node*); |
201 static bool isWhitespace(Node*); | 199 static bool isWhitespace(Node*); |
202 | 200 |
203 Node* assertNode(ErrorString*, int nodeId); | 201 Node* assertNode(ErrorString*, int nodeId); |
204 Element* assertElement(ErrorString*, int nodeId); | 202 Element* assertElement(ErrorString*, int nodeId); |
205 Document* assertDocument(ErrorString*, int nodeId); | 203 Document* assertDocument(ErrorString*, int nodeId); |
206 | 204 |
207 private: | 205 private: |
208 enum SearchMode { NotSearching, SearchingForNormal, SearchingForUAShadow }; | |
209 | |
210 InspectorDOMAgent(InspectorPageAgent*, InjectedScriptManager*, Client*); | 206 InspectorDOMAgent(InspectorPageAgent*, InjectedScriptManager*, Client*); |
211 | 207 |
212 void setDocument(Document*); | 208 void setDocument(Document*); |
213 void innerEnable(); | 209 void innerEnable(); |
214 | 210 |
215 void setSearchingForNode(ErrorString*, SearchMode, JSONObject* highlightConf
ig); | 211 void setSearchingForNode(ErrorString*, SearchMode, JSONObject* highlightConf
ig); |
216 PassOwnPtr<InspectorHighlightConfig> highlightConfigFromInspectorObject(Erro
rString*, JSONObject* highlightInspectorObject); | 212 PassOwnPtr<InspectorHighlightConfig> highlightConfigFromInspectorObject(Erro
rString*, JSONObject* highlightInspectorObject); |
217 | 213 |
218 // Node-related methods. | 214 // Node-related methods. |
219 typedef WillBeHeapHashMap<RefPtrWillBeMember<Node>, int> NodeToIdMap; | 215 typedef WillBeHeapHashMap<RefPtrWillBeMember<Node>, int> NodeToIdMap; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> > m_idToNode; | 253 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> > m_idToNode; |
258 WillBeHeapHashMap<int, RawPtrWillBeMember<NodeToIdMap> > m_idToNodesMap; | 254 WillBeHeapHashMap<int, RawPtrWillBeMember<NodeToIdMap> > m_idToNodesMap; |
259 HashSet<int> m_childrenRequested; | 255 HashSet<int> m_childrenRequested; |
260 HashSet<int> m_distributedNodesRequested; | 256 HashSet<int> m_distributedNodesRequested; |
261 HashMap<int, int> m_cachedChildCount; | 257 HashMap<int, int> m_cachedChildCount; |
262 int m_lastNodeId; | 258 int m_lastNodeId; |
263 RefPtrWillBeMember<Document> m_document; | 259 RefPtrWillBeMember<Document> m_document; |
264 typedef WillBeHeapHashMap<String, WillBeHeapVector<RefPtrWillBeMember<Node>
> > SearchResults; | 260 typedef WillBeHeapHashMap<String, WillBeHeapVector<RefPtrWillBeMember<Node>
> > SearchResults; |
265 SearchResults m_searchResults; | 261 SearchResults m_searchResults; |
266 OwnPtrWillBeMember<InspectorRevalidateDOMTask> m_revalidateTask; | 262 OwnPtrWillBeMember<InspectorRevalidateDOMTask> m_revalidateTask; |
267 SearchMode m_searchingForNode; | |
268 OwnPtr<InspectorHighlightConfig> m_inspectModeHighlightConfig; | |
269 RefPtrWillBeMember<Node> m_hoveredNodeForInspectMode; | |
270 OwnPtrWillBeMember<InspectorHistory> m_history; | 263 OwnPtrWillBeMember<InspectorHistory> m_history; |
271 OwnPtrWillBeMember<DOMEditor> m_domEditor; | 264 OwnPtrWillBeMember<DOMEditor> m_domEditor; |
272 bool m_suppressAttributeModifiedEvent; | 265 bool m_suppressAttributeModifiedEvent; |
273 int m_backendNodeIdToInspect; | 266 int m_backendNodeIdToInspect; |
274 }; | 267 }; |
275 | 268 |
276 | 269 |
277 } // namespace blink | 270 } // namespace blink |
278 | 271 |
279 #endif // !defined(InspectorDOMAgent_h) | 272 #endif // !defined(InspectorDOMAgent_h) |
OLD | NEW |