| 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 return; | 672 return; |
| 673 } | 673 } |
| 674 | 674 |
| 675 markMisspellings(spellingSelection); | 675 markMisspellings(spellingSelection); |
| 676 if (markGrammar) | 676 if (markGrammar) |
| 677 markBadGrammar(grammarSelection); | 677 markBadGrammar(grammarSelection); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele
ctionAtWordBoundary) | 680 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele
ctionAtWordBoundary) |
| 681 { | 681 { |
| 682 DCHECK(frame().selection().isAvailable()); |
| 682 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing"
); | 683 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing"
); |
| 683 if (!isSpellCheckingEnabledFor(frame().selection().selection())) | 684 if (!isSpellCheckingEnabledFor(frame().selection().selection())) |
| 684 return; | 685 return; |
| 685 | 686 |
| 686 // We want to remove the markers from a word if an editing command will chan
ge the word. This can happen in one of | 687 // We want to remove the markers from a word if an editing command will chan
ge the word. This can happen in one of |
| 687 // several scenarios: | 688 // several scenarios: |
| 688 // 1. Insert in the middle of a word. | 689 // 1. Insert in the middle of a word. |
| 689 // 2. Appending non whitespace at the beginning of word. | 690 // 2. Appending non whitespace at the beginning of word. |
| 690 // 3. Appending non whitespace at the end of word. | 691 // 3. Appending non whitespace at the end of word. |
| 691 // Note that, appending only whitespaces at the beginning or end of word won
't change the word, so we don't need to | 692 // Note that, appending only whitespaces at the beginning or end of word won
't change the word, so we don't need to |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 if (doNotRemoveIfSelectionAtWordBoundary && startOfLastWord.deepEquivalent()
== endOfSelection.deepEquivalent()) { | 729 if (doNotRemoveIfSelectionAtWordBoundary && startOfLastWord.deepEquivalent()
== endOfSelection.deepEquivalent()) { |
| 729 startOfLastWord = previousWordPosition(startOfLastWord); | 730 startOfLastWord = previousWordPosition(startOfLastWord); |
| 730 endOfLastWord = endOfWord(startOfLastWord, RightWordIfOnBoundary); | 731 endOfLastWord = endOfWord(startOfLastWord, RightWordIfOnBoundary); |
| 731 if (endOfLastWord.deepEquivalent() == startOfSelection.deepEquivalent()) | 732 if (endOfLastWord.deepEquivalent() == startOfSelection.deepEquivalent()) |
| 732 return; | 733 return; |
| 733 } | 734 } |
| 734 | 735 |
| 735 if (startOfFirstWord.isNull() || endOfFirstWord.isNull() || startOfLastWord.
isNull() || endOfLastWord.isNull()) | 736 if (startOfFirstWord.isNull() || endOfFirstWord.isNull() || startOfLastWord.
isNull() || endOfLastWord.isNull()) |
| 736 return; | 737 return; |
| 737 | 738 |
| 739 const Position& removeMarkerStart = startOfFirstWord.deepEquivalent(); |
| 740 const Position& removeMarkerEnd = endOfLastWord.deepEquivalent(); |
| 741 if (removeMarkerStart > removeMarkerEnd) { |
| 742 // editing/inserting/insert-br-008.html and more reach here. |
| 743 // TODO(yosin): To avoid |DCHECK(removeMarkerStart <= removeMarkerEnd)| |
| 744 // in |EphemeralRange| constructor, we have this if-statement. Once we |
| 745 // fix |startOfWord()| and |endOfWord()|, we should remove this |
| 746 // if-statement. |
| 747 return; |
| 748 } |
| 749 |
| 738 // Now we remove markers on everything between startOfFirstWord and endOfLas
tWord. | 750 // Now we remove markers on everything between startOfFirstWord and endOfLas
tWord. |
| 739 // However, if an autocorrection change a single word to multiple words, we
want to remove correction mark from all the | 751 // However, if an autocorrection change a single word to multiple words, we
want to remove correction mark from all the |
| 740 // resulted words even we only edit one of them. For example, assuming autoc
orrection changes "avantgarde" to "avant | 752 // resulted words even we only edit one of them. For example, assuming autoc
orrection changes "avantgarde" to "avant |
| 741 // garde", we will have CorrectionIndicator marker on both words and on the
whitespace between them. If we then edit garde, | 753 // garde", we will have CorrectionIndicator marker on both words and on the
whitespace between them. If we then edit garde, |
| 742 // we would like to remove the marker from word "avant" and whitespace as we
ll. So we need to get the continous range of | 754 // we would like to remove the marker from word "avant" and whitespace as we
ll. So we need to get the continous range of |
| 743 // of marker that contains the word in question, and remove marker on that w
hole range. | 755 // of marker that contains the word in question, and remove marker on that w
hole range. |
| 744 Document* document = frame().document(); | 756 Document* document = frame().document(); |
| 745 DCHECK(document); | 757 DCHECK(document); |
| 746 const EphemeralRange wordRange(startOfFirstWord.deepEquivalent(), endOfLastW
ord.deepEquivalent()); | 758 const EphemeralRange wordRange(removeMarkerStart, removeMarkerEnd); |
| 747 document->markers().removeMarkers(wordRange, DocumentMarker::MisspellingMark
ers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); | 759 document->markers().removeMarkers(wordRange, DocumentMarker::MisspellingMark
ers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); |
| 748 } | 760 } |
| 749 | 761 |
| 750 void SpellChecker::didEndEditingOnTextField(Element* e) | 762 void SpellChecker::didEndEditingOnTextField(Element* e) |
| 751 { | 763 { |
| 752 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); | 764 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); |
| 753 | 765 |
| 754 // Remove markers when deactivating a selection in an <input type="text"/>. | 766 // Remove markers when deactivating a selection in an <input type="text"/>. |
| 755 // Prevent new ones from appearing too. | 767 // Prevent new ones from appearing too. |
| 756 m_spellCheckRequester->cancelCheck(); | 768 m_spellCheckRequester->cancelCheck(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 visitor->trace(m_frame); | 970 visitor->trace(m_frame); |
| 959 visitor->trace(m_spellCheckRequester); | 971 visitor->trace(m_spellCheckRequester); |
| 960 } | 972 } |
| 961 | 973 |
| 962 void SpellChecker::prepareForLeakDetection() | 974 void SpellChecker::prepareForLeakDetection() |
| 963 { | 975 { |
| 964 m_spellCheckRequester->prepareForLeakDetection(); | 976 m_spellCheckRequester->prepareForLeakDetection(); |
| 965 } | 977 } |
| 966 | 978 |
| 967 } // namespace blink | 979 } // namespace blink |
| OLD | NEW |