Changeset 107176 in webkit


Ignore:
Timestamp:
Feb 8, 2012 9:23:21 PM (12 years ago)
Author:
morrita@google.com
Message:

Replacement text should be available from the marker.
https://bugs.webkit.org/show_bug.cgi?id=77934

.:

Reviewed by Kent Tamura.

  • Source/autotools/symbols.filter: Added an exporting symbol.

Source/WebCore:

Reviewed by Kent Tamura.

On spellchecking, TextCheckingResult can contain a replacement text
which is usable both for an automatic replacement and for showing a suggestion.

But when marking a misspelled word ragarding to returned
TextCheckingResult, Editor uses only the misspelled range data and
discards the replacement value. Then it asks the same value again
when showing suggestion/autocorrection.

It would be great if the marker holds the replacement text
and Editor can use it on suggesting a correction, without any re-request.
This is especially true in the case when it needs IPC messaging for spellchecking:
We can save one round-trip by this technique.

Here is actual change:

  • Passed the replacement text to addMarker() for for misspelling markers. Note that this is done only for the unified checker path because legacy TextCheckerClient API doesn't provide such a replacement.
  • Added an Internals API to retrieve a description text on a marker.

Test: editing/spelling/spelling-marker-description.html

  • WebCore.exp.in:
  • editing/Editor.cpp:

(WebCore::Editor::markAndReplaceFor):

  • testing/Internals.cpp:

(WebCore::Internals::markerAt):
(WebCore):
(WebCore::Internals::markerRangeForNode):
(WebCore::Internals::markerDescriptionForNode):

  • testing/Internals.h:

(WebCore):
(Internals):

  • testing/Internals.idl:

Source/WebKit/chromium:

didFinishCheckingText() accidentally dropped the description text
given from the backend. Fixed to copy it on the API-to-Core
convertion. The test won't work without this fix.

Reviewed by Kent Tamura.

  • src/WebTextCheckingCompletionImpl.cpp:

(WebKit::toCoreResults):

Source/WebKit/win:

Reviewed by Kent Tamura.

  • WebKit.vcproj/WebKit_Cairo.def:
  • WebKit.vcproj/WebKit_Cairo_debug.def:

Source/WebKit2:

Reviewed by Kent Tamura.

  • win/WebKit2.def:
  • win/WebKit2CFLite.def:

Tools:

Made the mock requestCheckingOfText() implementation to return
a replacement text for each misspelled word if available.

Reviewed by Kent Tamura.

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::finishLastTextCheck):

LayoutTests:

