Home | History | Annotate | Download | only in page
      1 /*
      2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
      3  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #ifndef EditorClient_h
     28 #define EditorClient_h
     29 
     30 #include "core/editing/EditorInsertAction.h"
     31 #include "core/editing/TextAffinity.h"
     32 #include "core/editing/UndoStep.h"
     33 #include "core/platform/graphics/FloatRect.h"
     34 #include "core/platform/text/TextChecking.h"
     35 #include "wtf/Forward.h"
     36 #include "wtf/Vector.h"
     37 
     38 namespace WebCore {
     39 
     40 class ArchiveResource;
     41 class DocumentFragment;
     42 class Editor;
     43 class Element;
     44 class Frame;
     45 class HTMLElement;
     46 class KeyboardEvent;
     47 class Node;
     48 class Range;
     49 class SharedBuffer;
     50 class SpellChecker;
     51 class StylePropertySet;
     52 class TextCheckerClient;
     53 class VisibleSelection;
     54 class VisiblePosition;
     55 
     56 struct GrammarDetail;
     57 
     58 class EditorClient {
     59 public:
     60     virtual ~EditorClient() {  }
     61 
     62     virtual bool shouldDeleteRange(Range*) = 0;
     63     virtual bool smartInsertDeleteEnabled() = 0;
     64     virtual bool isSelectTrailingWhitespaceEnabled() = 0;
     65     virtual bool isContinuousSpellCheckingEnabled() = 0;
     66     virtual void toggleContinuousSpellChecking() = 0;
     67     virtual bool isGrammarCheckingEnabled() = 0;
     68 
     69     virtual bool shouldBeginEditing(Range*) = 0;
     70     virtual bool shouldEndEditing(Range*) = 0;
     71     virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) = 0;
     72     virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) = 0;
     73     virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) = 0;
     74 
     75     virtual bool shouldApplyStyle(StylePropertySet*, Range*) = 0;
     76 
     77     virtual void didBeginEditing() = 0;
     78     virtual void respondToChangedContents() = 0;
     79     virtual void respondToChangedSelection(Frame*) = 0;
     80     virtual void didEndEditing() = 0;
     81     virtual void didCancelCompositionOnSelectionChange() = 0;
     82 
     83     virtual void registerUndoStep(PassRefPtr<UndoStep>) = 0;
     84     virtual void registerRedoStep(PassRefPtr<UndoStep>) = 0;
     85     virtual void clearUndoRedoOperations() = 0;
     86 
     87     virtual bool canCopyCut(Frame*, bool defaultValue) const = 0;
     88     virtual bool canPaste(Frame*, bool defaultValue) const = 0;
     89     virtual bool canUndo() const = 0;
     90     virtual bool canRedo() const = 0;
     91 
     92     virtual void undo() = 0;
     93     virtual void redo() = 0;
     94 
     95     virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
     96 
     97     virtual void textFieldDidEndEditing(Element*) = 0;
     98     virtual void textDidChangeInTextField(Element*) = 0;
     99     virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) = 0;
    100 
    101     virtual TextCheckerClient* textChecker() = 0;
    102 
    103     virtual void updateSpellingUIWithMisspelledWord(const String&) = 0;
    104     virtual void showSpellingUI(bool show) = 0;
    105     virtual bool spellingUIIsShowing() = 0;
    106     virtual void willSetInputMethodState() = 0;
    107 
    108     // Support for global selections, used on platforms like the X Window System that treat
    109     // selection as a type of clipboard.
    110     virtual bool supportsGlobalSelection() { return false; }
    111 };
    112 
    113 }
    114 
    115 #endif // EditorClient_h
    116