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

Side by Side Diff: Source/core/editing/spellcheck/SpellCheckRequester.cpp

Issue 1335573004: Introduce Range::dispose() for prompt detachment from owner Document. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: replace use of selectNodeContents() also Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 m_processingRequest->didCancel(); 204 m_processingRequest->didCancel();
205 } 205 }
206 206
207 void SpellCheckRequester::invokeRequest(PassRefPtrWillBeRawPtr<SpellCheckRequest > request) 207 void SpellCheckRequester::invokeRequest(PassRefPtrWillBeRawPtr<SpellCheckRequest > request)
208 { 208 {
209 ASSERT(!m_processingRequest); 209 ASSERT(!m_processingRequest);
210 m_processingRequest = request; 210 m_processingRequest = request;
211 client().requestCheckingOfString(m_processingRequest); 211 client().requestCheckingOfString(m_processingRequest);
212 } 212 }
213 213
214 void SpellCheckRequester::clearProcessingRequest()
215 {
216 // This assumes that m_processingRequest's Ranges aren't shared.
217 if (m_processingRequest->checkingRange())
218 m_processingRequest->checkingRange()->dispose();
219 if (m_processingRequest->paragraphRange())
220 m_processingRequest->paragraphRange()->dispose();
221
222 m_processingRequest.clear();
223 }
224
214 void SpellCheckRequester::enqueueRequest(PassRefPtrWillBeRawPtr<SpellCheckReques t> request) 225 void SpellCheckRequester::enqueueRequest(PassRefPtrWillBeRawPtr<SpellCheckReques t> request)
215 { 226 {
216 ASSERT(request); 227 ASSERT(request);
217 bool continuation = false; 228 bool continuation = false;
218 if (!m_requestQueue.isEmpty()) { 229 if (!m_requestQueue.isEmpty()) {
219 RefPtrWillBeRawPtr<SpellCheckRequest> lastRequest = m_requestQueue.last( ); 230 RefPtrWillBeRawPtr<SpellCheckRequest> lastRequest = m_requestQueue.last( );
220 // It's a continuation if the number of the last request got incremented in the new one and 231 // It's a continuation if the number of the last request got incremented in the new one and
221 // both apply to the same editable. 232 // both apply to the same editable.
222 continuation = request->rootEditableElement() == lastRequest->rootEditab leElement() 233 continuation = request->rootEditableElement() == lastRequest->rootEditab leElement()
223 && request->requestNumber() == lastRequest->requestNumber() + 1; 234 && request->requestNumber() == lastRequest->requestNumber() + 1;
(...skipping 20 matching lines...) Expand all
244 if (m_processingRequest->data().sequence() != sequence) { 255 if (m_processingRequest->data().sequence() != sequence) {
245 m_requestQueue.clear(); 256 m_requestQueue.clear();
246 return; 257 return;
247 } 258 }
248 259
249 frame().spellChecker().markAndReplaceFor(m_processingRequest, results); 260 frame().spellChecker().markAndReplaceFor(m_processingRequest, results);
250 261
251 if (m_lastProcessedSequence < sequence) 262 if (m_lastProcessedSequence < sequence)
252 m_lastProcessedSequence = sequence; 263 m_lastProcessedSequence = sequence;
253 264
254 m_processingRequest.clear(); 265 clearProcessingRequest();
255 if (!m_requestQueue.isEmpty()) 266 if (!m_requestQueue.isEmpty())
256 m_timerToProcessQueuedRequest.startOneShot(0, FROM_HERE); 267 m_timerToProcessQueuedRequest.startOneShot(0, FROM_HERE);
257 } 268 }
258 269
259 void SpellCheckRequester::didCheckSucceed(int sequence, const Vector<TextCheckin gResult>& results) 270 void SpellCheckRequester::didCheckSucceed(int sequence, const Vector<TextCheckin gResult>& results)
260 { 271 {
261 TextCheckingRequestData requestData = m_processingRequest->data(); 272 TextCheckingRequestData requestData = m_processingRequest->data();
262 if (requestData.sequence() == sequence) { 273 if (requestData.sequence() == sequence) {
263 DocumentMarker::MarkerTypes markers = DocumentMarker::SpellCheckClientMa rkers(); 274 DocumentMarker::MarkerTypes markers = DocumentMarker::SpellCheckClientMa rkers();
264 if (!requestData.maskContains(TextCheckingTypeSpelling)) 275 if (!requestData.maskContains(TextCheckingTypeSpelling))
(...skipping 13 matching lines...) Expand all
278 } 289 }
279 290
280 DEFINE_TRACE(SpellCheckRequester) 291 DEFINE_TRACE(SpellCheckRequester)
281 { 292 {
282 visitor->trace(m_frame); 293 visitor->trace(m_frame);
283 visitor->trace(m_processingRequest); 294 visitor->trace(m_processingRequest);
284 visitor->trace(m_requestQueue); 295 visitor->trace(m_requestQueue);
285 } 296 }
286 297
287 } // namespace blink 298 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698