Reviewed by Kent Tamura.

  • editing/spelling/spelling-marker-description-expected.txt: Added.
  • editing/spelling/spelling-marker-description.html: Added.
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:
Location:
trunk
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r107020 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Reviewed by Kent Tamura.
     7
     8        * Source/autotools/symbols.filter: Added an exporting symbol.
     9
    1102012-02-07  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    211
  • trunk/LayoutTests/ChangeLog

    r107162 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Reviewed by Kent Tamura.
     7
     8        * editing/spelling/spelling-marker-description-expected.txt: Added.
     9        * editing/spelling/spelling-marker-description.html: Added.
     10        * platform/gtk/Skipped:
     11        * platform/mac/Skipped:
     12        * platform/qt/Skipped:
     13        * platform/win/Skipped:
     14
    1152012-02-08  Igor Oliveira  <igor.o@sisa.samsung.com>
    216
  • trunk/LayoutTests/platform/gtk/Skipped

    r107077 r107176  
    124124editing/undo/undo-smart-delete-reversed-selection.html
    125125editing/selection/directionality-after-undo-replace.html
     126
     127# EditorClient::checkTextOfParagraph() is not implemented
     128editing/spelling/spelling-marker-description.html
    126129
    127130# https://bugs.webkit.org/show_bug.cgi?id=64530
  • trunk/LayoutTests/platform/mac/Skipped

    r106632 r107176  
    343343editing/pasteboard/data-transfer-items-drag-drop-string.html
    344344
     345# Replacement text for misspelling is not given from NSSpellChecker.
     346# https://bugs.webkit.org/show_bug.cgi?id=77934
     347editing/spelling/spelling-marker-description.html
     348
    345349# Custom MIME type support in DataTransfer is not yet implemented.
    346350editing/pasteboard/clipboard-customData.html
  • trunk/LayoutTests/platform/qt/Skipped

    r107104 r107176  
    737737editing/spelling/spellcheck-sequencenum.html
    738738editing/spelling/spellcheck-async-mutation.html
     739# EditorClient::checkTextOfParagraph() is not implemented
     740editing/spelling/spelling-marker-description.html
    739741
    740742# [Qt][GTK] editing/spelling/spellcheck-async.html fails
  • trunk/LayoutTests/platform/win/Skipped

    r106632 r107176  
    10581058# EditorClient::requestCheckingOfString() is not implemented
    10591059editing/spelling/spellcheck-paste.html
     1060# Replacement text for misspelling is not given.
     1061# https://bugs.webkit.org/show_bug.cgi?id=77934
     1062editing/spelling/spelling-marker-description.html
    10601063
    10611064# IndexedDB is not yet enabled.
  • trunk/Source/WebCore/ChangeLog

    r107175 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Reviewed by Kent Tamura.
     7
     8        On spellchecking, TextCheckingResult can contain a replacement text
     9        which is usable both for an automatic replacement and for showing a suggestion.
     10
     11        But when marking a misspelled word ragarding to returned
     12        TextCheckingResult, Editor uses only the misspelled range data and
     13        discards the replacement value. Then it asks the same value again
     14        when showing suggestion/autocorrection.
     15
     16        It would be great if the marker holds the replacement text
     17        and Editor can use it on suggesting a correction, without any re-request.
     18        This is especially true in the case when it needs IPC messaging for spellchecking:
     19        We can save one round-trip by this technique.
     20
     21        Here is actual change:
     22
     23        - Passed the replacement text to addMarker() for for misspelling markers.
     24          Note that this is done only for the unified checker path because legacy
     25          TextCheckerClient API doesn't provide such a replacement.
     26        - Added an Internals API to retrieve a description text on a marker.
     27
     28        Test: editing/spelling/spelling-marker-description.html
     29
     30        * WebCore.exp.in:
     31        * editing/Editor.cpp:
     32        (WebCore::Editor::markAndReplaceFor):
     33        * testing/Internals.cpp:
     34        (WebCore::Internals::markerAt):
     35        (WebCore):
     36        (WebCore::Internals::markerRangeForNode):
     37        (WebCore::Internals::markerDescriptionForNode):
     38        * testing/Internals.h:
     39        (WebCore):
     40        (Internals):
     41        * testing/Internals.idl:
     42
    1432012-02-08  Eric Seidel  <eric@webkit.org>
    244
  • trunk/Source/WebCore/WebCore.exp.in

    r106977 r107176  
    12471247__ZNK7WebCore14DocumentLoader28urlForHistoryReflectsFailureEv
    12481248__ZNK7WebCore14DocumentLoader3urlEv
     1249__ZNK7WebCore14DocumentMarker11descriptionEv
    12491250__ZNK7WebCore14FrameSelection11currentFormEv
    12501251__ZNK7WebCore14FrameSelection15copyTypingStyleEv
  • trunk/Source/WebCore/editing/Editor.cpp

    r106884 r107176  
    20912091            if (!m_spellingCorrector->isSpellingMarkerAllowed(misspellingRange))
    20922092                continue;
    2093             misspellingRange->startContainer()->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
     2093            misspellingRange->startContainer()->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling, result->replacement);
    20942094        } else if (shouldMarkGrammar && result->type == TextCheckingTypeGrammar && paragraph.checkingRangeCovers(resultLocation, resultLength)) {
    20952095            ASSERT(resultLength > 0 && resultLocation >= 0);
  • trunk/Source/WebCore/testing/Internals.cpp

    r106839 r107176  
    282282}
    283283
    284 PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
     284DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
    285285{
    286286    if (!node) {
     
    298298    if (markers.size() <= index)
    299299        return 0;
    300     return Range::create(node->document(), node, markers[index]->startOffset(), node, markers[index]->endOffset());
     300    return markers[index];
     301}
     302
     303PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
     304{
     305    DocumentMarker* marker = markerAt(node, markerType, index, ec);
     306    if (!marker)
     307        return 0;
     308    return Range::create(node->document(), node, marker->startOffset(), node, marker->endOffset());
     309}
     310
     311String Internals::markerDescriptionForNode(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
     312{
     313    DocumentMarker* marker = markerAt(node, markerType, index, ec);
     314    if (!marker)
     315        return String();
     316    return marker->description();
    301317}
    302318
  • trunk/Source/WebCore/testing/Internals.h

    r106839 r107176  
    3737class ClientRect;
    3838class Document;
     39class DocumentMarker;
    3940class Element;
    4041class InternalSettings;
     
    8081
    8182    unsigned markerCountForNode(Node*, const String&, ExceptionCode&);
    82     PassRefPtr<Range> markerRangeForNode(Node*, const String&, unsigned, ExceptionCode&);
     83    PassRefPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
     84    String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
    8385
    8486    void setScrollViewPosition(Document*, long x, long y, ExceptionCode&);
     
    114116private:
    115117    explicit Internals(Document*);
     118    DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
    116119
    117120    RefPtr<InternalSettings> m_settings;
  • trunk/Source/WebCore/testing/Internals.idl

    r106839 r107176  
    5454        unsigned long markerCountForNode(in Node node, in DOMString markerType) raises(DOMException);
    5555        Range markerRangeForNode(in Node node, in DOMString markerType, in unsigned long index) raises(DOMException);
     56        DOMString markerDescriptionForNode(in Node node, in DOMString markerType, in unsigned long index) raises(DOMException);
    5657
    5758        void setScrollViewPosition(in Document document, in long x, in long y) raises(DOMException);
  • trunk/Source/WebKit/chromium/ChangeLog

    r107174 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        didFinishCheckingText() accidentally dropped the description text
     7        given from the backend. Fixed to copy it on the API-to-Core
     8        convertion. The test won't work without this fix.
     9
     10        Reviewed by Kent Tamura.
     11
     12        * src/WebTextCheckingCompletionImpl.cpp:
     13        (WebKit::toCoreResults):
     14
    1152012-02-08  Dmitry Lomov  <dslomov@chromium.org>
    216
  • trunk/Source/WebKit/chromium/src/WebTextCheckingCompletionImpl.cpp

    r102044 r107176  
    4242namespace WebKit {
    4343
    44 static TextCheckingType toCoreCheckingType(WebTextCheckingResult::Error error)
    45 {
    46     if (error == WebTextCheckingResult::ErrorSpelling)
    47         return TextCheckingTypeSpelling;
    48     ASSERT(error == WebTextCheckingResult::ErrorGrammar);
    49     return TextCheckingTypeGrammar;
    50 }
    51 
    5244static Vector<TextCheckingResult> toCoreResults(const WebVector<WebTextCheckingResult>& results)
    5345{
    5446    Vector<TextCheckingResult> coreResults;
    55     for (size_t i = 0; i < results.size(); ++i) {
    56         TextCheckingResult coreResult;
    57         coreResult.type = toCoreCheckingType(results[i].error);
    58         coreResult.location = results[i].position;
    59         coreResult.length = results[i].length;
    60         coreResults.append(coreResult);
    61     }
    62 
     47    for (size_t i = 0; i < results.size(); ++i)
     48        coreResults.append(results[i]);
    6349    return coreResults;
    6450}
  • trunk/Source/WebKit/win/ChangeLog

    r106592 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Reviewed by Kent Tamura.
     7
     8        * WebKit.vcproj/WebKit_Cairo.def:
     9        * WebKit.vcproj/WebKit_Cairo_debug.def:
     10
    1112012-02-02  Jon Lee  <jonlee@apple.com>
    212
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKit_Cairo.def

    r92078 r107176  
    111111        ??0ClientRect@WebCore@@AAE@XZ
    112112        ?absoluteBoundingBoxRect@RenderObject@WebCore@@QAE?AVIntRect@2@_N@Z
     113        ?description@DocumentMarker@WebCore@@QBEABVString@WTF@@XZ
    113114        ?fastMalloc@WTF@@YAPAXI@Z
    114115        ?fastZeroedMalloc@WTF@@YAPAXI@Z
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKit_Cairo_debug.def

    r92078 r107176  
    111111        ??0ClientRect@WebCore@@AAE@XZ
    112112        ?absoluteBoundingBoxRect@RenderObject@WebCore@@QAE?AVIntRect@2@_N@Z
     113        ?description@DocumentMarker@WebCore@@QBEABVString@WTF@@XZ
    113114        ?fastMalloc@WTF@@YAPAXI@Z
    114115        ?fastZeroedMalloc@WTF@@YAPAXI@Z
  • trunk/Source/WebKit2/ChangeLog

    r107168 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Reviewed by Kent Tamura.
     7
     8        * win/WebKit2.def:
     9        * win/WebKit2CFLite.def:
     10
    1112012-02-08  Anders Carlsson  <andersca@apple.com>
    212
  • trunk/Source/WebKit2/win/WebKit2.def

    r106907 r107176  
    147147        ?absoluteBoundingBoxRect@RenderObject@WebCore@@QBE?AVIntRect@2@_N@Z
    148148        ?absoluteBoundingBoxRectIgnoringTransforms@RenderObject@WebCore@@QBE?AVIntRect@2@XZ
     149        ?description@DocumentMarker@WebCore@@QBEABVString@WTF@@XZ
    149150        ?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBD@Z
    150151        ?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBE@Z
  • trunk/Source/WebKit2/win/WebKit2CFLite.def

    r106907 r107176  
    141141        ?absoluteBoundingBoxRect@RenderObject@WebCore@@QBE?AVIntRect@2@_N@Z
    142142        ?absoluteBoundingBoxRectIgnoringTransforms@RenderObject@WebCore@@QBE?AVIntRect@2@XZ
     143        ?description@DocumentMarker@WebCore@@QBEABVString@WTF@@XZ
    143144        ?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBD@Z
    144145        ?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBE@Z
  • trunk/Source/autotools/symbols.filter

    r106907 r107176  
    8484_ZNK7WebCore8Document4viewEv;
    8585_ZNK7WebCore9TreeScope14getElementByIdERKN3WTF12AtomicStringE;
     86_ZNK7WebCore14DocumentMarker11descriptionEv;
    8687_ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE;
    8788_ZN7WebCore10ScrollView23setScrollbarsSuppressedEbb;
  • trunk/Tools/ChangeLog

    r107171 r107176  
     12012-02-07  MORITA Hajime  <morrita@google.com>
     2
     3        Replacement text should be available from the marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=77934
     5
     6        Made the mock requestCheckingOfText() implementation to return
     7        a replacement text for each misspelled word if available.
     8
     9        Reviewed by Kent Tamura.
     10
     11        * DumpRenderTree/chromium/WebViewHost.cpp:
     12        (WebViewHost::finishLastTextCheck):
     13
    1142012-02-08  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    215
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r106371 r107176  
    472472        if (!misspelledLength)
    473473            break;
    474         results.append(WebTextCheckingResult(WebTextCheckingResult::ErrorSpelling, offset + misspelledPosition, misspelledLength));
     474        Vector<WebString> suggestions;
     475        m_spellcheck.fillSuggestionList(WebString(text.characters() + misspelledPosition, misspelledLength), &suggestions);
     476        results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, offset + misspelledPosition, misspelledLength,
     477                                             suggestions.isEmpty() ? WebString() : suggestions[0]));
    475478        text = text.substring(misspelledPosition + misspelledLength);
    476479        offset += misspelledPosition + misspelledLength;
Note: See TracChangeset for help on using the changeset viewer.