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

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

Issue 1369713002: Avoid creating duplicate Range objects when handling misspellings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 5 years, 2 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/SpellCheckRequester.cpp ('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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 currentChunkStart += checkingLength; 530 currentChunkStart += checkingLength;
531 } 531 }
532 } 532 }
533 533
534 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& checkRange, const EphemeralRange& pa ragraphRange, bool asynchronous, int requestNumber, int* checkingLength) 534 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& checkRange, const EphemeralRange& pa ragraphRange, bool asynchronous, int requestNumber, int* checkingLength)
535 { 535 {
536 TextCheckingParagraph sentenceToCheck(checkRange, paragraphRange); 536 TextCheckingParagraph sentenceToCheck(checkRange, paragraphRange);
537 if (checkingLength) 537 if (checkingLength)
538 *checkingLength = sentenceToCheck.checkingLength(); 538 *checkingLength = sentenceToCheck.checkingLength();
539 539
540 RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(re solveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, create Range(checkRange), createRange(paragraphRange), requestNumber); 540 RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(re solveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, checkR ange, paragraphRange, requestNumber);
541 if (!request) 541 if (!request)
542 return; 542 return;
543 543
544 if (asynchronous) { 544 if (asynchronous) {
545 m_spellCheckRequester->requestCheckingFor(request); 545 m_spellCheckRequester->requestCheckingFor(request);
546 return; 546 return;
547 } 547 }
548 548
549 Vector<TextCheckingResult> results; 549 Vector<TextCheckingResult> results;
550 checkTextOfParagraph(textChecker(), sentenceToCheck.text(), resolveTextCheck ingTypeMask(textCheckingOptions), results); 550 checkTextOfParagraph(textChecker(), sentenceToCheck.text(), resolveTextCheck ingTypeMask(textCheckingOptions), results);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return blink::unifiedTextCheckerEnabled(m_frame); 923 return blink::unifiedTextCheckerEnabled(m_frame);
924 } 924 }
925 925
926 void SpellChecker::cancelCheck() 926 void SpellChecker::cancelCheck()
927 { 927 {
928 m_spellCheckRequester->cancelCheck(); 928 m_spellCheckRequester->cancelCheck();
929 } 929 }
930 930
931 void SpellChecker::requestTextChecking(const Element& element) 931 void SpellChecker::requestTextChecking(const Element& element)
932 { 932 {
933 const EphemeralRange range = EphemeralRange::rangeOfContents(element); 933 const EphemeralRange rangeToCheck = EphemeralRange::rangeOfContents(element) ;
934 RefPtrWillBeRawPtr<Range> rangeToCheck = Range::create(element.document(), r ange.startPosition(), range.endPosition());
935 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 934 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
936 } 935 }
937 936
938 DEFINE_TRACE(SpellChecker) 937 DEFINE_TRACE(SpellChecker)
939 { 938 {
940 visitor->trace(m_frame); 939 visitor->trace(m_frame);
941 visitor->trace(m_spellCheckRequester); 940 visitor->trace(m_spellCheckRequester);
942 } 941 }
943 942
944 } // namespace blink 943 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698