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

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

Issue 2639483002: Add sequence number to undo steps (Closed)
Patch Set: Rebase 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/UndoStep.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
51 m_redoStack.clear(); 53 m_redoStack.clear();
52 m_undoStack.append(step); 54 m_undoStack.append(step);
53 } 55 }
54 56
55 void UndoStack::registerRedoStep(UndoStep* step) { 57 void UndoStack::registerRedoStep(UndoStep* step) {
56 m_redoStack.append(step); 58 m_redoStack.append(step);
57 } 59 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 m_undoStack.clear(); 93 m_undoStack.clear();
92 m_redoStack.clear(); 94 m_redoStack.clear();
93 } 95 }
94 96
95 DEFINE_TRACE(UndoStack) { 97 DEFINE_TRACE(UndoStack) {
96 visitor->trace(m_undoStack); 98 visitor->trace(m_undoStack);
97 visitor->trace(m_redoStack); 99 visitor->trace(m_redoStack);
98 } 100 }
99 101
100 } // namespace blink 102 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/UndoStep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698