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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 } | 93 } |
94 | 94 |
95 void TypingCommand::deleteSelection(Document& document, Options options) | 95 void TypingCommand::deleteSelection(Document& document, Options options) |
96 { | 96 { |
97 LocalFrame* frame = document.frame(); | 97 LocalFrame* frame = document.frame(); |
98 ASSERT(frame); | 98 ASSERT(frame); |
99 | 99 |
100 if (!frame->selection().isRange()) | 100 if (!frame->selection().isRange()) |
101 return; | 101 return; |
102 | 102 |
103 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(frame)) { | 103 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(frame)) { |
104 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking); | 104 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking); |
105 lastTypingCommand->deleteSelection(options & SmartDelete); | 105 lastTypingCommand->deleteSelection(options & SmartDelete); |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 TypingCommand::create(document, DeleteSelection, "", options)->apply(); | 109 TypingCommand::create(document, DeleteSelection, "", options)->apply(); |
110 } | 110 } |
111 | 111 |
112 void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGr anularity granularity) | 112 void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGr anularity granularity) |
113 { | 113 { |
114 if (granularity == CharacterGranularity) { | 114 if (granularity == CharacterGranularity) { |
115 LocalFrame* frame = document.frame(); | 115 LocalFrame* frame = document.frame(); |
116 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(frame)) { | 116 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingComm andIfStillOpenForTyping(frame)) { |
117 // If the last typing command is not Delete, open a new typing comma nd. | 117 // If the last typing command is not Delete, open a new typing comma nd. |
118 // We need to group continuous delete commands alone in a single typ ing command. | 118 // We need to group continuous delete commands alone in a single typ ing command. |
119 if (lastTypingCommand->commandTypeOfOpenCommand() == DeleteKey) { | 119 if (lastTypingCommand->commandTypeOfOpenCommand() == DeleteKey) { |
120 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand .get(), frame); | 120 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand .get(), frame); |
121 lastTypingCommand->setShouldPreventSpellChecking(options & Preve ntSpellChecking); | 121 lastTypingCommand->setShouldPreventSpellChecking(options & Preve ntSpellChecking); |
122 lastTypingCommand->deleteKeyPressed(granularity, options & KillR ing); | 122 lastTypingCommand->deleteKeyPressed(granularity, options & KillR ing); |
123 return; | 123 return; |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 TypingCommand::create(document, DeleteKey, "", options, granularity)->apply( ); | 128 TypingCommand::create(document, DeleteKey, "", options, granularity)->apply( ); |
129 } | 129 } |
130 | 130 |
131 void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity) | 131 void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity) |
132 { | 132 { |
133 // FIXME: Forward delete in TextEdit appears to open and close a new typing command. | 133 // FIXME: Forward delete in TextEdit appears to open and close a new typing command. |
134 if (granularity == CharacterGranularity) { | 134 if (granularity == CharacterGranularity) { |
135 LocalFrame* frame = document.frame(); | 135 LocalFrame* frame = document.frame(); |
136 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOp enForTyping(frame)) { | 136 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingComm andIfStillOpenForTyping(frame)) { |
137 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get (), frame); | 137 updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get (), frame); |
138 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSp ellChecking); | 138 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSp ellChecking); |
139 lastTypingCommand->forwardDeleteKeyPressed(granularity, options & Ki llRing); | 139 lastTypingCommand->forwardDeleteKeyPressed(granularity, options & Ki llRing); |
140 return; | 140 return; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply(); | 144 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply(); |
145 } | 145 } |
146 | 146 |
(...skipping 25 matching lines...) Expand all Loading... | |
172 RefPtr<LocalFrame> frame = document.frame(); | 172 RefPtr<LocalFrame> frame = document.frame(); |
173 ASSERT(frame); | 173 ASSERT(frame); |
174 | 174 |
175 VisibleSelection currentSelection = frame->selection().selection(); | 175 VisibleSelection currentSelection = frame->selection().selection(); |
176 | 176 |
177 String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion , compositionType == TextCompositionUpdate); | 177 String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion , compositionType == TextCompositionUpdate); |
178 | 178 |
179 // Set the starting and ending selection appropriately if we are using a sel ection | 179 // Set the starting and ending selection appropriately if we are using a sel ection |
180 // that is different from the current selection. In the future, we should c hange EditCommand | 180 // that is different from the current selection. In the future, we should c hange EditCommand |
181 // to deal with custom selections in a general way that can be used by all o f the commands. | 181 // to deal with custom selections in a general way that can be used by all o f the commands. |
182 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(frame.get())) { | 182 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(frame.get())) { |
183 if (lastTypingCommand->endingSelection() != selectionForInsertion) { | 183 if (lastTypingCommand->endingSelection() != selectionForInsertion) { |
184 lastTypingCommand->setStartingSelection(selectionForInsertion); | 184 lastTypingCommand->setStartingSelection(selectionForInsertion); |
185 lastTypingCommand->setEndingSelection(selectionForInsertion); | 185 lastTypingCommand->setEndingSelection(selectionForInsertion); |
186 } | 186 } |
187 | 187 |
188 lastTypingCommand->setCompositionType(compositionType); | 188 lastTypingCommand->setCompositionType(compositionType); |
189 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); | 189 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); |
190 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking); | 190 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking); |
191 lastTypingCommand->insertText(newText, options & SelectInsertedText); | 191 lastTypingCommand->insertText(newText, options & SelectInsertedText); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 RefPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newT ext, options, compositionType); | 195 RefPtrWillBeRawPtr<TypingCommand> cmd = TypingCommand::create(document, Inse rtText, newText, options, compositionType); |
196 applyTextInsertionCommand(frame.get(), cmd, selectionForInsertion, currentSe lection); | 196 applyTextInsertionCommand(frame.get(), cmd, selectionForInsertion, currentSe lection); |
197 } | 197 } |
198 | 198 |
199 void TypingCommand::insertLineBreak(Document& document, Options options) | 199 void TypingCommand::insertLineBreak(Document& document, Options options) |
200 { | 200 { |
201 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(document.frame())) { | 201 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(document.frame())) { |
202 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); | 202 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); |
203 lastTypingCommand->insertLineBreak(); | 203 lastTypingCommand->insertLineBreak(); |
204 return; | 204 return; |
205 } | 205 } |
206 | 206 |
207 TypingCommand::create(document, InsertLineBreak, "", options)->apply(); | 207 TypingCommand::create(document, InsertLineBreak, "", options)->apply(); |
208 } | 208 } |
209 | 209 |
210 void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document) | 210 void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document) |
211 { | 211 { |
212 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(document.frame())) { | 212 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(document.frame())) { |
213 lastTypingCommand->insertParagraphSeparatorInQuotedContent(); | 213 lastTypingCommand->insertParagraphSeparatorInQuotedContent(); |
214 return; | 214 return; |
215 } | 215 } |
216 | 216 |
217 TypingCommand::create(document, InsertParagraphSeparatorInQuotedContent)->ap ply(); | 217 TypingCommand::create(document, InsertParagraphSeparatorInQuotedContent)->ap ply(); |
218 } | 218 } |
219 | 219 |
220 void TypingCommand::insertParagraphSeparator(Document& document, Options options ) | 220 void TypingCommand::insertParagraphSeparator(Document& document, Options options ) |
221 { | 221 { |
222 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(document.frame())) { | 222 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(document.frame())) { |
223 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); | 223 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); |
224 lastTypingCommand->insertParagraphSeparator(); | 224 lastTypingCommand->insertParagraphSeparator(); |
225 return; | 225 return; |
226 } | 226 } |
227 | 227 |
228 TypingCommand::create(document, InsertParagraphSeparator, "", options)->appl y(); | 228 TypingCommand::create(document, InsertParagraphSeparator, "", options)->appl y(); |
229 } | 229 } |
230 | 230 |
231 PassRefPtr<TypingCommand> TypingCommand::lastTypingCommandIfStillOpenForTyping(L ocalFrame* frame) | 231 PassRefPtrWillBeRawPtr<TypingCommand> TypingCommand::lastTypingCommandIfStillOpe nForTyping(LocalFrame* frame) |
232 { | 232 { |
233 ASSERT(frame); | 233 ASSERT(frame); |
234 | 234 |
235 RefPtr<CompositeEditCommand> lastEditCommand = frame->editor().lastEditComma nd(); | 235 RefPtrWillBeRawPtr<CompositeEditCommand> lastEditCommand = frame->editor().l astEditCommand(); |
236 if (!lastEditCommand || !lastEditCommand->isTypingCommand() || !static_cast< TypingCommand*>(lastEditCommand.get())->isOpenForMoreTyping()) | 236 if (!lastEditCommand || !lastEditCommand->isTypingCommand() || !static_cast< TypingCommand*>(lastEditCommand.get())->isOpenForMoreTyping()) |
237 return nullptr; | 237 return nullptr; |
238 | 238 |
239 return static_cast<TypingCommand*>(lastEditCommand.get()); | 239 return static_cast<TypingCommand*>(lastEditCommand.get()); |
240 } | 240 } |
241 | 241 |
242 void TypingCommand::closeTyping(LocalFrame* frame) | 242 void TypingCommand::closeTyping(LocalFrame* frame) |
243 { | 243 { |
244 if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenFo rTyping(frame)) | 244 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(frame)) |
245 lastTypingCommand->closeTyping(); | 245 lastTypingCommand->closeTyping(); |
246 } | 246 } |
247 | 247 |
248 void TypingCommand::doApply() | 248 void TypingCommand::doApply() |
249 { | 249 { |
250 if (!endingSelection().isNonOrphanedCaretOrRange()) | 250 if (!endingSelection().isNonOrphanedCaretOrRange()) |
251 return; | 251 return; |
252 | 252 |
253 if (m_commandType == DeleteKey) | 253 if (m_commandType == DeleteKey) |
254 if (m_commands.isEmpty()) | 254 if (m_commands.isEmpty()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 // This requires support from insertTextRunWithoutNewlines and insertParagra phSeparator for extending | 331 // This requires support from insertTextRunWithoutNewlines and insertParagra phSeparator for extending |
332 // an existing selection; at the moment they can either put the caret after what's inserted or | 332 // an existing selection; at the moment they can either put the caret after what's inserted or |
333 // select what's inserted, but there's no way to "extend selection" to inclu de both an old selection | 333 // select what's inserted, but there's no way to "extend selection" to inclu de both an old selection |
334 // that ends just before where we want to insert text and the newly inserted text. | 334 // that ends just before where we want to insert text and the newly inserted text. |
335 TypingCommandLineOperation operation(this, selectInsertedText, text); | 335 TypingCommandLineOperation operation(this, selectInsertedText, text); |
336 forEachLineInString(text, operation); | 336 forEachLineInString(text, operation); |
337 } | 337 } |
338 | 338 |
339 void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool select InsertedText) | 339 void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool select InsertedText) |
340 { | 340 { |
341 RefPtr<InsertTextCommand> command = InsertTextCommand::create(document(), te xt, selectInsertedText, | 341 RefPtrWillBeRawPtr<InsertTextCommand> command = InsertTextCommand::create(do cument(), text, selectInsertedText, |
342 m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceL eadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces); | 342 m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceL eadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces); |
343 | 343 |
344 applyCommandToComposite(command, endingSelection()); | 344 applyCommandToComposite(command, endingSelection()); |
345 | 345 |
346 typingAddedToOpenCommand(InsertText); | 346 typingAddedToOpenCommand(InsertText); |
347 } | 347 } |
348 | 348 |
349 void TypingCommand::insertLineBreak() | 349 void TypingCommand::insertLineBreak() |
350 { | 350 { |
351 if (!canAppendNewLineFeedToSelection(endingSelection())) | 351 if (!canAppendNewLineFeedToSelection(endingSelection())) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 selectionAfterUndo = selectionToDelete; | 418 selectionAfterUndo = selectionToDelete; |
419 break; | 419 break; |
420 case CaretSelection: { | 420 case CaretSelection: { |
421 // After breaking out of an empty mail blockquote, we still want continu e with the deletion | 421 // After breaking out of an empty mail blockquote, we still want continu e with the deletion |
422 // so actual content will get deleted, and not just the quote style. | 422 // so actual content will get deleted, and not just the quote style. |
423 if (breakOutOfEmptyMailBlockquotedParagraph()) | 423 if (breakOutOfEmptyMailBlockquotedParagraph()) |
424 typingAddedToOpenCommand(DeleteKey); | 424 typingAddedToOpenCommand(DeleteKey); |
425 | 425 |
426 m_smartDelete = false; | 426 m_smartDelete = false; |
427 | 427 |
428 FrameSelection selection; | 428 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create(); |
haraken
2014/05/26 02:36:12
Just to confirm: Does the plugin detect the error
zerny-chromium
2014/05/26 07:51:08
The plugin cannot check against the use of OwnPtr
| |
429 selection.setSelection(endingSelection()); | 429 selection->setSelection(endingSelection()); |
430 selection.modify(FrameSelection::AlterationExtend, DirectionBackward, gr anularity); | 430 selection->modify(FrameSelection::AlterationExtend, DirectionBackward, g ranularity); |
431 if (killRing && selection.isCaret() && granularity != CharacterGranulari ty) | 431 if (killRing && selection->isCaret() && granularity != CharacterGranular ity) |
432 selection.modify(FrameSelection::AlterationExtend, DirectionBackward , CharacterGranularity); | 432 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, CharacterGranularity); |
433 | 433 |
434 VisiblePosition visibleStart(endingSelection().visibleStart()); | 434 VisiblePosition visibleStart(endingSelection().visibleStart()); |
435 if (visibleStart.previous(CannotCrossEditingBoundary).isNull()) { | 435 if (visibleStart.previous(CannotCrossEditingBoundary).isNull()) { |
436 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item. | 436 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item. |
437 if (breakOutOfEmptyListItem()) { | 437 if (breakOutOfEmptyListItem()) { |
438 typingAddedToOpenCommand(DeleteKey); | 438 typingAddedToOpenCommand(DeleteKey); |
439 return; | 439 return; |
440 } | 440 } |
441 // When there are no visible positions in the editing root, delete i ts entire contents. | 441 // When there are no visible positions in the editing root, delete i ts entire contents. |
442 if (visibleStart.next(CannotCrossEditingBoundary).isNull() && makeEd itableRootEmpty()) { | 442 if (visibleStart.next(CannotCrossEditingBoundary).isNull() && makeEd itableRootEmpty()) { |
443 typingAddedToOpenCommand(DeleteKey); | 443 typingAddedToOpenCommand(DeleteKey); |
444 return; | 444 return; |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 // If we have a caret selection at the beginning of a cell, we have noth ing to do. | 448 // If we have a caret selection at the beginning of a cell, we have noth ing to do. |
449 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell); | 449 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell); |
450 if (enclosingTableCell && visibleStart == VisiblePosition(firstPositionI nNode(enclosingTableCell))) | 450 if (enclosingTableCell && visibleStart == VisiblePosition(firstPositionI nNode(enclosingTableCell))) |
451 return; | 451 return; |
452 | 452 |
453 // If the caret is at the start of a paragraph after a table, move conte nt into the last table cell. | 453 // If the caret is at the start of a paragraph after a table, move conte nt into the last table cell. |
454 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl eStart.previous(CannotCrossEditingBoundary))) { | 454 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl eStart.previous(CannotCrossEditingBoundary))) { |
455 // Unless the caret is just before a table. We don't want to move a table into the last table cell. | 455 // Unless the caret is just before a table. We don't want to move a table into the last table cell. |
456 if (isLastPositionBeforeTable(visibleStart)) | 456 if (isLastPositionBeforeTable(visibleStart)) |
457 return; | 457 return; |
458 // Extend the selection backward into the last cell, then deletion w ill handle the move. | 458 // Extend the selection backward into the last cell, then deletion w ill handle the move. |
459 selection.modify(FrameSelection::AlterationExtend, DirectionBackward , granularity); | 459 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, granularity); |
460 // If the caret is just after a table, select the table and don't delete anything. | 460 // If the caret is just after a table, select the table and don't delete anything. |
461 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { | 461 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { |
462 setEndingSelection(VisibleSelection(positionBeforeNode(table), endin gSelection().start(), DOWNSTREAM, endingSelection().isDirectional())); | 462 setEndingSelection(VisibleSelection(positionBeforeNode(table), endin gSelection().start(), DOWNSTREAM, endingSelection().isDirectional())); |
463 typingAddedToOpenCommand(DeleteKey); | 463 typingAddedToOpenCommand(DeleteKey); |
464 return; | 464 return; |
465 } | 465 } |
466 | 466 |
467 selectionToDelete = selection.selection(); | 467 selectionToDelete = selection->selection(); |
468 | 468 |
469 if (granularity == CharacterGranularity && selectionToDelete.end().conta inerNode() == selectionToDelete.start().containerNode() | 469 if (granularity == CharacterGranularity && selectionToDelete.end().conta inerNode() == selectionToDelete.start().containerNode() |
470 && selectionToDelete.end().computeOffsetInContainerNode() - selectio nToDelete.start().computeOffsetInContainerNode() > 1) { | 470 && selectionToDelete.end().computeOffsetInContainerNode() - selectio nToDelete.start().computeOffsetInContainerNode() > 1) { |
471 // If there are multiple Unicode code points to be deleted, adjust t he range to match platform conventions. | 471 // If there are multiple Unicode code points to be deleted, adjust t he range to match platform conventions. |
472 selectionToDelete.setWithoutValidation(selectionToDelete.end(), sele ctionToDelete.end().previous(BackwardDeletion)); | 472 selectionToDelete.setWithoutValidation(selectionToDelete.end(), sele ctionToDelete.end().previous(BackwardDeletion)); |
473 } | 473 } |
474 | 474 |
475 if (!startingSelection().isRange() || selectionToDelete.base() != starti ngSelection().start()) | 475 if (!startingSelection().isRange() || selectionToDelete.base() != starti ngSelection().start()) |
476 selectionAfterUndo = selectionToDelete; | 476 selectionAfterUndo = selectionToDelete; |
477 else | 477 else |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 case RangeSelection: | 520 case RangeSelection: |
521 selectionToDelete = endingSelection(); | 521 selectionToDelete = endingSelection(); |
522 selectionAfterUndo = selectionToDelete; | 522 selectionAfterUndo = selectionToDelete; |
523 break; | 523 break; |
524 case CaretSelection: { | 524 case CaretSelection: { |
525 m_smartDelete = false; | 525 m_smartDelete = false; |
526 | 526 |
527 // Handle delete at beginning-of-block case. | 527 // Handle delete at beginning-of-block case. |
528 // Do nothing in the case that the caret is at the start of a | 528 // Do nothing in the case that the caret is at the start of a |
529 // root editable element or at the start of a document. | 529 // root editable element or at the start of a document. |
530 FrameSelection selection; | 530 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create(); |
531 selection.setSelection(endingSelection()); | 531 selection->setSelection(endingSelection()); |
532 selection.modify(FrameSelection::AlterationExtend, DirectionForward, gra nularity); | 532 selection->modify(FrameSelection::AlterationExtend, DirectionForward, gr anularity); |
533 if (killRing && selection.isCaret() && granularity != CharacterGranulari ty) | 533 if (killRing && selection->isCaret() && granularity != CharacterGranular ity) |
534 selection.modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity); | 534 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity); |
535 | 535 |
536 Position downstreamEnd = endingSelection().end().downstream(); | 536 Position downstreamEnd = endingSelection().end().downstream(); |
537 VisiblePosition visibleEnd = endingSelection().visibleEnd(); | 537 VisiblePosition visibleEnd = endingSelection().visibleEnd(); |
538 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent (), &isTableCell); | 538 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent (), &isTableCell); |
539 if (enclosingTableCell && visibleEnd == VisiblePosition(lastPositionInNo de(enclosingTableCell))) | 539 if (enclosingTableCell && visibleEnd == VisiblePosition(lastPositionInNo de(enclosingTableCell))) |
540 return; | 540 return; |
541 if (visibleEnd == endOfParagraph(visibleEnd)) | 541 if (visibleEnd == endOfParagraph(visibleEnd)) |
542 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui valent().downstream(); | 542 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui valent().downstream(); |
543 // When deleting tables: Select the table first, then perform the deleti on | 543 // When deleting tables: Select the table first, then perform the deleti on |
544 if (isRenderedTable(downstreamEnd.containerNode()) && downstreamEnd.comp uteOffsetInContainerNode() <= caretMinOffset(downstreamEnd.containerNode())) { | 544 if (isRenderedTable(downstreamEnd.containerNode()) && downstreamEnd.comp uteOffsetInContainerNode() <= caretMinOffset(downstreamEnd.containerNode())) { |
545 setEndingSelection(VisibleSelection(endingSelection().end(), positio nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec tional())); | 545 setEndingSelection(VisibleSelection(endingSelection().end(), positio nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec tional())); |
546 typingAddedToOpenCommand(ForwardDeleteKey); | 546 typingAddedToOpenCommand(ForwardDeleteKey); |
547 return; | 547 return; |
548 } | 548 } |
549 | 549 |
550 // deleting to end of paragraph when at end of paragraph needs to merge the next paragraph (if any) | 550 // deleting to end of paragraph when at end of paragraph needs to merge the next paragraph (if any) |
551 if (granularity == ParagraphBoundary && selection.selection().isCaret() && isEndOfParagraph(selection.selection().visibleEnd())) | 551 if (granularity == ParagraphBoundary && selection->selection().isCaret() && isEndOfParagraph(selection->selection().visibleEnd())) |
552 selection.modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity); | 552 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity); |
553 | 553 |
554 selectionToDelete = selection.selection(); | 554 selectionToDelete = selection->selection(); |
555 if (!startingSelection().isRange() || selectionToDelete.base() != starti ngSelection().start()) | 555 if (!startingSelection().isRange() || selectionToDelete.base() != starti ngSelection().start()) |
556 selectionAfterUndo = selectionToDelete; | 556 selectionAfterUndo = selectionToDelete; |
557 else { | 557 else { |
558 // It's a little tricky to compute what the starting selection would have been in the original document. | 558 // It's a little tricky to compute what the starting selection would have been in the original document. |
559 // We can't let the VisibleSelection class's validation kick in or i t'll adjust for us based on | 559 // We can't let the VisibleSelection class's validation kick in or i t'll adjust for us based on |
560 // the current state of the document and we'll get the wrong result. | 560 // the current state of the document and we'll get the wrong result. |
561 Position extent = startingSelection().end(); | 561 Position extent = startingSelection().end(); |
562 if (extent.containerNode() != selectionToDelete.end().containerNode( )) | 562 if (extent.containerNode() != selectionToDelete.end().containerNode( )) |
563 extent = selectionToDelete.extent(); | 563 extent = selectionToDelete.extent(); |
564 else { | 564 else { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 ASSERT_NOT_REACHED(); | 619 ASSERT_NOT_REACHED(); |
620 m_preservesTypingStyle = false; | 620 m_preservesTypingStyle = false; |
621 } | 621 } |
622 | 622 |
623 bool TypingCommand::isTypingCommand() const | 623 bool TypingCommand::isTypingCommand() const |
624 { | 624 { |
625 return true; | 625 return true; |
626 } | 626 } |
627 | 627 |
628 } // namespace WebCore | 628 } // namespace WebCore |
OLD | NEW |