Changeset 143192 in webkit


Ignore:
Timestamp:
Feb 18, 2013 3:33:43 AM (11 years ago)
Author:
g.czajkowski@samsung.com
Message:

[WK2][EFL] Unified text checker implementation
https://bugs.webkit.org/show_bug.cgi?id=107682

Reviewed by Anders Carlsson.

Source/WebCore:

No new tests, covered by editing/spelling tests.

  • platform/text/TextChecking.h:

(WebCore):
Enabling unified text checker feature for WebKit-EFL.

Source/WebKit/efl:

Add an empty checkTextOfParagraph implementation for WK1-EFL
to do not break build when WTF_USE_UNIFIED_TEXT_CHECKING
is enabled.

  • WebCoreSupport/EditorClientEfl.h:

(EditorClientEfl):
(WebCore::EditorClientEfl::checkTextOfParagraph):

Source/WebKit2:

  • UIProcess/efl/TextCheckerEfl.cpp:

(WebKit):
(WebKit::nextWordOffset):
Helper function to determine the word offset to do not call
client's checkSpellingOfString for the word separators.

(WebKit::TextChecker::checkTextOfParagraph):
Allow to check spelling for multiple words,
their misspelling location and length are saved to the vector.

  • WebProcess/WebCoreSupport/WebEditorClient.h:

Add UNIFIED_TEXT_CHECKING guard to checkTextOfParagraph.

  • WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp:

