OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 InspectorHistory::Action::Action(const String& name) : m_name(name) | 57 InspectorHistory::Action::Action(const String& name) : m_name(name) |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
61 InspectorHistory::Action::~Action() | 61 InspectorHistory::Action::~Action() |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
| 65 void InspectorHistory::Action::trace(Visitor* visitor) |
| 66 { |
| 67 } |
| 68 |
65 String InspectorHistory::Action::toString() | 69 String InspectorHistory::Action::toString() |
66 { | 70 { |
67 return m_name; | 71 return m_name; |
68 } | 72 } |
69 | 73 |
70 bool InspectorHistory::Action::isUndoableStateMark() | 74 bool InspectorHistory::Action::isUndoableStateMark() |
71 { | 75 { |
72 return false; | 76 return false; |
73 } | 77 } |
74 | 78 |
75 String InspectorHistory::Action::mergeId() | 79 String InspectorHistory::Action::mergeId() |
76 { | 80 { |
77 return ""; | 81 return ""; |
78 } | 82 } |
79 | 83 |
80 void InspectorHistory::Action::merge(PassRefPtr<Action>) | 84 void InspectorHistory::Action::merge(PassRefPtrWillBeRawPtr<Action>) |
81 { | 85 { |
82 } | 86 } |
83 | 87 |
84 InspectorHistory::InspectorHistory() : m_afterLastActionIndex(0) { } | 88 InspectorHistory::InspectorHistory() : m_afterLastActionIndex(0) { } |
85 | 89 |
86 bool InspectorHistory::perform(PassRefPtr<Action> action, ExceptionState& except
ionState) | 90 bool InspectorHistory::perform(PassRefPtrWillBeRawPtr<Action> action, ExceptionS
tate& exceptionState) |
87 { | 91 { |
88 if (!action->perform(exceptionState)) | 92 if (!action->perform(exceptionState)) |
89 return false; | 93 return false; |
90 | 94 |
91 if (!action->mergeId().isEmpty() && m_afterLastActionIndex > 0 && action->me
rgeId() == m_history[m_afterLastActionIndex - 1]->mergeId()) | 95 if (!action->mergeId().isEmpty() && m_afterLastActionIndex > 0 && action->me
rgeId() == m_history[m_afterLastActionIndex - 1]->mergeId()) |
92 m_history[m_afterLastActionIndex - 1]->merge(action); | 96 m_history[m_afterLastActionIndex - 1]->merge(action); |
93 else { | 97 else { |
94 m_history.resize(m_afterLastActionIndex); | 98 m_history.resize(m_afterLastActionIndex); |
95 m_history.append(action); | 99 m_history.append(action); |
96 ++m_afterLastActionIndex; | 100 ++m_afterLastActionIndex; |
97 } | 101 } |
98 return true; | 102 return true; |
99 } | 103 } |
100 | 104 |
101 void InspectorHistory::markUndoableState() | 105 void InspectorHistory::markUndoableState() |
102 { | 106 { |
103 perform(adoptRef(new UndoableStateMark()), IGNORE_EXCEPTION); | 107 perform(adoptRefWillBeNoop(new UndoableStateMark()), IGNORE_EXCEPTION); |
104 } | 108 } |
105 | 109 |
106 bool InspectorHistory::undo(ExceptionState& exceptionState) | 110 bool InspectorHistory::undo(ExceptionState& exceptionState) |
107 { | 111 { |
108 while (m_afterLastActionIndex > 0 && m_history[m_afterLastActionIndex - 1]->
isUndoableStateMark()) | 112 while (m_afterLastActionIndex > 0 && m_history[m_afterLastActionIndex - 1]->
isUndoableStateMark()) |
109 --m_afterLastActionIndex; | 113 --m_afterLastActionIndex; |
110 | 114 |
111 while (m_afterLastActionIndex > 0) { | 115 while (m_afterLastActionIndex > 0) { |
112 Action* action = m_history[m_afterLastActionIndex - 1].get(); | 116 Action* action = m_history[m_afterLastActionIndex - 1].get(); |
113 if (!action->undo(exceptionState)) { | 117 if (!action->undo(exceptionState)) { |
(...skipping 25 matching lines...) Expand all Loading... |
139 } | 143 } |
140 return true; | 144 return true; |
141 } | 145 } |
142 | 146 |
143 void InspectorHistory::reset() | 147 void InspectorHistory::reset() |
144 { | 148 { |
145 m_afterLastActionIndex = 0; | 149 m_afterLastActionIndex = 0; |
146 m_history.clear(); | 150 m_history.clear(); |
147 } | 151 } |
148 | 152 |
| 153 void InspectorHistory::trace(Visitor* visitor) |
| 154 { |
| 155 visitor->trace(m_history); |
| 156 } |
| 157 |
149 } // namespace WebCore | 158 } // namespace WebCore |
150 | 159 |
OLD | NEW |