| 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 21 matching lines...) Expand all Loading... |
| 32 #define UndoStep_h | 32 #define UndoStep_h |
| 33 | 33 |
| 34 #include "core/editing/VisibleSelection.h" | 34 #include "core/editing/VisibleSelection.h" |
| 35 #include "core/events/InputEvent.h" | 35 #include "core/events/InputEvent.h" |
| 36 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class SimpleEditCommand; | 40 class SimpleEditCommand; |
| 41 | 41 |
| 42 // TODO(xiaochengh): Get rid of this interface, and then rename | 42 // TODO(xiaochengh): Rename this class to |UndoStep|. |
| 43 // |EditCommandComposition| to |UndoStep|. | 43 class EditCommandComposition |
| 44 class UndoStep : public GarbageCollectedFinalized<UndoStep> { | 44 : public GarbageCollectedFinalized<EditCommandComposition> { |
| 45 public: | |
| 46 virtual ~UndoStep() {} | |
| 47 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 48 | |
| 49 virtual void unapply() = 0; | |
| 50 virtual void reapply() = 0; | |
| 51 virtual InputEvent::InputType inputType() const = 0; | |
| 52 }; | |
| 53 | |
| 54 class EditCommandComposition final : public UndoStep { | |
| 55 public: | 45 public: |
| 56 static EditCommandComposition* create(Document*, | 46 static EditCommandComposition* create(Document*, |
| 57 const VisibleSelection&, | 47 const VisibleSelection&, |
| 58 const VisibleSelection&, | 48 const VisibleSelection&, |
| 59 InputEvent::InputType); | 49 InputEvent::InputType); |
| 60 | 50 |
| 61 void unapply() override; | 51 void unapply(); |
| 62 void reapply() override; | 52 void reapply(); |
| 63 InputEvent::InputType inputType() const override; | 53 InputEvent::InputType inputType() const; |
| 64 void append(SimpleEditCommand*); | 54 void append(SimpleEditCommand*); |
| 65 void append(EditCommandComposition*); | 55 void append(EditCommandComposition*); |
| 66 | 56 |
| 67 const VisibleSelection& startingSelection() const { | 57 const VisibleSelection& startingSelection() const { |
| 68 return m_startingSelection; | 58 return m_startingSelection; |
| 69 } | 59 } |
| 70 const VisibleSelection& endingSelection() const { return m_endingSelection; } | 60 const VisibleSelection& endingSelection() const { return m_endingSelection; } |
| 71 void setStartingSelection(const VisibleSelection&); | 61 void setStartingSelection(const VisibleSelection&); |
| 72 void setEndingSelection(const VisibleSelection&); | 62 void setEndingSelection(const VisibleSelection&); |
| 73 Element* startingRootEditableElement() const { | 63 Element* startingRootEditableElement() const { |
| 74 return m_startingRootEditableElement.get(); | 64 return m_startingRootEditableElement.get(); |
| 75 } | 65 } |
| 76 Element* endingRootEditableElement() const { | 66 Element* endingRootEditableElement() const { |
| 77 return m_endingRootEditableElement.get(); | 67 return m_endingRootEditableElement.get(); |
| 78 } | 68 } |
| 79 | 69 |
| 80 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_TRACE(); |
| 81 | 71 |
| 82 private: | 72 private: |
| 83 EditCommandComposition(Document*, | 73 EditCommandComposition(Document*, |
| 84 const VisibleSelection& startingSelection, | 74 const VisibleSelection& startingSelection, |
| 85 const VisibleSelection& endingSelection, | 75 const VisibleSelection& endingSelection, |
| 86 InputEvent::InputType); | 76 InputEvent::InputType); |
| 87 | 77 |
| 88 Member<Document> m_document; | 78 Member<Document> m_document; |
| 89 VisibleSelection m_startingSelection; | 79 VisibleSelection m_startingSelection; |
| 90 VisibleSelection m_endingSelection; | 80 VisibleSelection m_endingSelection; |
| 91 HeapVector<Member<SimpleEditCommand>> m_commands; | 81 HeapVector<Member<SimpleEditCommand>> m_commands; |
| 92 Member<Element> m_startingRootEditableElement; | 82 Member<Element> m_startingRootEditableElement; |
| 93 Member<Element> m_endingRootEditableElement; | 83 Member<Element> m_endingRootEditableElement; |
| 94 InputEvent::InputType m_inputType; | 84 InputEvent::InputType m_inputType; |
| 95 }; | 85 }; |
| 96 | 86 |
| 97 } // namespace blink | 87 } // namespace blink |
| 98 | 88 |
| 99 #endif | 89 #endif |
| OLD | NEW |