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

Side by Side Diff: Source/core/editing/SpellChecker.cpp

Issue 1280543002: Avoid temporary Range object creation in SpellChecker::replaceMisspelledRange() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-06T16:32:55 Created 5 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 | « no previous file | 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 752 }
753 753
754 void SpellChecker::replaceMisspelledRange(const String& text) 754 void SpellChecker::replaceMisspelledRange(const String& text)
755 { 755 {
756 EphemeralRange caretRange = frame().selection().selection().toNormalizedEphe meralRange(); 756 EphemeralRange caretRange = frame().selection().selection().toNormalizedEphe meralRange();
757 if (caretRange.isNull()) 757 if (caretRange.isNull())
758 return; 758 return;
759 DocumentMarkerVector markers = frame().document()->markers().markersInRange( caretRange, DocumentMarker::MisspellingMarkers()); 759 DocumentMarkerVector markers = frame().document()->markers().markersInRange( caretRange, DocumentMarker::MisspellingMarkers());
760 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset ()) 760 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset ())
761 return; 761 return;
762 // TODO(yosin) |markerRange| should be |EphemeralRange|. 762 EphemeralRange markerRange = EphemeralRange(Position(caretRange.startPositio n().computeContainerNode(), markers[0]->startOffset()), Position(caretRange.endP osition().computeContainerNode(), markers[0]->endOffset()));
763 RefPtrWillBeRawPtr<Range> markerRange = Range::create(caretRange.document(), caretRange.startPosition().computeContainerNode(), markers[0]->startOffset(), c aretRange.endPosition().computeContainerNode(), markers[0]->endOffset()); 763 if (markerRange.isNull())
764 if (!markerRange)
765 return; 764 return;
766 frame().selection().setSelection(VisibleSelection(markerRange.get()), Charac terGranularity); 765 frame().selection().setSelection(VisibleSelection(markerRange), CharacterGra nularity);
767 frame().editor().replaceSelectionWithText(text, false, false); 766 frame().editor().replaceSelectionWithText(text, false, false);
768 } 767 }
769 768
770 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio n, FrameSelection::SetSelectionOptions options) 769 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio n, FrameSelection::SetSelectionOptions options)
771 { 770 {
772 bool closeTyping = options & FrameSelection::CloseTyping; 771 bool closeTyping = options & FrameSelection::CloseTyping;
773 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabl ed(); 772 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabl ed();
774 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled & & isGrammarCheckingEnabled(); 773 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled & & isGrammarCheckingEnabled();
775 if (isContinuousSpellCheckingEnabled) { 774 if (isContinuousSpellCheckingEnabled) {
776 VisibleSelection newAdjacentWords; 775 VisibleSelection newAdjacentWords;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 942 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
944 } 943 }
945 944
946 DEFINE_TRACE(SpellChecker) 945 DEFINE_TRACE(SpellChecker)
947 { 946 {
948 visitor->trace(m_frame); 947 visitor->trace(m_frame);
949 visitor->trace(m_spellCheckRequester); 948 visitor->trace(m_spellCheckRequester);
950 } 949 }
951 950
952 } // namespace blink 951 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698