Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 if (!m_inRedo) | 56 if (!m_inRedo) |
| 57 m_redoStack.clear(); | 57 m_redoStack.clear(); |
| 58 m_undoStack.append(step); | 58 m_undoStack.append(step); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void UndoStack::registerRedoStep(UndoStep* step) | 61 void UndoStack::registerRedoStep(UndoStep* step) |
| 62 { | 62 { |
| 63 m_redoStack.append(step); | 63 m_redoStack.append(step); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void UndoStack::didUnloadFrame(const LocalFrame& frame) | 66 void UndoStack::didUnloadFrame() |
| 67 { | 67 { |
| 68 // TODO(xiaochengh): What's the use of this scope? Can we remove it? | |
|
yosin_UTC9
2016/07/01 09:21:21
This event scope to prevent JavaScript event handl
Xiaocheng
2016/07/04 06:29:23
Thanks. This method is removed.
| |
| 68 EventDispatchForbiddenScope assertNoEventDispatch; | 69 EventDispatchForbiddenScope assertNoEventDispatch; |
| 69 filterOutUndoSteps(m_undoStack, frame); | 70 m_undoStack.clear(); |
| 70 filterOutUndoSteps(m_redoStack, frame); | 71 m_redoStack.clear(); |
| 71 } | |
| 72 | |
| 73 void UndoStack::filterOutUndoSteps(UndoStepStack& stack, const LocalFrame& frame ) | |
| 74 { | |
| 75 UndoStepStack newStack; | |
| 76 while (!stack.isEmpty()) { | |
| 77 UndoStep* step = stack.first().get(); | |
| 78 if (!step->belongsTo(frame)) | |
| 79 newStack.append(step); | |
| 80 stack.removeFirst(); | |
| 81 } | |
| 82 stack.swap(newStack); | |
| 83 } | 72 } |
| 84 | 73 |
| 85 bool UndoStack::canUndo() const | 74 bool UndoStack::canUndo() const |
| 86 { | 75 { |
| 87 return !m_undoStack.isEmpty(); | 76 return !m_undoStack.isEmpty(); |
| 88 } | 77 } |
| 89 | 78 |
| 90 bool UndoStack::canRedo() const | 79 bool UndoStack::canRedo() const |
| 91 { | 80 { |
| 92 return !m_redoStack.isEmpty(); | 81 return !m_redoStack.isEmpty(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 117 } | 106 } |
| 118 } | 107 } |
| 119 | 108 |
| 120 DEFINE_TRACE(UndoStack) | 109 DEFINE_TRACE(UndoStack) |
| 121 { | 110 { |
| 122 visitor->trace(m_undoStack); | 111 visitor->trace(m_undoStack); |
| 123 visitor->trace(m_redoStack); | 112 visitor->trace(m_redoStack); |
| 124 } | 113 } |
| 125 | 114 |
| 126 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |