| Differences between
and this patch
- a/Source/WebCore/ChangeLog +36 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-02-21  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
2
3
        Allow to retrieve the request data from abstract TextCheckingRequest to be accessible for WK2
4
        https://bugs.webkit.org/show_bug.cgi?id=110208
5
6
        Reviewed by Hajime Morrita.
7
8
        The WebCore changes are required to implement asynchronous spell checking in WK2.
9
        The idea of asynchronous spell checking in WK1 is to pass the pointer to the abstract object
10
        to the client who is able to verify the given text and notify the WebCore about results.
11
        WK2 will extract the request data and pass it (with additional information) to the UIProcess.
12
13
        No new tests, covered by editing/spelling tests.
14
15
        * editing/Editor.cpp:
16
        (WebCore::Editor::markAndReplaceFor):
17
        Extract the request data as it is the member of 'TextCheckingRequest'.
18
19
        * editing/SpellChecker.cpp:
20
        (WebCore):
21
        (WebCore::SpellCheckRequest::didCancel):
22
        (WebCore::SpellCheckRequest::setCheckerAndSequence):
23
        (WebCore::SpellChecker::requestCheckingFor):
24
        (WebCore::SpellChecker::enqueueRequest):
25
        (WebCore::SpellChecker::didCheck):
26
        (WebCore::SpellChecker::didCheckSucceed):
27
        * platform/text/TextChecking.h:
28
        (WebCore):
29
        (TextCheckingRequestData):
30
        Introduce a new 'TextCheckingRequestData' class to keep the request data and to
31
        easy extract it from the 'TextCheckingRequest'.
32
33
        (WebCore::TextCheckingRequestData::TextCheckingRequestData):
34
        (TextCheckingRequest):
35
        (WebCore::TextCheckingRequest::~TextCheckingRequest):
36
1
2013-02-21  Ken Kania  <kkania@chromium.org>
37
2013-02-21  Ken Kania  <kkania@chromium.org>
2
38
3
        Web Inspector: Add command for selecting files for file input element
39
        Web Inspector: Add command for selecting files for file input element
