REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac

https://bugs.webkit.org/show_bug.cgi?id=86859

Source/WebCore:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

The test tries to reach an invalid SpellChecker object. Such an access should be guarded
beforehand.

Asynchronous spellchecking can return results after originated
frame is gone, which triggered an invalid access to the dead spellchecker
object. This chagne prevents it by marking request objects from
the spellchecker as invalid:

- Originally TextCheckerClient API was passed a SpellCheker object.
  This change abstracted it behind TextCheckingRequest interface,
  didSucceed() and didCancel() method specifically.
- TextCheckingRequest was turned from a plain old object into
  a refcounted abstract class, which is now subclassed by SpellCheckRequest.
- SpellChecker now marks pending SpellCheckRequest objects as invalid
  on its destructor.

Test: editing/spelling/spellcheck-async-remove-frame.html

* WebCore.exp.in:
* editing/SpellChecker.cpp:
(WebCore::SpellCheckRequest::SpellCheckRequest):
(WebCore::SpellCheckRequest::create):
(WebCore::SpellCheckRequest::didSucceed):
(WebCore):
(WebCore::SpellCheckRequest::didCancel):
(WebCore::SpellCheckRequest::wasRequestedBy):
(WebCore::SpellCheckRequest::requesterDestroyed):
(WebCore::SpellChecker::~SpellChecker):
(WebCore::SpellChecker::requestCheckingFor):
(WebCore::SpellChecker::invokeRequest):
(WebCore::SpellChecker::didCheckSucceed):
(WebCore::SpellChecker::didCheckCancel):
* editing/SpellChecker.h:
(WebCore):
(SpellCheckRequest):
(WebCore::SpellCheckRequest::isStarted):
(SpellChecker):
* loader/EmptyClients.h:
(WebCore::EmptyTextCheckerClient::requestCheckingOfString):
* platform/text/TextCheckerClient.h:
(TextCheckerClient):
* platform/text/TextChecking.h:
(GrammarDetail):
(TextCheckingResult):
(TextCheckingRequest):
(WebCore::TextCheckingRequest::~TextCheckingRequest):

Source/WebKit/blackberry:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::requestCheckingOfString):
* WebCoreSupport/EditorClientBlackBerry.h:
(EditorClientBlackBerry):

Source/WebKit/chromium:

Removed a port specific fix which was introduced at r117572.

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::frameWillDetachPage):
(WebKit::EditorClientImpl::requestCheckingOfString):
* src/EditorClientImpl.h:
(WebCore):
(EditorClientImpl):
* src/WebTextCheckingCompletionImpl.cpp:
(WebKit::WebTextCheckingCompletionImpl::didFinishCheckingText):
(WebKit::WebTextCheckingCompletionImpl::didCancelCheckingText):
* src/WebTextCheckingCompletionImpl.h:
(WebKit::WebTextCheckingCompletionImpl::WebTextCheckingCompletionImpl):
(WebTextCheckingCompletionImpl):

Source/WebKit/efl:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/EditorClientEfl.h:
(WebCore::EditorClientEfl::requestCheckingOfString):

Source/WebKit/gtk:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/TextCheckerClientGtk.h:
(WebKit::TextCheckerClientGtk::requestCheckingOfString):

Source/WebKit/mac:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(-[WebEditorSpellCheckResponder initWithClient:sequence:results:]):
(-[WebEditorSpellCheckResponder perform]):
(WebEditorClient::didCheckSucceeded):
(WebEditorClient::requestCheckingOfString):

Source/WebKit/qt:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/TextCheckerClientQt.h:
(WebCore::TextCheckerClientQt::requestCheckingOfString):

Source/WebKit/win:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/WebEditorClient.h:
(WebEditorClient::requestCheckingOfString):

Source/WebKit/wince:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebCoreSupport/EditorClientWinCE.h:
(WebKit::EditorClientWinCE::requestCheckingOfString):

Source/WebKit/wx:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebKitSupport/EditorClientWx.h:
(WebCore::EditorClientWx::requestCheckingOfString):

Source/WebKit2:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::requestCheckingOfString):
* WebProcess/WebCoreSupport/WebEditorClient.h:

LayoutTests:

