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

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

Issue 2634633002: Revert of [Editing] Introduce |CompositeEditCommand::willApplyEditing()| in prepare for (1/3) (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 UndoStep::trace(visitor); 180 UndoStep::trace(visitor);
181 } 181 }
182 182
183 CompositeEditCommand::CompositeEditCommand(Document& document) 183 CompositeEditCommand::CompositeEditCommand(Document& document)
184 : EditCommand(document) {} 184 : EditCommand(document) {}
185 185
186 CompositeEditCommand::~CompositeEditCommand() { 186 CompositeEditCommand::~CompositeEditCommand() {
187 DCHECK(isTopLevelCommand() || !m_composition); 187 DCHECK(isTopLevelCommand() || !m_composition);
188 } 188 }
189 189
190 bool CompositeEditCommand::apply(EditCommandSource source) { 190 // TODO(chongz): Fire 'beforeinput' based on |EditCommandSource|.
191 bool CompositeEditCommand::apply(EditCommandSource) {
191 DCHECK(!isCommandGroupWrapper()); 192 DCHECK(!isCommandGroupWrapper());
192 if (!endingSelection().isContentRichlyEditable()) { 193 if (!endingSelection().isContentRichlyEditable()) {
193 switch (inputType()) { 194 switch (inputType()) {
194 case InputEvent::InputType::InsertText: 195 case InputEvent::InputType::InsertText:
195 case InputEvent::InputType::InsertLineBreak: 196 case InputEvent::InputType::InsertLineBreak:
196 case InputEvent::InputType::InsertParagraph: 197 case InputEvent::InputType::InsertParagraph:
197 case InputEvent::InputType::InsertFromPaste: 198 case InputEvent::InputType::InsertFromPaste:
198 case InputEvent::InputType::InsertFromDrop: 199 case InputEvent::InputType::InsertFromDrop:
199 case InputEvent::InputType::InsertReplacementText: 200 case InputEvent::InputType::InsertReplacementText:
200 case InputEvent::InputType::DeleteComposedCharacterForward: 201 case InputEvent::InputType::DeleteComposedCharacterForward:
(...skipping 15 matching lines...) Expand all
216 } 217 }
217 ensureComposition(); 218 ensureComposition();
218 219
219 // Changes to the document may have been made since the last editing operation 220 // Changes to the document may have been made since the last editing operation
220 // that require a layout, as in <rdar://problem/5658603>. Low level 221 // that require a layout, as in <rdar://problem/5658603>. Low level
221 // operations, like RemoveNodeCommand, don't require a layout because the high 222 // operations, like RemoveNodeCommand, don't require a layout because the high
222 // level operations that use them perform one if one is necessary (like for 223 // level operations that use them perform one if one is necessary (like for
223 // the creation of VisiblePositions). 224 // the creation of VisiblePositions).
224 document().updateStyleAndLayoutIgnorePendingStylesheets(); 225 document().updateStyleAndLayoutIgnorePendingStylesheets();
225 226
226 if (!willApplyEditing(source))
227 return false;
228
229 LocalFrame* frame = document().frame(); 227 LocalFrame* frame = document().frame();
230 DCHECK(frame); 228 DCHECK(frame);
231 EditingState editingState; 229 EditingState editingState;
232 { 230 {
233 EventQueueScope eventQueueScope; 231 EventQueueScope eventQueueScope;
234 doApply(&editingState); 232 doApply(&editingState);
235 } 233 }
236 234
237 // Only need to call appliedEditing for top-level commands, and TypingCommands 235 // Only need to call appliedEditing for top-level commands, and TypingCommands
238 // do it on their own (see TypingCommand::typingAddedToOpenCommand). 236 // do it on their own (see TypingCommand::typingAddedToOpenCommand).
239 if (!isTypingCommand()) 237 if (!isTypingCommand())
240 frame->editor().appliedEditing(this); 238 frame->editor().appliedEditing(this);
241 setShouldRetainAutocorrectionIndicator(false); 239 setShouldRetainAutocorrectionIndicator(false);
242 return !editingState.isAborted(); 240 return !editingState.isAborted();
243 } 241 }
244 242
245 EditCommandComposition* CompositeEditCommand::ensureComposition() { 243 EditCommandComposition* CompositeEditCommand::ensureComposition() {
246 CompositeEditCommand* command = this; 244 CompositeEditCommand* command = this;
247 while (command && command->parent()) 245 while (command && command->parent())
248 command = command->parent(); 246 command = command->parent();
249 if (!command->m_composition) 247 if (!command->m_composition)
250 command->m_composition = EditCommandComposition::create( 248 command->m_composition = EditCommandComposition::create(
251 &document(), startingSelection(), endingSelection(), inputType()); 249 &document(), startingSelection(), endingSelection(), inputType());
252 return command->m_composition.get(); 250 return command->m_composition.get();
253 } 251 }
254 252
255 bool CompositeEditCommand::willApplyEditing(EditCommandSource) {
256 // TODO(chongz): Move all the 'beforeinput' dispatching logic here.
257 return true;
258 }
259
260 bool CompositeEditCommand::preservesTypingStyle() const { 253 bool CompositeEditCommand::preservesTypingStyle() const {
261 return false; 254 return false;
262 } 255 }
263 256
264 bool CompositeEditCommand::isTypingCommand() const { 257 bool CompositeEditCommand::isTypingCommand() const {
265 return false; 258 return false;
266 } 259 }
267 260
268 bool CompositeEditCommand::isCommandGroupWrapper() const { 261 bool CompositeEditCommand::isCommandGroupWrapper() const {
269 return false; 262 return false;
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 return node; 2030 return node;
2038 } 2031 }
2039 2032
2040 DEFINE_TRACE(CompositeEditCommand) { 2033 DEFINE_TRACE(CompositeEditCommand) {
2041 visitor->trace(m_commands); 2034 visitor->trace(m_commands);
2042 visitor->trace(m_composition); 2035 visitor->trace(m_composition);
2043 EditCommand::trace(visitor); 2036 EditCommand::trace(visitor);
2044 } 2037 }
2045 2038
2046 } // namespace blink 2039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698