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 InspectorOverlay_h
30 #define InspectorOverlay_h
32 #include "InspectorTypeBuilder.h"
33 #include "platform/Timer.h"
34 #include "platform/geometry/FloatQuad.h"
35 #include "platform/geometry/LayoutRect.h"
36 #include "platform/graphics/Color.h"
37 #include "platform/heap/Handle.h"
38 #include "wtf/OwnPtr.h"
39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/RefPtr.h"
41 #include "wtf/Vector.h"
42 #include "wtf/text/WTFString.h"
47 class EmptyChromeClient;
48 class GraphicsContext;
49 class InspectorClient;
50 class InspectorOverlayHost;
55 class PlatformGestureEvent;
56 class PlatformKeyboardEvent;
57 class PlatformMouseEvent;
58 class PlatformTouchEvent;
60 struct HighlightConfig {
61 WTF_MAKE_FAST_ALLOCATED;
80 : type(HighlightTypeNode)
85 void setDataFromConfig(const HighlightConfig& highlightConfig)
87 contentColor = highlightConfig.content;
88 contentOutlineColor = highlightConfig.contentOutline;
89 paddingColor = highlightConfig.padding;
90 borderColor = highlightConfig.border;
91 marginColor = highlightConfig.margin;
92 eventTargetColor = highlightConfig.eventTarget;
93 showRulers = highlightConfig.showRulers;
97 Color contentOutlineColor;
101 Color eventTargetColor;
103 // When the type is Node, there are 4 or 5 quads (margin, border, padding, content, optional eventTarget).
104 // When the type is Rects, this is just a list of quads.
106 Vector<FloatQuad> quads;
110 class InspectorOverlay {
111 WTF_MAKE_FAST_ALLOCATED;
113 static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
115 return adoptPtr(new InspectorOverlay(page, client));
122 void paint(GraphicsContext&);
123 void drawOutline(GraphicsContext*, const LayoutRect&, const Color&);
124 void resize(const IntSize&);
125 bool handleGestureEvent(const PlatformGestureEvent&);
126 bool handleMouseEvent(const PlatformMouseEvent&);
127 bool handleTouchEvent(const PlatformTouchEvent&);
128 bool handleKeyboardEvent(const PlatformKeyboardEvent&);
130 void setPausedInDebuggerMessage(const String*);
131 void setInspectModeEnabled(bool);
133 void hideHighlight();
134 void highlightNode(Node*, Node* eventTarget, const HighlightConfig&, bool omitTooltip);
135 void highlightQuad(PassOwnPtr<FloatQuad>, const HighlightConfig&);
136 void showAndHideViewSize(bool showGrid);
138 Node* highlightedNode() const;
139 bool getBoxModel(Node*, Vector<FloatQuad>*);
140 PassRefPtr<TypeBuilder::DOM::ShapeOutsideInfo> buildObjectForShapeOutside(Node*);
144 InspectorOverlayHost* overlayHost() const { return m_overlayHost.get(); }
146 void startedRecordingProfile();
147 void finishedRecordingProfile() { m_activeProfilerCount--; }
149 // Methods supporting underlying overlay page.
152 InspectorOverlay(Page*, InspectorClient*);
156 void drawNodeHighlight();
157 void drawQuadHighlight();
158 void drawPausedInDebuggerMessage();
162 void reset(const IntSize& viewportSize, const IntSize& frameViewFullSize, int scrollX, int scrollY);
163 void evaluateInOverlay(const String& method, const String& argument);
164 void evaluateInOverlay(const String& method, PassRefPtr<JSONValue> argument);
165 void onTimer(Timer<InspectorOverlay>*);
168 InspectorClient* m_client;
169 String m_pausedInDebuggerMessage;
170 bool m_inspectModeEnabled;
171 RefPtr<Node> m_highlightNode;
172 RefPtr<Node> m_eventTargetNode;
173 HighlightConfig m_nodeHighlightConfig;
174 OwnPtr<FloatQuad> m_highlightQuad;
175 OwnPtrWillBePersistent<Page> m_overlayPage;
176 OwnPtr<EmptyChromeClient> m_overlayChromeClient;
177 RefPtr<InspectorOverlayHost> m_overlayHost;
178 HighlightConfig m_quadHighlightConfig;
181 bool m_drawViewSizeWithGrid;
183 Timer<InspectorOverlay> m_timer;
184 int m_activeProfilerCount;
187 } // namespace WebCore
190 #endif // InspectorOverlay_h