| 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 USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayAgent); | |
| 65 | |
| 66 public: | |
| 67 InspectorOverlayAgent(WebLocalFrameImpl*, | |
| 68 InspectedFrames*, | |
| 69 v8_inspector::V8InspectorSession*, | |
| 70 InspectorDOMAgent*); | |
| 71 ~InspectorOverlayAgent() override; | |
| 72 DECLARE_TRACE(); | |
| 73 | |
| 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; | |
| 112 | |
| 113 // InspectorBaseAgent overrides. | |
| 114 void Restore() override; | |
| 115 | |
| 116 void Inspect(Node*); | |
| 117 bool HandleInputEvent(const WebInputEvent&); | |
| 118 void PageLayoutInvalidated(bool resized); | |
| 119 void ShowReloadingBlanket(); | |
| 120 void HideReloadingBlanket(); | |
| 121 // Does not yet include paint. | |
| 122 void UpdateAllLifecyclePhases(); | |
| 123 PageOverlay* GetPageOverlay() { return page_overlay_.get(); }; | |
| 124 String EvaluateInOverlayForTest(const String&); | |
| 125 | |
| 126 private: | |
| 127 class InspectorOverlayChromeClient; | |
| 128 class InspectorPageOverlayDelegate; | |
| 129 | |
| 130 enum SearchMode { | |
| 131 kNotSearching, | |
| 132 kSearchingForNormal, | |
| 133 kSearchingForUAShadow, | |
| 134 }; | |
| 135 | |
| 136 // InspectorOverlayHost::Listener implementation. | |
| 137 void OverlayResumed() override; | |
| 138 void OverlaySteppedOver() override; | |
| 139 | |
| 140 bool IsEmpty(); | |
| 141 void DrawNodeHighlight(); | |
| 142 void DrawQuadHighlight(); | |
| 143 void DrawPausedInDebuggerMessage(); | |
| 144 void DrawViewSize(); | |
| 145 | |
| 146 float WindowToViewportScale() const; | |
| 147 | |
| 148 Page* OverlayPage(); | |
| 149 LocalFrame* OverlayMainFrame(); | |
| 150 void Reset(const IntSize& viewport_size, | |
| 151 const IntPoint& document_scroll_offset); | |
| 152 void EvaluateInOverlay(const String& method, const String& argument); | |
| 153 void EvaluateInOverlay(const String& method, | |
| 154 std::unique_ptr<protocol::Value> argument); | |
| 155 void OnTimer(TimerBase*); | |
| 156 void RebuildOverlayPage(); | |
| 157 void Invalidate(); | |
| 158 void ScheduleUpdate(); | |
| 159 void ClearInternal(); | |
| 160 | |
| 161 bool HandleMouseDown(); | |
| 162 bool HandleMouseUp(); | |
| 163 bool HandleGestureEvent(const WebGestureEvent&); | |
| 164 bool HandleTouchEvent(const WebTouchEvent&); | |
| 165 bool HandleMouseMove(const WebMouseEvent&); | |
| 166 | |
| 167 protocol::Response CompositingEnabled(); | |
| 168 | |
| 169 bool ShouldSearchForNode(); | |
| 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(); | |
| 186 | |
| 187 Member<WebLocalFrameImpl> frame_impl_; | |
| 188 Member<InspectedFrames> inspected_frames_; | |
| 189 bool enabled_; | |
| 190 String paused_in_debugger_message_; | |
| 191 Member<Node> highlight_node_; | |
| 192 Member<Node> event_target_node_; | |
| 193 InspectorHighlightConfig node_highlight_config_; | |
| 194 std::unique_ptr<FloatQuad> highlight_quad_; | |
| 195 Member<Page> overlay_page_; | |
| 196 Member<InspectorOverlayChromeClient> overlay_chrome_client_; | |
| 197 Member<InspectorOverlayHost> overlay_host_; | |
| 198 Color quad_content_color_; | |
| 199 Color quad_content_outline_color_; | |
| 200 bool draw_view_size_; | |
| 201 bool resize_timer_active_; | |
| 202 bool omit_tooltip_; | |
| 203 TaskRunnerTimer<InspectorOverlayAgent> timer_; | |
| 204 bool suspended_; | |
| 205 bool show_reloading_blanket_; | |
| 206 bool in_layout_; | |
| 207 bool needs_update_; | |
| 208 v8_inspector::V8InspectorSession* v8_session_; | |
| 209 Member<InspectorDOMAgent> dom_agent_; | |
| 210 std::unique_ptr<PageOverlay> page_overlay_; | |
| 211 Member<Node> hovered_node_for_inspect_mode_; | |
| 212 bool swallow_next_mouse_up_; | |
| 213 SearchMode inspect_mode_; | |
| 214 std::unique_ptr<InspectorHighlightConfig> inspect_mode_highlight_config_; | |
| 215 int backend_node_id_to_inspect_; | |
| 216 }; | |
| 217 | |
| 218 } // namespace blink | |
| 219 | |
| 220 #endif // InspectorOverlayAgent_h | |
| OLD | NEW |