OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2006 Eric Seidel (eric@webkit.org) | |
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 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #ifndef EmptyClients_h | |
27 #define EmptyClients_h | |
28 | |
29 #include "ChromeClient.h" | |
30 #include "ContextMenuClient.h" | |
31 #include "DragClient.h" | |
32 #include "DocumentLoader.h" | |
33 #include "EditCommand.h" | |
34 #include "EditorClient.h" | |
35 #include "FocusDirection.h" | |
36 #include "FloatRect.h" | |
37 #include "FrameLoaderClient.h" | |
38 #include "InspectorClient.h" | |
39 #include "ResourceError.h" | |
40 #include "SharedBuffer.h" | |
41 | |
42 /* | |
43 This file holds empty Client stubs for use by WebCore. | |
44 Viewless element needs to create a dummy Page->Frame->FrameView tree for use in
parsing or executing JavaScript. | |
45 This tree depends heavily on Clients (usually provided by WebKit classes). | |
46 | |
47 This file was first created for SVGImage as it had no way to access the current
Page (nor should it, | |
48 since Images are not tied to a page). | |
49 See http://bugs.webkit.org/show_bug.cgi?id=5971 for the original discussion abo
ut this file. | |
50 | |
51 Ideally, whenever you change a Client class, you should add a stub here. | |
52 Brittle, yes. Unfortunate, yes. Hopefully temporary. | |
53 */ | |
54 | |
55 namespace WebCore { | |
56 | |
57 class EmptyChromeClient : public ChromeClient { | |
58 public: | |
59 virtual ~EmptyChromeClient() { } | |
60 virtual void chromeDestroyed() { } | |
61 | |
62 virtual void setWindowRect(const FloatRect&) { } | |
63 virtual FloatRect windowRect() { return FloatRect(); } | |
64 | |
65 virtual FloatRect pageRect() { return FloatRect(); } | |
66 | |
67 virtual float scaleFactor() { return 1.f; } | |
68 | |
69 virtual void focus() { } | |
70 virtual void unfocus() { } | |
71 | |
72 virtual bool canTakeFocus(FocusDirection) { return false; } | |
73 virtual void takeFocus(FocusDirection) { } | |
74 | |
75 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeat
ures&) { return 0; } | |
76 virtual void show() { } | |
77 | |
78 virtual bool canRunModal() { return false; } | |
79 virtual void runModal() { } | |
80 | |
81 virtual void setToolbarsVisible(bool) { } | |
82 virtual bool toolbarsVisible() { return false; } | |
83 | |
84 virtual void setStatusbarVisible(bool) { } | |
85 virtual bool statusbarVisible() { return false; } | |
86 | |
87 virtual void setScrollbarsVisible(bool) { } | |
88 virtual bool scrollbarsVisible() { return false; } | |
89 | |
90 virtual void setMenubarVisible(bool) { } | |
91 virtual bool menubarVisible() { return false; } | |
92 | |
93 virtual void setResizable(bool) { } | |
94 | |
95 virtual void addMessageToConsole(const String& message, unsigned int lineNum
ber, const String& sourceID) { } | |
96 | |
97 virtual bool canRunBeforeUnloadConfirmPanel() { return false; } | |
98 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame
) { return true; } | |
99 | |
100 virtual void closeWindowSoon() { } | |
101 | |
102 virtual void runJavaScriptAlert(Frame*, const String&) { } | |
103 virtual bool runJavaScriptConfirm(Frame*, const String&) { return false; } | |
104 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String
& defaultValue, String& result) { return false; } | |
105 virtual bool shouldInterruptJavaScript() { return false; } | |
106 | |
107 virtual void setStatusbarText(const String&) { } | |
108 | |
109 virtual bool tabsToLinks() const { return false; } | |
110 | |
111 virtual IntRect windowResizerRect() const { return IntRect(); } | |
112 virtual void addToDirtyRegion(const IntRect&) { } | |
113 virtual void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRec
t, const IntRect& clipRect) { } | |
114 virtual void updateBackingStore() { } | |
115 | |
116 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifier
Flags) { } | |
117 | |
118 virtual void setToolTip(const String&) { } | |
119 | |
120 virtual void print(Frame*) { } | |
121 | |
122 virtual void exceededDatabaseQuota(Frame*, const String&) { } | |
123 }; | |
124 | |
125 class EmptyFrameLoaderClient : public FrameLoaderClient { | |
126 public: | |
127 virtual ~EmptyFrameLoaderClient() { } | |
128 virtual void frameLoaderDestroyed() { } | |
129 | |
130 virtual bool hasWebView() const { return true; } // mainly for assertions | |
131 virtual bool hasFrameView() const { return true; } // ditto | |
132 | |
133 virtual void makeRepresentation(DocumentLoader*) { } | |
134 virtual void forceLayout() { } | |
135 virtual void forceLayoutForNonHTML() { } | |
136 | |
137 virtual void updateHistoryForCommit() { } | |
138 | |
139 virtual void updateHistoryForBackForwardNavigation() { } | |
140 virtual void updateHistoryForReload() { } | |
141 virtual void updateHistoryForStandardLoad() { } | |
142 virtual void updateHistoryForInternalLoad() { } | |
143 | |
144 virtual void updateHistoryAfterClientRedirect() { } | |
145 | |
146 virtual void setCopiesOnScroll() { } | |
147 | |
148 virtual void detachedFromParent2() { } | |
149 virtual void detachedFromParent3() { } | |
150 virtual void detachedFromParent4() { } | |
151 | |
152 virtual void download(ResourceHandle*, const ResourceRequest&, const Resourc
eRequest&, const ResourceResponse&) { } | |
153 | |
154 virtual void assignIdentifierToInitialRequest(unsigned long identifier, Docu
mentLoader*, const ResourceRequest&) { } | |
155 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifi
er, ResourceRequest&, const ResourceResponse& redirectResponse) { } | |
156 virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsi
gned long identifier, const AuthenticationChallenge&) { } | |
157 virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsig
ned long identifier, const AuthenticationChallenge&) { } | |
158 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long ident
ifier, const ResourceResponse&) { } | |
159 virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long
identifier, int lengthReceived) { } | |
160 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identif
ier) { } | |
161 virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifie
r, const ResourceError&) { } | |
162 virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const R
esourceRequest&, const ResourceResponse&, int length) { return false; } | |
163 | |
164 virtual void dispatchDidHandleOnloadEvents() { } | |
165 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() { } | |
166 virtual void dispatchDidCancelClientRedirect() { } | |
167 virtual void dispatchWillPerformClientRedirect(const KURL&, double interval,
double fireDate) { } | |
168 virtual void dispatchDidChangeLocationWithinPage() { } | |
169 virtual void dispatchWillClose() { } | |
170 virtual void dispatchDidReceiveIcon() { } | |
171 virtual void dispatchDidStartProvisionalLoad() { } | |
172 virtual void dispatchDidReceiveTitle(const String& title) { } | |
173 virtual void dispatchDidCommitLoad() { } | |
174 virtual void dispatchDidFailProvisionalLoad(const ResourceError&) { } | |
175 virtual void dispatchDidFailLoad(const ResourceError&) { } | |
176 virtual void dispatchDidFinishDocumentLoad() { } | |
177 virtual void dispatchDidFinishLoad() { } | |
178 virtual void dispatchDidFirstLayout() { } | |
179 | |
180 virtual Frame* dispatchCreatePage() { return 0; } | |
181 virtual void dispatchShow() { } | |
182 | |
183 virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const Stri
ng& MIMEType, const ResourceRequest&) { } | |
184 virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, con
st NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const Strin
g& frameName) { } | |
185 virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, co
nst NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>) { } | |
186 virtual void cancelPolicyCheck() { } | |
187 | |
188 virtual void dispatchUnableToImplementPolicy(const ResourceError&) { } | |
189 | |
190 virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormStat
e>) { } | |
191 | |
192 virtual void dispatchDidLoadMainResource(DocumentLoader*) { } | |
193 virtual void revertToProvisionalState(DocumentLoader*) { } | |
194 virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) { } | |
195 | |
196 virtual void willChangeEstimatedProgress() { } | |
197 virtual void didChangeEstimatedProgress() { } | |
198 virtual void postProgressStartedNotification() { } | |
199 virtual void postProgressEstimateChangedNotification() { } | |
200 virtual void postProgressFinishedNotification() { } | |
201 | |
202 virtual void setMainFrameDocumentReady(bool) { } | |
203 | |
204 virtual void startDownload(const ResourceRequest&) { } | |
205 | |
206 virtual void willChangeTitle(DocumentLoader*) { } | |
207 virtual void didChangeTitle(DocumentLoader*) { } | |
208 | |
209 virtual void committedLoad(DocumentLoader*, const char*, int) { } | |
210 virtual void finishedLoading(DocumentLoader*) { } | |
211 | |
212 virtual ResourceError cancelledError(const ResourceRequest&) { return Resour
ceError(); } | |
213 virtual ResourceError blockedError(const ResourceRequest&) { return Resource
Error(); } | |
214 virtual ResourceError cannotShowURLError(const ResourceRequest&) { return Re
sourceError(); } | |
215 virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&)
{ return ResourceError(); } | |
216 | |
217 virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) { ret
urn ResourceError(); } | |
218 virtual ResourceError fileDoesNotExistError(const ResourceResponse&) { retur
n ResourceError(); } | |
219 virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) { r
eturn ResourceError(); } | |
220 | |
221 virtual bool shouldFallBack(const ResourceError&) { return false; } | |
222 | |
223 virtual bool canHandleRequest(const ResourceRequest&) const { return false;
} | |
224 virtual bool canShowMIMEType(const String& MIMEType) const { return false; } | |
225 virtual bool representationExistsForURLScheme(const String& URLScheme) const
{ return false; } | |
226 virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const
{ return ""; } | |
227 | |
228 virtual void frameLoadCompleted() { } | |
229 virtual void restoreViewState() { } | |
230 virtual void provisionalLoadStarted() { } | |
231 virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const { return false
; } | |
232 virtual void addHistoryItemForFragmentScroll() { } | |
233 virtual void didFinishLoad() { } | |
234 virtual void prepareForDataSourceReplacement() { } | |
235 | |
236 virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceReques
t& request, const SubstituteData& substituteData) { return DocumentLoader::creat
e(request, substituteData); } | |
237 virtual void setTitle(const String& title, const KURL&) { } | |
238 | |
239 virtual String userAgent(const KURL&) { return ""; } | |
240 | |
241 virtual void savePlatformDataToCachedPage(CachedPage*) { } | |
242 virtual void transitionToCommittedFromCachedPage(CachedPage*) { } | |
243 virtual void transitionToCommittedForNewPage() { } | |
244 | |
245 virtual void updateGlobalHistory(const KURL&) { } | |
246 virtual bool shouldGoToHistoryItem(HistoryItem*) const { return false; } | |
247 virtual void saveViewStateToItem(HistoryItem*) { } | |
248 virtual bool canCachePage() const { return false; } | |
249 | |
250 virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, H
TMLFrameOwnerElement* ownerElement, | |
251 const String& referrer, bool allowsScrolling, int
marginWidth, int marginHeight) { return 0; } | |
252 virtual Widget* createPlugin(const IntSize&,Element*, const KURL&, const Vec
tor<String>&, const Vector<String>&, const String&, bool) { return 0; } | |
253 virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL&
, const Vector<String>&, const Vector<String>&) { return 0; } | |
254 | |
255 virtual ObjectContentType objectContentType(const KURL& url, const String& m
imeType) { return ObjectContentType(); } | |
256 virtual String overrideMediaType() const { return String(); } | |
257 | |
258 virtual void redirectDataToPlugin(Widget*) {} | |
259 virtual void windowObjectCleared() {} | |
260 virtual void didPerformFirstNavigation() const {} | |
261 | |
262 virtual void registerForIconNotification(bool listen) {} | |
263 | |
264 virtual void unloadListenerChanged() {} | |
265 | |
266 #if PLATFORM(MAC) | |
267 virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned lon
g identifier, NSCachedURLResponse* response) const { return response; } | |
268 #endif | |
269 | |
270 }; | |
271 | |
272 class EmptyEditorClient : public EditorClient { | |
273 public: | |
274 virtual ~EmptyEditorClient() { } | |
275 virtual void pageDestroyed() { } | |
276 | |
277 virtual bool shouldDeleteRange(Range*) { return false; } | |
278 virtual bool shouldShowDeleteInterface(HTMLElement*) { return false; } | |
279 virtual bool smartInsertDeleteEnabled() { return false; } | |
280 virtual bool isContinuousSpellCheckingEnabled() { return false; } | |
281 virtual void toggleContinuousSpellChecking() { } | |
282 virtual bool isGrammarCheckingEnabled() { return false; } | |
283 virtual void toggleGrammarChecking() { } | |
284 virtual int spellCheckerDocumentTag() { return -1; } | |
285 | |
286 virtual bool selectWordBeforeMenuEvent() { return false; } | |
287 virtual bool isEditable() { return false; } | |
288 | |
289 virtual bool shouldBeginEditing(Range*) { return false; } | |
290 virtual bool shouldEndEditing(Range*) { return false; } | |
291 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) { return fa
lse; } | |
292 // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInser
tAction) { return false; } | |
293 virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) { r
eturn false; } | |
294 virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAf
finity, bool stillSelecting) { return false; } | |
295 | |
296 virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) { return false;
} | |
297 virtual bool shouldMoveRangeAfterDelete(Range*, Range*) { return false; } | |
298 // virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSS
StyleDeclaration* toStyle) { return false; } | |
299 // virtual bool doCommandBySelector(SEL selector) { return false; } | |
300 // | |
301 virtual void didBeginEditing() { } | |
302 virtual void respondToChangedContents() { } | |
303 virtual void respondToChangedSelection() { } | |
304 virtual void didEndEditing() { } | |
305 virtual void didWriteSelectionToPasteboard() { } | |
306 virtual void didSetSelectionTypesForPasteboard() { } | |
307 // virtual void webViewDidChangeTypingStyle:(NSNotification *)notification
{ } | |
308 // virtual void webViewDidChangeSelection:(NSNotification *)notification {
} | |
309 // virtual NSUndoManager* undoManagerForWebView:(WebView *)webView { return
0; } | |
310 | |
311 virtual void registerCommandForUndo(PassRefPtr<EditCommand>) { } | |
312 virtual void registerCommandForRedo(PassRefPtr<EditCommand>) { } | |
313 virtual void clearUndoRedoOperations() { } | |
314 | |
315 virtual bool canUndo() const { return false; } | |
316 virtual bool canRedo() const { return false; } | |
317 | |
318 virtual void undo() { } | |
319 virtual void redo() { } | |
320 | |
321 virtual void handleKeyboardEvent(KeyboardEvent*) { } | |
322 virtual void handleInputMethodKeydown(KeyboardEvent*) { } | |
323 | |
324 virtual void textFieldDidBeginEditing(Element*) { } | |
325 virtual void textFieldDidEndEditing(Element*) { } | |
326 virtual void textDidChangeInTextField(Element*) { } | |
327 virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) { return
false; } | |
328 virtual void textWillBeDeletedInTextField(Element*) { } | |
329 virtual void textDidChangeInTextArea(Element*) { } | |
330 | |
331 #if PLATFORM(MAC) | |
332 virtual void markedTextAbandoned(Frame*) { } | |
333 | |
334 virtual NSString* userVisibleString(NSURL*) { return 0; } | |
335 #ifdef BUILDING_ON_TIGER | |
336 virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; } | |
337 #endif | |
338 #endif | |
339 virtual void ignoreWordInSpellDocument(const String&) { } | |
340 virtual void learnWord(const String&) { } | |
341 virtual void checkSpellingOfString(const UChar*, int length, int* misspellin
gLocation, int* misspellingLength) { } | |
342 virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDe
tail>&, int* badGrammarLocation, int* badGrammarLength) { } | |
343 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarD
etail&) { } | |
344 virtual void updateSpellingUIWithMisspelledWord(const String&) { } | |
345 virtual void showSpellingUI(bool show) { } | |
346 virtual bool spellingUIIsShowing() { return false; } | |
347 virtual void getGuessesForWord(const String&, Vector<String>& guesses) { } | |
348 virtual void setInputMethodState(bool enabled) { } | |
349 | |
350 | |
351 }; | |
352 | |
353 class EmptyContextMenuClient : public ContextMenuClient { | |
354 public: | |
355 virtual ~EmptyContextMenuClient() { } | |
356 virtual void contextMenuDestroyed() { } | |
357 | |
358 virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*)
{ return 0; } | |
359 virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) {
} | |
360 | |
361 virtual void downloadURL(const KURL& url) { } | |
362 virtual void copyImageToClipboard(const HitTestResult&) { } | |
363 virtual void searchWithGoogle(const Frame*) { } | |
364 virtual void lookUpInDictionary(Frame*) { } | |
365 virtual void speak(const String&) { } | |
366 virtual void stopSpeaking() { } | |
367 | |
368 #if PLATFORM(MAC) | |
369 virtual void searchWithSpotlight() { } | |
370 #endif | |
371 }; | |
372 | |
373 class EmptyDragClient : public DragClient { | |
374 public: | |
375 virtual ~EmptyDragClient() {} | |
376 virtual void willPerformDragDestinationAction(DragDestinationAction, DragDat
a*) { } | |
377 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&,
Clipboard*) { } | |
378 virtual DragDestinationAction actionMaskForDrag(DragData*) { return DragDest
inationActionNone; } | |
379 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) { ret
urn DragSourceActionNone; } | |
380 virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipb
oard*, Frame*, bool) { } | |
381 virtual DragImageRef createDragImageForLink(KURL&, const String& label, Fram
e*) { return 0; } | |
382 virtual void dragControllerDestroyed() { } | |
383 }; | |
384 | |
385 class EmptyInspectorClient : public InspectorClient { | |
386 public: | |
387 virtual ~EmptyInspectorClient() {} | |
388 | |
389 virtual void inspectorDestroyed() {}; | |
390 | |
391 virtual Page* createPage() { return 0; }; | |
392 | |
393 virtual String localizedStringsURL() { return String(); }; | |
394 | |
395 virtual void showWindow() {}; | |
396 virtual void closeWindow() {}; | |
397 | |
398 virtual void attachWindow() {}; | |
399 virtual void detachWindow() {}; | |
400 | |
401 virtual void setAttachedWindowHeight(unsigned) {}; | |
402 | |
403 virtual void highlight(Node*) {}; | |
404 virtual void hideHighlight() {}; | |
405 virtual void inspectedURLChanged(const String& newURL) {}; | |
406 }; | |
407 | |
408 } | |
409 | |
410 #endif // EmptyClients_h | |
OLD | NEW |