Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: third_party/WebKit/Source/web/InspectorOverlayAgent.h

Issue 2819183002: [DevTools] Consolidate overlay-related functionality in Overlay domain (Closed)
Patch Set: rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayAgent);
67 65
68 public: 66 public:
69 explicit InspectorOverlay(WebLocalFrameImpl*); 67 InspectorOverlayAgent(WebLocalFrameImpl*,
70 ~InspectorOverlay() override; 68 InspectedFrames*,
69 v8_inspector::V8InspectorSession*,
70 InspectorDOMAgent*);
71 ~InspectorOverlayAgent() override;
71 DECLARE_TRACE(); 72 DECLARE_TRACE();
72 73
73 void Init(v8_inspector::V8InspectorSession*, InspectorDOMAgent*); 74 // protocol::Dispatcher::OverlayCommandHandler implementation.
75 protocol::Response enable() override;
76 protocol::Response disable() override;
77 protocol::Response setShowPaintRects(bool) override;
78 protocol::Response setShowDebugBorders(bool) override;
79 protocol::Response setShowFPSCounter(bool) override;
80 protocol::Response setShowScrollBottleneckRects(bool) override;
81 protocol::Response setShowViewportSizeOnResize(bool) override;
82 protocol::Response setPausedInDebuggerMessage(
83 protocol::Maybe<String>) override;
84 protocol::Response setSuspended(bool) override;
85 protocol::Response setInspectMode(
86 const String& mode,
87 protocol::Maybe<protocol::Overlay::HighlightConfig>) override;
88 protocol::Response highlightRect(
89 int x,
90 int y,
91 int width,
92 int height,
93 protocol::Maybe<protocol::DOM::RGBA> color,
94 protocol::Maybe<protocol::DOM::RGBA> outline_color) override;
95 protocol::Response highlightQuad(
96 std::unique_ptr<protocol::Array<double>> quad,
97 protocol::Maybe<protocol::DOM::RGBA> color,
98 protocol::Maybe<protocol::DOM::RGBA> outline_color) override;
99 protocol::Response highlightNode(
100 std::unique_ptr<protocol::Overlay::HighlightConfig>,
101 protocol::Maybe<int> node_id,
102 protocol::Maybe<int> backend_node_id,
103 protocol::Maybe<String> object_id) override;
104 protocol::Response hideHighlight() override;
105 protocol::Response highlightFrame(
106 const String& frame_id,
107 protocol::Maybe<protocol::DOM::RGBA> content_color,
108 protocol::Maybe<protocol::DOM::RGBA> content_outline_color) override;
109 protocol::Response getHighlightObjectForTest(
110 int node_id,
111 std::unique_ptr<protocol::DictionaryValue>* highlight) override;
74 112
75 void Clear(); 113 // InspectorBaseAgent overrides.
76 void Suspend(); 114 void Restore() override;
77 void Resume(); 115
116 void Inspect(Node*);
78 bool HandleInputEvent(const WebInputEvent&); 117 bool HandleInputEvent(const WebInputEvent&);
79 void PageLayoutInvalidated(bool resized); 118 void PageLayoutInvalidated(bool resized);
80 void SetShowViewportSizeOnResize(bool);
81 void ShowReloadingBlanket(); 119 void ShowReloadingBlanket();
82 void HideReloadingBlanket(); 120 void HideReloadingBlanket();
83 void SetPausedInDebuggerMessage(const String&);
84
85 // Does not yet include paint. 121 // Does not yet include paint.
86 void UpdateAllLifecyclePhases(); 122 void UpdateAllLifecyclePhases();
87
88 PageOverlay* GetPageOverlay() { return page_overlay_.get(); }; 123 PageOverlay* GetPageOverlay() { return page_overlay_.get(); };
89 String EvaluateInOverlayForTest(const String&); 124 String EvaluateInOverlayForTest(const String&);
90 125
91 private: 126 private:
92 class InspectorOverlayChromeClient; 127 class InspectorOverlayChromeClient;
93 class InspectorPageOverlayDelegate; 128 class InspectorPageOverlayDelegate;
94 129
130 enum SearchMode {
131 kNotSearching,
132 kSearchingForNormal,
133 kSearchingForUAShadow,
134 };
135
95 // InspectorOverlayHost::Listener implementation. 136 // InspectorOverlayHost::Listener implementation.
96 void OverlayResumed() override; 137 void OverlayResumed() override;
97 void OverlaySteppedOver() override; 138 void OverlaySteppedOver() override;
98 139
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(); 140 bool IsEmpty();
114 void DrawNodeHighlight(); 141 void DrawNodeHighlight();
115 void DrawQuadHighlight(); 142 void DrawQuadHighlight();
116 void DrawPausedInDebuggerMessage(); 143 void DrawPausedInDebuggerMessage();
117 void DrawViewSize(); 144 void DrawViewSize();
118 145
119 float WindowToViewportScale() const; 146 float WindowToViewportScale() const;
120 147
121 Page* OverlayPage(); 148 Page* OverlayPage();
122 LocalFrame* OverlayMainFrame(); 149 LocalFrame* OverlayMainFrame();
123 void Reset(const IntSize& viewport_size, 150 void Reset(const IntSize& viewport_size,
124 const IntPoint& document_scroll_offset); 151 const IntPoint& document_scroll_offset);
125 void EvaluateInOverlay(const String& method, const String& argument); 152 void EvaluateInOverlay(const String& method, const String& argument);
126 void EvaluateInOverlay(const String& method, 153 void EvaluateInOverlay(const String& method,
127 std::unique_ptr<protocol::Value> argument); 154 std::unique_ptr<protocol::Value> argument);
128 void OnTimer(TimerBase*); 155 void OnTimer(TimerBase*);
129 void RebuildOverlayPage(); 156 void RebuildOverlayPage();
130 void Invalidate(); 157 void Invalidate();
131 void ScheduleUpdate(); 158 void ScheduleUpdate();
132 void ClearInternal(); 159 void ClearInternal();
133 160
134 bool HandleMouseDown(); 161 bool HandleMouseDown();
135 bool HandleMouseUp(); 162 bool HandleMouseUp();
136 bool HandleGestureEvent(const WebGestureEvent&); 163 bool HandleGestureEvent(const WebGestureEvent&);
137 bool HandleTouchEvent(const WebTouchEvent&); 164 bool HandleTouchEvent(const WebTouchEvent&);
138 bool HandleMouseMove(const WebMouseEvent&); 165 bool HandleMouseMove(const WebMouseEvent&);
166
167 protocol::Response CompositingEnabled();
168
139 bool ShouldSearchForNode(); 169 bool ShouldSearchForNode();
140 void Inspect(Node*); 170 void NodeHighlightRequested(Node*);
171 protocol::Response SetSearchingForNode(
172 SearchMode,
173 protocol::Maybe<protocol::Overlay::HighlightConfig>);
174 protocol::Response HighlightConfigFromInspectorObject(
175 protocol::Maybe<protocol::Overlay::HighlightConfig>
176 highlight_inspector_object,
177 std::unique_ptr<InspectorHighlightConfig>*);
178 void InnerHighlightQuad(std::unique_ptr<FloatQuad>,
179 protocol::Maybe<protocol::DOM::RGBA> color,
180 protocol::Maybe<protocol::DOM::RGBA> outline_color);
181 void InnerHighlightNode(Node*,
182 Node* event_target,
183 const InspectorHighlightConfig&,
184 bool omit_tooltip);
185 void InnerHideHighlight();
141 186
142 Member<WebLocalFrameImpl> frame_impl_; 187 Member<WebLocalFrameImpl> frame_impl_;
188 Member<InspectedFrames> inspected_frames_;
189 bool enabled_;
143 String paused_in_debugger_message_; 190 String paused_in_debugger_message_;
144 Member<Node> highlight_node_; 191 Member<Node> highlight_node_;
145 Member<Node> event_target_node_; 192 Member<Node> event_target_node_;
146 InspectorHighlightConfig node_highlight_config_; 193 InspectorHighlightConfig node_highlight_config_;
147 std::unique_ptr<FloatQuad> highlight_quad_; 194 std::unique_ptr<FloatQuad> highlight_quad_;
148 Member<Page> overlay_page_; 195 Member<Page> overlay_page_;
149 Member<InspectorOverlayChromeClient> overlay_chrome_client_; 196 Member<InspectorOverlayChromeClient> overlay_chrome_client_;
150 Member<InspectorOverlayHost> overlay_host_; 197 Member<InspectorOverlayHost> overlay_host_;
151 InspectorHighlightConfig quad_highlight_config_; 198 Color quad_content_color_;
199 Color quad_content_outline_color_;
152 bool draw_view_size_; 200 bool draw_view_size_;
153 bool resize_timer_active_; 201 bool resize_timer_active_;
154 bool omit_tooltip_; 202 bool omit_tooltip_;
155 TaskRunnerTimer<InspectorOverlay> timer_; 203 TaskRunnerTimer<InspectorOverlayAgent> timer_;
156 bool suspended_; 204 bool suspended_;
157 bool show_reloading_blanket_; 205 bool show_reloading_blanket_;
158 bool in_layout_; 206 bool in_layout_;
159 bool needs_update_; 207 bool needs_update_;
160 v8_inspector::V8InspectorSession* v8_session_; 208 v8_inspector::V8InspectorSession* v8_session_;
161 Member<InspectorDOMAgent> dom_agent_; 209 Member<InspectorDOMAgent> dom_agent_;
162 std::unique_ptr<PageOverlay> page_overlay_; 210 std::unique_ptr<PageOverlay> page_overlay_;
163 Member<Node> hovered_node_for_inspect_mode_; 211 Member<Node> hovered_node_for_inspect_mode_;
164 bool swallow_next_mouse_up_; 212 bool swallow_next_mouse_up_;
165 InspectorDOMAgent::SearchMode inspect_mode_; 213 SearchMode inspect_mode_;
166 std::unique_ptr<InspectorHighlightConfig> inspect_mode_highlight_config_; 214 std::unique_ptr<InspectorHighlightConfig> inspect_mode_highlight_config_;
215 int backend_node_id_to_inspect_;
167 }; 216 };
168 217
169 } // namespace blink 218 } // namespace blink
170 219
171 #endif // InspectorOverlay_h 220 #endif // InspectorOverlayAgent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698