]> git.saurik.com Git - iphone-api.git/blob - WebCore/ChromeClient.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / ChromeClient.h
1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef ChromeClient_h
21 #define ChromeClient_h
22
23 #include "FocusDirection.h"
24 #include "GraphicsContext.h"
25 #include "HostWindow.h"
26 #include "ScrollTypes.h"
27 #include <wtf/Forward.h>
28 #include <wtf/Vector.h>
29
30 #include "Console.h"
31 #include <wtf/HashMap.h>
32
33 #if PLATFORM(MAC)
34 #include "WebCoreKeyboardUIMode.h"
35 #endif
36
37 #define NSResponder WAKResponder
38 #ifndef __OBJC__
39 class WAKResponder;
40 #else
41 @class WAKResponder;
42 #endif
43
44 #ifndef __OBJC__
45 class NSMenu;
46 class NSResponder;
47 #endif
48
49 namespace WebCore {
50
51 class AtomicString;
52 class FileChooser;
53 class FloatRect;
54 class Frame;
55 class Geolocation;
56 class HTMLParserQuirks;
57 class HitTestResult;
58 class IntRect;
59 class Node;
60 class Page;
61 class String;
62 class Widget;
63
64 struct FrameLoadRequest;
65 struct ViewportArguments;
66 struct WindowFeatures;
67
68 #if USE(ACCELERATED_COMPOSITING)
69 class GraphicsLayer;
70 #endif
71
72 class ChromeClient {
73 public:
74 virtual void chromeDestroyed() = 0;
75
76 virtual void setWindowRect(const FloatRect&) = 0;
77 virtual FloatRect windowRect() = 0;
78
79 virtual FloatRect pageRect() = 0;
80
81 virtual float scaleFactor() = 0;
82
83 virtual void focus(bool userGesture) = 0;
84 virtual void unfocus() = 0;
85
86 virtual bool canTakeFocus(FocusDirection) = 0;
87 virtual void takeFocus(FocusDirection) = 0;
88
89 // The Frame pointer provides the ChromeClient with context about which
90 // Frame wants to create the new Page. Also, the newly created window
91 // should not be shown to the user until the ChromeClient of the newly
92 // created Page has its show method called.
93 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const bool userGesture) = 0;
94 virtual void show() = 0;
95
96 virtual bool canRunModal() = 0;
97 virtual void runModal() = 0;
98
99 virtual void setToolbarsVisible(bool) = 0;
100 virtual bool toolbarsVisible() = 0;
101
102 virtual void setStatusbarVisible(bool) = 0;
103 virtual bool statusbarVisible() = 0;
104
105 virtual void setScrollbarsVisible(bool) = 0;
106 virtual bool scrollbarsVisible() = 0;
107
108 virtual void setMenubarVisible(bool) = 0;
109 virtual bool menubarVisible() = 0;
110
111 virtual void setResizable(bool) = 0;
112
113 virtual void addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) = 0;
114
115 virtual bool canRunBeforeUnloadConfirmPanel() = 0;
116 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
117
118 virtual void closeWindowSoon() = 0;
119
120 virtual void runJavaScriptAlert(Frame*, const String&) = 0;
121 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
122 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
123 virtual void setStatusbarText(const String&) = 0;
124 virtual bool shouldInterruptJavaScript() = 0;
125 virtual bool tabsToLinks() const = 0;
126
127 virtual IntRect windowResizerRect() const = 0;
128
129 // Methods used by HostWindow.
130 virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false) = 0;
131 virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) = 0;
132 virtual IntPoint screenToWindow(const IntPoint&) const = 0;
133 virtual IntRect windowToScreen(const IntRect&) const = 0;
134 virtual PlatformWidget platformWindow() const = 0;
135 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0;
136 virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {} // Platforms other than Mac can implement this if it ever becomes necessary for them to do so.
137 // End methods used by HostWindow.
138
139 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
140
141 virtual void setToolTip(const String&) = 0;
142
143 virtual void print(Frame*) = 0;
144
145 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
146
147 #if ENABLE(DASHBOARD_SUPPORT)
148 virtual void dashboardRegionsChanged();
149 #endif
150
151 virtual void populateVisitedLinks();
152
153 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
154 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
155 bool behindText, bool entireLine);
156
157 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
158 virtual String generateReplacementFile(const String& path);
159
160 virtual void enableSuddenTermination();
161 virtual void disableSuddenTermination();
162
163 virtual bool paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize,
164 ScrollbarControlState, ScrollbarPart pressedPart, bool vertical,
165 float value, float proportion, ScrollbarControlPartMask);
166 virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&);
167
168 #if ENABLE(TOUCH_EVENTS)
169 virtual void eventRegionsChanged(const HashMap< RefPtr<Node>, unsigned>&) const = 0;
170 virtual void didPreventDefaultForEvent() const = 0;
171 #endif
172 virtual void didReceiveDocType(Frame*) const = 0;
173 virtual void setNeedsScrollNotifications(Frame*, bool) const = 0;
174 virtual void observedContentChange(Frame*) const = 0;
175 virtual void clearContentChangeObservers(Frame*) const = 0;
176 virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const = 0;
177 virtual void notifyRevealedSelectionByScrollingFrame(Frame*) const = 0;
178 virtual bool isStopping() const = 0;
179 virtual void didLayout() const = 0;
180
181 // This is an synchronous call. The ChromeClient can display UI asking the user for permission
182 // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately.
183 virtual bool requestGeolocationPermissionForFrame(Frame*, Geolocation*) { return false; }
184
185 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
186
187 // Notification that the given form element has changed. This function
188 // will be called frequently, so handling should be very fast.
189 virtual void formStateDidChange(const Node*) = 0;
190
191 virtual HTMLParserQuirks* createHTMLParserQuirks() = 0;
192
193 #if USE(ACCELERATED_COMPOSITING)
194 // Pass 0 as the GraphicsLayer to detatch the root layer.
195 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) { }
196 // Sets a flag to specify that the next time content is drawn to the window,
197 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
198 virtual void setNeedsOneShotDrawingSynchronization() { }
199 // Sets a flag to specify that the view needs to be updated, so we need
200 // to do an eager layout before the drawing.
201 virtual void scheduleViewUpdate() { }
202 #endif
203
204 #if PLATFORM(MAC)
205 virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; }
206
207 virtual NSResponder *firstResponder() { return 0; }
208 virtual void makeFirstResponder(NSResponder *) { }
209
210 #endif
211
212 protected:
213 virtual ~ChromeClient() { }
214 };
215
216 }
217
218 #endif // ChromeClient_h