2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
29 #ifndef InspectorOverlayImpl_h
30 #define InspectorOverlayImpl_h
32 #include "core/InspectorTypeBuilder.h"
33 #include "core/inspector/InspectorDOMAgent.h"
34 #include "core/inspector/InspectorOverlayHost.h"
35 #include "core/inspector/InspectorPageAgent.h"
36 #include "core/inspector/InspectorProfilerAgent.h"
37 #include "platform/Timer.h"
38 #include "platform/geometry/FloatQuad.h"
39 #include "platform/geometry/LayoutRect.h"
40 #include "platform/graphics/Color.h"
41 #include "platform/heap/Handle.h"
42 #include "public/web/WebInputEvent.h"
43 #include "wtf/OwnPtr.h"
44 #include "wtf/PassOwnPtr.h"
45 #include "wtf/RefPtr.h"
46 #include "wtf/text/WTFString.h"
51 class EmptyChromeClient
;
53 class GraphicsContext
;
55 class InspectorCSSAgent
;
56 class InspectorDebuggerAgent
;
64 class InspectorOverlayImpl final
65 : public NoBaseWillBeGarbageCollectedFinalized
<InspectorOverlayImpl
>
66 , public InspectorDOMAgent::Client
67 , public InspectorPageAgent::Client
68 , public InspectorProfilerAgent::Client
69 , public InspectorOverlayHost::Listener
{
70 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InspectorOverlayImpl
);
71 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayImpl
);
73 static PassOwnPtrWillBeRawPtr
<InspectorOverlayImpl
> create(WebViewImpl
* webViewImpl
)
75 return adoptPtrWillBeNoop(new InspectorOverlayImpl(webViewImpl
));
78 ~InspectorOverlayImpl() override
;
81 void init(InspectorCSSAgent
*, InspectorDebuggerAgent
*, InspectorDOMAgent
*);
84 bool handleInputEvent(const WebInputEvent
&);
86 PageOverlay
* pageOverlay() { return m_pageOverlay
.get(); };
89 explicit InspectorOverlayImpl(WebViewImpl
*);
90 class InspectorOverlayChromeClient
;
91 class InspectorPageOverlayDelegate
;
93 // InspectorOverlayHost::Listener implementation.
94 void overlayResumed() override
;
95 void overlaySteppedOver() override
;
96 void overlayStartedPropertyChange(const String
&) override
;
97 void overlayPropertyChanged(float) override
;
98 void overlayEndedPropertyChange() override
;
99 void overlayClearSelection(bool) override
;
100 void overlayNextSelector() override
;
101 void overlayPreviousSelector() override
;
102 String
overlayCurrentSelectorInfo() override
;
104 // InspectorProfilerAgent::Client implementation.
105 void profilingStarted() override
;
106 void profilingStopped() override
;
108 // InspectorPageAgent::Client implementation.
109 void pageLayoutInvalidated(bool resized
) override
;
110 void setShowViewportSizeOnResize(bool show
, bool showGrid
) override
;
111 void setPausedInDebuggerMessage(const String
*) override
;
113 // InspectorDOMAgent::Client implementation.
114 void hideHighlight() override
;
115 void highlightNode(Node
*, const InspectorHighlightConfig
&, bool omitTooltip
) override
;
116 void highlightQuad(PassOwnPtr
<FloatQuad
>, const InspectorHighlightConfig
&) override
;
117 void setInspectMode(InspectorDOMAgent::SearchMode
, PassOwnPtr
<InspectorHighlightConfig
>) override
;
119 void highlightNode(Node
*, Node
* eventTarget
, const InspectorHighlightConfig
&, bool omitTooltip
);
121 void drawNodeHighlight();
122 void drawQuadHighlight();
123 void drawPausedInDebuggerMessage();
127 LocalFrame
* overlayMainFrame();
128 void reset(const IntSize
& viewportSize
, const IntPoint
& documentScrollOffset
);
129 void evaluateInOverlay(const String
& method
, const String
& argument
);
130 void evaluateInOverlay(const String
& method
, PassRefPtr
<JSONValue
> argument
);
131 void onTimer(Timer
<InspectorOverlayImpl
>*);
132 void rebuildOverlayPage();
134 void scheduleUpdate();
136 bool handleMousePress();
137 bool handleGestureEvent(const PlatformGestureEvent
&);
138 bool handleTouchEvent(const PlatformTouchEvent
&);
139 bool handleMouseMove(const PlatformMouseEvent
&);
140 bool shouldSearchForNode();
143 WebViewImpl
* m_webViewImpl
;
144 String m_pausedInDebuggerMessage
;
145 RefPtrWillBeMember
<Node
> m_highlightNode
;
146 RefPtrWillBeMember
<Node
> m_eventTargetNode
;
147 InspectorHighlightConfig m_nodeHighlightConfig
;
148 OwnPtr
<FloatQuad
> m_highlightQuad
;
149 OwnPtrWillBeMember
<Page
> m_overlayPage
;
150 OwnPtrWillBeMember
<InspectorOverlayChromeClient
> m_overlayChromeClient
;
151 RefPtrWillBeMember
<InspectorOverlayHost
> m_overlayHost
;
152 InspectorHighlightConfig m_quadHighlightConfig
;
154 bool m_drawViewSizeWithGrid
;
155 bool m_resizeTimerActive
;
157 Timer
<InspectorOverlayImpl
> m_timer
;
161 RawPtrWillBeMember
<InspectorDebuggerAgent
> m_debuggerAgent
;
162 RawPtrWillBeMember
<InspectorDOMAgent
> m_domAgent
;
163 RawPtrWillBeMember
<InspectorCSSAgent
> m_cssAgent
;
164 OwnPtrWillBeMember
<LayoutEditor
> m_layoutEditor
;
165 OwnPtr
<PageOverlay
> m_pageOverlay
;
166 RefPtrWillBeMember
<Node
> m_hoveredNodeForInspectMode
;
167 InspectorDOMAgent::SearchMode m_inspectMode
;
168 OwnPtr
<InspectorHighlightConfig
> m_inspectModeHighlightConfig
;
174 #endif // InspectorOverlayImpl_h