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

Unified Diff: Source/core/editing/SpellCheckRequester.cpp

Issue 23332004: Trigger spell check/remove markers if spell checker gets enabled/disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: true=>asynchronous Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/SpellCheckRequester.h ('k') | Source/web/EditorClientImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/SpellCheckRequester.cpp
diff --git a/Source/core/editing/SpellCheckRequester.cpp b/Source/core/editing/SpellCheckRequester.cpp
index 64e149774163b21aab24cb70b0026bb1a9fd1b30..a36c0d35b95fc7f42209eda7244c53e4d8f915f9 100644
--- a/Source/core/editing/SpellCheckRequester.cpp
+++ b/Source/core/editing/SpellCheckRequester.cpp
@@ -46,12 +46,14 @@ SpellCheckRequest::SpellCheckRequest(
TextCheckingTypeMask mask,
TextCheckingProcessType processType,
const Vector<uint32_t>& documentMarkersInRange,
- const Vector<unsigned>& documentMarkerOffsets)
+ const Vector<unsigned>& documentMarkerOffsets,
+ int requestNumber)
: m_requester(0)
, m_checkingRange(checkingRange)
, m_paragraphRange(paragraphRange)
, m_rootEditableElement(m_checkingRange->startContainer()->rootEditableElement())
, m_requestData(unrequestedTextCheckingSequence, text, mask, processType, documentMarkersInRange, documentMarkerOffsets)
+ , m_requestNumber(requestNumber)
{
}
@@ -60,7 +62,7 @@ SpellCheckRequest::~SpellCheckRequest()
}
// static
-PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask textCheckingOptions, TextCheckingProcessType processType, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange)
+PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask textCheckingOptions, TextCheckingProcessType processType, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, int requestNubmer)
{
ASSERT(checkingRange);
ASSERT(paragraphRange);
@@ -77,7 +79,7 @@ PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask tex
offsets[i] = markers[i]->startOffset();
}
- return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType, hashes, offsets));
+ return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType, hashes, offsets, requestNubmer));
}
const TextCheckingRequestData& SpellCheckRequest::data() const
@@ -205,13 +207,24 @@ void SpellCheckRequester::invokeRequest(PassRefPtr<SpellCheckRequest> request)
void SpellCheckRequester::enqueueRequest(PassRefPtr<SpellCheckRequest> request)
{
ASSERT(request);
+ bool continuation = false;
+ if (!m_requestQueue.isEmpty()) {
+ RefPtr<SpellCheckRequest> lastRequest = m_requestQueue.last();
+ // It's a continuation if the number of the last request got incremented in the new one and
+ // both apply to the same editable.
+ continuation = request->rootEditableElement() == lastRequest->rootEditableElement()
+ && request->requestNumber() == lastRequest->requestNumber() + 1;
+ }
- for (RequestQueue::iterator it = m_requestQueue.begin(); it != m_requestQueue.end(); ++it) {
- if (request->rootEditableElement() != (*it)->rootEditableElement())
- continue;
+ // Spellcheck requests for chunks of text in the same element should not overwrite each other.
+ if (!continuation) {
+ for (RequestQueue::iterator it = m_requestQueue.begin(); it != m_requestQueue.end(); ++it) {
+ if (request->rootEditableElement() != (*it)->rootEditableElement())
+ continue;
- *it = request;
- return;
+ *it = request;
+ return;
+ }
}
m_requestQueue.append(request);
« no previous file with comments | « Source/core/editing/SpellCheckRequester.h ('k') | Source/web/EditorClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698