2 * Copyright (C) 2006, 2007, 2008 Apple, Inc. All rights reserved.
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.
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.
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.
20 #ifndef ChromeClient_h
21 #define ChromeClient_h
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>
31 #include <wtf/HashMap.h>
34 #include "WebCoreKeyboardUIMode.h"
37 #define NSResponder WAKResponder
56 class HTMLParserQuirks
;
64 struct FrameLoadRequest
;
65 struct ViewportArguments
;
66 struct WindowFeatures
;
68 #if USE(ACCELERATED_COMPOSITING)
74 virtual void chromeDestroyed() = 0;
76 virtual void setWindowRect(const FloatRect
&) = 0;
77 virtual FloatRect
windowRect() = 0;
79 virtual FloatRect
pageRect() = 0;
81 virtual float scaleFactor() = 0;
83 virtual void focus(bool userGesture
) = 0;
84 virtual void unfocus() = 0;
86 virtual bool canTakeFocus(FocusDirection
) = 0;
87 virtual void takeFocus(FocusDirection
) = 0;
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;
96 virtual bool canRunModal() = 0;
97 virtual void runModal() = 0;
99 virtual void setToolbarsVisible(bool) = 0;
100 virtual bool toolbarsVisible() = 0;
102 virtual void setStatusbarVisible(bool) = 0;
103 virtual bool statusbarVisible() = 0;
105 virtual void setScrollbarsVisible(bool) = 0;
106 virtual bool scrollbarsVisible() = 0;
108 virtual void setMenubarVisible(bool) = 0;
109 virtual bool menubarVisible() = 0;
111 virtual void setResizable(bool) = 0;
113 virtual void addMessageToConsole(MessageSource source
, MessageLevel level
, const String
& message
, unsigned lineNumber
, const String
& sourceID
) = 0;
115 virtual bool canRunBeforeUnloadConfirmPanel() = 0;
116 virtual bool runBeforeUnloadConfirmPanel(const String
& message
, Frame
* frame
) = 0;
118 virtual void closeWindowSoon() = 0;
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;
127 virtual IntRect
windowResizerRect() const = 0;
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.
139 virtual void mouseDidMoveOverElement(const HitTestResult
&, unsigned modifierFlags
) = 0;
141 virtual void setToolTip(const String
&) = 0;
143 virtual void print(Frame
*) = 0;
145 virtual void exceededDatabaseQuota(Frame
*, const String
& databaseName
) = 0;
147 #if ENABLE(DASHBOARD_SUPPORT)
148 virtual void dashboardRegionsChanged();
151 virtual void populateVisitedLinks();
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
);
157 virtual bool shouldReplaceWithGeneratedFileForUpload(const String
& path
, String
& generatedFilename
);
158 virtual String
generateReplacementFile(const String
& path
);
160 virtual void enableSuddenTermination();
161 virtual void disableSuddenTermination();
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
&);
168 #if ENABLE(TOUCH_EVENTS)
169 virtual void eventRegionsChanged(const HashMap
< RefPtr
<Node
>, unsigned>&) const = 0;
170 virtual void didPreventDefaultForEvent() const = 0;
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;
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; }
185 virtual void runOpenPanel(Frame
*, PassRefPtr
<FileChooser
>) = 0;
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;
191 virtual HTMLParserQuirks
* createHTMLParserQuirks() = 0;
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() { }
205 virtual KeyboardUIMode
keyboardUIMode() { return KeyboardAccessDefault
; }
207 virtual NSResponder
*firstResponder() { return 0; }
208 virtual void makeFirstResponder(NSResponder
*) { }
213 virtual ~ChromeClient() { }
218 #endif // ChromeClient_h