(WebKit):
(WebKit::WebEditorClient::checkTextOfParagraph):
As spelling implementation is exposed to UIProcess,
send a meesage to UIProcess to call TextChecker::checkTextOfParagraph.

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143188 r143192  
     12013-02-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [WK2][EFL] Unified text checker implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=107682
     5
     6        Reviewed by Anders Carlsson.
     7
     8        No new tests, covered by editing/spelling tests.
     9
     10        * platform/text/TextChecking.h:
     11        (WebCore):
     12        Enabling unified text checker feature for WebKit-EFL.
     13
    1142013-02-18  Nico Weber  <thakis@chromium.org>
    215
  • trunk/Source/WebCore/platform/text/TextChecking.h

    r141387 r143192  
    4040#define WTF_USE_GRAMMAR_CHECKING 1
    4141
    42 #if (PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060)) || PLATFORM(BLACKBERRY)
     42#if (PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060)) || PLATFORM(BLACKBERRY) || PLATFORM(EFL)
    4343#define WTF_USE_UNIFIED_TEXT_CHECKING 1
    4444#endif
  • trunk/Source/WebKit/efl/ChangeLog

    r142977 r143192  
     12013-02-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [WK2][EFL] Unified text checker implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=107682
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Add an empty checkTextOfParagraph implementation for WK1-EFL
     9        to do not break build when WTF_USE_UNIFIED_TEXT_CHECKING
     10        is enabled.
     11
     12        * WebCoreSupport/EditorClientEfl.h:
     13        (EditorClientEfl):
     14        (WebCore::EditorClientEfl::checkTextOfParagraph):
     15
    1162013-02-15  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    217
  • trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h

    r142576 r143192  
    151151    virtual void setInputMethodState(bool enabled);
    152152    virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) { }
     153#if USE(UNIFIED_TEXT_CHECKING)
     154    virtual void checkTextOfParagraph(const UChar*, int, TextCheckingTypeMask, Vector<TextCheckingResult>&) { }
     155#endif
    153156    virtual TextCheckerClient* textChecker() { return this; }
    154157
  • trunk/Source/WebKit2/ChangeLog

    r143190 r143192  
     12013-02-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [WK2][EFL] Unified text checker implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=107682
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/efl/TextCheckerEfl.cpp:
     9        (WebKit):
     10        (WebKit::nextWordOffset):
     11        Helper function to determine the word offset to do not call
     12        client's checkSpellingOfString for the word separators.
     13
     14        (WebKit::TextChecker::checkTextOfParagraph):
     15        Allow to check spelling for multiple words,
     16        their misspelling location and length are saved to the vector.
     17
     18        * WebProcess/WebCoreSupport/WebEditorClient.h:
     19        Add UNIFIED_TEXT_CHECKING guard to checkTextOfParagraph.
     20
     21        * WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp:
     22        (WebKit):
     23        (WebKit::WebEditorClient::checkTextOfParagraph):
     24        As spelling implementation is exposed to UIProcess,
     25        send a meesage to UIProcess to call TextChecker::checkTextOfParagraph.
     26
    1272013-02-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    228
  • trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp

    r141387 r143192  
    3232
    3333#if ENABLE(SPELLCHECK)
     34#include "TextBreakIterator.h"
    3435#include "WebTextChecker.h"
    3536#endif
     
    124125#endif
    125126}
     127
     128#if USE(UNIFIED_TEXT_CHECKING)
     129static int nextWordOffset(const UChar* text, int length, int currentOffset)
     130{
     131    // FIXME: avoid creating textIterator object here, it could be passed as a parameter.
     132    //        isTextBreak() leaves the iterator pointing to the first boundary position at
     133    //        or after "offset" (ubrk_isBoundary side effect).
     134    //        For many word separators, the method doesn't properly determine the boundaries
     135    //        without resetting the iterator.
     136    TextBreakIterator* textIterator = wordBreakIterator(text, length);
     137    if (!textIterator)
     138        return currentOffset;
     139
     140    int wordOffset = currentOffset;
     141    while (wordOffset < length && isTextBreak(textIterator, wordOffset))
     142        ++wordOffset;
     143
     144    // Do not treat the word's boundary as a separator.
     145    if (!currentOffset && wordOffset == 1)
     146        return currentOffset;
     147
     148    // Omit multiple separators.
     149    if ((wordOffset - currentOffset) > 1)
     150        --wordOffset;
     151
     152    return wordOffset;
     153}
     154
     155Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
     156{
     157    Vector<TextCheckingResult> paragraphCheckingResult;
     158#if ENABLE(SPELLCHECK)
     159    if (checkingTypes & TextCheckingTypeSpelling) {
     160        TextBreakIterator* textIterator = wordBreakIterator(text, length);
     161        if (!textIterator)
     162            return paragraphCheckingResult;
     163
     164        // Omit the word separators at the beginning/end of the text to don't unnecessarily
     165        // involve the client to check spelling for them.
     166        int offset = nextWordOffset(text, length, 0);
     167        int lengthStrip = length;
     168        while (lengthStrip > 0 && isTextBreak(textIterator, lengthStrip - 1))
     169            --lengthStrip;
     170
     171        while (offset >= 0 && offset < lengthStrip) {
     172            int32_t misspellingLocation = -1;
     173            int32_t misspellingLength = 0;
     174            checkSpellingOfString(spellDocumentTag, text + offset, lengthStrip - offset, misspellingLocation, misspellingLength);
     175            if (!misspellingLength)
     176                break;
     177
     178            TextCheckingResult misspellingResult;
     179            misspellingResult.type = TextCheckingTypeSpelling;
     180            misspellingResult.location = offset + misspellingLocation;
     181            misspellingResult.length = misspellingLength;
     182            paragraphCheckingResult.append(misspellingResult);
     183            offset += misspellingLocation + misspellingLength;
     184            // Generally, we end up checking at the word separator, move to the adjacent word.
     185            offset = nextWordOffset(text, lengthStrip, offset);
     186        }
     187    }
     188#else
     189    UNUSED_PARAM(spellDocumentTag);
     190    UNUSED_PARAM(text);
     191    UNUSED_PARAM(length);
     192    UNUSED_PARAM(checkingTypes);
     193#endif
     194    return paragraphCheckingResult;
     195}
     196#endif
    126197
    127198void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h

    r142908 r143192  
    143143    virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) OVERRIDE;
    144144    virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) OVERRIDE;
    145 #if PLATFORM(MAC)
     145#if USE(UNIFIED_TEXT_CHECKING)
    146146    virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector<WebCore::TextCheckingResult>& results) OVERRIDE;
    147147#endif
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp

    r141387 r143192  
    6161}
    6262
     63#if USE(UNIFIED_TEXT_CHECKING)
     64void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
     65{
     66    m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
    6367}
     68#endif
     69
     70}
Note: See TracChangeset for help on using the changeset viewer.