OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. |
3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 bool UndoStack::canUndo() const { | 59 bool UndoStack::canUndo() const { |
60 return !m_undoStack.isEmpty(); | 60 return !m_undoStack.isEmpty(); |
61 } | 61 } |
62 | 62 |
63 bool UndoStack::canRedo() const { | 63 bool UndoStack::canRedo() const { |
64 return !m_redoStack.isEmpty(); | 64 return !m_redoStack.isEmpty(); |
65 } | 65 } |
66 | 66 |
67 void UndoStack::undo(EditCommandSource source) { | 67 void UndoStack::undo() { |
68 if (canUndo()) { | 68 if (canUndo()) { |
69 UndoStepStack::iterator back = --m_undoStack.end(); | 69 UndoStepStack::iterator back = --m_undoStack.end(); |
70 UndoStep* step(back->get()); | 70 UndoStep* step(back->get()); |
71 m_undoStack.remove(back); | 71 m_undoStack.remove(back); |
72 step->unapply(source); | 72 step->unapply(); |
73 // unapply will call us back to push this command onto the redo stack. | 73 // unapply will call us back to push this command onto the redo stack. |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void UndoStack::redo(EditCommandSource source) { | 77 void UndoStack::redo() { |
78 if (canRedo()) { | 78 if (canRedo()) { |
79 UndoStepStack::iterator back = --m_redoStack.end(); | 79 UndoStepStack::iterator back = --m_redoStack.end(); |
80 UndoStep* step(back->get()); | 80 UndoStep* step(back->get()); |
81 m_redoStack.remove(back); | 81 m_redoStack.remove(back); |
82 | 82 |
83 DCHECK(!m_inRedo); | 83 DCHECK(!m_inRedo); |
84 AutoReset<bool> redoScope(&m_inRedo, true); | 84 AutoReset<bool> redoScope(&m_inRedo, true); |
85 step->reapply(source); | 85 step->reapply(); |
86 // reapply will call us back to push this command onto the undo stack. | 86 // reapply will call us back to push this command onto the undo stack. |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void UndoStack::clear() { | 90 void UndoStack::clear() { |
91 m_undoStack.clear(); | 91 m_undoStack.clear(); |
92 m_redoStack.clear(); | 92 m_redoStack.clear(); |
93 } | 93 } |
94 | 94 |
95 DEFINE_TRACE(UndoStack) { | 95 DEFINE_TRACE(UndoStack) { |
96 visitor->trace(m_undoStack); | 96 visitor->trace(m_undoStack); |
97 visitor->trace(m_redoStack); | 97 visitor->trace(m_redoStack); |
98 } | 98 } |
99 | 99 |
100 } // namespace blink | 100 } // namespace blink |
OLD | NEW |