Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/UndoStack.cpp

Issue 2639483002: Add sequence number to undo steps (Closed)
Patch Set: Fri Feb 17 13:12:45 PST 2017 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 // into a single action. 38 // into a single action.
39 static const size_t maximumUndoStackDepth = 1000; 39 static const size_t maximumUndoStackDepth = 1000;
40 40
41 UndoStack::UndoStack() : m_inRedo(false) {} 41 UndoStack::UndoStack() : m_inRedo(false) {}
42 42
43 UndoStack* UndoStack::create() { 43 UndoStack* UndoStack::create() {
44 return new UndoStack(); 44 return new UndoStack();
45 } 45 }
46 46
47 void UndoStack::registerUndoStep(UndoStep* step) { 47 void UndoStack::registerUndoStep(UndoStep* step) {
48 if (m_undoStack.size())
49 DCHECK_GE(step->sequenceNumber(), m_undoStack.back()->sequenceNumber());
48 if (m_undoStack.size() == maximumUndoStackDepth) 50 if (m_undoStack.size() == maximumUndoStackDepth)
49 m_undoStack.removeFirst(); // drop oldest item off the far end 51 m_undoStack.removeFirst(); // drop oldest item off the far end
50 if (!m_inRedo) 52 if (!m_inRedo) {
yosin_UTC9 2017/02/20 06:17:50 nit: No need to have braces.
Xiaocheng 2017/02/22 02:47:32 Whoops. Done.
51 m_redoStack.clear(); 53 m_redoStack.clear();
54 }
52 m_undoStack.append(step); 55 m_undoStack.append(step);
53 } 56 }
54 57
55 void UndoStack::registerRedoStep(UndoStep* step) { 58 void UndoStack::registerRedoStep(UndoStep* step) {
56 m_redoStack.append(step); 59 m_redoStack.append(step);
57 } 60 }
58 61
59 bool UndoStack::canUndo() const { 62 bool UndoStack::canUndo() const {
60 return !m_undoStack.isEmpty(); 63 return !m_undoStack.isEmpty();
61 } 64 }
(...skipping 29 matching lines...) Expand all
91 m_undoStack.clear(); 94 m_undoStack.clear();
92 m_redoStack.clear(); 95 m_redoStack.clear();
93 } 96 }
94 97
95 DEFINE_TRACE(UndoStack) { 98 DEFINE_TRACE(UndoStack) {
96 visitor->trace(m_undoStack); 99 visitor->trace(m_undoStack);
97 visitor->trace(m_redoStack); 100 visitor->trace(m_redoStack);
98 } 101 }
99 102
100 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698