| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class CompositeEditCommand; | 36 class CompositeEditCommand; |
| 37 class Document; | 37 class Document; |
| 38 class EditingState; | 38 class EditingState; |
| 39 | 39 |
| 40 class CORE_EXPORT EditCommand : public GarbageCollectedFinalized<EditCommand> { | 40 class CORE_EXPORT EditCommand : public GarbageCollectedFinalized<EditCommand> { |
| 41 public: | 41 public: |
| 42 virtual ~EditCommand(); | 42 virtual ~EditCommand(); |
| 43 | 43 |
| 44 void setParent(CompositeEditCommand*); | 44 virtual void setParent(CompositeEditCommand*); |
| 45 | 45 |
| 46 virtual InputEvent::InputType inputType() const; | 46 virtual InputEvent::InputType inputType() const; |
| 47 | 47 |
| 48 const VisibleSelection& startingSelection() const { | |
| 49 return m_startingSelection; | |
| 50 } | |
| 51 const VisibleSelection& endingSelection() const { return m_endingSelection; } | |
| 52 | |
| 53 virtual bool isSimpleEditCommand() const { return false; } | 48 virtual bool isSimpleEditCommand() const { return false; } |
| 54 virtual bool isCompositeEditCommand() const { return false; } | 49 virtual bool isCompositeEditCommand() const { return false; } |
| 55 bool isTopLevelCommand() const { return !m_parent; } | 50 bool isTopLevelCommand() const { return !m_parent; } |
| 56 | 51 |
| 57 // The |EditingState*| argument must not be nullptr. | 52 // The |EditingState*| argument must not be nullptr. |
| 58 virtual void doApply(EditingState*) = 0; | 53 virtual void doApply(EditingState*) = 0; |
| 59 | 54 |
| 60 // |TypingCommand| will return the text of the last |m_commands|. | 55 // |TypingCommand| will return the text of the last |m_commands|. |
| 61 virtual String textDataForInputEvent() const; | 56 virtual String textDataForInputEvent() const; |
| 62 | 57 |
| 63 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
| 64 | 59 |
| 65 protected: | 60 protected: |
| 66 explicit EditCommand(Document&); | 61 explicit EditCommand(Document&); |
| 67 | 62 |
| 68 Document& document() const { return *m_document.get(); } | 63 Document& document() const { return *m_document.get(); } |
| 69 CompositeEditCommand* parent() const { return m_parent; } | 64 CompositeEditCommand* parent() const { return m_parent; } |
| 70 void setStartingSelection(const VisibleSelection&); | |
| 71 void setEndingSelection(const SelectionInDOMTree&); | |
| 72 // TODO(yosin): |setEndingVisibleSelection()| will take |SelectionInUndoStep| | |
| 73 // You should not use this function other than copying existing selection. | |
| 74 void setEndingVisibleSelection(const VisibleSelection&); | |
| 75 | 65 |
| 76 // TODO(yosin) |isRenderedCharacter()| should be removed, and we should use | 66 // TODO(yosin) |isRenderedCharacter()| should be removed, and we should use |
| 77 // |VisiblePosition::characterAfter()| and | 67 // |VisiblePosition::characterAfter()| and |
| 78 // |VisiblePosition::characterBefore()|. | 68 // |VisiblePosition::characterBefore()|. |
| 79 static bool isRenderedCharacter(const Position&); | 69 static bool isRenderedCharacter(const Position&); |
| 80 | 70 |
| 81 private: | 71 private: |
| 82 Member<Document> m_document; | 72 Member<Document> m_document; |
| 83 VisibleSelection m_startingSelection; | |
| 84 VisibleSelection m_endingSelection; | |
| 85 Member<CompositeEditCommand> m_parent; | 73 Member<CompositeEditCommand> m_parent; |
| 86 }; | 74 }; |
| 87 | 75 |
| 88 enum ShouldAssumeContentIsAlwaysEditable { | 76 enum ShouldAssumeContentIsAlwaysEditable { |
| 89 AssumeContentIsAlwaysEditable, | 77 AssumeContentIsAlwaysEditable, |
| 90 DoNotAssumeContentIsAlwaysEditable, | 78 DoNotAssumeContentIsAlwaysEditable, |
| 91 }; | 79 }; |
| 92 | 80 |
| 93 class SimpleEditCommand : public EditCommand { | 81 class SimpleEditCommand : public EditCommand { |
| 94 public: | 82 public: |
| 95 virtual void doUnapply() = 0; | 83 virtual void doUnapply() = 0; |
| 96 virtual void doReapply(); // calls doApply() | 84 virtual void doReapply(); // calls doApply() |
| 97 | 85 |
| 98 protected: | 86 protected: |
| 99 explicit SimpleEditCommand(Document& document) : EditCommand(document) {} | 87 explicit SimpleEditCommand(Document& document) : EditCommand(document) {} |
| 100 | 88 |
| 101 private: | 89 private: |
| 102 bool isSimpleEditCommand() const final { return true; } | 90 bool isSimpleEditCommand() const final { return true; } |
| 103 }; | 91 }; |
| 104 | 92 |
| 105 DEFINE_TYPE_CASTS(SimpleEditCommand, | 93 DEFINE_TYPE_CASTS(SimpleEditCommand, |
| 106 EditCommand, | 94 EditCommand, |
| 107 command, | 95 command, |
| 108 command->isSimpleEditCommand(), | 96 command->isSimpleEditCommand(), |
| 109 command.isSimpleEditCommand()); | 97 command.isSimpleEditCommand()); |
| 110 | 98 |
| 111 } // namespace blink | 99 } // namespace blink |
| 112 | 100 |
| 113 #endif // EditCommand_h | 101 #endif // EditCommand_h |
| OLD | NEW |