| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 #include "platform/text/TextCheckerClient.h" | 35 #include "platform/text/TextCheckerClient.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 SpellCheckRequest::SpellCheckRequest( | 39 SpellCheckRequest::SpellCheckRequest( |
| 40 Range* checkingRange, | 40 Range* checkingRange, |
| 41 Range* paragraphRange, | 41 Range* paragraphRange, |
| 42 const String& text, | 42 const String& text, |
| 43 TextCheckingTypeMask mask, | 43 TextCheckingTypeMask mask, |
| 44 TextCheckingProcessType processType, | 44 TextCheckingProcessType processType, |
| 45 const Vector<uint32_t>& documentMarkersInRange, | |
| 46 const Vector<unsigned>& documentMarkerOffsets, | |
| 47 int requestNumber) | 45 int requestNumber) |
| 48 : m_requester(nullptr) | 46 : m_requester(nullptr) |
| 49 , m_checkingRange(checkingRange) | 47 , m_checkingRange(checkingRange) |
| 50 , m_paragraphRange(paragraphRange) | 48 , m_paragraphRange(paragraphRange) |
| 51 , m_rootEditableElement(blink::rootEditableElement(*m_checkingRange->startCo
ntainer())) | 49 , m_rootEditableElement(blink::rootEditableElement(*m_checkingRange->startCo
ntainer())) |
| 52 , m_requestData(unrequestedTextCheckingSequence, text, mask, processType, do
cumentMarkersInRange, documentMarkerOffsets) | 50 , m_requestData(unrequestedTextCheckingSequence, text, mask, processType) |
| 53 , m_requestNumber(requestNumber) | 51 , m_requestNumber(requestNumber) |
| 54 { | 52 { |
| 55 DCHECK(m_checkingRange); | 53 DCHECK(m_checkingRange); |
| 56 DCHECK(m_checkingRange->isConnected()); | 54 DCHECK(m_checkingRange->isConnected()); |
| 57 DCHECK(m_paragraphRange); | 55 DCHECK(m_paragraphRange); |
| 58 DCHECK(m_paragraphRange->isConnected()); | 56 DCHECK(m_paragraphRange->isConnected()); |
| 59 DCHECK(m_rootEditableElement); | 57 DCHECK(m_rootEditableElement); |
| 60 } | 58 } |
| 61 | 59 |
| 62 SpellCheckRequest::~SpellCheckRequest() | 60 SpellCheckRequest::~SpellCheckRequest() |
| (...skipping 30 matching lines...) Expand all Loading... |
| 93 return nullptr; | 91 return nullptr; |
| 94 | 92 |
| 95 Range* checkingRangeObject = createRange(checkingRange); | 93 Range* checkingRangeObject = createRange(checkingRange); |
| 96 Range* paragraphRangeObject = nullptr; | 94 Range* paragraphRangeObject = nullptr; |
| 97 // Share identical Range objects. | 95 // Share identical Range objects. |
| 98 if (checkingRange == paragraphRange) | 96 if (checkingRange == paragraphRange) |
| 99 paragraphRangeObject = checkingRangeObject; | 97 paragraphRangeObject = checkingRangeObject; |
| 100 else | 98 else |
| 101 paragraphRangeObject = createRange(paragraphRange); | 99 paragraphRangeObject = createRange(paragraphRange); |
| 102 | 100 |
| 103 const DocumentMarkerVector& markers = checkingRangeObject->ownerDocument().m
arkers().markersInRange(checkingRange, DocumentMarker::SpellCheckClientMarkers()
); | 101 return new SpellCheckRequest(checkingRangeObject, paragraphRangeObject, text
, textCheckingOptions, processType, requestNumber); |
| 104 Vector<uint32_t> hashes(markers.size()); | |
| 105 Vector<unsigned> offsets(markers.size()); | |
| 106 for (size_t i = 0; i < markers.size(); ++i) { | |
| 107 hashes[i] = markers[i]->hash(); | |
| 108 offsets[i] = markers[i]->startOffset(); | |
| 109 } | |
| 110 | |
| 111 return new SpellCheckRequest(checkingRangeObject, paragraphRangeObject, text
, textCheckingOptions, processType, hashes, offsets, requestNumber); | |
| 112 } | 102 } |
| 113 | 103 |
| 114 const TextCheckingRequestData& SpellCheckRequest::data() const | 104 const TextCheckingRequestData& SpellCheckRequest::data() const |
| 115 { | 105 { |
| 116 return m_requestData; | 106 return m_requestData; |
| 117 } | 107 } |
| 118 | 108 |
| 119 bool SpellCheckRequest::isValid() const | 109 bool SpellCheckRequest::isValid() const |
| 120 { | 110 { |
| 121 return m_checkingRange->isConnected() && m_paragraphRange->isConnected() &&
m_rootEditableElement->isConnected(); | 111 return m_checkingRange->isConnected() && m_paragraphRange->isConnected() &&
m_rootEditableElement->isConnected(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 270 |
| 281 clearProcessingRequest(); | 271 clearProcessingRequest(); |
| 282 if (!m_requestQueue.isEmpty()) | 272 if (!m_requestQueue.isEmpty()) |
| 283 m_timerToProcessQueuedRequest.startOneShot(0, BLINK_FROM_HERE); | 273 m_timerToProcessQueuedRequest.startOneShot(0, BLINK_FROM_HERE); |
| 284 } | 274 } |
| 285 | 275 |
| 286 void SpellCheckRequester::didCheckSucceed(int sequence, const Vector<TextCheckin
gResult>& results) | 276 void SpellCheckRequester::didCheckSucceed(int sequence, const Vector<TextCheckin
gResult>& results) |
| 287 { | 277 { |
| 288 TextCheckingRequestData requestData = m_processingRequest->data(); | 278 TextCheckingRequestData requestData = m_processingRequest->data(); |
| 289 if (requestData.sequence() == sequence) { | 279 if (requestData.sequence() == sequence) { |
| 290 DocumentMarker::MarkerTypes markers = DocumentMarker::SpellCheckClientMa
rkers(); | 280 DocumentMarker::MarkerTypes markers = DocumentMarker::MisspellingMarkers
(); |
| 291 if (!requestData.maskContains(TextCheckingTypeSpelling)) | 281 if (!requestData.maskContains(TextCheckingTypeSpelling)) |
| 292 markers.remove(DocumentMarker::Spelling); | 282 markers.remove(DocumentMarker::Spelling); |
| 293 if (!requestData.maskContains(TextCheckingTypeGrammar)) | 283 if (!requestData.maskContains(TextCheckingTypeGrammar)) |
| 294 markers.remove(DocumentMarker::Grammar); | 284 markers.remove(DocumentMarker::Grammar); |
| 295 if (m_processingRequest->isValid()) { | 285 if (m_processingRequest->isValid()) { |
| 296 Range* checkingRange = m_processingRequest->checkingRange(); | 286 Range* checkingRange = m_processingRequest->checkingRange(); |
| 297 frame().document()->markers().removeMarkers(EphemeralRange(checkingR
ange), markers); | 287 frame().document()->markers().removeMarkers(EphemeralRange(checkingR
ange), markers); |
| 298 } | 288 } |
| 299 } | 289 } |
| 300 didCheck(sequence, results); | 290 didCheck(sequence, results); |
| 301 } | 291 } |
| 302 | 292 |
| 303 void SpellCheckRequester::didCheckCancel(int sequence) | 293 void SpellCheckRequester::didCheckCancel(int sequence) |
| 304 { | 294 { |
| 305 Vector<TextCheckingResult> results; | 295 Vector<TextCheckingResult> results; |
| 306 didCheck(sequence, results); | 296 didCheck(sequence, results); |
| 307 } | 297 } |
| 308 | 298 |
| 309 DEFINE_TRACE(SpellCheckRequester) | 299 DEFINE_TRACE(SpellCheckRequester) |
| 310 { | 300 { |
| 311 visitor->trace(m_frame); | 301 visitor->trace(m_frame); |
| 312 visitor->trace(m_processingRequest); | 302 visitor->trace(m_processingRequest); |
| 313 visitor->trace(m_requestQueue); | 303 visitor->trace(m_requestQueue); |
| 314 } | 304 } |
| 315 | 305 |
| 316 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |