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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // blur. | 178 // blur. |
179 const VisibleSelection selection = createVisibleSelection( | 179 const VisibleSelection selection = createVisibleSelection( |
180 SelectionInDOMTree::Builder().selectAllChildren(*element).build()); | 180 SelectionInDOMTree::Builder().selectAllChildren(*element).build()); |
181 markMisspellingsInternal(selection); | 181 markMisspellingsInternal(selection); |
182 if (!isTextField) | 182 if (!isTextField) |
183 parent->setAlreadySpellChecked(true); | 183 parent->setAlreadySpellChecked(true); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 void SpellChecker::ignoreSpelling() { | 187 void SpellChecker::ignoreSpelling() { |
188 removeMarkers(frame().selection().computeVisibleSelectionInDOMTree(), | 188 removeMarkers(frame() |
| 189 .selection() |
| 190 .computeVisibleSelectionInDOMTree() |
| 191 .toNormalizedEphemeralRange(), |
189 DocumentMarker::Spelling); | 192 DocumentMarker::Spelling); |
190 } | 193 } |
191 | 194 |
192 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection) { | 195 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection) { |
193 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 196 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
194 frame().document()->lifecycle()); | 197 frame().document()->lifecycle()); |
195 | 198 |
196 // The basic approach is to search in two phases - from the selection end to | 199 // The basic approach is to search in two phases - from the selection end to |
197 // the end of the doc, and then we wrap and search from the doc start to | 200 // the end of the doc, and then we wrap and search from the doc start to |
198 // (approximately) where we started. | 201 // (approximately) where we started. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 spellCheckerClient().showSpellingUI(false); | 313 spellCheckerClient().showSpellingUI(false); |
311 return; | 314 return; |
312 } | 315 } |
313 | 316 |
314 advanceToNextMisspelling(true); | 317 advanceToNextMisspelling(true); |
315 spellCheckerClient().showSpellingUI(true); | 318 spellCheckerClient().showSpellingUI(true); |
316 } | 319 } |
317 | 320 |
318 void SpellChecker::clearMisspellingsForMovingParagraphs( | 321 void SpellChecker::clearMisspellingsForMovingParagraphs( |
319 const VisibleSelection& movingSelection) { | 322 const VisibleSelection& movingSelection) { |
320 removeMarkers(movingSelection, DocumentMarker::MisspellingMarkers()); | 323 removeMarkers(movingSelection.toNormalizedEphemeralRange(), |
| 324 DocumentMarker::MisspellingMarkers()); |
321 } | 325 } |
322 | 326 |
323 void SpellChecker::markMisspellingsForMovingParagraphs( | 327 void SpellChecker::markMisspellingsForMovingParagraphs( |
324 const VisibleSelection& movingSelection) { | 328 const VisibleSelection& movingSelection) { |
325 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 329 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
326 return; | 330 return; |
327 | 331 |
328 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 332 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
329 // needs to be audited. See http://crbug.com/590369 for more details. | 333 // needs to be audited. See http://crbug.com/590369 for more details. |
330 // In the long term we should use idle time spell checker to prevent | 334 // In the long term we should use idle time spell checker to prevent |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1017 |
1014 return false; | 1018 return false; |
1015 } | 1019 } |
1016 | 1020 |
1017 // TODO(editing-dev): No one uses this function. Remove it. | 1021 // TODO(editing-dev): No one uses this function. Remove it. |
1018 bool SpellChecker::selectionStartHasSpellingMarkerFor(int from, | 1022 bool SpellChecker::selectionStartHasSpellingMarkerFor(int from, |
1019 int length) const { | 1023 int length) const { |
1020 return selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); | 1024 return selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); |
1021 } | 1025 } |
1022 | 1026 |
1023 void SpellChecker::removeMarkers(const VisibleSelection& selection, | 1027 void SpellChecker::removeMarkers(const EphemeralRange& range, |
1024 DocumentMarker::MarkerTypes markerTypes) { | 1028 DocumentMarker::MarkerTypes markerTypes) { |
1025 DCHECK(!frame().document()->needsLayoutTreeUpdate()); | 1029 DCHECK(!frame().document()->needsLayoutTreeUpdate()); |
1026 | 1030 |
1027 const EphemeralRange& range = selection.toNormalizedEphemeralRange(); | |
1028 if (range.isNull()) | 1031 if (range.isNull()) |
1029 return; | 1032 return; |
1030 | 1033 |
1031 frame().document()->markers().removeMarkers(range, markerTypes); | 1034 frame().document()->markers().removeMarkers(range, markerTypes); |
1032 } | 1035 } |
1033 | 1036 |
1034 // TODO(xiaochengh): This function is only used by unit tests. We should move it | 1037 // TODO(xiaochengh): This function is only used by unit tests. We should move it |
1035 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell | 1038 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell |
1036 // checker. | 1039 // checker. |
1037 void SpellChecker::cancelCheck() { | 1040 void SpellChecker::cancelCheck() { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 if (!input.isFocusedElementInDocument()) | 1189 if (!input.isFocusedElementInDocument()) |
1187 return false; | 1190 return false; |
1188 } | 1191 } |
1189 } | 1192 } |
1190 HTMLElement* element = | 1193 HTMLElement* element = |
1191 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); | 1194 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); |
1192 return element && element->isSpellCheckingEnabled(); | 1195 return element && element->isSpellCheckingEnabled(); |
1193 } | 1196 } |
1194 | 1197 |
1195 } // namespace blink | 1198 } // namespace blink |
OLD | NEW |