OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::P reventNesting | ReplaceSelectionCommand::SanitizeFragment; | 502 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::P reventNesting | ReplaceSelectionCommand::SanitizeFragment; |
503 if (selectReplacement) | 503 if (selectReplacement) |
504 options |= ReplaceSelectionCommand::SelectReplacement; | 504 options |= ReplaceSelectionCommand::SelectReplacement; |
505 if (smartReplace) | 505 if (smartReplace) |
506 options |= ReplaceSelectionCommand::SmartReplace; | 506 options |= ReplaceSelectionCommand::SmartReplace; |
507 if (matchStyle) | 507 if (matchStyle) |
508 options |= ReplaceSelectionCommand::MatchStyle; | 508 options |= ReplaceSelectionCommand::MatchStyle; |
509 ASSERT(frame().document()); | 509 ASSERT(frame().document()); |
510 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Edit ActionPaste)->apply(); | 510 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Edit ActionPaste)->apply(); |
511 revealSelectionAfterEditingOperation(); | 511 revealSelectionAfterEditingOperation(); |
512 | |
513 if (frame().selection().isInPasswordField() || !spellChecker().isContinuousS pellCheckingEnabled()) | |
514 return; | |
515 ASSERT(lastEditCommand()->isReplaceSelectionCommand()); | |
516 const EphemeralRange& insertedRange = toReplaceSelectionCommand(lastEditComm and())->insertedRange(); | |
517 if (insertedRange.isNull()) | |
518 return; | |
519 spellChecker().chunkAndMarkAllMisspellingsAndBadGrammar(frame().selection(). rootEditableElement(), insertedRange); | |
520 } | 512 } |
521 | 513 |
522 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement , bool smartReplace) | 514 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement , bool smartReplace) |
523 { | 515 { |
524 replaceSelectionWithFragment(createFragmentFromText(selectedRange(), text), selectReplacement, smartReplace, true); | 516 replaceSelectionWithFragment(createFragmentFromText(selectedRange(), text), selectReplacement, smartReplace, true); |
525 } | 517 } |
526 | 518 |
527 EphemeralRange Editor::selectedRange() | 519 EphemeralRange Editor::selectedRange() |
528 { | 520 { |
529 return frame().selection().selection().toNormalizedEphemeralRange(); | 521 return frame().selection().selection().toNormalizedEphemeralRange(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 startRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableCon tentChanged)); | 643 startRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableCon tentChanged)); |
652 if (endRoot && endRoot != startRoot) | 644 if (endRoot && endRoot != startRoot) |
653 endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableConte ntChanged)); | 645 endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableConte ntChanged)); |
654 } | 646 } |
655 | 647 |
656 void Editor::appliedEditing(PassRefPtrWillBeRawPtr<CompositeEditCommand> cmd) | 648 void Editor::appliedEditing(PassRefPtrWillBeRawPtr<CompositeEditCommand> cmd) |
657 { | 649 { |
658 EventQueueScope scope; | 650 EventQueueScope scope; |
659 frame().document()->updateLayout(); | 651 frame().document()->updateLayout(); |
660 | 652 |
653 // Need to request spell checking after pasting, which must be done before | |
654 // any further DOM change. | |
655 // Note: We enter this branch for and only for |ReplaceSelectionCommand|s | |
656 // created in |Editor::replaceSelectionWithFragment()|. | |
657 if (cmd->editingAction() == EditActionPaste) { | |
yosin_UTC9
2016/01/27 02:06:43
Can we have a function |Editor::requestSpellChecki
Xiaocheng
2016/01/27 02:49:10
Good point, I'll move them to a separate function.
| |
658 ASSERT(cmd->isReplaceSelectionCommand()); | |
659 if (!frame().selection().isInPasswordField() && spellChecker().isContinu ousSpellCheckingEnabled()) { | |
660 const EphemeralRange& insertedRange = toReplaceSelectionCommand(cmd. get())->insertedRange(); | |
661 if (insertedRange.isNotNull()) | |
662 spellChecker().chunkAndMarkAllMisspellingsAndBadGrammar(cmd->end ingSelection().rootEditableElement(), insertedRange); | |
663 } | |
664 } | |
665 | |
661 EditCommandComposition* composition = cmd->composition(); | 666 EditCommandComposition* composition = cmd->composition(); |
662 ASSERT(composition); | 667 ASSERT(composition); |
663 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement()); | 668 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement()); |
664 VisibleSelection newSelection(cmd->endingSelection()); | 669 VisibleSelection newSelection(cmd->endingSelection()); |
665 | 670 |
666 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary. | 671 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary. |
667 changeSelectionAfterCommand(newSelection, 0); | 672 changeSelectionAfterCommand(newSelection, 0); |
668 | 673 |
669 if (!cmd->preservesTypingStyle()) | 674 if (!cmd->preservesTypingStyle()) |
670 frame().selection().clearTypingStyle(); | 675 frame().selection().clearTypingStyle(); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 } | 1309 } |
1305 | 1310 |
1306 DEFINE_TRACE(Editor) | 1311 DEFINE_TRACE(Editor) |
1307 { | 1312 { |
1308 visitor->trace(m_frame); | 1313 visitor->trace(m_frame); |
1309 visitor->trace(m_lastEditCommand); | 1314 visitor->trace(m_lastEditCommand); |
1310 visitor->trace(m_mark); | 1315 visitor->trace(m_mark); |
1311 } | 1316 } |
1312 | 1317 |
1313 } // namespace blink | 1318 } // namespace blink |
OLD | NEW |