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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 return; | 703 return; |
704 | 704 |
705 // Now we remove markers on everything between startOfFirstWord and endOfLas
tWord. | 705 // Now we remove markers on everything between startOfFirstWord and endOfLas
tWord. |
706 // However, if an autocorrection change a single word to multiple words, we
want to remove correction mark from all the | 706 // However, if an autocorrection change a single word to multiple words, we
want to remove correction mark from all the |
707 // resulted words even we only edit one of them. For example, assuming autoc
orrection changes "avantgarde" to "avant | 707 // resulted words even we only edit one of them. For example, assuming autoc
orrection changes "avantgarde" to "avant |
708 // garde", we will have CorrectionIndicator marker on both words and on the
whitespace between them. If we then edit garde, | 708 // garde", we will have CorrectionIndicator marker on both words and on the
whitespace between them. If we then edit garde, |
709 // we would like to remove the marker from word "avant" and whitespace as we
ll. So we need to get the continous range of | 709 // we would like to remove the marker from word "avant" and whitespace as we
ll. So we need to get the continous range of |
710 // of marker that contains the word in question, and remove marker on that w
hole range. | 710 // of marker that contains the word in question, and remove marker on that w
hole range. |
711 Document* document = frame().document(); | 711 Document* document = frame().document(); |
712 ASSERT(document); | 712 ASSERT(document); |
713 Node* startNode = startOfFirstWord.deepEquivalent().computeContainerNode(); | 713 const EphemeralRange wordRange(startOfFirstWord.deepEquivalent(), endOfLastW
ord.deepEquivalent()); |
714 int startOffset = startOfFirstWord.deepEquivalent().computeOffsetInContainer
Node(); | 714 document->markers().removeMarkers(wordRange, DocumentMarker::MisspellingMark
ers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); |
715 int endOffset = endOfLastWord.deepEquivalent().computeOffsetInContainerNode(
); | |
716 document->markers().removeMarkers(startNode, startOffset, endOffset - startO
ffset, DocumentMarker::MisspellingMarkers(), DocumentMarkerController::RemovePar
tiallyOverlappingMarker); | |
717 } | 715 } |
718 | 716 |
719 void SpellChecker::didEndEditingOnTextField(Element* e) | 717 void SpellChecker::didEndEditingOnTextField(Element* e) |
720 { | 718 { |
721 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); | 719 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); |
722 | 720 |
723 // Remove markers when deactivating a selection in an <input type="text"/>. | 721 // Remove markers when deactivating a selection in an <input type="text"/>. |
724 // Prevent new ones from appearing too. | 722 // Prevent new ones from appearing too. |
725 m_spellCheckRequester->cancelCheck(); | 723 m_spellCheckRequester->cancelCheck(); |
726 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl
ement(e); | 724 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl
ement(e); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); | 916 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); |
919 } | 917 } |
920 | 918 |
921 DEFINE_TRACE(SpellChecker) | 919 DEFINE_TRACE(SpellChecker) |
922 { | 920 { |
923 visitor->trace(m_frame); | 921 visitor->trace(m_frame); |
924 visitor->trace(m_spellCheckRequester); | 922 visitor->trace(m_spellCheckRequester); |
925 } | 923 } |
926 | 924 |
927 } // namespace blink | 925 } // namespace blink |
OLD | NEW |