Chromium Code Reviews| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 spellCheckerClient().showSpellingUI(true); | 330 spellCheckerClient().showSpellingUI(true); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void SpellChecker::clearMisspellingsAndBadGrammar(const VisibleSelection &moving Selection) | 333 void SpellChecker::clearMisspellingsAndBadGrammar(const VisibleSelection &moving Selection) |
| 334 { | 334 { |
| 335 removeMarkers(movingSelection, DocumentMarker::MisspellingMarkers()); | 335 removeMarkers(movingSelection, DocumentMarker::MisspellingMarkers()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS election) | 338 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS election) |
| 339 { | 339 { |
| 340 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab led(), movingSelection); | 340 if (unifiedTextCheckerEnabled()) { |
| 341 if (!isContinuousSpellCheckingEnabled()) | |
| 342 return; | |
| 343 | |
| 344 // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling, but don't autocorrect misspellings. | |
|
yosin_UTC9
2016/08/02 07:38:15
OPTIONAL: Could you format comments in 80 chars pe
Xiaocheng
2016/08/02 07:40:00
All right. I'll do it in the next patch.
| |
| 345 markAllMisspellingsInRange(movingSelection.toNormalizedEphemeralRange()) ; | |
| 346 return; | |
| 347 } | |
| 348 | |
| 349 markMisspellings(movingSelection); | |
| 341 } | 350 } |
| 342 | 351 |
| 343 void SpellChecker::markMisspellingsAfterLineBreak(const VisibleSelection& wordSe lection) | 352 void SpellChecker::markMisspellingsAfterLineBreak(const VisibleSelection& wordSe lection) |
| 344 { | 353 { |
| 345 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterLineBreak"); | 354 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterLineBreak"); |
| 346 | 355 |
| 347 if (!unifiedTextCheckerEnabled()) { | 356 if (!unifiedTextCheckerEnabled()) { |
| 348 markMisspellings(wordSelection); | 357 markMisspellings(wordSelection); |
| 349 return; | 358 return; |
| 350 } | 359 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 if (adjustSelectionForParagraphBoundaries) | 629 if (adjustSelectionForParagraphBoundaries) |
| 621 frame().selection().modify(FrameSelection::AlterationMove, Direc tionForward, CharacterGranularity); | 630 frame().selection().modify(FrameSelection::AlterationMove, Direc tionForward, CharacterGranularity); |
| 622 } else { | 631 } else { |
| 623 // If this fails for any reason, the fallback is to go one position beyond the last replacement | 632 // If this fails for any reason, the fallback is to go one position beyond the last replacement |
| 624 frame().selection().moveTo(frame().selection().selection().visibleEn d()); | 633 frame().selection().moveTo(frame().selection().selection().visibleEn d()); |
| 625 frame().selection().modify(FrameSelection::AlterationMove, Direction Forward, CharacterGranularity); | 634 frame().selection().modify(FrameSelection::AlterationMove, Direction Forward, CharacterGranularity); |
| 626 } | 635 } |
| 627 } | 636 } |
| 628 } | 637 } |
| 629 | 638 |
| 630 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& spellin gSelection, bool markGrammar, const VisibleSelection& grammarSelection) | |
| 631 { | |
| 632 if (unifiedTextCheckerEnabled()) { | |
| 633 if (!isContinuousSpellCheckingEnabled()) | |
| 634 return; | |
| 635 | |
| 636 // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling and grammar, but don't autocorrect misspellings. | |
| 637 markAllMisspellingsInRange(spellingSelection.toNormalizedEphemeralRange( )); | |
| 638 return; | |
| 639 } | |
| 640 | |
| 641 markMisspellings(spellingSelection); | |
| 642 } | |
| 643 | |
| 644 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele ctionAtWordBoundary) | 639 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele ctionAtWordBoundary) |
| 645 { | 640 { |
| 646 DCHECK(frame().selection().isAvailable()); | 641 DCHECK(frame().selection().isAvailable()); |
| 647 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing" ); | 642 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing" ); |
| 648 if (!isSpellCheckingEnabledFor(frame().selection().selection())) | 643 if (!isSpellCheckingEnabledFor(frame().selection().selection())) |
| 649 return; | 644 return; |
| 650 | 645 |
| 651 // We want to remove the markers from a word if an editing command will chan ge the word. This can happen in one of | 646 // We want to remove the markers from a word if an editing command will chan ge the word. This can happen in one of |
| 652 // several scenarios: | 647 // several scenarios: |
| 653 // 1. Insert in the middle of a word. | 648 // 1. Insert in the middle of a word. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 } | 830 } |
| 836 | 831 |
| 837 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords) | 832 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords) |
| 838 { | 833 { |
| 839 TRACE_EVENT0("blink", "SpellChecker::spellCheckOldSelection"); | 834 TRACE_EVENT0("blink", "SpellChecker::spellCheckOldSelection"); |
| 840 | 835 |
| 841 VisiblePosition oldStart(oldSelection.visibleStart()); | 836 VisiblePosition oldStart(oldSelection.visibleStart()); |
| 842 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); | 837 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); |
| 843 if (oldAdjacentWords == newAdjacentWords) | 838 if (oldAdjacentWords == newAdjacentWords) |
| 844 return; | 839 return; |
| 845 if (isContinuousSpellCheckingEnabled()) { | 840 markMisspellingsAndBadGrammar(oldAdjacentWords); |
| 846 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(old Start), endOfSentence(oldStart)); | |
| 847 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSentence); | |
| 848 return; | |
| 849 } | |
| 850 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWords); | |
| 851 } | 841 } |
| 852 | 842 |
| 853 static Node* findFirstMarkable(Node* node) | 843 static Node* findFirstMarkable(Node* node) |
| 854 { | 844 { |
| 855 while (node) { | 845 while (node) { |
| 856 if (!node->layoutObject()) | 846 if (!node->layoutObject()) |
| 857 return 0; | 847 return 0; |
| 858 if (node->layoutObject()->isText()) | 848 if (node->layoutObject()->isText()) |
| 859 return node; | 849 return node; |
| 860 if (node->layoutObject()->isTextControl()) | 850 if (node->layoutObject()->isTextControl()) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 visitor->trace(m_frame); | 924 visitor->trace(m_frame); |
| 935 visitor->trace(m_spellCheckRequester); | 925 visitor->trace(m_spellCheckRequester); |
| 936 } | 926 } |
| 937 | 927 |
| 938 void SpellChecker::prepareForLeakDetection() | 928 void SpellChecker::prepareForLeakDetection() |
| 939 { | 929 { |
| 940 m_spellCheckRequester->prepareForLeakDetection(); | 930 m_spellCheckRequester->prepareForLeakDetection(); |
| 941 } | 931 } |
| 942 | 932 |
| 943 } // namespace blink | 933 } // namespace blink |
| OLD | NEW |