KHtml

SVGImageEmptyClients.h
1 /*
2  * Copyright (C) 2006 Eric Seidel ([email protected])
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 SVGImageEmptyClients_h
27 #define SVGImageEmptyClients_h
28 
29 #if ENABLE(SVG)
30 
31 #include "ChromeClient.h"
32 #include "ContextMenuClient.h"
33 #include "DragClient.h"
34 #include "EditorClient.h"
35 #include "FocusDirection.h"
36 #include "FrameLoaderClient.h"
37 #include "InspectorClient.h"
38 #include "SharedBuffer.h"
39 
40 /*
41  This file holds empty Client stubs for use by SVGImage.
42  SVGImage needs to create a dummy Page->Frame->FrameView tree for use in parsing an SVGDocument.
43  This tree depends heavily on Clients (usually provided by WebKit classes).
44 
45  SVGImage has no way to access the current Page (nor should it, since Images are not tied to a page).
46  See https://bugs.webkit.org/show_bug.cgi?id=5971 for more discussion on this issue.
47 
48  Ideally, whenever you change a Client class, you should add a stub here.
49  Brittle, yes. Unfortunate, yes. Hopefully temporary.
50 */
51 
52 namespace WebCore
53 {
54 
55 class SVGEmptyChromeClient : public ChromeClient
56 {
57 public:
58  virtual ~SVGEmptyChromeClient() { }
59  virtual void chromeDestroyed() { }
60 
61  virtual void setWindowRect(const FloatRect &) { }
62  virtual FloatRect windowRect()
63  {
64  return FloatRect();
65  }
66 
67  virtual FloatRect pageRect()
68  {
69  return FloatRect();
70  }
71 
72  virtual float scaleFactor()
73  {
74  return 1.f;
75  }
76 
77  virtual void focus() { }
78  virtual void unfocus() { }
79 
80  virtual bool canTakeFocus(FocusDirection)
81  {
82  return false;
83  }
84  virtual void takeFocus(FocusDirection) { }
85 
86  virtual Page *createWindow(Frame *, const FrameLoadRequest &, const WindowFeatures &)
87  {
88  return 0;
89  }
90  virtual void show() { }
91 
92  virtual bool canRunModal()
93  {
94  return false;
95  }
96  virtual void runModal() { }
97 
98  virtual void setToolbarsVisible(bool) { }
99  virtual bool toolbarsVisible()
100  {
101  return false;
102  }
103 
104  virtual void setStatusbarVisible(bool) { }
105  virtual bool statusbarVisible()
106  {
107  return false;
108  }
109 
110  virtual void setScrollbarsVisible(bool) { }
111  virtual bool scrollbarsVisible()
112  {
113  return false;
114  }
115 
116  virtual void setMenubarVisible(bool) { }
117  virtual bool menubarVisible()
118  {
119  return false;
120  }
121 
122  virtual void setResizable(bool) { }
123 
124  virtual void addMessageToConsole(const String &message, unsigned int lineNumber, const String &sourceID) { }
125 
126  virtual bool canRunBeforeUnloadConfirmPanel()
127  {
128  return false;
129  }
130  virtual bool runBeforeUnloadConfirmPanel(const String &message, Frame *frame)
131  {
132  return true;
133  }
134 
135  virtual void closeWindowSoon() { }
136 
137  virtual void runJavaScriptAlert(Frame *, const String &) { }
138  virtual bool runJavaScriptConfirm(Frame *, const String &)
139  {
140  return false;
141  }
142  virtual bool runJavaScriptPrompt(Frame *, const String &message, const String &defaultValue, String &result)
143  {
144  return false;
145  }
146  virtual bool shouldInterruptJavaScript()
147  {
148  return false;
149  }
150 
151  virtual void setStatusbarText(const String &) { }
152 
153  virtual bool tabsToLinks() const
154  {
155  return false;
156  }
157 
158  virtual IntRect windowResizerRect() const
159  {
160  return IntRect();
161  }
162  virtual void addToDirtyRegion(const IntRect &) { }
163  virtual void scrollBackingStore(int dx, int dy, const IntRect &scrollViewRect, const IntRect &clipRect) { }
164  virtual void updateBackingStore() { }
165 
166  virtual void mouseDidMoveOverElement(const HitTestResult &, unsigned modifierFlags) { }
167 
168  virtual void setToolTip(const String &) { }
169 
170  virtual void print(Frame *) { }
171 
172  virtual void exceededDatabaseQuota(Frame *, const String &) { }
173 };
174 
175 class SVGEmptyFrameLoaderClient : public FrameLoaderClient
176 {
177 public:
178  virtual ~SVGEmptyFrameLoaderClient() { }
179  virtual void frameLoaderDestroyed() { }
180 
181  virtual bool hasWebView() const
182  {
183  return true; // mainly for assertions
184  }
185  virtual bool hasFrameView() const
186  {
187  return true; // ditto
188  }
189 
190  virtual void makeRepresentation(DocumentLoader *) { }
191  virtual void forceLayout() { }
192  virtual void forceLayoutForNonHTML() { }
193 
194  virtual void updateHistoryForCommit() { }
195 
196  virtual void updateHistoryForBackForwardNavigation() { }
197  virtual void updateHistoryForReload() { }
198  virtual void updateHistoryForStandardLoad() { }
199  virtual void updateHistoryForInternalLoad() { }
200 
201  virtual void updateHistoryAfterClientRedirect() { }
202 
203  virtual void setCopiesOnScroll() { }
204 
205  virtual void detachedFromParent2() { }
206  virtual void detachedFromParent3() { }
207  virtual void detachedFromParent4() { }
208 
209  virtual void download(ResourceHandle *, const ResourceRequest &, const ResourceRequest &, const ResourceResponse &) { }
210 
211  virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader *, const ResourceRequest &) { }
212  virtual void dispatchWillSendRequest(DocumentLoader *, unsigned long identifier, ResourceRequest &, const ResourceResponse &redirectResponse) { }
213  virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader *, unsigned long identifier, const AuthenticationChallenge &) { }
214  virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader *, unsigned long identifier, const AuthenticationChallenge &) { }
215  virtual void dispatchDidReceiveResponse(DocumentLoader *, unsigned long identifier, const ResourceResponse &) { }
216  virtual void dispatchDidReceiveContentLength(DocumentLoader *, unsigned long identifier, int lengthReceived) { }
217  virtual void dispatchDidFinishLoading(DocumentLoader *, unsigned long identifier) { }
218  virtual void dispatchDidFailLoading(DocumentLoader *, unsigned long identifier, const ResourceError &) { }
219  virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader *, const ResourceRequest &, const ResourceResponse &, int length)
220  {
221  return false;
222  }
223 
224  virtual void dispatchDidHandleOnloadEvents() { }
225  virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() { }
226  virtual void dispatchDidCancelClientRedirect() { }
227  virtual void dispatchWillPerformClientRedirect(const KURL &, double interval, double fireDate) { }
228  virtual void dispatchDidChangeLocationWithinPage() { }
229  virtual void dispatchWillClose() { }
230  virtual void dispatchDidReceiveIcon() { }
231  virtual void dispatchDidStartProvisionalLoad() { }
232  virtual void dispatchDidReceiveTitle(const String &title) { }
233  virtual void dispatchDidCommitLoad() { }
234  virtual void dispatchDidFailProvisionalLoad(const ResourceError &) { }
235  virtual void dispatchDidFailLoad(const ResourceError &) { }
236  virtual void dispatchDidFinishDocumentLoad() { }
237  virtual void dispatchDidFinishLoad() { }
238  virtual void dispatchDidFirstLayout() { }
239 
240  virtual Frame *dispatchCreatePage()
241  {
242  return 0;
243  }
244  virtual void dispatchShow() { }
245 
246  virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String &MIMEType, const ResourceRequest &) { }
247  virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction &, const ResourceRequest &, const String &frameName) { }
248  virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction &, const ResourceRequest &) { }
249  virtual void cancelPolicyCheck() { }
250 
251  virtual void dispatchUnableToImplementPolicy(const ResourceError &) { }
252 
253  virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) { }
254 
255  virtual void dispatchDidLoadMainResource(DocumentLoader *) { }
256  virtual void revertToProvisionalState(DocumentLoader *) { }
257  virtual void setMainDocumentError(DocumentLoader *, const ResourceError &) { }
258 
259  virtual void willChangeEstimatedProgress() { }
260  virtual void didChangeEstimatedProgress() { }
261  virtual void postProgressStartedNotification() { }
262  virtual void postProgressEstimateChangedNotification() { }
263  virtual void postProgressFinishedNotification() { }
264 
265  virtual void setMainFrameDocumentReady(bool) { }
266 
267  virtual void startDownload(const ResourceRequest &) { }
268 
269  virtual void willChangeTitle(DocumentLoader *) { }
270  virtual void didChangeTitle(DocumentLoader *) { }
271 
272  virtual void committedLoad(DocumentLoader *, const char *, int) { }
273  virtual void finishedLoading(DocumentLoader *) { }
274 
275  virtual ResourceError cancelledError(const ResourceRequest &)
276  {
277  return ResourceError();
278  }
279  virtual ResourceError blockedError(const ResourceRequest &)
280  {
281  return ResourceError();
282  }
283  virtual ResourceError cannotShowURLError(const ResourceRequest &)
284  {
285  return ResourceError();
286  }
287  virtual ResourceError interruptForPolicyChangeError(const ResourceRequest &)
288  {
289  return ResourceError();
290  }
291 
292  virtual ResourceError cannotShowMIMETypeError(const ResourceResponse &)
293  {
294  return ResourceError();
295  }
296  virtual ResourceError fileDoesNotExistError(const ResourceResponse &)
297  {
298  return ResourceError();
299  }
300 
301  virtual bool shouldFallBack(const ResourceError &)
302  {
303  return false;
304  }
305 
306  virtual bool canHandleRequest(const ResourceRequest &) const
307  {
308  return false;
309  }
310  virtual bool canShowMIMEType(const String &MIMEType) const
311  {
312  return false;
313  }
314  virtual bool representationExistsForURLScheme(const String &URLScheme) const
315  {
316  return false;
317  }
318  virtual String generatedMIMETypeForURLScheme(const String &URLScheme) const
319  {
320  return "";
321  }
322 
323  virtual void frameLoadCompleted() { }
324  virtual void restoreViewState() { }
325  virtual void provisionalLoadStarted() { }
326  virtual bool shouldTreatURLAsSameAsCurrent(const KURL &) const
327  {
328  return false;
329  }
330  virtual void addHistoryItemForFragmentScroll() { }
331  virtual void didFinishLoad() { }
332  virtual void prepareForDataSourceReplacement() { }
333 
334  virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest &request, const SubstituteData &substituteData)
335  {
336  return new DocumentLoader(request, substituteData);
337  }
338  virtual void setTitle(const String &title, const KURL &) { }
339 
340  virtual String userAgent(const KURL &)
341  {
342  return "";
343  }
344 
345  virtual void savePlatformDataToCachedPage(CachedPage *) { }
346  virtual void transitionToCommittedFromCachedPage(CachedPage *) { }
347  virtual void transitionToCommittedForNewPage() { }
348 
349  virtual void updateGlobalHistory(const KURL &) { }
350  virtual bool shouldGoToHistoryItem(HistoryItem *) const
351  {
352  return false;
353  }
354  virtual void saveViewStateToItem(HistoryItem *) { }
355  virtual bool canCachePage() const
356  {
357  return false;
358  }
359 
360  virtual PassRefPtr<Frame> createFrame(const KURL &url, const String &name, HTMLFrameOwnerElement *ownerElement,
361  const String &referrer, bool allowsScrolling, int marginWidth, int marginHeight)
362  {
363  return 0;
364  }
365  virtual Widget *createPlugin(const IntSize &, Element *, const KURL &, const Vector<String> &, const Vector<String> &, const String &, bool)
366  {
367  return 0;
368  }
369  virtual Widget *createJavaAppletWidget(const IntSize &, Element *, const KURL &, const Vector<String> &, const Vector<String> &)
370  {
371  return 0;
372  }
373 
374  virtual ObjectContentType objectContentType(const KURL &url, const String &mimeType)
375  {
376  return ObjectContentType();
377  }
378  virtual String overrideMediaType() const
379  {
380  return String();
381  }
382 
383  virtual void redirectDataToPlugin(Widget *) {}
384  virtual void windowObjectCleared() {}
385  virtual void didPerformFirstNavigation() const {}
386 
387  virtual void registerForIconNotification(bool listen) {}
388 
389 #if PLATFORM(MAC)
390  virtual NSCachedURLResponse *willCacheResponse(DocumentLoader *, unsigned long identifier, NSCachedURLResponse *response) const
391  {
392  return response;
393  }
394 #endif
395 
396 };
397 
398 class SVGEmptyEditorClient : public EditorClient
399 {
400 public:
401  virtual ~SVGEmptyEditorClient() { }
402  virtual void pageDestroyed() { }
403 
404  virtual bool shouldDeleteRange(Range *)
405  {
406  return false;
407  }
408  virtual bool shouldShowDeleteInterface(HTMLElement *)
409  {
410  return false;
411  }
412  virtual bool smartInsertDeleteEnabled()
413  {
414  return false;
415  }
416  virtual bool isContinuousSpellCheckingEnabled()
417  {
418  return false;
419  }
420  virtual void toggleContinuousSpellChecking() { }
421  virtual bool isGrammarCheckingEnabled()
422  {
423  return false;
424  }
425  virtual void toggleGrammarChecking() { }
426  virtual int spellCheckerDocumentTag()
427  {
428  return -1;
429  }
430 
431  virtual bool selectWordBeforeMenuEvent()
432  {
433  return false;
434  }
435  virtual bool isEditable()
436  {
437  return false;
438  }
439 
440  virtual bool shouldBeginEditing(Range *)
441  {
442  return false;
443  }
444  virtual bool shouldEndEditing(Range *)
445  {
446  return false;
447  }
448  virtual bool shouldInsertNode(Node *, Range *, EditorInsertAction)
449  {
450  return false;
451  }
452  // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) { return false; }
453  virtual bool shouldInsertText(const String &, Range *, EditorInsertAction)
454  {
455  return false;
456  }
457  virtual bool shouldChangeSelectedRange(Range *fromRange, Range *toRange, EAffinity, bool stillSelecting)
458  {
459  return false;
460  }
461 
462  virtual bool shouldApplyStyle(CSSStyleDeclaration *, Range *)
463  {
464  return false;
465  }
466  virtual bool shouldMoveRangeAfterDelete(Range *, Range *)
467  {
468  return false;
469  }
470  // virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle) { return false; }
471  // virtual bool doCommandBySelector(SEL selector) { return false; }
472  //
473  virtual void didBeginEditing() { }
474  virtual void respondToChangedContents() { }
475  virtual void respondToChangedSelection() { }
476  virtual void didEndEditing() { }
477  virtual void didWriteSelectionToPasteboard() { }
478  virtual void didSetSelectionTypesForPasteboard() { }
479  // virtual void webViewDidChangeTypingStyle:(NSNotification *)notification { }
480  // virtual void webViewDidChangeSelection:(NSNotification *)notification { }
481  // virtual NSUndoManager* undoManagerForWebView:(WebView *)webView { return 0; }
482 
483  virtual void registerCommandForUndo(PassRefPtr<EditCommand>) { }
484  virtual void registerCommandForRedo(PassRefPtr<EditCommand>) { }
485  virtual void clearUndoRedoOperations() { }
486 
487  virtual bool canUndo() const
488  {
489  return false;
490  }
491  virtual bool canRedo() const
492  {
493  return false;
494  }
495 
496  virtual void undo() { }
497  virtual void redo() { }
498 
499  virtual void handleKeyboardEvent(KeyboardEvent *) { }
500  virtual void handleInputMethodKeydown(KeyboardEvent *) { }
501 
502  virtual void textFieldDidBeginEditing(Element *) { }
503  virtual void textFieldDidEndEditing(Element *) { }
504  virtual void textDidChangeInTextField(Element *) { }
505  virtual bool doTextFieldCommandFromEvent(Element *, KeyboardEvent *)
506  {
507  return false;
508  }
509  virtual void textWillBeDeletedInTextField(Element *) { }
510  virtual void textDidChangeInTextArea(Element *) { }
511 
512 #if PLATFORM(MAC)
513  virtual void markedTextAbandoned(Frame *) { }
514 
515  virtual NSString *userVisibleString(NSURL *)
516  {
517  return 0;
518  }
519 #ifdef BUILDING_ON_TIGER
520  virtual NSArray *pasteboardTypesForSelection(Frame *)
521  {
522  return 0;
523  }
524 #endif
525 #endif
526  virtual void ignoreWordInSpellDocument(const String &) { }
527  virtual void learnWord(const String &) { }
528  virtual void checkSpellingOfString(const UChar *, int length, int *misspellingLocation, int *misspellingLength) { }
529  virtual void checkGrammarOfString(const UChar *, int length, Vector<GrammarDetail> &, int *badGrammarLocation, int *badGrammarLength) { }
530  virtual void updateSpellingUIWithGrammarString(const String &, const GrammarDetail &) { }
531  virtual void updateSpellingUIWithMisspelledWord(const String &) { }
532  virtual void showSpellingUI(bool show) { }
533  virtual bool spellingUIIsShowing()
534  {
535  return false;
536  }
537  virtual void getGuessesForWord(const String &, Vector<String> &guesses) { }
538  virtual void setInputMethodState(bool enabled) { }
539 
540 };
541 
542 class SVGEmptyContextMenuClient : public ContextMenuClient
543 {
544 public:
545  virtual ~SVGEmptyContextMenuClient() { }
546  virtual void contextMenuDestroyed() { }
547 
548  virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu *)
549  {
550  return 0;
551  }
552  virtual void contextMenuItemSelected(ContextMenuItem *, const ContextMenu *) { }
553 
554  virtual void downloadURL(const KURL &url) { }
555  virtual void copyImageToClipboard(const HitTestResult &) { }
556  virtual void searchWithGoogle(const Frame *) { }
557  virtual void lookUpInDictionary(Frame *) { }
558  virtual void speak(const String &) { }
559  virtual void stopSpeaking() { }
560 
561 #if PLATFORM(MAC)
562  virtual void searchWithSpotlight() { }
563 #endif
564 };
565 
566 class SVGEmptyDragClient : public DragClient
567 {
568 public:
569  virtual ~SVGEmptyDragClient() {}
570  virtual void willPerformDragDestinationAction(DragDestinationAction, DragData *) { }
571  virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint &, Clipboard *) { }
572  virtual DragDestinationAction actionMaskForDrag(DragData *)
573  {
574  return DragDestinationActionNone;
575  }
576  virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint &)
577  {
578  return DragSourceActionNone;
579  }
580  virtual void startDrag(DragImageRef, const IntPoint &, const IntPoint &, Clipboard *, Frame *, bool) { }
581  virtual DragImageRef createDragImageForLink(KURL &, const String &label, Frame *)
582  {
583  return 0;
584  }
585  virtual void dragControllerDestroyed() { }
586 };
587 
588 class SVGEmptyInspectorClient : public InspectorClient
589 {
590 public:
591  virtual ~SVGEmptyInspectorClient() {}
592 
593  virtual void inspectorDestroyed() {};
594 
595  virtual Page *createPage()
596  {
597  return 0;
598  };
599 
600  virtual String localizedStringsURL()
601  {
602  return String();
603  };
604 
605  virtual void showWindow() {};
606  virtual void closeWindow() {};
607 
608  virtual void attachWindow() {};
609  virtual void detachWindow() {};
610 
611  virtual void highlight(Node *) {};
612  virtual void hideHighlight() {};
613  virtual void inspectedURLChanged(const String &newURL) {};
614 };
615 
616 }
617 
618 #endif // ENABLE(SVG)
619 
620 #endif // SVGImageEmptyClients_h
621 
const QList< QKeySequence > & redo()
KGuiItem closeWindow()
const QList< QKeySequence > & undo()
const QList< QKeySequence > & print()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.