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

Side by Side Diff: third_party/WebKit/WebCore/editing/TypingCommand.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 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 | Annotate | Revision Log
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 { 366 {
367 applyCommandToComposite(BreakBlockquoteCommand::create(document())); 367 applyCommandToComposite(BreakBlockquoteCommand::create(document()));
368 typingAddedToOpenCommand(); 368 typingAddedToOpenCommand();
369 } 369 }
370 370
371 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing) 371 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
372 { 372 {
373 Selection selectionToDelete; 373 Selection selectionToDelete;
374 Selection selectionAfterUndo; 374 Selection selectionAfterUndo;
375 375
376 switch (endingSelection().state()) { 376 switch (endingSelection().selectionType()) {
377 case Selection::RANGE: 377 case Selection::RangeSelection:
378 selectionToDelete = endingSelection(); 378 selectionToDelete = endingSelection();
379 selectionAfterUndo = selectionToDelete; 379 selectionAfterUndo = selectionToDelete;
380 break; 380 break;
381 case Selection::CARET: { 381 case Selection::CaretSelection: {
382 if (breakOutOfEmptyMailBlockquotedParagraph()) { 382 if (breakOutOfEmptyMailBlockquotedParagraph()) {
383 typingAddedToOpenCommand(); 383 typingAddedToOpenCommand();
384 return; 384 return;
385 } 385 }
386 386
387 m_smartDelete = false; 387 m_smartDelete = false;
388 388
389 SelectionController selection; 389 SelectionController selection;
390 selection.setSelection(endingSelection()); 390 selection.setSelection(endingSelection());
391 selection.modify(SelectionController::EXTEND, SelectionController::B ACKWARD, granularity); 391 selection.modify(SelectionController::EXTEND, SelectionController::B ACKWARD, granularity);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 if (!startingSelection().isRange() || selectionToDelete.base() != st artingSelection().start()) 425 if (!startingSelection().isRange() || selectionToDelete.base() != st artingSelection().start())
426 selectionAfterUndo = selectionToDelete; 426 selectionAfterUndo = selectionToDelete;
427 else 427 else
428 // It's a little tricky to compute what the starting selection w ould have been in the original document. 428 // It's a little tricky to compute what the starting selection w ould have been in the original document.
429 // We can't let the Selection class's validation kick in or it'l l adjust for us based on 429 // We can't let the Selection class's validation kick in or it'l l adjust for us based on
430 // the current state of the document and we'll get the wrong res ult. 430 // the current state of the document and we'll get the wrong res ult.
431 selectionAfterUndo.setWithoutValidation(startingSelection().end( ), selectionToDelete.extent()); 431 selectionAfterUndo.setWithoutValidation(startingSelection().end( ), selectionToDelete.extent());
432 break; 432 break;
433 } 433 }
434 case Selection::NONE: 434 case Selection::NoSelection:
435 ASSERT_NOT_REACHED(); 435 ASSERT_NOT_REACHED();
436 break; 436 break;
437 } 437 }
438 438
439 if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteS election(selectionToDelete)) { 439 if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteS election(selectionToDelete)) {
440 if (killRing) 440 if (killRing)
441 document()->frame()->editor()->addToKillRing(selectionToDelete.toRan ge().get(), false); 441 document()->frame()->editor()->addToKillRing(selectionToDelete.toNor malizedRange().get(), false);
442 // Make undo select everything that has been deleted, unless an undo wil l undo more than just this deletion. 442 // Make undo select everything that has been deleted, unless an undo wil l undo more than just this deletion.
443 // FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete 443 // FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete
444 // more text than you insert. In that case all of the text that was aro und originally should be selected. 444 // more text than you insert. In that case all of the text that was aro und originally should be selected.
445 if (m_openedByBackwardDelete) 445 if (m_openedByBackwardDelete)
446 setStartingSelection(selectionAfterUndo); 446 setStartingSelection(selectionAfterUndo);
447 CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete); 447 CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
448 setSmartDelete(false); 448 setSmartDelete(false);
449 typingAddedToOpenCommand(); 449 typingAddedToOpenCommand();
450 } 450 }
451 } 451 }
452 452
453 void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool ki llRing) 453 void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool ki llRing)
454 { 454 {
455 Selection selectionToDelete; 455 Selection selectionToDelete;
456 Selection selectionAfterUndo; 456 Selection selectionAfterUndo;
457 457
458 switch (endingSelection().state()) { 458 switch (endingSelection().selectionType()) {
459 case Selection::RANGE: 459 case Selection::RangeSelection:
460 selectionToDelete = endingSelection(); 460 selectionToDelete = endingSelection();
461 selectionAfterUndo = selectionToDelete; 461 selectionAfterUndo = selectionToDelete;
462 break; 462 break;
463 case Selection::CARET: { 463 case Selection::CaretSelection: {
464 m_smartDelete = false; 464 m_smartDelete = false;
465 465
466 // Handle delete at beginning-of-block case. 466 // Handle delete at beginning-of-block case.
467 // Do nothing in the case that the caret is at the start of a 467 // Do nothing in the case that the caret is at the start of a
468 // root editable element or at the start of a document. 468 // root editable element or at the start of a document.
469 SelectionController selection; 469 SelectionController selection;
470 selection.setSelection(endingSelection()); 470 selection.setSelection(endingSelection());
471 selection.modify(SelectionController::EXTEND, SelectionController::F ORWARD, granularity); 471 selection.modify(SelectionController::EXTEND, SelectionController::F ORWARD, granularity);
472 if (killRing && selection.isCaret() && granularity != CharacterGranu larity) 472 if (killRing && selection.isCaret() && granularity != CharacterGranu larity)
473 selection.modify(SelectionController::EXTEND, SelectionControlle r::FORWARD, CharacterGranularity); 473 selection.modify(SelectionController::EXTEND, SelectionControlle r::FORWARD, CharacterGranularity);
(...skipping 28 matching lines...) Expand all
502 if (selectionToDelete.start().node() == selectionToDelete.en d().node()) 502 if (selectionToDelete.start().node() == selectionToDelete.en d().node())
503 extraCharacters = selectionToDelete.end().offset() - sel ectionToDelete.start().offset(); 503 extraCharacters = selectionToDelete.end().offset() - sel ectionToDelete.start().offset();
504 else 504 else
505 extraCharacters = selectionToDelete.end().offset(); 505 extraCharacters = selectionToDelete.end().offset();
506 extent = Position(extent.node(), extent.offset() + extraChar acters); 506 extent = Position(extent.node(), extent.offset() + extraChar acters);
507 } 507 }
508 selectionAfterUndo.setWithoutValidation(startingSelection().star t(), extent); 508 selectionAfterUndo.setWithoutValidation(startingSelection().star t(), extent);
509 } 509 }
510 break; 510 break;
511 } 511 }
512 case Selection::NONE: 512 case Selection::NoSelection:
513 ASSERT_NOT_REACHED(); 513 ASSERT_NOT_REACHED();
514 break; 514 break;
515 } 515 }
516 516
517 if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteS election(selectionToDelete)) { 517 if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteS election(selectionToDelete)) {
518 if (killRing) 518 if (killRing)
519 document()->frame()->editor()->addToKillRing(selectionToDelete.toRan ge().get(), false); 519 document()->frame()->editor()->addToKillRing(selectionToDelete.toNor malizedRange().get(), false);
520 // make undo select what was deleted 520 // make undo select what was deleted
521 setStartingSelection(selectionAfterUndo); 521 setStartingSelection(selectionAfterUndo);
522 CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete); 522 CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
523 setSmartDelete(false); 523 setSmartDelete(false);
524 typingAddedToOpenCommand(); 524 typingAddedToOpenCommand();
525 } 525 }
526 } 526 }
527 527
528 void TypingCommand::deleteSelection(bool smartDelete) 528 void TypingCommand::deleteSelection(bool smartDelete)
529 { 529 {
(...skipping 18 matching lines...) Expand all
548 return false; 548 return false;
549 } 549 }
550 550
551 bool TypingCommand::isTypingCommand() const 551 bool TypingCommand::isTypingCommand() const
552 { 552 {
553 return true; 553 return true;
554 } 554 }
555 555
556 } // namespace WebCore 556 } // namespace WebCore
557 557
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/editing/SelectionController.h ('k') | third_party/WebKit/WebCore/editing/htmlediting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698