EditorClientEfl.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
  6. * Copyright (C) 2009-2010 ProFUSION embedded systems
  7. * Copyright (C) 2009-2010 Samsung Electronics
  8. *
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  21. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  28. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef EditorClientEfl_h
  33. #define EditorClientEfl_h
  34. #include "EditorClient.h"
  35. #include "EditorInsertAction.h"
  36. #include "TextAffinity.h"
  37. #include "TextCheckerClient.h"
  38. #include <wtf/Deque.h>
  39. #include <wtf/Forward.h>
  40. struct Ewk_Should_Insert_Node_Event {
  41. WebCore::Node* node;
  42. WebCore::Range* range;
  43. WebCore::EditorInsertAction action;
  44. };
  45. struct Ewk_Should_Insert_Text_Event {
  46. const char* text;
  47. WebCore::Range* range;
  48. WebCore::EditorInsertAction action;
  49. };
  50. struct Ewk_Should_Change_Selected_Range_Event {
  51. WebCore::Range* fromRange;
  52. WebCore::Range* toRange;
  53. WebCore::EAffinity affinity;
  54. bool stillSelecting;
  55. };
  56. struct Ewk_Should_Apply_Style_Event {
  57. WebCore::StylePropertySet* style;
  58. WebCore::Range* range;
  59. };
  60. namespace WebCore {
  61. class Page;
  62. class EditorClientEfl : public EditorClient, public TextCheckerClient {
  63. protected:
  64. bool m_isInRedo;
  65. WTF::Deque<WTF::RefPtr<WebCore::UndoStep> > undoStack;
  66. WTF::Deque<WTF::RefPtr<WebCore::UndoStep> > redoStack;
  67. public:
  68. explicit EditorClientEfl(Evas_Object* view);
  69. ~EditorClientEfl();
  70. // from EditorClient
  71. virtual void pageDestroyed();
  72. virtual void frameWillDetachPage(Frame*) { }
  73. virtual bool shouldDeleteRange(Range*);
  74. virtual bool smartInsertDeleteEnabled();
  75. virtual bool isSelectTrailingWhitespaceEnabled();
  76. virtual bool isContinuousSpellCheckingEnabled();
  77. virtual void toggleContinuousSpellChecking();
  78. virtual bool isGrammarCheckingEnabled();
  79. virtual void toggleGrammarChecking();
  80. virtual int spellCheckerDocumentTag();
  81. virtual bool shouldBeginEditing(Range*);
  82. virtual bool shouldEndEditing(Range*);
  83. virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
  84. virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
  85. virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
  86. virtual bool shouldApplyStyle(StylePropertySet*, Range*);
  87. virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
  88. virtual void didBeginEditing();
  89. virtual void respondToChangedContents();
  90. virtual void respondToChangedSelection(Frame*);
  91. virtual void didEndEditing();
  92. virtual void willWriteSelectionToPasteboard(WebCore::Range*);
  93. virtual void didWriteSelectionToPasteboard();
  94. virtual void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer> >& pasteboardData);
  95. virtual void didSetSelectionTypesForPasteboard();
  96. virtual void registerUndoStep(WTF::PassRefPtr<UndoStep>);
  97. virtual void registerRedoStep(WTF::PassRefPtr<UndoStep>);
  98. virtual void clearUndoRedoOperations();
  99. virtual bool canCopyCut(Frame*, bool defaultValue) const;
  100. virtual bool canPaste(Frame*, bool defaultValue) const;
  101. virtual bool canUndo() const;
  102. virtual bool canRedo() const;
  103. virtual void undo();
  104. virtual void redo();
  105. virtual const char* interpretKeyEvent(const KeyboardEvent*);
  106. virtual bool handleEditingKeyboardEvent(KeyboardEvent*);
  107. virtual void handleKeyboardEvent(KeyboardEvent*);
  108. virtual void handleInputMethodKeydown(KeyboardEvent*);
  109. virtual void textFieldDidBeginEditing(Element*);
  110. virtual void textFieldDidEndEditing(Element*);
  111. virtual void textDidChangeInTextField(Element*);
  112. virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
  113. virtual void textWillBeDeletedInTextField(Element*);
  114. virtual void textDidChangeInTextArea(Element*);
  115. virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const;
  116. virtual void ignoreWordInSpellDocument(const String&);
  117. virtual void learnWord(const String&);
  118. virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
  119. virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
  120. virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
  121. virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
  122. virtual void updateSpellingUIWithMisspelledWord(const String&);
  123. virtual void showSpellingUI(bool show);
  124. virtual bool spellingUIIsShowing();
  125. virtual void getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses);
  126. virtual void willSetInputMethodState();
  127. virtual void setInputMethodState(bool enabled);
  128. virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) { }
  129. #if USE(UNIFIED_TEXT_CHECKING)
  130. virtual void checkTextOfParagraph(const UChar*, int, TextCheckingTypeMask, Vector<TextCheckingResult>&) { }
  131. #endif
  132. virtual TextCheckerClient* textChecker() { return this; }
  133. private:
  134. Evas_Object *m_view;
  135. };
  136. }
  137. #endif // EditorClientEfl_h