Patch by Hajime Morrita <morrita@chromium.org> on 2012-05-31
Reviewed by Ryosuke Niwa.

* platform/mac/Skipped: Unskipped the test.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 15e0ad1f
2012-05-31 Hajime Morrita <morrita@chromium.org>
REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac
https://bugs.webkit.org/show_bug.cgi?id=86859
Reviewed by Ryosuke Niwa.
* platform/mac/Skipped: Unskipped the test.
2012-05-31 Tony Chang <tony@chromium.org>
initial flex value should be 1 1 auto
......
......@@ -842,8 +842,9 @@ plugins/npruntime/delete-plugin-within-setProperty.html
plugins/npruntime/delete-plugin-within-hasProperty-return-true.html
plugins/npruntime/delete-plugin-within-hasProperty-return-false.html
# https://bugs.webkit.org/show_bug.cgi?id=86859
editing/spelling/spellcheck-async-remove-frame.html
# https://bugs.webkit.org/show_bug.cgi?id=86786
mathml/presentation/mo-stretch.html
mathml/presentation/mroot-pref-width.html
# https://bugs.webkit.org/show_bug.cgi?id=87199
compositing/video/video-poster.html
......
2012-05-31 Hajime Morrita <morrita@chromium.org>
REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac
https://bugs.webkit.org/show_bug.cgi?id=86859
Reviewed by Ryosuke Niwa.
The test tries to reach an invalid SpellChecker object. Such an access should be guarded
beforehand.
Asynchronous spellchecking can return results after originated
frame is gone, which triggered an invalid access to the dead spellchecker
object. This chagne prevents it by marking request objects from
the spellchecker as invalid:
- Originally TextCheckerClient API was passed a SpellCheker object.
This change abstracted it behind TextCheckingRequest interface,
didSucceed() and didCancel() method specifically.
- TextCheckingRequest was turned from a plain old object into
a refcounted abstract class, which is now subclassed by SpellCheckRequest.
- SpellChecker now marks pending SpellCheckRequest objects as invalid
on its destructor.
Test: editing/spelling/spellcheck-async-remove-frame.html
* WebCore.exp.in:
* editing/SpellChecker.cpp:
(WebCore::SpellCheckRequest::SpellCheckRequest):
(WebCore::SpellCheckRequest::create):
(WebCore::SpellCheckRequest::didSucceed):
(WebCore):
(WebCore::SpellCheckRequest::didCancel):
(WebCore::SpellCheckRequest::wasRequestedBy):
(WebCore::SpellCheckRequest::requesterDestroyed):
(WebCore::SpellChecker::~SpellChecker):
(WebCore::SpellChecker::requestCheckingFor):
(WebCore::SpellChecker::invokeRequest):
(WebCore::SpellChecker::didCheckSucceed):
(WebCore::SpellChecker::didCheckCancel):
* editing/SpellChecker.h:
(WebCore):
(SpellCheckRequest):
(WebCore::SpellCheckRequest::isStarted):
(SpellChecker):
* loader/EmptyClients.h:
(WebCore::EmptyTextCheckerClient::requestCheckingOfString):
* platform/text/TextCheckerClient.h:
(TextCheckerClient):
* platform/text/TextChecking.h:
(GrammarDetail):
(TextCheckingResult):
(TextCheckingRequest):
(WebCore::TextCheckingRequest::~TextCheckingRequest):
2012-05-31 Tony Chang <tony@chromium.org>
initial flex value should be 1 1 auto
......
......@@ -281,7 +281,6 @@ __ZN7WebCore12SharedBufferC1EPKci
__ZN7WebCore12SharedBufferC1EPKhi
__ZN7WebCore12SharedBufferC1Ev
__ZN7WebCore12SharedBufferD1Ev
__ZN7WebCore12SpellChecker17didCheckSucceededEiRKN3WTF6VectorINS_18TextCheckingResultELm0EEE
__ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
__ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib
......
......@@ -47,11 +47,9 @@ namespace WebCore {
static const int unrequestedSequence = -1;
SpellCheckRequest::SpellCheckRequest(int sequence, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
: m_sequence(sequence)
, m_text(text)
, m_mask(mask)
, m_processType(processType)
SpellCheckRequest::SpellCheckRequest(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
: TextCheckingRequest(unrequestedSequence, text, mask, processType)
, m_checker(0)
, m_checkingRange(checkingRange)
, m_paragraphRange(paragraphRange)
, m_rootEditableElement(m_checkingRange->startContainer()->rootEditableElement())
......@@ -72,10 +70,37 @@ PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask tex
if (!text.length())
return PassRefPtr<SpellCheckRequest>();
return adoptRef(new SpellCheckRequest(unrequestedSequence, checkingRange, paragraphRange, text, textCheckingOptions, processType));
return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType));
}
void SpellCheckRequest::didSucceed(const Vector<TextCheckingResult>& results)
{
if (!m_checker)
return;
m_checker->didCheckSucceed(m_sequence, results);
m_checker = 0;
}
void SpellCheckRequest::didCancel()
{
if (!m_checker)
return;
m_checker->didCheckCancel(m_sequence);
m_checker = 0;
}
void SpellCheckRequest::setCheckerAndSequence(SpellChecker* requester, int sequence)
{
ASSERT(!m_checker);
ASSERT(m_sequence == unrequestedSequence);
m_checker = requester;
m_sequence = sequence;
}
void SpellCheckRequest::requesterDestroyed()
{
m_checker = 0;
}
SpellChecker::SpellChecker(Frame* frame)
: m_frame(frame)
......@@ -87,6 +112,10 @@ SpellChecker::SpellChecker(Frame* frame)
SpellChecker::~SpellChecker()
{
if (m_processingRequest)
m_processingRequest->requesterDestroyed();
for (RequestQueue::iterator i = m_requestQueue.begin(); i != m_requestQueue.end(); ++i)
(*i)->requesterDestroyed();
}
TextCheckerClient* SpellChecker::client() const
......@@ -136,7 +165,7 @@ void SpellChecker::requestCheckingFor(PassRefPtr<SpellCheckRequest> request)
if (sequence == unrequestedSequence)
sequence = ++m_lastRequestSequence;
request->setSequence(sequence);
request->setCheckerAndSequence(this, sequence);
if (m_timerToProcessQueuedRequest.isActive() || m_processingRequest) {
enqueueRequest(request);
......@@ -151,7 +180,7 @@ void SpellChecker::invokeRequest(PassRefPtr<SpellCheckRequest> request)
ASSERT(!m_processingRequest);
m_processingRequest = request;
client()->requestCheckingOfString(this, m_processingRequest->textCheckingRequest());
client()->requestCheckingOfString(m_processingRequest);
}
void SpellChecker::enqueueRequest(PassRefPtr<SpellCheckRequest> request)
......@@ -188,7 +217,7 @@ void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& resu
m_timerToProcessQueuedRequest.startOneShot(0);
}
void SpellChecker::didCheckSucceeded(int sequence, const Vector<TextCheckingResult>& results)
void SpellChecker::didCheckSucceed(int sequence, const Vector<TextCheckingResult>& results)
{
if (m_processingRequest->sequence() == sequence) {
unsigned markers = 0;
......@@ -202,7 +231,7 @@ void SpellChecker::didCheckSucceeded(int sequence, const Vector<TextCheckingResu
didCheck(sequence, results);
}
void SpellChecker::didCheckCanceled(int sequence)
void SpellChecker::didCheckCancel(int sequence)
{
Vector<TextCheckingResult> results;
didCheck(sequence, results);
......
......@@ -42,30 +42,28 @@ namespace WebCore {
class Frame;
class Node;
class TextCheckerClient;
struct TextCheckingResult;
class SpellChecker;
class SpellCheckRequest : public RefCounted<SpellCheckRequest> {
class SpellCheckRequest : public TextCheckingRequest {
public:
SpellCheckRequest(int sequence, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String&, TextCheckingTypeMask, TextCheckingProcessType);
~SpellCheckRequest();
SpellCheckRequest(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String&, TextCheckingTypeMask, TextCheckingProcessType);
virtual ~SpellCheckRequest();
static PassRefPtr<SpellCheckRequest> create(TextCheckingTypeMask, TextCheckingProcessType, PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange);
TextCheckingRequest textCheckingRequest() const;
void setSequence(int sequence) { m_sequence = sequence; }
int sequence() const { return m_sequence; }
PassRefPtr<Range> checkingRange() const { return m_checkingRange; }
PassRefPtr<Range> paragraphRange() const { return m_paragraphRange; }
const String& text() const { return m_text; }
TextCheckingTypeMask mask() const { return m_mask; }
TextCheckingProcessType processType() const { return m_processType; }
PassRefPtr<Element> rootEditableElement() const { return m_rootEditableElement; }
void setCheckerAndSequence(SpellChecker*, int sequence);
void requesterDestroyed();
bool isStarted() const { return m_checker; }
virtual void didSucceed(const Vector<TextCheckingResult>&) OVERRIDE;
virtual void didCancel() OVERRIDE;
private:
int m_sequence;
String m_text;
TextCheckingTypeMask m_mask;
TextCheckingProcessType m_processType;
SpellChecker* m_checker;
RefPtr<Range> m_checkingRange;
RefPtr<Range> m_paragraphRange;
RefPtr<Element> m_rootEditableElement;
......@@ -74,6 +72,8 @@ private:
class SpellChecker {
WTF_MAKE_NONCOPYABLE(SpellChecker);
public:
friend class SpellCheckRequest;
explicit SpellChecker(Frame*);
~SpellChecker();
......@@ -81,8 +81,6 @@ public:
bool isCheckable(Range*) const;
void requestCheckingFor(PassRefPtr<SpellCheckRequest>);
void didCheckSucceeded(int sequence, const Vector<TextCheckingResult>&);
void didCheckCanceled(int sequence);
int lastRequestSequence() const
{
......@@ -102,6 +100,8 @@ private:
void timerFiredToProcessQueuedRequest(Timer<SpellChecker>*);
void invokeRequest(PassRefPtr<SpellCheckRequest>);
void enqueueRequest(PassRefPtr<SpellCheckRequest>);
void didCheckSucceed(int sequence, const Vector<TextCheckingResult>&);
void didCheckCancel(int sequence);
void didCheck(int sequence, const Vector<TextCheckingResult>&);
Frame* m_frame;
......@@ -114,11 +114,6 @@ private:
RequestQueue m_requestQueue;
};
inline TextCheckingRequest SpellCheckRequest::textCheckingRequest() const
{
return TextCheckingRequest(m_sequence, m_text, m_mask, m_processType);
}
} // namespace WebCore
#endif // SpellChecker_h
......@@ -428,7 +428,7 @@ public:
#endif
virtual void getGuessesForWord(const String&, const String&, Vector<String>&) { }
virtual void requestCheckingOfString(SpellChecker*, const TextCheckingRequest&) { }
virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) { }
};
class EmptyEditorClient : public EditorClient {
......
......@@ -31,29 +31,12 @@
#include "TextChecking.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class SpellChecker;
class TextCheckingRequest;
struct GrammarDetail {
int location;
int length;
Vector<String> guesses;
String userDescription;
};
struct TextCheckingResult {
TextCheckingType type;
int location;
int length;
Vector<GrammarDetail> details;
String replacement;
};
class TextCheckerClient {
public:
virtual ~TextCheckerClient() {}
......@@ -73,7 +56,7 @@ public:
// provide more accurate correction suggestions. Caller can pass in more text in "context" to aid such spellcheckers on language
// identification. Noramlly it's the text surrounding the "word" for which we are getting correction suggestions.
virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) = 0;
virtual void requestCheckingOfString(SpellChecker*, const TextCheckingRequest&) = 0;
virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) = 0;
};
}
......
......@@ -31,6 +31,8 @@
#ifndef TextChecking_h
#define TextChecking_h
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
......@@ -68,23 +70,40 @@ enum TextCheckingProcessType {
TextCheckingProcessIncremental
};
class TextCheckingRequest {
struct GrammarDetail {
int location;
int length;
Vector<String> guesses;
String userDescription;
};
struct TextCheckingResult {
TextCheckingType type;
int location;
int length;
Vector<GrammarDetail> details;
String replacement;
};
class TextCheckingRequest : public RefCounted<TextCheckingRequest> {
public:
TextCheckingRequest(int sequence, String text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
TextCheckingRequest(int sequence, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
: m_sequence(sequence)
, m_text(text)
, m_mask(mask)
, m_processType(processType)
{
}
{ }
virtual ~TextCheckingRequest() { }
virtual void didSucceed(const Vector<TextCheckingResult>&) = 0;
virtual void didCancel() = 0;
void setSequence(int sequence) { m_sequence = sequence; }
int sequence() const { return m_sequence; }
String text() const { return m_text; }
TextCheckingTypeMask mask() const { return m_mask; }
TextCheckingProcessType processType() const { return m_processType; }
private:
protected:
int m_sequence;
String m_text;
TextCheckingTypeMask m_mask;
......
2012-05-31 Hajime Morrita <morrita@chromium.org>
REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac
https://bugs.webkit.org/show_bug.cgi?id=86859
Reviewed by Ryosuke Niwa.
* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::requestCheckingOfString):
* WebCoreSupport/EditorClientBlackBerry.h:
(EditorClientBlackBerry):
2012-05-31 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebGL and 2D canvas output not available to WebPageCompositor
......
......@@ -565,7 +565,7 @@ void EditorClientBlackBerry::checkGrammarOfString(const UChar*, int, WTF::Vector
notImplemented();
}
void EditorClientBlackBerry::requestCheckingOfString(SpellChecker*, const TextCheckingRequest&)
void EditorClientBlackBerry::requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>)
{
notImplemented();
}
......
......@@ -86,7 +86,7 @@ public:
virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
virtual void checkGrammarOfString(const UChar*, int, Vector<GrammarDetail, 0u>&, int*, int*);
virtual void getGuessesForWord(const String&, const String&, Vector<String>&);
virtual void requestCheckingOfString(SpellChecker*, const TextCheckingRequest&);
virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>);
virtual TextCheckerClient* textChecker();
virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
......
2012-05-31 Hajime Morrita <morrita@chromium.org>
REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac
https://bugs.webkit.org/show_bug.cgi?id=86859
Removed a port specific fix which was introduced at r117572.
Reviewed by Ryosuke Niwa.
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::frameWillDetachPage):
(WebKit::EditorClientImpl::requestCheckingOfString):
* src/EditorClientImpl.h:
(WebCore):
(EditorClientImpl):
* src/WebTextCheckingCompletionImpl.cpp:
(WebKit::WebTextCheckingCompletionImpl::didFinishCheckingText):
(WebKit::WebTextCheckingCompletionImpl::didCancelCheckingText):
* src/WebTextCheckingCompletionImpl.h:
(WebKit::WebTextCheckingCompletionImpl::WebTextCheckingCompletionImpl):
(WebTextCheckingCompletionImpl):
2012-05-31 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r119146.
......
......@@ -90,17 +90,6 @@ void EditorClientImpl::pageDestroyed()
void EditorClientImpl::frameWillDetachPage(WebCore::Frame* frame)
{
HashSet<WebTextCheckingCompletionImpl*> validRequests;
for (HashSet<WebTextCheckingCompletionImpl*>::iterator i = m_pendingTextChecks.begin();
i != m_pendingTextChecks.end(); ++i) {
if (frame->editor()->spellChecker() == (*i)->spellChecker())
(*i)->invalidate();
else
validRequests.add(*i);
}
m_pendingTextChecks.swap(validRequests);
}
bool EditorClientImpl::shouldShowDeleteInterface(HTMLElement* elem)
......@@ -752,19 +741,12 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
*misspellingLength = spellLength;
}
void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, const WebCore::TextCheckingRequest& request)
void EditorClientImpl::requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
{
if (!m_webView->spellCheckClient())
return;
WebTextCheckingCompletionImpl* completion = new WebTextCheckingCompletionImpl(request.sequence(), sender, this);
m_pendingTextChecks.add(completion);
m_webView->spellCheckClient()->requestCheckingOfText(request.text(), completion);
}
void EditorClientImpl::didCheckString(WebTextCheckingCompletionImpl* completion)
{
m_pendingTextChecks.remove(completion);
if (m_webView->spellCheckClient()) {
String text = request->text();
m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(request));
}
}
String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord)
......
......@@ -40,7 +40,6 @@
namespace WebCore {
class Frame;
class HTMLInputElement;
class SpellChecker;
}
namespace WebKit {
......@@ -113,12 +112,10 @@ public:
virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
virtual void willSetInputMethodState();
virtual void setInputMethodState(bool enabled);
virtual void requestCheckingOfString(WebCore::SpellChecker*, const WebCore::TextCheckingRequest&);
virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>);
virtual WebCore::TextCheckerClient* textChecker() { return this; }
void didCheckString(WebTextCheckingCompletionImpl*);
private:
void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*);
......@@ -146,8 +143,6 @@ private:
SpellCheckForcedOff
};
int m_spellCheckThisFieldStatus;
WTF::HashSet<WebTextCheckingCompletionImpl*> m_pendingTextChecks;
};
} // namespace WebKit
......
......@@ -52,28 +52,14 @@ static Vector<TextCheckingResult> toCoreResults(const WebVector<WebTextCheckingR
void WebTextCheckingCompletionImpl::didFinishCheckingText(const WebVector<WebTextCheckingResult>& results)
{
if (m_spellChecker) {
m_spellChecker->didCheckSucceeded(m_identifier, toCoreResults(results));
m_editorClient->didCheckString(this);
}
m_request->didSucceed(toCoreResults(results));
delete this;
}
void WebTextCheckingCompletionImpl::didCancelCheckingText()
{
if (m_spellChecker) {
m_spellChecker->didCheckCanceled(m_identifier);
m_editorClient->didCheckString(this);
}
m_request->didCancel();
delete this;
}
void WebTextCheckingCompletionImpl::invalidate()
{
m_spellChecker = 0;
m_editorClient = 0;
}
} // namespace WebKit
......@@ -31,11 +31,9 @@
#ifndef WebTextCheckingCompletionImpl_h
#define WebTextCheckingCompletionImpl_h
#include "TextChecking.h"
#include "WebTextCheckingCompletion.h"
namespace WebCore {
class SpellChecker;
}
#include <wtf/RefPtr.h>
namespace WebKit {
......@@ -43,25 +41,18 @@ class EditorClientImpl;
class WebTextCheckingCompletionImpl : public WebTextCheckingCompletion {
public:
WebTextCheckingCompletionImpl(int identifier, WebCore::SpellChecker* spellchecker, EditorClientImpl* editorClient)
: m_identifier(identifier)
, m_spellChecker(spellchecker)
, m_editorClient(editorClient)
explicit WebTextCheckingCompletionImpl(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
: m_request(request)
{
}
virtual void didFinishCheckingText(const WebVector<WebTextCheckingResult>&);
virtual void didCancelCheckingText();
void invalidate();
WebCore::SpellChecker* spellChecker() const { return m_spellChecker; }
virtual void didFinishCheckingText(const WebVector<WebTextCheckingResult>&) OVERRIDE;
virtual void didCancelCheckingText() OVERRIDE;
private:
virtual ~WebTextCheckingCompletionImpl() { }
int m_identifier;
WebCore::SpellChecker* m_spellChecker;
EditorClientImpl* m_editorClient;
WTF::RefPtr<WebCore::TextCheckingRequest> m_request;
};
} // namespace WebKit
......
2012-05-31 Hajime Morrita <morrita@chromium.org>
REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac
https://bugs.webkit.org/show_bug.cgi?id=86859
Reviewed by Ryosuke Niwa.
* WebCoreSupport/EditorClientEfl.h:
(WebCore::EditorClientEfl::requestCheckingOfString):
2012-05-31 Jussi Kukkonen <jussi.kukkonen@intel.com>
[EFL][DRT] LayoutTestController does not implement clearApplicationCacheForOrigin
......
......@@ -150,7 +150,7 @@ public:
virtual void getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses);
virtual void willSetInputMethodState();
virtual void setInputMethodState(bool enabled);
virtual void requestCheckingOfString(WebCore::SpellChecker*, const WebCore::TextCheckingRequest&) { }
virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) { }
virtual TextCheckerClient* textChecker() { return this; }
private:
......
2012-05-31 Hajime Morrita <morrita@chromium.org>