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

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

Issue 828293002: Do not create a temporary Range object on updating spell checking markers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 return; 726 return;
727 727
728 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord. 728 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord.
729 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the 729 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the
730 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant 730 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant
731 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde, 731 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde,
732 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of 732 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of
733 // of marker that contains the word in question, and remove marker on that w hole range. 733 // of marker that contains the word in question, and remove marker on that w hole range.
734 Document* document = frame().document(); 734 Document* document = frame().document();
735 ASSERT(document); 735 ASSERT(document);
736 RefPtrWillBeRawPtr<Range> wordRange = Range::create(*document, startOfFirstW ord.deepEquivalent(), endOfLastWord.deepEquivalent()); 736 Node* startNode = startOfFirstWord.deepEquivalent().containerNode();
737 document->markers().removeMarkers(wordRange.get(), DocumentMarker::Misspelli ngMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); 737 int startOffset = startOfFirstWord.deepEquivalent().computeOffsetInContainer Node();
738 int endOffset = endOfLastWord.deepEquivalent().computeOffsetInContainerNode( );
739 document->markers().removeMarkers(startNode, startOffset, endOffset - startO ffset, DocumentMarker::MisspellingMarkers(), DocumentMarkerController::RemovePar tiallyOverlappingMarker);
738 } 740 }
739 741
740 void SpellChecker::didEndEditingOnTextField(Element* e) 742 void SpellChecker::didEndEditingOnTextField(Element* e)
741 { 743 {
742 // Remove markers when deactivating a selection in an <input type="text"/>. 744 // Remove markers when deactivating a selection in an <input type="text"/>.
743 // Prevent new ones from appearing too. 745 // Prevent new ones from appearing too.
744 m_spellCheckRequester->cancelCheck(); 746 m_spellCheckRequester->cancelCheck();
745 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl ement(e); 747 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl ement(e);
746 HTMLElement* innerEditor = textFormControlElement->innerEditorElement(); 748 HTMLElement* innerEditor = textFormControlElement->innerEditorElement();
747 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); 749 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 941 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
940 } 942 }
941 943
942 void SpellChecker::trace(Visitor* visitor) 944 void SpellChecker::trace(Visitor* visitor)
943 { 945 {
944 visitor->trace(m_frame); 946 visitor->trace(m_frame);
945 visitor->trace(m_spellCheckRequester); 947 visitor->trace(m_spellCheckRequester);
946 } 948 }
947 949
948 } // namespace blink 950 } // 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