Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2220493002: Code cleanup in blink::SpellChecker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 spellCheckerClient().showSpellingUI(true); 330 spellCheckerClient().showSpellingUI(true);
331 } 331 }
332 332
333 void SpellChecker::clearMisspellingsAndBadGrammar(const VisibleSelection &moving Selection) 333 void SpellChecker::clearMisspellingsAndBadGrammar(const VisibleSelection &moving Selection)
334 { 334 {
335 removeMarkers(movingSelection, DocumentMarker::MisspellingMarkers()); 335 removeMarkers(movingSelection, DocumentMarker::MisspellingMarkers());
336 } 336 }
337 337
338 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS election) 338 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS election)
339 { 339 {
340 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab led(), movingSelection); 340 markMisspellingsAndBadGrammar(movingSelection, movingSelection);
341 } 341 }
342 342
343 void SpellChecker::markMisspellingsAfterLineBreak(const VisibleSelection& wordSe lection) 343 void SpellChecker::markMisspellingsAfterLineBreak(const VisibleSelection& wordSe lection)
344 { 344 {
345 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterLineBreak"); 345 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterLineBreak");
346 346
347 if (!unifiedTextCheckerEnabled()) { 347 if (!unifiedTextCheckerEnabled()) {
348 markMisspellings(wordSelection); 348 markMisspellings(wordSelection);
349 return; 349 return;
350 } 350 }
351 351
352 TextCheckingTypeMask textCheckingOptions = TextCheckingTypeGrammar;
353
354 if (isContinuousSpellCheckingEnabled())
355 textCheckingOptions |= TextCheckingTypeSpelling;
356
357 VisibleSelection wholeParagraph(
358 startOfParagraph(wordSelection.visibleStart()),
359 endOfParagraph(wordSelection.visibleEnd()));
360
361 markAllMisspellingsAndBadGrammarInRanges(
362 textCheckingOptions, wordSelection.toNormalizedEphemeralRange(),
363 wholeParagraph.toNormalizedEphemeralRange());
364 }
365
366 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word Start, const VisibleSelection& selectionAfterTyping)
367 {
368 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterTypingToWord");
369
370 if (unifiedTextCheckerEnabled()) {
371 TextCheckingTypeMask textCheckingOptions = 0;
372
373 if (isContinuousSpellCheckingEnabled())
374 textCheckingOptions |= TextCheckingTypeSpelling;
375
376 if (!(textCheckingOptions & TextCheckingTypeSpelling))
377 return;
378
379 textCheckingOptions |= TextCheckingTypeGrammar;
380
381 VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary));
382 if (textCheckingOptions & TextCheckingTypeGrammar) {
383 VisibleSelection selectedSentence = VisibleSelection(startOfSentence (wordStart), endOfSentence(wordStart));
384 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjace ntWords.toNormalizedEphemeralRange(), selectedSentence.toNormalizedEphemeralRang e());
385 } else {
386 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjace ntWords.toNormalizedEphemeralRange(), adjacentWords.toNormalizedEphemeralRange() );
387 }
388 return;
389 }
390
391 if (!isContinuousSpellCheckingEnabled()) 352 if (!isContinuousSpellCheckingEnabled())
392 return; 353 return;
393 354
355 VisibleSelection wholeParagraph(
356 startOfParagraph(wordSelection.visibleStart()),
357 endOfParagraph(wordSelection.visibleEnd()));
358
359 markAllMisspellingsAndBadGrammarInRanges(wordSelection.toNormalizedEphemeral Range(), wholeParagraph.toNormalizedEphemeralRange());
360 }
361
362 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word Start, const VisibleSelection& selectionAfterTyping)
363 {
364 if (!isContinuousSpellCheckingEnabled())
365 return;
366
367 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterTypingToWord");
368
369 if (unifiedTextCheckerEnabled()) {
370 VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary));
371 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(wor dStart), endOfSentence(wordStart));
372 markAllMisspellingsAndBadGrammarInRanges(adjacentWords.toNormalizedEphem eralRange(), selectedSentence.toNormalizedEphemeralRange());
373 return;
374 }
375
394 // Check spelling of one word 376 // Check spelling of one word
395 bool result = markMisspellings(VisibleSelection(startOfWord(wordStart, LeftW ordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary))); 377 bool result = markMisspellings(VisibleSelection(startOfWord(wordStart, LeftW ordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary)));
396 378
397 if (!result) 379 if (!result)
398 return; 380 return;
399 381
400 // Check grammar of entire sentence 382 // Check grammar of entire sentence
401 markBadGrammar(VisibleSelection(startOfSentence(wordStart), endOfSentence(wo rdStart))); 383 markBadGrammar(VisibleSelection(startOfSentence(wordStart), endOfSentence(wo rdStart)));
402 } 384 }
403 385
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 bool SpellChecker::markMisspellings(const VisibleSelection& selection) 450 bool SpellChecker::markMisspellings(const VisibleSelection& selection)
469 { 451 {
470 return markMisspellingsOrBadGrammar(selection, true); 452 return markMisspellingsOrBadGrammar(selection, true);
471 } 453 }
472 454
473 void SpellChecker::markBadGrammar(const VisibleSelection& selection) 455 void SpellChecker::markBadGrammar(const VisibleSelection& selection)
474 { 456 {
475 markMisspellingsOrBadGrammar(selection, false); 457 markMisspellingsOrBadGrammar(selection, false);
476 } 458 }
477 459
478 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& spellingRange, const EphemeralRange& grammarRange) 460 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(const EphemeralRange & spellingRange, const EphemeralRange& grammarRange)
479 { 461 {
480 DCHECK(unifiedTextCheckerEnabled()); 462 DCHECK(unifiedTextCheckerEnabled());
481 463
482 bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
483
484 // This function is called with selections already expanded to word boundari es. 464 // This function is called with selections already expanded to word boundari es.
485 if (spellingRange.isNull() || (shouldMarkGrammar && grammarRange.isNull())) 465 if (spellingRange.isNull() || grammarRange.isNull())
486 return; 466 return;
487 467
488 // If we're not in an editable node, bail. 468 // If we're not in an editable node, bail.
489 Node* editableNode = spellingRange.startPosition().computeContainerNode(); 469 Node* editableNode = spellingRange.startPosition().computeContainerNode();
490 if (!editableNode || !hasEditableStyle(*editableNode)) 470 if (!editableNode || !hasEditableStyle(*editableNode))
491 return; 471 return;
492 472
493 if (!isSpellCheckingEnabledFor(editableNode)) 473 if (!isSpellCheckingEnabledFor(editableNode))
494 return; 474 return;
495 475
496 TextCheckingParagraph fullParagraphToCheck(shouldMarkGrammar ? grammarRange : spellingRange); 476 TextCheckingParagraph fullParagraphToCheck(grammarRange);
497 chunkAndMarkAllMisspellingsAndBadGrammar(textCheckingOptions, fullParagraphT oCheck); 477 chunkAndMarkAllMisspellingsAndBadGrammar(fullParagraphToCheck);
498 } 478 }
499 479
500 static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range) 480 static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range)
501 { 481 {
502 DCHECK(range.isNotNull()); 482 DCHECK(range.isNotNull());
503 const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition( )); 483 const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition( ));
504 DCHECK(visibleEnd.isNotNull()); 484 DCHECK(visibleEnd.isNotNull());
505 const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent(); 485 const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent();
506 return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() ? sente nceEnd : range.endPosition()); 486 return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() ? sente nceEnd : range.endPosition());
507 } 487 }
508 488
509 static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range) 489 static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range)
510 { 490 {
511 DCHECK(range.isNotNull()); 491 DCHECK(range.isNotNull());
512 const VisiblePosition& visibleStart = createVisiblePosition(range.startPosit ion()); 492 const VisiblePosition& visibleStart = createVisiblePosition(range.startPosit ion());
513 DCHECK(visibleStart.isNotNull()); 493 DCHECK(visibleStart.isNotNull());
514 const Position& sentenceStart = startOfSentence(visibleStart).deepEquivalent (); 494 const Position& sentenceStart = startOfSentence(visibleStart).deepEquivalent ();
515 return expandEndToSentenceBoundary(EphemeralRange(sentenceStart.isNull() ? r ange.startPosition() : sentenceStart, range.endPosition())); 495 return expandEndToSentenceBoundary(EphemeralRange(sentenceStart.isNull() ? r ange.startPosition() : sentenceStart, range.endPosition()));
516 } 496 }
517 497
518 void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(Node* node, const Ep hemeralRange& insertedRange) 498 void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(Node* node, const Ep hemeralRange& insertedRange)
519 { 499 {
520 TRACE_EVENT0("blink", "SpellChecker::chunkAndMarkAllMisspellingsAndBadGramma r"); 500 TRACE_EVENT0("blink", "SpellChecker::chunkAndMarkAllMisspellingsAndBadGramma r");
521 if (!node) 501 if (!node)
522 return; 502 return;
523 EphemeralRange paragraphRange(Position::firstPositionInNode(node), Position: :lastPositionInNode(node)); 503 EphemeralRange paragraphRange(Position::firstPositionInNode(node), Position: :lastPositionInNode(node));
524 TextCheckingParagraph textToCheck(insertedRange, paragraphRange); 504 TextCheckingParagraph textToCheck(insertedRange, paragraphRange);
525 chunkAndMarkAllMisspellingsAndBadGrammar(resolveTextCheckingTypeMask(TextChe ckingTypeSpelling | TextCheckingTypeGrammar), textToCheck); 505 chunkAndMarkAllMisspellingsAndBadGrammar(textToCheck);
526 } 506 }
527 507
528 void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask textCheckingOptions, const TextCheckingParagraph& fullParagraphToCheck) 508 void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(const TextCheckingPa ragraph& fullParagraphToCheck)
529 { 509 {
530 if (fullParagraphToCheck.isEmpty()) 510 if (fullParagraphToCheck.isEmpty())
531 return; 511 return;
532 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange() ; 512 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange() ;
533 513
534 // Since the text may be quite big chunk it up and adjust to the sentence bo undary. 514 // Since the text may be quite big chunk it up and adjust to the sentence bo undary.
535 const int kChunkSize = 16 * 1024; 515 const int kChunkSize = 16 * 1024;
536 516
537 // Check the full paragraph instead if the paragraph is short, which saves 517 // Check the full paragraph instead if the paragraph is short, which saves
538 // the cost on sentence boundary finding. 518 // the cost on sentence boundary finding.
539 if (fullParagraphToCheck.rangeLength() <= kChunkSize) { 519 if (fullParagraphToCheck.rangeLength() <= kChunkSize) {
540 SpellCheckRequest* request = SpellCheckRequest::create(resolveTextChecki ngTypeMask(textCheckingOptions), TextCheckingProcessBatch, paragraphRange, parag raphRange, 0); 520 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingTypeS pelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, paragraphRange, par agraphRange, 0);
541 if (request) 521 if (request)
542 m_spellCheckRequester->requestCheckingFor(request); 522 m_spellCheckRequester->requestCheckingFor(request);
543 return; 523 return;
544 } 524 }
545 525
546 CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), T extIteratorEmitsObjectReplacementCharacter); 526 CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), T extIteratorEmitsObjectReplacementCharacter);
547 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) { 527 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) {
548 EphemeralRange chunkRange = checkRangeIterator.calculateCharacterSubrang e(0, kChunkSize); 528 EphemeralRange chunkRange = checkRangeIterator.calculateCharacterSubrang e(0, kChunkSize);
549 EphemeralRange checkRange = requestNum ? expandEndToSentenceBoundary(chu nkRange) : expandRangeToSentenceBoundary(chunkRange); 529 EphemeralRange checkRange = requestNum ? expandEndToSentenceBoundary(chu nkRange) : expandRangeToSentenceBoundary(chunkRange);
550 530
551 SpellCheckRequest* request = SpellCheckRequest::create(resolveTextChecki ngTypeMask(textCheckingOptions), TextCheckingProcessBatch, checkRange, paragraph Range, requestNum); 531 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingTypeS pelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, checkRange, paragra phRange, requestNum);
552 if (request) 532 if (request)
553 m_spellCheckRequester->requestCheckingFor(request); 533 m_spellCheckRequester->requestCheckingFor(request);
554 534
555 if (!checkRangeIterator.atEnd()) { 535 if (!checkRangeIterator.atEnd()) {
556 checkRangeIterator.advance(1); 536 checkRangeIterator.advance(1);
557 // The layout should be already update due to the initialization of checkRangeIterator, 537 // The layout should be already update due to the initialization of checkRangeIterator,
558 // so comparePositions can be directly called. 538 // so comparePositions can be directly called.
559 if (comparePositions(chunkRange.endPosition(), checkRange.endPositio n()) < 0) 539 if (comparePositions(chunkRange.endPosition(), checkRange.endPositio n()) < 0)
560 checkRangeIterator.advance(TextIterator::rangeLength(chunkRange. endPosition(), checkRange.endPosition())); 540 checkRangeIterator.advance(TextIterator::rangeLength(chunkRange. endPosition(), checkRange.endPosition()));
561 } 541 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 if (adjustSelectionForParagraphBoundaries) 639 if (adjustSelectionForParagraphBoundaries)
660 frame().selection().modify(FrameSelection::AlterationMove, Direc tionForward, CharacterGranularity); 640 frame().selection().modify(FrameSelection::AlterationMove, Direc tionForward, CharacterGranularity);
661 } else { 641 } else {
662 // If this fails for any reason, the fallback is to go one position beyond the last replacement 642 // If this fails for any reason, the fallback is to go one position beyond the last replacement
663 frame().selection().moveTo(frame().selection().selection().visibleEn d()); 643 frame().selection().moveTo(frame().selection().selection().visibleEn d());
664 frame().selection().modify(FrameSelection::AlterationMove, Direction Forward, CharacterGranularity); 644 frame().selection().modify(FrameSelection::AlterationMove, Direction Forward, CharacterGranularity);
665 } 645 }
666 } 646 }
667 } 647 }
668 648
669 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& spellin gSelection, bool markGrammar, const VisibleSelection& grammarSelection) 649 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& spellin gSelection, const VisibleSelection& grammarSelection)
670 { 650 {
671 if (unifiedTextCheckerEnabled()) { 651 if (unifiedTextCheckerEnabled()) {
672 if (!isContinuousSpellCheckingEnabled()) 652 if (!isContinuousSpellCheckingEnabled())
673 return; 653 return;
674 654
675 // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling and grammar, but don't autocorrect misspellings. 655 // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling and grammar, but don't autocorrect misspellings.
676 TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling; 656 markAllMisspellingsAndBadGrammarInRanges(spellingSelection.toNormalizedE phemeralRange(), grammarSelection.toNormalizedEphemeralRange());
677 if (markGrammar)
678 textCheckingOptions |= TextCheckingTypeGrammar;
679 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellingSe lection.toNormalizedEphemeralRange(), grammarSelection.toNormalizedEphemeralRang e());
680 return; 657 return;
681 } 658 }
682 659
683 markMisspellings(spellingSelection); 660 markMisspellings(spellingSelection);
684 if (markGrammar) 661 if (isContinuousSpellCheckingEnabled())
685 markBadGrammar(grammarSelection); 662 markBadGrammar(grammarSelection);
686 } 663 }
687 664
688 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele ctionAtWordBoundary) 665 void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele ctionAtWordBoundary)
689 { 666 {
690 DCHECK(frame().selection().isAvailable()); 667 DCHECK(frame().selection().isAvailable());
691 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing" ); 668 TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing" );
692 if (!isSpellCheckingEnabledFor(frame().selection().selection())) 669 if (!isSpellCheckingEnabledFor(frame().selection().selection()))
693 return; 670 return;
694 671
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords) 858 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords)
882 { 859 {
883 TRACE_EVENT0("blink", "SpellChecker::spellCheckOldSelection"); 860 TRACE_EVENT0("blink", "SpellChecker::spellCheckOldSelection");
884 861
885 VisiblePosition oldStart(oldSelection.visibleStart()); 862 VisiblePosition oldStart(oldSelection.visibleStart());
886 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); 863 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary));
887 if (oldAdjacentWords == newAdjacentWords) 864 if (oldAdjacentWords == newAdjacentWords)
888 return; 865 return;
889 if (isContinuousSpellCheckingEnabled()) { 866 if (isContinuousSpellCheckingEnabled()) {
890 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(old Start), endOfSentence(oldStart)); 867 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(old Start), endOfSentence(oldStart));
891 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSentence); 868 markMisspellingsAndBadGrammar(oldAdjacentWords, selectedSentence);
892 return; 869 return;
893 } 870 }
894 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWords); 871 markMisspellingsAndBadGrammar(oldAdjacentWords, oldAdjacentWords);
895 } 872 }
896 873
897 static Node* findFirstMarkable(Node* node) 874 static Node* findFirstMarkable(Node* node)
898 { 875 {
899 while (node) { 876 while (node) {
900 if (!node->layoutObject()) 877 if (!node->layoutObject())
901 return 0; 878 return 0;
902 if (node->layoutObject()->isText()) 879 if (node->layoutObject()->isText())
903 return node; 880 return node;
904 if (node->layoutObject()->isTextControl()) 881 if (node->layoutObject()->isTextControl())
(...skipping 23 matching lines...) Expand all
928 } 905 }
929 906
930 return false; 907 return false;
931 } 908 }
932 909
933 bool SpellChecker::selectionStartHasSpellingMarkerFor(int from, int length) cons t 910 bool SpellChecker::selectionStartHasSpellingMarkerFor(int from, int length) cons t
934 { 911 {
935 return selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); 912 return selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length);
936 } 913 }
937 914
938 TextCheckingTypeMask SpellChecker::resolveTextCheckingTypeMask(TextCheckingTypeM ask textCheckingOptions)
939 {
940 bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
941 bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
942
943 TextCheckingTypeMask checkingTypes = 0;
944 if (shouldMarkSpelling)
945 checkingTypes |= TextCheckingTypeSpelling;
946 if (shouldMarkGrammar)
947 checkingTypes |= TextCheckingTypeGrammar;
948
949 return checkingTypes;
950 }
951
952 void SpellChecker::removeMarkers(const VisibleSelection& selection, DocumentMark er::MarkerTypes markerTypes) 915 void SpellChecker::removeMarkers(const VisibleSelection& selection, DocumentMark er::MarkerTypes markerTypes)
953 { 916 {
954 const EphemeralRange range = selection.toNormalizedEphemeralRange(); 917 const EphemeralRange range = selection.toNormalizedEphemeralRange();
955 if (range.isNull()) 918 if (range.isNull())
956 return; 919 return;
957 frame().document()->markers().removeMarkers(range, markerTypes); 920 frame().document()->markers().removeMarkers(range, markerTypes);
958 } 921 }
959 922
960 bool SpellChecker::unifiedTextCheckerEnabled() const 923 bool SpellChecker::unifiedTextCheckerEnabled() const
961 { 924 {
(...skipping 16 matching lines...) Expand all
978 visitor->trace(m_frame); 941 visitor->trace(m_frame);
979 visitor->trace(m_spellCheckRequester); 942 visitor->trace(m_spellCheckRequester);
980 } 943 }
981 944
982 void SpellChecker::prepareForLeakDetection() 945 void SpellChecker::prepareForLeakDetection()
983 { 946 {
984 m_spellCheckRequester->prepareForLeakDetection(); 947 m_spellCheckRequester->prepareForLeakDetection();
985 } 948 }
986 949
987 } // namespace blink 950 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698