| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 // Changes to the document may have been made since the last editing operati
on that require a layout, as in <rdar://problem/5658603>. | 198 // Changes to the document may have been made since the last editing operati
on that require a layout, as in <rdar://problem/5658603>. |
| 199 // Low level operations, like RemoveNodeCommand, don't require a layout beca
use the high level operations that use them perform one | 199 // Low level operations, like RemoveNodeCommand, don't require a layout beca
use the high level operations that use them perform one |
| 200 // if one is necessary (like for the creation of VisiblePositions). | 200 // if one is necessary (like for the creation of VisiblePositions). |
| 201 document().updateLayoutIgnorePendingStylesheets(); | 201 document().updateLayoutIgnorePendingStylesheets(); |
| 202 | 202 |
| 203 LocalFrame* frame = document().frame(); | 203 LocalFrame* frame = document().frame(); |
| 204 ASSERT(frame); | 204 ASSERT(frame); |
| 205 { | 205 { |
| 206 EventQueueScope eventQueueScope; | 206 EventQueueScope eventQueueScope; |
| 207 doApply(); | 207 EditingState editingState; |
| 208 doApply(&editingState); |
| 208 } | 209 } |
| 209 | 210 |
| 210 // Only need to call appliedEditing for top-level commands, | 211 // Only need to call appliedEditing for top-level commands, |
| 211 // and TypingCommands do it on their own (see TypingCommand::typingAddedToOp
enCommand). | 212 // and TypingCommands do it on their own (see TypingCommand::typingAddedToOp
enCommand). |
| 212 if (!isTypingCommand()) | 213 if (!isTypingCommand()) |
| 213 frame->editor().appliedEditing(this); | 214 frame->editor().appliedEditing(this); |
| 214 setShouldRetainAutocorrectionIndicator(false); | 215 setShouldRetainAutocorrectionIndicator(false); |
| 215 } | 216 } |
| 216 | 217 |
| 217 EditCommandComposition* CompositeEditCommand::ensureComposition() | 218 EditCommandComposition* CompositeEditCommand::ensureComposition() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 239 return false; | 240 return false; |
| 240 } | 241 } |
| 241 | 242 |
| 242 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) | 243 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) |
| 243 { | 244 { |
| 244 } | 245 } |
| 245 | 246 |
| 246 // | 247 // |
| 247 // sugary-sweet convenience functions to help create and apply edit commands in
composite commands | 248 // sugary-sweet convenience functions to help create and apply edit commands in
composite commands |
| 248 // | 249 // |
| 249 void CompositeEditCommand::applyCommandToComposite(PassRefPtrWillBeRawPtr<EditCo
mmand> prpCommand) | 250 void CompositeEditCommand::applyCommandToComposite(PassRefPtrWillBeRawPtr<EditCo
mmand> prpCommand, EditingState* editingState) |
| 250 { | 251 { |
| 251 RefPtrWillBeRawPtr<EditCommand> command = prpCommand; | 252 RefPtrWillBeRawPtr<EditCommand> command = prpCommand; |
| 252 command->setParent(this); | 253 command->setParent(this); |
| 253 command->doApply(); | 254 command->doApply(editingState); |
| 255 if (editingState->isAborted()) { |
| 256 command->setParent(nullptr); |
| 257 return; |
| 258 } |
| 254 if (command->isSimpleEditCommand()) { | 259 if (command->isSimpleEditCommand()) { |
| 255 command->setParent(0); | 260 command->setParent(0); |
| 256 ensureComposition()->append(toSimpleEditCommand(command.get())); | 261 ensureComposition()->append(toSimpleEditCommand(command.get())); |
| 257 } | 262 } |
| 258 m_commands.append(command.release()); | 263 m_commands.append(command.release()); |
| 259 } | 264 } |
| 260 | 265 |
| 261 void CompositeEditCommand::applyCommandToComposite(PassRefPtrWillBeRawPtr<Compos
iteEditCommand> command, const VisibleSelection& selection) | 266 void CompositeEditCommand::applyCommandToComposite(PassRefPtrWillBeRawPtr<Compos
iteEditCommand> command, const VisibleSelection& selection, EditingState* editin
gState) |
| 262 { | 267 { |
| 263 command->setParent(this); | 268 command->setParent(this); |
| 264 if (!equalSelectionsInDOMTree(selection, command->endingSelection())) { | 269 if (!equalSelectionsInDOMTree(selection, command->endingSelection())) { |
| 265 command->setStartingSelection(selection); | 270 command->setStartingSelection(selection); |
| 266 command->setEndingSelection(selection); | 271 command->setEndingSelection(selection); |
| 267 } | 272 } |
| 268 command->doApply(); | 273 command->doApply(editingState); |
| 269 m_commands.append(command); | 274 if (!editingState->isAborted()) |
| 275 m_commands.append(command); |
| 270 } | 276 } |
| 271 | 277 |
| 272 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditAction edit
ingAction) | 278 void CompositeEditCommand::applyStyle(const EditingStyle* style, EditAction edit
ingAction) |
| 273 { | 279 { |
| 274 applyCommandToComposite(ApplyStyleCommand::create(document(), style, editing
Action)); | 280 applyCommandToComposite(ApplyStyleCommand::create(document(), style, editing
Action)); |
| 275 } | 281 } |
| 276 | 282 |
| 277 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position&
start, const Position& end, EditAction editingAction) | 283 void CompositeEditCommand::applyStyle(const EditingStyle* style, const Position&
start, const Position& end, EditAction editingAction) |
| 278 { | 284 { |
| 279 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start,
end, editingAction)); | 285 applyCommandToComposite(ApplyStyleCommand::create(document(), style, start,
end, editingAction)); |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 } | 1513 } |
| 1508 | 1514 |
| 1509 DEFINE_TRACE(CompositeEditCommand) | 1515 DEFINE_TRACE(CompositeEditCommand) |
| 1510 { | 1516 { |
| 1511 visitor->trace(m_commands); | 1517 visitor->trace(m_commands); |
| 1512 visitor->trace(m_composition); | 1518 visitor->trace(m_composition); |
| 1513 EditCommand::trace(visitor); | 1519 EditCommand::trace(visitor); |
| 1514 } | 1520 } |
| 1515 | 1521 |
| 1516 } // namespace blink | 1522 } // namespace blink |
| OLD | NEW |