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

Side by Side Diff: Source/core/editing/UndoStack.cpp

Issue 333313002: Oilpan: move a page's UndoStack to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove redundant semicolon Created 6 years, 6 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 | « Source/core/editing/UndoStack.h ('k') | Source/core/page/Page.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 // unbounded memory. This is the maximum number of distinct undoable 38 // unbounded memory. This is the maximum number of distinct undoable
39 // actions -- unbroken stretches of typed characters are coalesced 39 // actions -- unbroken stretches of typed characters are coalesced
40 // into a single action. 40 // into a single action.
41 static const size_t maximumUndoStackDepth = 1000; 41 static const size_t maximumUndoStackDepth = 1000;
42 42
43 UndoStack::UndoStack() 43 UndoStack::UndoStack()
44 : m_inRedo(false) 44 : m_inRedo(false)
45 { 45 {
46 } 46 }
47 47
48 UndoStack::~UndoStack() 48 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(UndoStack)
49
50 PassOwnPtrWillBeRawPtr<UndoStack> UndoStack::create()
49 { 51 {
50 } 52 return adoptPtrWillBeNoop(new UndoStack());
51
52 PassOwnPtr<UndoStack> UndoStack::create()
53 {
54 return adoptPtr(new UndoStack());
55 } 53 }
56 54
57 void UndoStack::registerUndoStep(PassRefPtrWillBeRawPtr<UndoStep> step) 55 void UndoStack::registerUndoStep(PassRefPtrWillBeRawPtr<UndoStep> step)
58 { 56 {
59 if (m_undoStack.size() == maximumUndoStackDepth) 57 if (m_undoStack.size() == maximumUndoStackDepth)
60 m_undoStack.removeFirst(); // drop oldest item off the far end 58 m_undoStack.removeFirst(); // drop oldest item off the far end
61 if (!m_inRedo) 59 if (!m_inRedo)
62 m_redoStack.clear(); 60 m_redoStack.clear();
63 m_undoStack.append(step); 61 m_undoStack.append(step);
64 } 62 }
65 63
66 void UndoStack::registerRedoStep(PassRefPtrWillBeRawPtr<UndoStep> step) 64 void UndoStack::registerRedoStep(PassRefPtrWillBeRawPtr<UndoStep> step)
67 { 65 {
68 m_redoStack.append(step); 66 m_redoStack.append(step);
69 } 67 }
70 68
71 void UndoStack::didUnloadFrame(const LocalFrame& frame) 69 void UndoStack::didUnloadFrame(const LocalFrame& frame)
72 { 70 {
73 NoEventDispatchAssertion assertNoEventDispatch; 71 NoEventDispatchAssertion assertNoEventDispatch;
74 filterOutUndoSteps(m_undoStack, frame); 72 filterOutUndoSteps(m_undoStack, frame);
75 filterOutUndoSteps(m_redoStack, frame); 73 filterOutUndoSteps(m_redoStack, frame);
76 } 74 }
77 75
78 void UndoStack::filterOutUndoSteps(WillBePersistentUndoStepStack& stack, const L ocalFrame& frame) 76 void UndoStack::filterOutUndoSteps(UndoStepStack& stack, const LocalFrame& frame )
79 { 77 {
80 UndoStepStack newStack; 78 UndoStepStack newStack;
81 while (!stack.isEmpty()) { 79 while (!stack.isEmpty()) {
82 UndoStep* step = stack.first().get(); 80 UndoStep* step = stack.first().get();
83 if (!step->belongsTo(frame)) 81 if (!step->belongsTo(frame))
84 newStack.append(step); 82 newStack.append(step);
85 stack.removeFirst(); 83 stack.removeFirst();
86 } 84 }
87 stack.swap(newStack); 85 stack.swap(newStack);
88 } 86 }
(...skipping 26 matching lines...) Expand all
115 RefPtrWillBeRawPtr<UndoStep> step(back->get()); 113 RefPtrWillBeRawPtr<UndoStep> step(back->get());
116 m_redoStack.remove(back); 114 m_redoStack.remove(back);
117 115
118 ASSERT(!m_inRedo); 116 ASSERT(!m_inRedo);
119 TemporaryChange<bool> redoScope(m_inRedo, true); 117 TemporaryChange<bool> redoScope(m_inRedo, true);
120 step->reapply(); 118 step->reapply();
121 // reapply will call us back to push this command onto the undo stack. 119 // reapply will call us back to push this command onto the undo stack.
122 } 120 }
123 } 121 }
124 122
123 void UndoStack::trace(Visitor* visitor)
124 {
125 visitor->trace(m_undoStack);
126 visitor->trace(m_redoStack);
127 }
128
125 } // namesace WebCore 129 } // namesace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/UndoStack.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698