OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 m_endingSelection(endingSelection), | 98 m_endingSelection(endingSelection), |
99 m_startingRootEditableElement(startingSelection.rootEditableElement()), | 99 m_startingRootEditableElement(startingSelection.rootEditableElement()), |
100 m_endingRootEditableElement(endingSelection.rootEditableElement()), | 100 m_endingRootEditableElement(endingSelection.rootEditableElement()), |
101 m_inputType(inputType) {} | 101 m_inputType(inputType) {} |
102 | 102 |
103 bool EditCommandComposition::belongsTo(const LocalFrame& frame) const { | 103 bool EditCommandComposition::belongsTo(const LocalFrame& frame) const { |
104 DCHECK(m_document); | 104 DCHECK(m_document); |
105 return m_document->frame() == &frame; | 105 return m_document->frame() == &frame; |
106 } | 106 } |
107 | 107 |
108 void EditCommandComposition::unapply(EditCommandSource source) { | 108 void EditCommandComposition::unapply() { |
109 DCHECK(m_document); | 109 DCHECK(m_document); |
110 LocalFrame* frame = m_document->frame(); | 110 LocalFrame* frame = m_document->frame(); |
111 DCHECK(frame); | 111 DCHECK(frame); |
112 | 112 |
113 if (!willUnapply(source)) | |
114 return; | |
115 | |
116 // Changes to the document may have been made since the last editing operation | 113 // Changes to the document may have been made since the last editing operation |
117 // that require a layout, as in <rdar://problem/5658603>. Low level | 114 // that require a layout, as in <rdar://problem/5658603>. Low level |
118 // operations, like RemoveNodeCommand, don't require a layout because the high | 115 // operations, like RemoveNodeCommand, don't require a layout because the high |
119 // level operations that use them perform one if one is necessary (like for | 116 // level operations that use them perform one if one is necessary (like for |
120 // the creation of VisiblePositions). | 117 // the creation of VisiblePositions). |
121 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); | 118 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); |
122 | 119 |
123 { | 120 { |
124 size_t size = m_commands.size(); | 121 size_t size = m_commands.size(); |
125 for (size_t i = size; i; --i) | 122 for (size_t i = size; i; --i) |
126 m_commands[i - 1]->doUnapply(); | 123 m_commands[i - 1]->doUnapply(); |
127 } | 124 } |
128 | 125 |
129 frame->editor().unappliedEditing(this); | 126 frame->editor().unappliedEditing(this); |
130 } | 127 } |
131 | 128 |
132 void EditCommandComposition::reapply(EditCommandSource source) { | 129 void EditCommandComposition::reapply() { |
133 DCHECK(m_document); | 130 DCHECK(m_document); |
134 LocalFrame* frame = m_document->frame(); | 131 LocalFrame* frame = m_document->frame(); |
135 DCHECK(frame); | 132 DCHECK(frame); |
136 | 133 |
137 if (!willReapply(source)) | |
138 return; | |
139 | |
140 // Changes to the document may have been made since the last editing operation | 134 // Changes to the document may have been made since the last editing operation |
141 // that require a layout, as in <rdar://problem/5658603>. Low level | 135 // that require a layout, as in <rdar://problem/5658603>. Low level |
142 // operations, like RemoveNodeCommand, don't require a layout because the high | 136 // operations, like RemoveNodeCommand, don't require a layout because the high |
143 // level operations that use them perform one if one is necessary (like for | 137 // level operations that use them perform one if one is necessary (like for |
144 // the creation of VisiblePositions). | 138 // the creation of VisiblePositions). |
145 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); | 139 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); |
146 | 140 |
147 { | 141 { |
148 for (const auto& command : m_commands) | 142 for (const auto& command : m_commands) |
149 command->doReapply(); | 143 command->doReapply(); |
150 } | 144 } |
151 | 145 |
152 frame->editor().reappliedEditing(this); | 146 frame->editor().reappliedEditing(this); |
153 } | 147 } |
154 | 148 |
155 bool EditCommandComposition::willUnapply(EditCommandSource) { | |
156 // TODO(chongz): Fire 'beforeinput' for 'historyUndo'. | |
157 return true; | |
158 } | |
159 | |
160 bool EditCommandComposition::willReapply(EditCommandSource) { | |
161 // TODO(chongz): Fire 'beforeinput' for 'historyRedo'. | |
162 return true; | |
163 } | |
164 | |
165 InputEvent::InputType EditCommandComposition::inputType() const { | 149 InputEvent::InputType EditCommandComposition::inputType() const { |
166 return m_inputType; | 150 return m_inputType; |
167 } | 151 } |
168 | 152 |
169 void EditCommandComposition::append(SimpleEditCommand* command) { | 153 void EditCommandComposition::append(SimpleEditCommand* command) { |
170 m_commands.push_back(command); | 154 m_commands.push_back(command); |
171 } | 155 } |
172 | 156 |
173 void EditCommandComposition::append(EditCommandComposition* composition) { | 157 void EditCommandComposition::append(EditCommandComposition* composition) { |
174 m_commands.appendVector(composition->m_commands); | 158 m_commands.appendVector(composition->m_commands); |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 return node; | 2037 return node; |
2054 } | 2038 } |
2055 | 2039 |
2056 DEFINE_TRACE(CompositeEditCommand) { | 2040 DEFINE_TRACE(CompositeEditCommand) { |
2057 visitor->trace(m_commands); | 2041 visitor->trace(m_commands); |
2058 visitor->trace(m_composition); | 2042 visitor->trace(m_composition); |
2059 EditCommand::trace(visitor); | 2043 EditCommand::trace(visitor); |
2060 } | 2044 } |
2061 | 2045 |
2062 } // namespace blink | 2046 } // namespace blink |
OLD | NEW |