EditorClientQt.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
  3. * Copyright (C) 2006 Zack Rusin <zack@kde.org>
  4. * Copyright (C) 2006 Apple Computer, Inc.
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  21. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  22. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  23. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  25. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef EditorClientQt_h
  30. #define EditorClientQt_h
  31. #include "EditorClient.h"
  32. #include "TextCheckerClientQt.h"
  33. #include <wtf/Forward.h>
  34. #include <wtf/RefCounted.h>
  35. class QWebPage;
  36. class QWebPageAdapter;
  37. namespace WebCore {
  38. class EditorClientQt : public EditorClient {
  39. public:
  40. EditorClientQt(QWebPageAdapter*);
  41. virtual void pageDestroyed();
  42. virtual void frameWillDetachPage(Frame*) { }
  43. virtual bool shouldDeleteRange(Range*);
  44. virtual bool smartInsertDeleteEnabled();
  45. virtual void toggleSmartInsertDelete();
  46. virtual bool isSelectTrailingWhitespaceEnabled();
  47. virtual bool isContinuousSpellCheckingEnabled();
  48. virtual void toggleContinuousSpellChecking();
  49. virtual bool isGrammarCheckingEnabled();
  50. virtual void toggleGrammarChecking();
  51. virtual int spellCheckerDocumentTag();
  52. virtual bool selectWordBeforeMenuEvent();
  53. virtual bool shouldBeginEditing(Range*);
  54. virtual bool shouldEndEditing(Range*);
  55. virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
  56. virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
  57. virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
  58. virtual bool shouldApplyStyle(StylePropertySet*, Range*);
  59. virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
  60. virtual void didBeginEditing();
  61. virtual void respondToChangedContents();
  62. virtual void respondToChangedSelection(Frame*);
  63. virtual void didEndEditing();
  64. virtual void willWriteSelectionToPasteboard(Range*);
  65. virtual void didWriteSelectionToPasteboard();
  66. virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer> >& pasteboardData);
  67. virtual void didSetSelectionTypesForPasteboard();
  68. virtual void registerUndoStep(PassRefPtr<UndoStep>);
  69. virtual void registerRedoStep(PassRefPtr<UndoStep>);
  70. virtual void clearUndoRedoOperations();
  71. virtual bool canCopyCut(Frame*, bool defaultValue) const;
  72. virtual bool canPaste(Frame*, bool defaultValue) const;
  73. virtual bool canUndo() const;
  74. virtual bool canRedo() const;
  75. virtual void undo();
  76. virtual void redo();
  77. virtual void handleKeyboardEvent(KeyboardEvent*);
  78. virtual void handleInputMethodKeydown(KeyboardEvent*);
  79. virtual void textFieldDidBeginEditing(Element*);
  80. virtual void textFieldDidEndEditing(Element*);
  81. virtual void textDidChangeInTextField(Element*);
  82. virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
  83. virtual void textWillBeDeletedInTextField(Element*);
  84. virtual void textDidChangeInTextArea(Element*);
  85. virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
  86. virtual void updateSpellingUIWithMisspelledWord(const String&);
  87. virtual void showSpellingUI(bool show);
  88. virtual bool spellingUIIsShowing();
  89. virtual void willSetInputMethodState();
  90. virtual void setInputMethodState(bool enabled);
  91. virtual TextCheckerClient* textChecker() { return &m_textCheckerClient; }
  92. virtual bool supportsGlobalSelection() OVERRIDE;
  93. bool isEditing() const;
  94. static bool dumpEditingCallbacks;
  95. static bool acceptsEditing;
  96. private:
  97. TextCheckerClientQt m_textCheckerClient;
  98. QWebPageAdapter* m_page;
  99. bool m_editing;
  100. bool m_inUndoRedo; // our undo stack works differently - don't re-enter!
  101. };
  102. }
  103. #endif
  104. // vim: ts=4 sw=4 et