| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef UndoStep_h | 31 #ifndef UndoStep_h |
| 32 #define UndoStep_h | 32 #define UndoStep_h |
| 33 | 33 |
| 34 #include "core/editing/VisibleSelection.h" |
| 34 #include "core/events/InputEvent.h" | 35 #include "core/events/InputEvent.h" |
| 35 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 40 class SimpleEditCommand; |
| 41 |
| 42 // TODO(xiaochengh): Get rid of this interface, and then rename |
| 43 // |EditCommandComposition| to |UndoStep|. |
| 39 class UndoStep : public GarbageCollectedFinalized<UndoStep> { | 44 class UndoStep : public GarbageCollectedFinalized<UndoStep> { |
| 40 public: | 45 public: |
| 41 virtual ~UndoStep() {} | 46 virtual ~UndoStep() {} |
| 42 DEFINE_INLINE_VIRTUAL_TRACE() {} | 47 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 43 | 48 |
| 44 virtual void unapply() = 0; | 49 virtual void unapply() = 0; |
| 45 virtual void reapply() = 0; | 50 virtual void reapply() = 0; |
| 46 virtual InputEvent::InputType inputType() const = 0; | 51 virtual InputEvent::InputType inputType() const = 0; |
| 47 }; | 52 }; |
| 48 | 53 |
| 54 class EditCommandComposition final : public UndoStep { |
| 55 public: |
| 56 static EditCommandComposition* create(Document*, |
| 57 const VisibleSelection&, |
| 58 const VisibleSelection&, |
| 59 InputEvent::InputType); |
| 60 |
| 61 void unapply() override; |
| 62 void reapply() override; |
| 63 InputEvent::InputType inputType() const override; |
| 64 void append(SimpleEditCommand*); |
| 65 void append(EditCommandComposition*); |
| 66 |
| 67 const VisibleSelection& startingSelection() const { |
| 68 return m_startingSelection; |
| 69 } |
| 70 const VisibleSelection& endingSelection() const { return m_endingSelection; } |
| 71 void setStartingSelection(const VisibleSelection&); |
| 72 void setEndingSelection(const VisibleSelection&); |
| 73 Element* startingRootEditableElement() const { |
| 74 return m_startingRootEditableElement.get(); |
| 75 } |
| 76 Element* endingRootEditableElement() const { |
| 77 return m_endingRootEditableElement.get(); |
| 78 } |
| 79 |
| 80 DECLARE_VIRTUAL_TRACE(); |
| 81 |
| 82 private: |
| 83 EditCommandComposition(Document*, |
| 84 const VisibleSelection& startingSelection, |
| 85 const VisibleSelection& endingSelection, |
| 86 InputEvent::InputType); |
| 87 |
| 88 Member<Document> m_document; |
| 89 VisibleSelection m_startingSelection; |
| 90 VisibleSelection m_endingSelection; |
| 91 HeapVector<Member<SimpleEditCommand>> m_commands; |
| 92 Member<Element> m_startingRootEditableElement; |
| 93 Member<Element> m_endingRootEditableElement; |
| 94 InputEvent::InputType m_inputType; |
| 95 }; |
| 96 |
| 49 } // namespace blink | 97 } // namespace blink |
| 50 | 98 |
| 51 #endif | 99 #endif |
| OLD | NEW |