Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 lastTypingCommand->deleteSelection(options & SmartDelete); | 103 lastTypingCommand->deleteSelection(options & SmartDelete); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 TypingCommand::create(document, DeleteSelection, "", options)->apply(); | 107 TypingCommand::create(document, DeleteSelection, "", options)->apply(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGr anularity granularity) | 110 void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGr anularity granularity) |
| 111 { | 111 { |
| 112 if (granularity == CharacterGranularity) { | 112 if (granularity == CharacterGranularity) { |
| 113 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(document.frame())) { | 113 Frame* frame = document.frame(); |
| 114 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get (), document.frame()); | 114 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(frame)) { |
|
yosin_UTC9
2013/11/15 10:22:22
lastTypingCommandIfStillOpenForTyping() should che
yosin_UTC9
2013/11/15 10:55:12
I'm wrong. Please ignore this comment.
| |
| 115 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSp ellChecking); | 115 // If the last typing command is not Delete, open a new typing comma nd. |
| 116 lastTypingCommand->deleteKeyPressed(granularity, options & KillRing) ; | 116 // We need to group continuous delete commands alone in a single typ ing command. |
| 117 return; | 117 if (lastTypingCommand->commandTypeOfOpenCommand() == DeleteKey) { |
| 118 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand .get(), frame); | |
| 119 lastTypingCommand->setShouldPreventSpellChecking(options & Preve ntSpellChecking); | |
| 120 lastTypingCommand->deleteKeyPressed(granularity, options & KillR ing); | |
| 121 return; | |
| 122 } | |
| 118 } | 123 } |
| 119 } | 124 } |
| 120 | 125 |
| 121 TypingCommand::create(document, DeleteKey, "", options, granularity)->apply( ); | 126 TypingCommand::create(document, DeleteKey, "", options, granularity)->apply( ); |
| 122 } | 127 } |
| 123 | 128 |
| 124 void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity) | 129 void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity) |
| 125 { | 130 { |
| 126 // FIXME: Forward delete in TextEdit appears to open and close a new typing command. | 131 // FIXME: Forward delete in TextEdit appears to open and close a new typing command. |
| 127 Frame* frame = document.frame(); | |
| 128 if (granularity == CharacterGranularity) { | 132 if (granularity == CharacterGranularity) { |
| 133 Frame* frame = document.frame(); | |
| 129 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(frame)) { | 134 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(frame)) { |
| 130 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get (), frame); | 135 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get (), frame); |
| 131 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSp ellChecking); | 136 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSp ellChecking); |
| 132 lastTypingCommand->forwardDeleteKeyPressed(granularity, options & Ki llRing); | 137 lastTypingCommand->forwardDeleteKeyPressed(granularity, options & Ki llRing); |
| 133 return; | 138 return; |
| 134 } | 139 } |
| 135 } | 140 } |
| 136 | 141 |
| 137 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply(); | 142 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply(); |
| 138 } | 143 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 } | 309 } |
| 305 } | 310 } |
| 306 | 311 |
| 307 void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedT yping) | 312 void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedT yping) |
| 308 { | 313 { |
| 309 Frame* frame = document().frame(); | 314 Frame* frame = document().frame(); |
| 310 if (!frame) | 315 if (!frame) |
| 311 return; | 316 return; |
| 312 | 317 |
| 313 updatePreservesTypingStyle(commandTypeForAddedTyping); | 318 updatePreservesTypingStyle(commandTypeForAddedTyping); |
| 319 updateCommandTypeOfOpenCommand(commandTypeForAddedTyping); | |
| 314 | 320 |
| 315 // The old spellchecking code requires that checking be done first, to preve nt issues like that in 6864072, where <doesn't> is marked as misspelled. | 321 // The old spellchecking code requires that checking be done first, to preve nt issues like that in 6864072, where <doesn't> is marked as misspelled. |
| 316 markMisspellingsAfterTyping(commandTypeForAddedTyping); | 322 markMisspellingsAfterTyping(commandTypeForAddedTyping); |
| 317 frame->editor().appliedEditing(this); | 323 frame->editor().appliedEditing(this); |
| 318 } | 324 } |
| 319 | 325 |
| 320 void TypingCommand::insertText(const String &text, bool selectInsertedText) | 326 void TypingCommand::insertText(const String &text, bool selectInsertedText) |
| 321 { | 327 { |
| 322 // FIXME: Need to implement selectInsertedText for cases where more than one insert is involved. | 328 // FIXME: Need to implement selectInsertedText for cases where more than one insert is involved. |
| 323 // This requires support from insertTextRunWithoutNewlines and insertParagra phSeparator for extending | 329 // This requires support from insertTextRunWithoutNewlines and insertParagra phSeparator for extending |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 ASSERT_NOT_REACHED(); | 615 ASSERT_NOT_REACHED(); |
| 610 m_preservesTypingStyle = false; | 616 m_preservesTypingStyle = false; |
| 611 } | 617 } |
| 612 | 618 |
| 613 bool TypingCommand::isTypingCommand() const | 619 bool TypingCommand::isTypingCommand() const |
| 614 { | 620 { |
| 615 return true; | 621 return true; |
| 616 } | 622 } |
| 617 | 623 |
| 618 } // namespace WebCore | 624 } // namespace WebCore |
| OLD | NEW |