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