- a/Source/WebCore/editing/Editor.cpp -1 / +1 lines
Lines 2135-2141 void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect a/Source/WebCore/editing/Editor.cpp_sec1
2135
{
2135
{
2136
    ASSERT(request);
2136
    ASSERT(request);
2137
2137
2138
    TextCheckingTypeMask textCheckingOptions = request->mask();
2138
    TextCheckingTypeMask textCheckingOptions = request->data().mask();
2139
    TextCheckingParagraph paragraph(request->checkingRange(), request->paragraphRange());
2139
    TextCheckingParagraph paragraph(request->checkingRange(), request->paragraphRange());
2140
2140
2141
    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
2141
    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
- a/Source/WebCore/editing/SpellChecker.cpp -15 / +19 lines
Lines 45-58 a/Source/WebCore/editing/SpellChecker.cpp_sec1
45
45
46
namespace WebCore {
46
namespace WebCore {
47
47
48
static const int unrequestedSequence = -1;
49
50
SpellCheckRequest::SpellCheckRequest(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
48
SpellCheckRequest::SpellCheckRequest(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
51
    : TextCheckingRequest(unrequestedSequence, text, mask, processType)
49
    : m_checker(0)
52
    , m_checker(0)
53
    , m_checkingRange(checkingRange)
50
    , m_checkingRange(checkingRange)
54
    , m_paragraphRange(paragraphRange)
51
    , m_paragraphRange(paragraphRange)
55
    , m_rootEditableElement(m_checkingRange->startContainer()->rootEditableElement())
52
    , m_rootEditableElement(m_checkingRange->startContainer()->rootEditableElement())
53
    , m_requestData(unrequestedTextCheckingSequence, text, mask, processType)
56
{
54
{
57
}
55
}
58
56
Lines 73-83 PassRefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask tex a/Source/WebCore/editing/SpellChecker.cpp_sec2
73
    return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType));
71
    return adoptRef(new SpellCheckRequest(checkingRange, paragraphRange, text, textCheckingOptions, processType));
74
}
72
}
75
73
74
const TextCheckingRequestData& SpellCheckRequest::data() const
75
{
76
    return m_requestData;
77
}
78
76
void SpellCheckRequest::didSucceed(const Vector<TextCheckingResult>& results)
79
void SpellCheckRequest::didSucceed(const Vector<TextCheckingResult>& results)
77
{
80
{
78
    if (!m_checker)
81
    if (!m_checker)
79
        return;
82
        return;
80
    m_checker->didCheckSucceed(m_sequence, results);
83
    m_checker->didCheckSucceed(m_requestData.sequence(), results);
81
    m_checker = 0;
84
    m_checker = 0;
82
}
85
}
83
86
Lines 85-100 void SpellCheckRequest::didCancel() a/Source/WebCore/editing/SpellChecker.cpp_sec3
85
{
88
{
86
    if (!m_checker)
89
    if (!m_checker)
87
        return;
90
        return;
88
    m_checker->didCheckCancel(m_sequence);
91
    m_checker->didCheckCancel(m_requestData.sequence());
89
    m_checker = 0;
92
    m_checker = 0;
90
}
93
}
91
94
92
void SpellCheckRequest::setCheckerAndSequence(SpellChecker* requester, int sequence)
95
void SpellCheckRequest::setCheckerAndSequence(SpellChecker* requester, int sequence)
93
{
96
{
94
    ASSERT(!m_checker);
97
    ASSERT(!m_checker);
95
    ASSERT(m_sequence == unrequestedSequence);
98
    ASSERT(m_requestData.sequence() == unrequestedTextCheckingSequence);
96
    m_checker = requester;
99
    m_checker = requester;
97
    m_sequence = sequence;
100
    m_requestData.m_sequence = sequence;
98
}
101
}
99
102
100
void SpellCheckRequest::requesterDestroyed()
103
void SpellCheckRequest::requesterDestroyed()
Lines 160-168 void SpellChecker::requestCheckingFor(PassRefPtr<SpellCheckRequest> request) a/Source/WebCore/editing/SpellChecker.cpp_sec4
160
    if (!request || !canCheckAsynchronously(request->paragraphRange().get()))
163
    if (!request || !canCheckAsynchronously(request->paragraphRange().get()))
161
        return;
164
        return;
162
165
163
    ASSERT(request->sequence() == unrequestedSequence);
166
    ASSERT(request->data().sequence() == unrequestedTextCheckingSequence);
164
    int sequence = ++m_lastRequestSequence;
167
    int sequence = ++m_lastRequestSequence;
165
    if (sequence == unrequestedSequence)
168
    if (sequence == unrequestedTextCheckingSequence)
166
        sequence = ++m_lastRequestSequence;
169
        sequence = ++m_lastRequestSequence;
167
170
168
    request->setCheckerAndSequence(this, sequence);
171
    request->setCheckerAndSequence(this, sequence);
Lines 202-209 void SpellChecker::enqueueRequest(PassRefPtr<SpellCheckRequest> request) a/Source/WebCore/editing/SpellChecker.cpp_sec5
202
void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& results)
205
void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& results)
203
{
206
{
204
    ASSERT(m_processingRequest);
207
    ASSERT(m_processingRequest);
205
    ASSERT(m_processingRequest->sequence() == sequence);
208
    ASSERT(m_processingRequest->data().sequence() == sequence);
206
    if (m_processingRequest->sequence() != sequence) {
209
    if (m_processingRequest->data().sequence() != sequence) {
207
        m_requestQueue.clear();
210
        m_requestQueue.clear();
208
        return;
211
        return;
209
    }
212
    }
Lines 220-230 void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& resu a/Source/WebCore/editing/SpellChecker.cpp_sec6
220
223
221
void SpellChecker::didCheckSucceed(int sequence, const Vector<TextCheckingResult>& results)
224
void SpellChecker::didCheckSucceed(int sequence, const Vector<TextCheckingResult>& results)
222
{
225
{
223
    if (m_processingRequest->sequence() == sequence) {
226
    TextCheckingRequestData requestData = m_processingRequest->data();
227
    if (requestData.sequence() == sequence) {
224
        unsigned markers = 0;
228
        unsigned markers = 0;
225
        if (m_processingRequest->mask() & TextCheckingTypeSpelling)
229
        if (requestData.mask() & TextCheckingTypeSpelling)
226
            markers |= DocumentMarker::Spelling;
230
            markers |= DocumentMarker::Spelling;
227
        if (m_processingRequest->mask() & TextCheckingTypeGrammar)
231
        if (requestData.mask() & TextCheckingTypeGrammar)
228
            markers |= DocumentMarker::Grammar;
232
            markers |= DocumentMarker::Grammar;
229
        if (markers)
233
        if (markers)
230
            m_frame->document()->markers()->removeMarkers(m_processingRequest->checkingRange().get(), markers);
234
            m_frame->document()->markers()->removeMarkers(m_processingRequest->checkingRange().get(), markers);
- a/Source/WebCore/editing/SpellChecker.h +2 lines
Lines 59-64 public: a/Source/WebCore/editing/SpellChecker.h_sec1
59
    void requesterDestroyed();
59
    void requesterDestroyed();
60
    bool isStarted() const { return m_checker; }
60
    bool isStarted() const { return m_checker; }
61
61
62
    virtual const TextCheckingRequestData& data() const OVERRIDE;
62
    virtual void didSucceed(const Vector<TextCheckingResult>&) OVERRIDE;
63
    virtual void didSucceed(const Vector<TextCheckingResult>&) OVERRIDE;
63
    virtual void didCancel() OVERRIDE;
64
    virtual void didCancel() OVERRIDE;
64
65
Lines 67-72 private: a/Source/WebCore/editing/SpellChecker.h_sec2
67
    RefPtr<Range> m_checkingRange;
68
    RefPtr<Range> m_checkingRange;
68
    RefPtr<Range> m_paragraphRange;
69
    RefPtr<Range> m_paragraphRange;
69
    RefPtr<Element> m_rootEditableElement;
70
    RefPtr<Element> m_rootEditableElement;
71
    TextCheckingRequestData m_requestData;
70
};
72
};
71
73
72
class SpellChecker {
74
class SpellChecker {
- a/Source/WebCore/platform/text/TextChecking.h -7 / +21 lines
Lines 55-60 namespace WebCore { a/Source/WebCore/platform/text/TextChecking.h_sec1
55
#endif // #if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
55
#endif // #if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
56
56
57
enum TextCheckingType {
57
enum TextCheckingType {
58
    TextCheckingTypeNone        = 0,
58
    TextCheckingTypeSpelling    = 1 << 1,
59
    TextCheckingTypeSpelling    = 1 << 1,
59
    TextCheckingTypeGrammar     = 1 << 2,
60
    TextCheckingTypeGrammar     = 1 << 2,
60
    TextCheckingTypeLink        = 1 << 5,
61
    TextCheckingTypeLink        = 1 << 5,
Lines 87-117 struct TextCheckingResult { a/Source/WebCore/platform/text/TextChecking.h_sec2
87
    String replacement;
88
    String replacement;
88
};
89
};
89
90
90
class TextCheckingRequest : public RefCounted<TextCheckingRequest> {
91
const int unrequestedTextCheckingSequence = -1;
92
93
class TextCheckingRequestData {
94
    friend class SpellCheckRequest; // For access to m_sequence.
91
public:
95
public:
92
    TextCheckingRequest(int sequence, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
96
    TextCheckingRequestData()
97
        : m_sequence(unrequestedTextCheckingSequence)
98
        , m_mask(TextCheckingTypeNone)
99
        , m_processType(TextCheckingProcessIncremental)
100
    { }
101
    TextCheckingRequestData(int sequence, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
93
        : m_sequence(sequence)
102
        : m_sequence(sequence)
94
        , m_text(text)
103
        , m_text(text)
95
        , m_mask(mask)
104
        , m_mask(mask)
96
        , m_processType(processType)
105
        , m_processType(processType)
97
    { }
106
    { }
98
107
99
    virtual ~TextCheckingRequest() { }
100
    virtual void didSucceed(const Vector<TextCheckingResult>&) = 0;
101
    virtual void didCancel() = 0;
102
103
    int sequence() const { return m_sequence; }
108
    int sequence() const { return m_sequence; }
104
    String text() const { return m_text; }
109
    String text() const { return m_text; }
105
    TextCheckingTypeMask mask() const { return m_mask; }
110
    TextCheckingTypeMask mask() const { return m_mask; }
106
    TextCheckingProcessType processType() const { return m_processType; }
111
    TextCheckingProcessType processType() const { return m_processType; }
107
112
108
protected:
113
private:
109
    int m_sequence;
114
    int m_sequence;
110
    String m_text;
115
    String m_text;
111
    TextCheckingTypeMask m_mask;
116
    TextCheckingTypeMask m_mask;
112
    TextCheckingProcessType m_processType;
117
    TextCheckingProcessType m_processType;
113
};
118
};
114
119
120
class TextCheckingRequest : public RefCounted<TextCheckingRequest> {
121
public:
122
    virtual ~TextCheckingRequest() { }
123
124
    virtual const TextCheckingRequestData& data() const = 0;
125
    virtual void didSucceed(const Vector<TextCheckingResult>&) = 0;
126
    virtual void didCancel() = 0;
127
};
128
115
}
129
}
116
130
117
#endif // TextChecking_h
131
#endif // TextChecking_h
- a/Source/WebKit/blackberry/ChangeLog +11 lines
Lines 1-3 a/Source/WebKit/blackberry/ChangeLog_sec1
1
2013-02-21  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
2
3
        Allow to retrieve the request data from abstract TextCheckingRequest to be accessible for WK2
4
        https://bugs.webkit.org/show_bug.cgi?id=110208
5
6
        Reviewed by Hajime Morrita.
7
8
        * WebKitSupport/InputHandler.cpp:
9
        (BlackBerry::WebKit::InputHandler::requestCheckingOfString):
10
        Extract the request data as it is the member of 'TextCheckingRequest'.
11
1
2013-02-20  Nima Ghanavatian  <nghanavatian@rim.com>
12
2013-02-20  Nima Ghanavatian  <nghanavatian@rim.com>
2
13
3
        [BlackBerry] Check offset for initialized value
14
        [BlackBerry] Check offset for initialized value
- a/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp -3 / +3 lines
Lines 597-610 void InputHandler::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingReque a/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp_sec1
597
{
597
{
598
    m_request = textCheckingRequest;
598
    m_request = textCheckingRequest;
599
599
600
    InputLog(Platform::LogLevelInfo, "InputHandler::requestCheckingOfString '%s'", m_request->text().latin1().data());
600
    InputLog(Platform::LogLevelInfo, "InputHandler::requestCheckingOfString '%s'", m_request->data().text().latin1().data());
601
601
602
    if (!m_request) {
602
    if (!m_request) {
603
        SpellingLog(Platform::LogLevelWarn, "InputHandler::requestCheckingOfString did not receive a valid request.");
603
        SpellingLog(Platform::LogLevelWarn, "InputHandler::requestCheckingOfString did not receive a valid request.");
604
        return;
604
        return;
605
    }
605
    }
606
606
607
    unsigned requestLength = m_request->text().length();
607
    unsigned requestLength = m_request->data().text().length();
608
608
609
    // Check if the field should be spellchecked.
609
    // Check if the field should be spellchecked.
610
    if (!isActiveTextEdit() || !shouldSpellCheckElement(m_currentFocusElement.get()) || requestLength < 2) {
610
    if (!isActiveTextEdit() || !shouldSpellCheckElement(m_currentFocusElement.get()) || requestLength < 2) {
Lines 639-645 void InputHandler::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingReque a/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp_sec2
639
    }
639
    }
640
640
641
    int paragraphLength = 0;
641
    int paragraphLength = 0;
642
    if (!convertStringToWchar(m_request->text(), checkingString, requestLength + 1, &paragraphLength)) {
642
    if (!convertStringToWchar(m_request->data().text(), checkingString, requestLength + 1, &paragraphLength)) {
643
        Platform::logAlways(Platform::LogLevelCritical, "InputHandler::requestCheckingOfString Failed to convert String to wchar type.");
643
        Platform::logAlways(Platform::LogLevelCritical, "InputHandler::requestCheckingOfString Failed to convert String to wchar type.");
644
        free(checkingString);
644
        free(checkingString);
645
        m_request->didCancel();
645
        m_request->didCancel();
- a/Source/WebKit/chromium/ChangeLog +11 lines
Lines 1-3 a/Source/WebKit/chromium/ChangeLog_sec1
1
2013-02-21  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
2
3
        Allow to retrieve the request data from abstract TextCheckingRequest to be accessible for WK2
4
        https://bugs.webkit.org/show_bug.cgi?id=110208
5
6
        Reviewed by Hajime Morrita.
7
8
        * src/EditorClientImpl.cpp:
9
        (WebKit::EditorClientImpl::requestCheckingOfString):
10
        Extract the request data as it is the member of 'TextCheckingRequest'.
11
1
2013-02-21  Ken Kania  <kkania@chromium.org>
12
2013-02-21  Ken Kania  <kkania@chromium.org>
2
13
3
        Web Inspector: Add command for selecting files for file input element
14
        Web Inspector: Add command for selecting files for file input element
- a/Source/WebKit/chromium/src/EditorClientImpl.cpp -1 / +1 lines
Lines 746-752 void EditorClientImpl::checkSpellingOfString(const UChar* text, int length, a/Source/WebKit/chromium/src/EditorClientImpl.cpp_sec1
746
void EditorClientImpl::requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
746
void EditorClientImpl::requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
747
{
747
{
748
    if (m_webView->spellCheckClient()) {
748
    if (m_webView->spellCheckClient()) {
749
        String text = request->text();
749
        String text = request->data().text();
750
        m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(request));
750
        m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(request));
751
    }
751
    }
752
}
752
}
- a/Source/WebKit/mac/ChangeLog +12 lines
Lines 1-3 a/Source/WebKit/mac/ChangeLog_sec1
1
2013-02-21  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
2
3
        Allow to retrieve the request data from abstract TextCheckingRequest to be accessible for WK2
4
        https://bugs.webkit.org/show_bug.cgi?id=110208
5
6
        Reviewed by Hajime Morrita.
7
8
        * WebCoreSupport/WebEditorClient.mm:
9
        (WebEditorClient::didCheckSucceed):
10
        (WebEditorClient::requestCheckingOfString):
11
        Extract the request data as it is the member of 'TextCheckingRequest'.
12
1
2013-02-20  Dirk Schulze  <krit@webkit.org>
13
2013-02-20  Dirk Schulze  <krit@webkit.org>
2
14
3
        Enable CANVAS_PATH flag
15
        Enable CANVAS_PATH flag
- a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm -5 / +5 lines
Lines 972-979 void WebEditorClient::setInputMethodState(bool) a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm_sec1
972
972
973
void WebEditorClient::didCheckSucceed(int sequence, NSArray* results)
973
void WebEditorClient::didCheckSucceed(int sequence, NSArray* results)
974
{
974
{
975
    ASSERT_UNUSED(sequence, sequence == m_textCheckingRequest->sequence());
975
    ASSERT_UNUSED(sequence, sequence == m_textCheckingRequest->data().sequence());
976
    m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->mask()));
976
    m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->data().mask()));
977
    m_textCheckingRequest.clear();
977
    m_textCheckingRequest.clear();
978
}
978
}
979
979
Lines 983-992 void WebEditorClient::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRe a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm_sec2
983
    ASSERT(!m_textCheckingRequest);
983
    ASSERT(!m_textCheckingRequest);
984
    m_textCheckingRequest = request;
984
    m_textCheckingRequest = request;
985
985
986
    int sequence = m_textCheckingRequest->sequence();
986
    int sequence = m_textCheckingRequest->data().sequence();
987
    NSRange range = NSMakeRange(0, m_textCheckingRequest->text().length());
987
    NSRange range = NSMakeRange(0, m_textCheckingRequest->data().text().length());
988
    NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
988
    NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
989
    [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->text() range:range types:NSTextCheckingAllSystemTypes options:0 inSpellDocumentWithTag:0
989
    [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->data().text() range:range types:NSTextCheckingAllSystemTypes options:0 inSpellDocumentWithTag:0
990
                                         completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
990
                                         completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
991
            [currentLoop performSelector:@selector(perform) 
991
            [currentLoop performSelector:@selector(perform) 
992
                                  target:[[[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results] autorelease]
992
                                  target:[[[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results] autorelease]

Return to Bug 110208