summaryrefslogtreecommitdiff
path: root/Source/WebCore/editing/SpellChecker.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/editing/SpellChecker.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/editing/SpellChecker.cpp')
-rw-r--r--Source/WebCore/editing/SpellChecker.cpp57
1 files changed, 28 insertions, 29 deletions
diff --git a/Source/WebCore/editing/SpellChecker.cpp b/Source/WebCore/editing/SpellChecker.cpp
index d2e4b82ab..7cb6237a4 100644
--- a/Source/WebCore/editing/SpellChecker.cpp
+++ b/Source/WebCore/editing/SpellChecker.cpp
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -30,9 +30,6 @@
#include "DocumentMarkerController.h"
#include "Editor.h"
#include "Frame.h"
-#include "HTMLInputElement.h"
-#include "HTMLTextAreaElement.h"
-#include "Node.h"
#include "Page.h"
#include "PositionIterator.h"
#include "RenderObject.h"
@@ -44,10 +41,9 @@
namespace WebCore {
SpellCheckRequest::SpellCheckRequest(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
- : m_checker(0)
- , m_checkingRange(checkingRange)
+ : m_checkingRange(checkingRange)
, m_paragraphRange(paragraphRange)
- , m_rootEditableElement(m_checkingRange->startContainer()->rootEditableElement())
+ , m_rootEditableElement(m_checkingRange->startContainer().rootEditableElement())
, m_requestData(unrequestedTextCheckingSequence, text, mask, processType)
{
}
@@ -57,16 +53,16 @@ SpellCheckRequest::~SpellCheckRequest()
}
// static
-PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask textCheckingOptions, TextCheckingProcessType processType, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange)
+RefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask textCheckingOptions, TextCheckingProcessType processType, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange)
{
ASSERT(checkingRange);
ASSERT(paragraphRange);
String text = checkingRange->text();
if (!text.length())
- return PassRefPtr<SpellCheckRequest>();
+ return nullptr;
- return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType));
+ return adoptRef(*new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType));
}
const TextCheckingRequestData& SpellCheckRequest::data() const
@@ -78,16 +74,20 @@ void SpellCheckRequest::didSucceed(const Vector<TextCheckingResult>& results)
{
if (!m_checker)
return;
+
+ Ref<SpellCheckRequest> protectedThis(*this);
m_checker->didCheckSucceed(m_requestData.sequence(), results);
- m_checker = 0;
+ m_checker = nullptr;
}
void SpellCheckRequest::didCancel()
{
if (!m_checker)
return;
+
+ Ref<SpellCheckRequest> protectedThis(*this);
m_checker->didCheckCancel(m_requestData.sequence());
- m_checker = 0;
+ m_checker = nullptr;
}
void SpellCheckRequest::setCheckerAndSequence(SpellChecker* requester, int sequence)
@@ -100,14 +100,14 @@ void SpellCheckRequest::setCheckerAndSequence(SpellChecker* requester, int seque
void SpellCheckRequest::requesterDestroyed()
{
- m_checker = 0;
+ m_checker = nullptr;
}
SpellChecker::SpellChecker(Frame& frame)
: m_frame(frame)
, m_lastRequestSequence(0)
, m_lastProcessedSequence(0)
- , m_timerToProcessQueuedRequest(this, &SpellChecker::timerFiredToProcessQueuedRequest)
+ , m_timerToProcessQueuedRequest(*this, &SpellChecker::timerFiredToProcessQueuedRequest)
{
}
@@ -115,19 +115,19 @@ SpellChecker::~SpellChecker()
{
if (m_processingRequest)
m_processingRequest->requesterDestroyed();
- for (RequestQueue::iterator i = m_requestQueue.begin(); i != m_requestQueue.end(); ++i)
- (*i)->requesterDestroyed();
+ for (auto& queue : m_requestQueue)
+ queue->requesterDestroyed();
}
TextCheckerClient* SpellChecker::client() const
{
Page* page = m_frame.page();
if (!page)
- return 0;
- return page->editorClient()->textChecker();
+ return nullptr;
+ return page->editorClient().textChecker();
}
-void SpellChecker::timerFiredToProcessQueuedRequest(Timer<SpellChecker>*)
+void SpellChecker::timerFiredToProcessQueuedRequest()
{
ASSERT(!m_requestQueue.isEmpty());
if (m_requestQueue.isEmpty())
@@ -150,8 +150,8 @@ bool SpellChecker::isCheckable(Range* range) const
{
if (!range || !range->firstNode() || !range->firstNode()->renderer())
return false;
- const Node* node = range->startContainer();
- if (node && node->isElementNode() && !toElement(node)->isSpellCheckingEnabled())
+ const Node& node = range->startContainer();
+ if (is<Element>(node) && !downcast<Element>(node).isSpellCheckingEnabled())
return false;
return true;
}
@@ -182,18 +182,18 @@ void SpellChecker::invokeRequest(PassRefPtr<SpellCheckRequest> request)
if (!client())
return;
m_processingRequest = request;
- client()->requestCheckingOfString(m_processingRequest);
+ client()->requestCheckingOfString(*m_processingRequest, m_frame.selection().selection());
}
void SpellChecker::enqueueRequest(PassRefPtr<SpellCheckRequest> request)
{
ASSERT(request);
- for (RequestQueue::iterator it = m_requestQueue.begin(); it != m_requestQueue.end(); ++it) {
- if (request->rootEditableElement() != (*it)->rootEditableElement())
+ for (auto& queue : m_requestQueue) {
+ if (request->rootEditableElement() != queue->rootEditableElement())
continue;
- *it = request;
+ queue = request;
return;
}
@@ -214,7 +214,7 @@ void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& resu
if (m_lastProcessedSequence < sequence)
m_lastProcessedSequence = sequence;
- m_processingRequest.clear();
+ m_processingRequest = nullptr;
if (!m_requestQueue.isEmpty())
m_timerToProcessQueuedRequest.startOneShot(0);
}
@@ -236,8 +236,7 @@ void SpellChecker::didCheckSucceed(int sequence, const Vector<TextCheckingResult
void SpellChecker::didCheckCancel(int sequence)
{
- Vector<TextCheckingResult> results;
- didCheck(sequence, results);
+ didCheck(sequence, Vector<TextCheckingResult>());
}
} // namespace WebCore