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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // panel, and store a marker so we draw the red squiggle later. | 295 // panel, and store a marker so we draw the red squiggle later. |
296 | 296 |
297 const EphemeralRange misspellingRange = calculateCharacterSubrange( | 297 const EphemeralRange misspellingRange = calculateCharacterSubrange( |
298 EphemeralRange(spellingSearchStart, spellingSearchEnd), | 298 EphemeralRange(spellingSearchStart, spellingSearchEnd), |
299 misspellingOffset, misspelledWord.length()); | 299 misspellingOffset, misspelledWord.length()); |
300 frame().selection().setSelection(SelectionInDOMTree::Builder() | 300 frame().selection().setSelection(SelectionInDOMTree::Builder() |
301 .setBaseAndExtent(misspellingRange) | 301 .setBaseAndExtent(misspellingRange) |
302 .build()); | 302 .build()); |
303 frame().selection().revealSelection(); | 303 frame().selection().revealSelection(); |
304 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); | 304 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); |
305 frame().document()->markers().addMarker(misspellingRange.startPosition(), | 305 frame().document()->markers().addSpellingMarker( |
306 misspellingRange.endPosition(), | 306 misspellingRange.startPosition(), misspellingRange.endPosition()); |
307 DocumentMarker::Spelling); | |
308 } | 307 } |
309 } | 308 } |
310 | 309 |
311 void SpellChecker::showSpellingGuessPanel() { | 310 void SpellChecker::showSpellingGuessPanel() { |
312 if (spellCheckerClient().spellingUIIsShowing()) { | 311 if (spellCheckerClient().spellingUIIsShowing()) { |
313 spellCheckerClient().showSpellingUI(false); | 312 spellCheckerClient().showSpellingUI(false); |
314 return; | 313 return; |
315 } | 314 } |
316 | 315 |
317 advanceToNextMisspelling(true); | 316 advanceToNextMisspelling(true); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 int length, | 540 int length, |
542 const String& description) { | 541 const String& description) { |
543 DCHECK_GT(length, 0); | 542 DCHECK_GT(length, 0); |
544 DCHECK_GE(location, 0); | 543 DCHECK_GE(location, 0); |
545 const EphemeralRange& rangeToMark = | 544 const EphemeralRange& rangeToMark = |
546 calculateCharacterSubrange(checkingRange, location, length); | 545 calculateCharacterSubrange(checkingRange, location, length); |
547 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.startPosition())) | 546 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.startPosition())) |
548 return; | 547 return; |
549 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.endPosition())) | 548 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.endPosition())) |
550 return; | 549 return; |
551 document->markers().addMarker(rangeToMark.startPosition(), | 550 |
552 rangeToMark.endPosition(), type, description); | 551 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); |
| 552 if (type == DocumentMarker::Grammar) { |
| 553 document->markers().addGrammarMarker( |
| 554 rangeToMark.startPosition(), rangeToMark.endPosition(), description); |
| 555 } else { |
| 556 document->markers().addSpellingMarker( |
| 557 rangeToMark.startPosition(), rangeToMark.endPosition(), description); |
| 558 } |
553 } | 559 } |
554 | 560 |
555 void SpellChecker::markAndReplaceFor( | 561 void SpellChecker::markAndReplaceFor( |
556 SpellCheckRequest* request, | 562 SpellCheckRequest* request, |
557 const Vector<TextCheckingResult>& results) { | 563 const Vector<TextCheckingResult>& results) { |
558 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 564 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
559 DCHECK(request); | 565 DCHECK(request); |
560 if (!frame().selection().isAvailable()) { | 566 if (!frame().selection().isAvailable()) { |
561 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. | 567 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. |
562 return; | 568 return; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 m_idleSpellCheckCallback->setNeedsInvocation(); | 916 m_idleSpellCheckCallback->setNeedsInvocation(); |
911 } | 917 } |
912 | 918 |
913 void SpellChecker::removeSpellingMarkers() { | 919 void SpellChecker::removeSpellingMarkers() { |
914 frame().document()->markers().removeMarkers( | 920 frame().document()->markers().removeMarkers( |
915 DocumentMarker::MisspellingMarkers()); | 921 DocumentMarker::MisspellingMarkers()); |
916 } | 922 } |
917 | 923 |
918 void SpellChecker::removeSpellingMarkersUnderWords( | 924 void SpellChecker::removeSpellingMarkersUnderWords( |
919 const Vector<String>& words) { | 925 const Vector<String>& words) { |
920 MarkerRemoverPredicate removerPredicate(words); | |
921 | |
922 DocumentMarkerController& markerController = frame().document()->markers(); | 926 DocumentMarkerController& markerController = frame().document()->markers(); |
923 markerController.removeMarkers(removerPredicate); | 927 markerController.removeSpellingMarkersForWords(words); |
924 markerController.repaintMarkers(); | 928 markerController.repaintMarkers(); |
925 } | 929 } |
926 | 930 |
927 void SpellChecker::spellCheckAfterBlur() { | 931 void SpellChecker::spellCheckAfterBlur() { |
928 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 932 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
929 return; | 933 return; |
930 | 934 |
931 // TODO(yosin): We should hoist updateStyleAndLayoutIgnorePendingStylesheets | 935 // TODO(yosin): We should hoist updateStyleAndLayoutIgnorePendingStylesheets |
932 // to caller. See http://crbug.com/590369 for more details. | 936 // to caller. See http://crbug.com/590369 for more details. |
933 // TODO(xiaochengh): In the long term we should use idle time spell checker to | 937 // TODO(xiaochengh): In the long term we should use idle time spell checker to |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 if (!input.isFocusedElementInDocument()) | 1187 if (!input.isFocusedElementInDocument()) |
1184 return false; | 1188 return false; |
1185 } | 1189 } |
1186 } | 1190 } |
1187 HTMLElement* element = | 1191 HTMLElement* element = |
1188 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); | 1192 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); |
1189 return element && element->isSpellCheckingEnabled(); | 1193 return element && element->isSpellCheckingEnabled(); |
1190 } | 1194 } |
1191 | 1195 |
1192 } // namespace blink | 1196 } // namespace blink |
OLD | NEW |