| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 spellingSearchStart = position.parentAnchoredEquivalent(); | 201 spellingSearchStart = position.parentAnchoredEquivalent(); |
| 202 startedWithSelection = false; // won't need to wrap | 202 startedWithSelection = false; // won't need to wrap |
| 203 } | 203 } |
| 204 | 204 |
| 205 // topNode defines the whole range we want to operate on | 205 // topNode defines the whole range we want to operate on |
| 206 ContainerNode* topNode = highestEditableRoot(position); | 206 ContainerNode* topNode = highestEditableRoot(position); |
| 207 // TODO(yosin): |lastOffsetForEditing()| is wrong here if | 207 // TODO(yosin): |lastOffsetForEditing()| is wrong here if |
| 208 // |editingIgnoresContent(highestEditableRoot())| returns true, e.g. <table> | 208 // |editingIgnoresContent(highestEditableRoot())| returns true, e.g. <table> |
| 209 spellingSearchEnd = createLegacyEditingPosition(topNode, EditingStrategy::la
stOffsetForEditing(topNode)); | 209 spellingSearchEnd = Position::editingPositionOf(topNode, EditingStrategy::la
stOffsetForEditing(topNode)); |
| 210 | 210 |
| 211 // If spellingSearchRange starts in the middle of a word, advance to the nex
t word so we start checking | 211 // If spellingSearchRange starts in the middle of a word, advance to the nex
t word so we start checking |
| 212 // at a word boundary. Going back by one char and then forward by a word doe
s the trick. | 212 // at a word boundary. Going back by one char and then forward by a word doe
s the trick. |
| 213 if (startedWithSelection) { | 213 if (startedWithSelection) { |
| 214 VisiblePosition oneBeforeStart = VisiblePosition(spellingSearchStart, DOWNST
REAM).previous(); | 214 VisiblePosition oneBeforeStart = VisiblePosition(spellingSearchStart, DOWNST
REAM).previous(); |
| 215 if (oneBeforeStart.isNotNull()) | 215 if (oneBeforeStart.isNotNull()) |
| 216 spellingSearchStart = endOfWord(oneBeforeStart).toParentAnchoredPosi
tion(); | 216 spellingSearchStart = endOfWord(oneBeforeStart).toParentAnchoredPosi
tion(); |
| 217 // else we were already at the start of the editable node | 217 // else we were already at the start of the editable node |
| 218 } | 218 } |
| 219 | 219 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 grammarSearchEnd = chars.startPosition(); | 259 grammarSearchEnd = chars.startPosition(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 if (isGrammarCheckingEnabled()) | 262 if (isGrammarCheckingEnabled()) |
| 263 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarS
earchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhraseOf
fset, false); | 263 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarS
earchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhraseOf
fset, false); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // If we found neither bad grammar nor a misspelled word, wrap and try again
(but don't bother if we started at the beginning of the | 266 // If we found neither bad grammar nor a misspelled word, wrap and try again
(but don't bother if we started at the beginning of the |
| 267 // block rather than at a selection). | 267 // block rather than at a selection). |
| 268 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { | 268 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { |
| 269 spellingSearchStart = createLegacyEditingPosition(topNode, 0); | 269 spellingSearchStart = Position::editingPositionOf(topNode, 0); |
| 270 // going until the end of the very first chunk we tested is far enough | 270 // going until the end of the very first chunk we tested is far enough |
| 271 spellingSearchEnd = createLegacyEditingPosition(searchEndNodeAfterWrap,
searchEndOffsetAfterWrap); | 271 spellingSearchEnd = Position::editingPositionOf(searchEndNodeAfterWrap,
searchEndOffsetAfterWrap); |
| 272 | 272 |
| 273 if (unifiedTextCheckerEnabled()) { | 273 if (unifiedTextCheckerEnabled()) { |
| 274 grammarSearchStart = spellingSearchStart; | 274 grammarSearchStart = spellingSearchStart; |
| 275 grammarSearchEnd = spellingSearchEnd; | 275 grammarSearchEnd = spellingSearchEnd; |
| 276 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchS
tart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabl
ed(), isSpelling, foundOffset, grammarDetail); | 276 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchS
tart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabl
ed(), isSpelling, foundOffset, grammarDetail); |
| 277 if (isSpelling) { | 277 if (isSpelling) { |
| 278 misspelledWord = foundItem; | 278 misspelledWord = foundItem; |
| 279 misspellingOffset = foundOffset; | 279 misspellingOffset = foundOffset; |
| 280 } else { | 280 } else { |
| 281 badGrammarPhrase = foundItem; | 281 badGrammarPhrase = foundItem; |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); | 937 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); |
| 938 } | 938 } |
| 939 | 939 |
| 940 DEFINE_TRACE(SpellChecker) | 940 DEFINE_TRACE(SpellChecker) |
| 941 { | 941 { |
| 942 visitor->trace(m_frame); | 942 visitor->trace(m_frame); |
| 943 visitor->trace(m_spellCheckRequester); | 943 visitor->trace(m_spellCheckRequester); |
| 944 } | 944 } |
| 945 | 945 |
| 946 } // namespace blink | 946 } // namespace blink |
| OLD | NEW |