OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
14 * its contributors may be used to endorse or promote products derived | |
15 * from this software without specific prior written permission. | |
16 * | |
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #ifndef InspectorOverlayAgent_h | |
30 #define InspectorOverlayAgent_h | |
31 | |
32 #include <v8-inspector.h> | |
33 #include <memory> | |
34 #include "core/inspector/InspectorBaseAgent.h" | |
35 #include "core/inspector/InspectorHighlight.h" | |
36 #include "core/inspector/InspectorOverlayHost.h" | |
37 #include "core/inspector/protocol/Overlay.h" | |
38 #include "platform/Timer.h" | |
39 #include "platform/geometry/FloatQuad.h" | |
40 #include "platform/geometry/LayoutRect.h" | |
41 #include "platform/graphics/Color.h" | |
42 #include "platform/heap/Handle.h" | |
43 #include "platform/wtf/RefPtr.h" | |
44 #include "platform/wtf/text/WTFString.h" | |
45 #include "public/platform/WebInputEvent.h" | |
46 | |
47 namespace blink { | |
48 | |
49 class Color; | |
50 class InspectedFrames; | |
51 class InspectorDOMAgent; | |
52 class LocalFrame; | |
53 class Node; | |
54 class Page; | |
55 class PageOverlay; | |
56 class WebGestureEvent; | |
57 class WebMouseEvent; | |
58 class WebLocalFrameImpl; | |
59 class WebTouchEvent; | |
60 | |
61 class InspectorOverlayAgent final | |
62 : public InspectorBaseAgent<protocol::Overlay::Metainfo>, | |
63 public InspectorOverlayHost::Listener { | |
64 WTF_MAKE_NONCOPYABLE(InspectorOverlayAgent); | |
65 USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayAgent); | |
66 | |
67 public: | |
68 InspectorOverlayAgent(WebLocalFrameImpl*, | |
69 InspectedFrames*, | |
70 v8_inspector::V8InspectorSession*, | |
71 InspectorDOMAgent*); | |
72 ~InspectorOverlayAgent() override; | |
73 DECLARE_TRACE(); | |
74 | |
75 // protocol::Dispatcher::OverlayCommandHandler implementation. | |
76 protocol::Response enable() override; | |
77 protocol::Response disable() override; | |
78 protocol::Response setShowPaintRects(bool) override; | |
79 protocol::Response setShowDebugBorders(bool) override; | |
80 protocol::Response setShowFPSCounter(bool) override; | |
81 protocol::Response setShowScrollBottleneckRects(bool) override; | |
82 protocol::Response setShowViewportSizeOnResize(bool) override; | |
83 protocol::Response setPausedInDebuggerMessage( | |
84 protocol::Maybe<String>) override; | |
85 protocol::Response setSuspended(bool) override; | |
86 protocol::Response setInspectMode( | |
87 const String& mode, | |
88 protocol::Maybe<protocol::Overlay::HighlightConfig>) override; | |
89 protocol::Response highlightRect( | |
90 int x, | |
91 int y, | |
92 int width, | |
93 int height, | |
94 protocol::Maybe<protocol::DOM::RGBA> color, | |
95 protocol::Maybe<protocol::DOM::RGBA> outline_color) override; | |
96 protocol::Response highlightQuad( | |
97 std::unique_ptr<protocol::Array<double>> quad, | |
98 protocol::Maybe<protocol::DOM::RGBA> color, | |
99 protocol::Maybe<protocol::DOM::RGBA> outline_color) override; | |
100 protocol::Response highlightNode( | |
101 std::unique_ptr<protocol::Overlay::HighlightConfig>, | |
102 protocol::Maybe<int> node_id, | |
103 protocol::Maybe<int> backend_node_id, | |
104 protocol::Maybe<String> object_id) override; | |
105 protocol::Response hideHighlight() override; | |
106 protocol::Response highlightFrame( | |
107 const String& frame_id, | |
108 protocol::Maybe<protocol::DOM::RGBA> content_color, | |
109 protocol::Maybe<protocol::DOM::RGBA> content_outline_color) override; | |
110 protocol::Response getHighlightObjectForTest( | |
111 int node_id, | |
112 std::unique_ptr<protocol::DictionaryValue>* highlight) override; | |
113 | |
114 // InspectorBaseAgent overrides. | |
115 void Restore() override; | |
116 void Dispose() override; | |
117 | |
118 void Inspect(Node*); | |
119 bool HandleInputEvent(const WebInputEvent&); | |
120 void PageLayoutInvalidated(bool resized); | |
121 void ShowReloadingBlanket(); | |
122 void HideReloadingBlanket(); | |
123 // Does not yet include paint. | |
124 void UpdateAllLifecyclePhases(); | |
125 PageOverlay* GetPageOverlay() { return page_overlay_.get(); }; | |
126 String EvaluateInOverlayForTest(const String&); | |
127 | |
128 private: | |
129 class InspectorOverlayChromeClient; | |
130 class InspectorPageOverlayDelegate; | |
131 | |
132 enum SearchMode { | |
133 kNotSearching, | |
134 kSearchingForNormal, | |
135 kSearchingForUAShadow, | |
136 }; | |
137 | |
138 // InspectorOverlayHost::Listener implementation. | |
139 void OverlayResumed() override; | |
140 void OverlaySteppedOver() override; | |
141 | |
142 bool IsEmpty(); | |
143 void DrawNodeHighlight(); | |
144 void DrawQuadHighlight(); | |
145 void DrawPausedInDebuggerMessage(); | |
146 void DrawViewSize(); | |
147 | |
148 float WindowToViewportScale() const; | |
149 | |
150 Page* OverlayPage(); | |
151 LocalFrame* OverlayMainFrame(); | |
152 void Reset(const IntSize& viewport_size, | |
153 const IntPoint& document_scroll_offset); | |
154 void EvaluateInOverlay(const String& method, const String& argument); | |
155 void EvaluateInOverlay(const String& method, | |
156 std::unique_ptr<protocol::Value> argument); | |
157 void OnTimer(TimerBase*); | |
158 void RebuildOverlayPage(); | |
159 void Invalidate(); | |
160 void ScheduleUpdate(); | |
161 void ClearInternal(); | |
162 | |
163 bool HandleMouseDown(); | |
164 bool HandleMouseUp(); | |
165 bool HandleGestureEvent(const WebGestureEvent&); | |
166 bool HandleTouchEvent(const WebTouchEvent&); | |
167 bool HandleMouseMove(const WebMouseEvent&); | |
168 | |
169 protocol::Response CompositingEnabled(); | |
170 | |
171 bool ShouldSearchForNode(); | |
172 void NodeHighlightRequested(Node*); | |
173 protocol::Response SetSearchingForNode( | |
174 SearchMode, | |
175 protocol::Maybe<protocol::Overlay::HighlightConfig>); | |
176 protocol::Response HighlightConfigFromInspectorObject( | |
177 protocol::Maybe<protocol::Overlay::HighlightConfig> | |
178 highlight_inspector_object, | |
179 std::unique_ptr<InspectorHighlightConfig>*); | |
180 void InnerHighlightQuad(std::unique_ptr<FloatQuad>, | |
181 protocol::Maybe<protocol::DOM::RGBA> color, | |
182 protocol::Maybe<protocol::DOM::RGBA> outline_color); | |
183 void InnerHighlightNode(Node*, | |
184 Node* event_target, | |
185 const InspectorHighlightConfig&, | |
186 bool omit_tooltip); | |
187 void InnerHideHighlight(); | |
188 | |
189 Member<WebLocalFrameImpl> frame_impl_; | |
190 Member<InspectedFrames> inspected_frames_; | |
191 bool enabled_; | |
192 String paused_in_debugger_message_; | |
193 Member<Node> highlight_node_; | |
194 Member<Node> event_target_node_; | |
195 InspectorHighlightConfig node_highlight_config_; | |
196 std::unique_ptr<FloatQuad> highlight_quad_; | |
197 Member<Page> overlay_page_; | |
198 Member<InspectorOverlayChromeClient> overlay_chrome_client_; | |
199 Member<InspectorOverlayHost> overlay_host_; | |
200 Color quad_content_color_; | |
201 Color quad_content_outline_color_; | |
202 bool draw_view_size_; | |
203 bool resize_timer_active_; | |
204 bool omit_tooltip_; | |
205 TaskRunnerTimer<InspectorOverlayAgent> timer_; | |
206 bool suspended_; | |
207 bool show_reloading_blanket_; | |
208 bool in_layout_; | |
209 bool needs_update_; | |
210 v8_inspector::V8InspectorSession* v8_session_; | |
211 Member<InspectorDOMAgent> dom_agent_; | |
212 std::unique_ptr<PageOverlay> page_overlay_; | |
213 Member<Node> hovered_node_for_inspect_mode_; | |
214 bool swallow_next_mouse_up_; | |
215 SearchMode inspect_mode_; | |
216 std::unique_ptr<InspectorHighlightConfig> inspect_mode_highlight_config_; | |
217 int backend_node_id_to_inspect_; | |
218 }; | |
219 | |
220 } // namespace blink | |
221 | |
222 #endif // InspectorOverlayAgent_h | |
OLD | NEW |